Skip to content

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

Merged
merged 10 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/website/root/manual/develop/nodes/mithril-aggregator.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ Here is a list of the available parameters for the serve command:
| `data_stores_directory` | - | - | `data_stores_directory` | Directory to store aggregator databases | - | `./mithril-aggregator/stores` | :heavy_check_mark: |
| `db_directory` | `--db-directory` | - | `DB_DIRECTORY` | Directory of the **Cardano node** stores | `/db` | - | :heavy_check_mark: |
| `genesis_verification_key` | - | - | `GENESIS_VERIFICATION_KEY` | Genesis verification key | - | - | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |
| `protocol_parameters` | - | - | `PROTOCOL_PARAMETERS__K`, `PROTOCOL_PARAMETERS__M`, and `PROTOCOL_PARAMETERS__PHI_F` | Mithril protocol parameters | - | `{ k: 5, m: 100, phi_f: 0.65 }` | :heavy_check_mark: |
| `run_mode` | `--run-mode` | `-r` | `RUN_MODE` | Runtime mode | `dev` | - | :heavy_check_mark: |
Expand Down Expand Up @@ -552,7 +552,7 @@ Here is a list of the available parameters for the serve command:
| `cardano_node_socket_path` | - | - | `CARDANO_NODE_SOCKET_PATH` | Path of the socket opened by the Cardano node | - | `/ipc/node.socket` | :heavy_check_mark: |
| `cardano_cli_path` | - | - | `CARDANO_CLI_PATH` | Cardano CLI tool path | - | `cardano-cli` | - |
| `chain_observer_type` | - | - | `CHAIN_OBSERVER_TYPE` | Chain observer type that can be `cardano-cli`, `pallas` or `fake`. | `pallas` | - | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |

`genesis export` command:
Expand All @@ -564,7 +564,7 @@ Here is a list of the available parameters for the serve command:
| `cardano_node_socket_path` | - | - | `CARDANO_NODE_SOCKET_PATH` | Path of the socket opened by the Cardano node | - | `/ipc/node.socket` | :heavy_check_mark: |
| `cardano_cli_path` | - | - | `CARDANO_CLI_PATH` | Cardano CLI tool path | - | `cardano-cli` | - |
| `chain_observer_type` | - | - | `CHAIN_OBSERVER_TYPE` | Chain observer type that can be `cardano-cli`, `pallas` or `fake`. | `pallas` | - | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |

`genesis import` command:
Expand All @@ -577,7 +577,7 @@ Here is a list of the available parameters for the serve command:
| `cardano_node_socket_path` | - | - | `CARDANO_NODE_SOCKET_PATH` | Path of the socket opened by the Cardano node | - | `/ipc/node.socket` | :heavy_check_mark: |
| `cardano_cli_path` | - | - | `CARDANO_CLI_PATH` | Cardano CLI tool path | - | `cardano-cli` | - |
| `chain_observer_type` | - | - | `CHAIN_OBSERVER_TYPE` | Chain observer type that can be `cardano-cli`, `pallas` or `fake`. | `pallas` | - | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |

`genesis sign` command:
Expand Down
2 changes: 1 addition & 1 deletion docs/website/root/manual/develop/nodes/mithril-signer.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Here is a list of the available parameters:
| `cardano_cli_path` | - | - | `CARDANO_CLI_PATH` | Cardano CLI tool path | - | `cardano-cli` | :heavy_check_mark: |
| `cardano_node_socket_path` | - | - | `CARDANO_NODE_SOCKET_PATH` | Path of the socket opened by the Cardano node | - | `/ipc/node.socket` | :heavy_check_mark: |
| `db_directory` | `--db-directory` | - | `DB_DIRECTORY` | Directory to snapshot from the **Cardano node** | `/db` | - | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |
| `party_id` | - | - | `PARTY_ID` | Party Id of the signer, usually the `Pool Id` of the SPO | - | `pool1pxaqe80sqpde7902er5kf6v0c7y0sv6d5g676766v2h829fvs3x` | Mandatory in `pool Id declaration mode` where the owner is not verified (decommissioned, only available when built with `allow_skip_signer_certification` feature, for test only) |
| `run_interval` | - | - | `RUN_INTERVAL` | Interval between two runtime cycles in ms | - | `60000` | :heavy_check_mark: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-cardano-node-chain"
version = "0.1.3"
version = "0.1.4"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ impl CardanoCliRunner {
fn post_config_command<'a>(&'a self, command: &'a mut Command) -> &'a mut Command {
match self.network {
CardanoNetwork::MainNet => command.arg("--mainnet"),
CardanoNetwork::DevNet(magic) => command.args(vec![
"--cardano-mode",
"--testnet-magic",
&magic.to_string(),
]),
CardanoNetwork::TestNet(magic) => {
command.args(vec!["--testnet-magic", &magic.to_string()])
}
Expand Down Expand Up @@ -638,26 +633,6 @@ mod tests {
);
}

#[tokio::test]
async fn test_cli_devnet_runner() {
let runner = CardanoCliRunner::new(
PathBuf::from("cardano-cli"),
PathBuf::from("/tmp/whatever.sock"),
CardanoNetwork::DevNet(25),
);

assert_cli_command!(
runner.command_for_epoch(),
r#""cardano-cli" "latest" "query" "tip" "--cardano-mode" "--testnet-magic" "25""#,
envs: vec![(OsStr::new("CARDANO_NODE_SOCKET_PATH"), Some(OsStr::new("/tmp/whatever.sock")))]
);
assert_cli_command!(
runner.command_for_stake_distribution(),
r#""cardano-cli" "latest" "query" "stake-distribution" "--cardano-mode" "--testnet-magic" "25""#,
envs: vec![(OsStr::new("CARDANO_NODE_SOCKET_PATH"), Some(OsStr::new("/tmp/whatever.sock")))]
);
}

#[tokio::test]
async fn test_cli_mainnet_runner() {
let runner = CardanoCliRunner::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl PallasChainObserver {

/// Creates and returns a new `NodeClient` connected to the specified socket.
async fn new_client(&self) -> StdResult<NodeClient> {
let magic = self.network.code();
let magic = self.network.magic_id();
let client = NodeClient::connect(&self.socket, magic).await?;

Ok(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl PallasChainReader {

/// Creates and returns a new `NodeClient` connected to the specified socket.
async fn new_client(&self) -> StdResult<NodeClient> {
let magic = self.network.code();
let magic = self.network.magic_id();
NodeClient::connect(&self.socket, magic)
.await
.map_err(|err| anyhow!(err))
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-dmq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mithril-dmq"
description = "Mechanisms to publish and consume messages of a 'Decentralized Message Queue network' through a DMQ node"
version = "0.1.3"
version = "0.1.4"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-dmq/src/consumer/pallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
"socket" => ?self.socket,
"network" => ?self.network
);
DmqClient::connect(&self.socket, self.network.code())
DmqClient::connect(&self.socket, self.network.magic_id())
.await
.with_context(|| "DmqConsumerPallas failed to create a new client")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-dmq/src/publisher/pallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<M: TryToBytes + Debug> DmqPublisherPallas<M> {

/// Creates and returns a new `DmqClient` connected to the specified socket.
async fn new_client(&self) -> StdResult<DmqClient> {
let magic = self.network.code();
let magic = self.network.magic_id();
DmqClient::connect(&self.socket, magic)
.await
.with_context(|| "DmqPublisherPallas failed to create a new client")
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.7.73"
version = "0.7.74"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ mod tests {
let test_dir = get_test_directory("should_compute_valid_artifact");

let beacon = CardanoDbBeacon::new(123, 3);
let network = CardanoNetwork::DevNet(123);
let network = CardanoNetwork::TestNet(123);
let immutable_trio_file_size = 777;
let ledger_file_size = 6666;
let volatile_file_size = 99;
Expand Down
Loading
Loading