-
Notifications
You must be signed in to change notification settings - Fork 45
refactor: unify and extend CardanoNetwork
implementation
#2643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: unify and extend CardanoNetwork
implementation
#2643
Conversation
…ith magic ID `42`
…ril-client` library in the `tools utxo-hd snapshot-converter` command in the client CLI
Test Results 4 files ±0 154 suites ±0 23m 41s ⏱️ -54s Results for commit 2d90b53. ± Comparison against base commit f19a476. This pull request removes 3 and adds 3 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the CardanoNetwork
enum by merging the former DevNet
variant into TestNet
, making the enum and its magic ID constants public, and introducing a From<MagicId>
conversion. It also updates all client code, scripts, and tests to use the new magic_id()
method instead of the old code()
API.
- Unified
DevNet
intoTestNet
and exposedCardanoNetwork
and its magic ID constants publicly. - Added
From<MagicId>
for direct network construction and renamedcode()
tomagic_id()
. - Updated CLI tools, end-to-end tests, scripts, and internal clients to use the new API and removed duplicated network logic.
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
mithril-common/src/entities/cardano_network.rs | Refactored enum variants, made magic ID constants public, added From |
mithril-common/src/entities/mod.rs | Exposed CardanoNetwork and magic ID constants in the public API |
mithril-client/src/utils/bootstrap_files.rs | Switched to magic_id() and adjusted bootstrap file creation tests |
mithril-client-cli/src/commands/tools/snapshot_converter.rs | Introduced CardanoNetworkCliArg and updated detection logic |
internal/cardano-node//pallas_.rs | Replaced network.code() calls with network.magic_id() |
Comments suppressed due to low confidence (4)
mithril-common/src/entities/cardano_network.rs:39
- The
from_code
function no longer recognizes the standard "testnet" network code, which will break parsing of the main public testnet magic ID. Consider re-adding the mapping"testnet" => Ok(CardanoNetwork::TestNet(TESTNET_MAGIC_ID))
.
match network_code.to_lowercase().as_str() {
mithril-client/src/utils/bootstrap_files.rs:105
- [nitpick] The test name states that the protocol magic ID file should not be created, yet the test actually asserts its creation. Consider renaming the test to accurately reflect that the file is expected to exist.
fn create_bootstrap_node_files_does_not_create_protocol_magic_id_file_and_create_clean_file_for_private_network()
internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/cli_observer.rs:170
- There is no test verifying that a TestNet with the devnet magic ID (now collapsed into TestNet) yields the correct CLI flags. Add a test for
CardanoNetwork::TestNet(DEVNET_MAGIC_ID)
to ensure the devnet scenario is covered.
CardanoNetwork::TestNet(magic) => {
mithril-common/src/entities/cardano_network.rs:83
- The
Display
implementation no longer prints "testnet" for the formerTESTNET_MAGIC_ID
, causing that case to fall through to "private". Add a case for the original testnet magic ID to correctly format it as "testnet".
CardanoNetwork::TestNet(magic_id) => match magic_id {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
…te exports/imports
…RSION` version * mithril-cardano-node-chain from `0.1.3` to `0.1.4` * mithril-dmq from `0.1.3` to `0.1.4` * mithril-aggregator from `0.7.73` to `0.7.74` * mithril-client-cli from `0.12.21` to `0.12.22` * mithril-client from `0.12.21` to `0.12.22` * mithril-common from `0.6.8` to `0.6.9` * mithril-signer from `0.2.259` to `0.2.260` * mithril-end-to-end from `0.4.96` to `0.4.97` * mithril-test-lab/mithril-devnet/VERSION from `0.4.13` to `0.4.14`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✨
Content
This PR includes a refactoring and extends the
CardanoNetwork
enum inmithril-common
to allow usage from clients, particularly for themithril-client
CLI.Main changes include:
CardanoNetwork
publicly accessible.From<MagicId>
implementation to support direct conversion from network magic IDs.DevNet
variant into theTestNet
variant.tools utxo-hd snapshot-converter
command in themithril-client
CLI to useCardanoNetwork
and remove duplicated logic.Pre-submit checklist
Issue(s)
Closes #2590