Skip to content

Commit d8ac86c

Browse files
authored
Merge pull request #2643 from input-output-hk/dlachaume/2590/refactor-cardano-network-entity
refactor: unify and extend `CardanoNetwork` implementation
2 parents f19a476 + 2d90b53 commit d8ac86c

File tree

38 files changed

+193
-181
lines changed

38 files changed

+193
-181
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/website/root/manual/develop/nodes/mithril-aggregator.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ Here is a list of the available parameters for the serve command:
503503
| `data_stores_directory` | - | - | `data_stores_directory` | Directory to store aggregator databases | - | `./mithril-aggregator/stores` | :heavy_check_mark: |
504504
| `db_directory` | `--db-directory` | - | `DB_DIRECTORY` | Directory of the **Cardano node** stores | `/db` | - | :heavy_check_mark: |
505505
| `genesis_verification_key` | - | - | `GENESIS_VERIFICATION_KEY` | Genesis verification key | - | - | :heavy_check_mark: |
506-
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
506+
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
507507
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |
508508
| `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: |
509509
| `run_mode` | `--run-mode` | `-r` | `RUN_MODE` | Runtime mode | `dev` | - | :heavy_check_mark: |
@@ -552,7 +552,7 @@ Here is a list of the available parameters for the serve command:
552552
| `cardano_node_socket_path` | - | - | `CARDANO_NODE_SOCKET_PATH` | Path of the socket opened by the Cardano node | - | `/ipc/node.socket` | :heavy_check_mark: |
553553
| `cardano_cli_path` | - | - | `CARDANO_CLI_PATH` | Cardano CLI tool path | - | `cardano-cli` | - |
554554
| `chain_observer_type` | - | - | `CHAIN_OBSERVER_TYPE` | Chain observer type that can be `cardano-cli`, `pallas` or `fake`. | `pallas` | - | :heavy_check_mark: |
555-
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
555+
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
556556
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |
557557

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

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

583583
`genesis sign` command:

docs/website/root/manual/develop/nodes/mithril-signer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ Here is a list of the available parameters:
238238
| `cardano_cli_path` | - | - | `CARDANO_CLI_PATH` | Cardano CLI tool path | - | `cardano-cli` | :heavy_check_mark: |
239239
| `cardano_node_socket_path` | - | - | `CARDANO_NODE_SOCKET_PATH` | Path of the socket opened by the Cardano node | - | `/ipc/node.socket` | :heavy_check_mark: |
240240
| `db_directory` | `--db-directory` | - | `DB_DIRECTORY` | Directory to snapshot from the **Cardano node** | `/db` | - | :heavy_check_mark: |
241-
| `network` | - | - | `NETWORK` | Cardano network | - | `testnet` or `mainnet` or `devnet` | :heavy_check_mark: |
241+
| `network` | - | - | `NETWORK` | Cardano network | - | `mainnet` or `preprod` or `devnet` | :heavy_check_mark: |
242242
| `network_magic` | - | - | `NETWORK_MAGIC` | Cardano network magic number (for `testnet` and `devnet`) | - | `1097911063` or `42` | - |
243243
| `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) |
244244
| `run_interval` | - | - | `RUN_INTERVAL` | Interval between two runtime cycles in ms | - | `60000` | :heavy_check_mark: |

internal/cardano-node/mithril-cardano-node-chain/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-cardano-node-chain"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
authors.workspace = true
55
documentation.workspace = true
66
edition.workspace = true

internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/cli_observer.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ impl CardanoCliRunner {
167167
fn post_config_command<'a>(&'a self, command: &'a mut Command) -> &'a mut Command {
168168
match self.network {
169169
CardanoNetwork::MainNet => command.arg("--mainnet"),
170-
CardanoNetwork::DevNet(magic) => command.args(vec![
171-
"--cardano-mode",
172-
"--testnet-magic",
173-
&magic.to_string(),
174-
]),
175170
CardanoNetwork::TestNet(magic) => {
176171
command.args(vec!["--testnet-magic", &magic.to_string()])
177172
}
@@ -638,26 +633,6 @@ mod tests {
638633
);
639634
}
640635

641-
#[tokio::test]
642-
async fn test_cli_devnet_runner() {
643-
let runner = CardanoCliRunner::new(
644-
PathBuf::from("cardano-cli"),
645-
PathBuf::from("/tmp/whatever.sock"),
646-
CardanoNetwork::DevNet(25),
647-
);
648-
649-
assert_cli_command!(
650-
runner.command_for_epoch(),
651-
r#""cardano-cli" "latest" "query" "tip" "--cardano-mode" "--testnet-magic" "25""#,
652-
envs: vec![(OsStr::new("CARDANO_NODE_SOCKET_PATH"), Some(OsStr::new("/tmp/whatever.sock")))]
653-
);
654-
assert_cli_command!(
655-
runner.command_for_stake_distribution(),
656-
r#""cardano-cli" "latest" "query" "stake-distribution" "--cardano-mode" "--testnet-magic" "25""#,
657-
envs: vec![(OsStr::new("CARDANO_NODE_SOCKET_PATH"), Some(OsStr::new("/tmp/whatever.sock")))]
658-
);
659-
}
660-
661636
#[tokio::test]
662637
async fn test_cli_mainnet_runner() {
663638
let runner = CardanoCliRunner::new(

internal/cardano-node/mithril-cardano-node-chain/src/chain_observer/pallas_observer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl PallasChainObserver {
5656

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

6262
Ok(client)

internal/cardano-node/mithril-cardano-node-chain/src/chain_reader/pallas_chain_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl PallasChainReader {
3838

3939
/// Creates and returns a new `NodeClient` connected to the specified socket.
4040
async fn new_client(&self) -> StdResult<NodeClient> {
41-
let magic = self.network.code();
41+
let magic = self.network.magic_id();
4242
NodeClient::connect(&self.socket, magic)
4343
.await
4444
.map_err(|err| anyhow!(err))

internal/mithril-dmq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "mithril-dmq"
33
description = "Mechanisms to publish and consume messages of a 'Decentralized Message Queue network' through a DMQ node"
4-
version = "0.1.3"
4+
version = "0.1.4"
55
authors.workspace = true
66
documentation.workspace = true
77
edition.workspace = true

internal/mithril-dmq/src/consumer/pallas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
4545
"socket" => ?self.socket,
4646
"network" => ?self.network
4747
);
48-
DmqClient::connect(&self.socket, self.network.code())
48+
DmqClient::connect(&self.socket, self.network.magic_id())
4949
.await
5050
.with_context(|| "DmqConsumerPallas failed to create a new client")
5151
}

internal/mithril-dmq/src/publisher/pallas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<M: TryToBytes + Debug> DmqPublisherPallas<M> {
4040

4141
/// Creates and returns a new `DmqClient` connected to the specified socket.
4242
async fn new_client(&self) -> StdResult<DmqClient> {
43-
let magic = self.network.code();
43+
let magic = self.network.magic_id();
4444
DmqClient::connect(&self.socket, magic)
4545
.await
4646
.with_context(|| "DmqPublisherPallas failed to create a new client")

0 commit comments

Comments
 (0)