From f04f95f428ddfca273e72ed8510a66d59a8aed7d Mon Sep 17 00:00:00 2001 From: Francesco Medas Date: Tue, 24 Sep 2024 14:31:39 +0400 Subject: [PATCH 1/2] feat: DEVOPS-1568 replace consensus deposit with a validator --- z2/resources/chain-specs/zq2-devnet.toml | 2 +- z2/resources/chain-specs/zq2-prototestnet.toml | 2 +- z2/resources/config.tera.toml | 2 +- z2/src/chain/instance.rs | 17 +++++++++++++++++ z2/src/chain/node.rs | 12 +++++++++++- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/z2/resources/chain-specs/zq2-devnet.toml b/z2/resources/chain-specs/zq2-devnet.toml index dddbc5b34..9f6a8a316 100644 --- a/z2/resources/chain-specs/zq2-devnet.toml +++ b/z2/resources/chain-specs/zq2-devnet.toml @@ -6,7 +6,7 @@ eth_chain_id = 33469 allowed_timestamp_skew = { secs = 60, nanos = 0 } data_dir = "/data" consensus.genesis_accounts = [ ["0x977a797a0546cdb1082c2368921af455dfdc7a5a", "21_000_000_000_000_000_000_000_000_000"] ] -consensus.genesis_deposits = [ ["8a968db895dc1f17d1e13bbf1582078f82657247820411ad3fe4f5816a75566cd9a4ba9f8e73f6306d7a7b7086e4e8a6", "12D3KooWJNUNgs1UM9mw1Pfskxk4o3VWz37cpneSHZsUecGGZgkb", "100_000_000_000_000_000_000_000_000", "0x977a797a0546cdb1082c2368921af455dfdc7a5a"] ] +consensus.genesis_deposits = [ ["b0447d886f8499bc0fd4aa21da63d71a0175ddd005d217a00c5304e1272e4a79a7df0ecb878a343582c9f2ca78c8c17f", "12D3KooWE4sUhynBXB99BciBuXDiMXWLACcqRq4ggXWdCsWxrvn3", "100_000_000_000_000_000_000_000_000", "0x977a797a0546cdb1082c2368921af455dfdc7a5a"] ] # Reward parameters consensus.rewards_per_hour = "51_000_000_000_000_000_000_000" diff --git a/z2/resources/chain-specs/zq2-prototestnet.toml b/z2/resources/chain-specs/zq2-prototestnet.toml index 9c0070e96..7c43fab91 100644 --- a/z2/resources/chain-specs/zq2-prototestnet.toml +++ b/z2/resources/chain-specs/zq2-prototestnet.toml @@ -6,7 +6,7 @@ eth_chain_id = 33103 allowed_timestamp_skew = { secs = 60, nanos = 0 } data_dir = "/data" consensus.genesis_accounts = [ ["0x3b5cf50bb3ed8d77d1895084092156c7549be7df", "21_000_000_000_000_000_000_000_000_000"] ] -consensus.genesis_deposits = [ ["b95bb5b3669baa33ebedd784bcab7e281deba89537ccabbe2bbb81c7bdbbd11c8a8118dfc3fd8af17077c4636c52b508", "12D3KooWEpeCSbza6zYXJ8PY8v6iEZYzYD4mhk4QbmHGbjx186dS", "100_000_000_000_000_000_000_000_000", "0x3b5cf50bb3ed8d77d1895084092156c7549be7df"] ] +consensus.genesis_deposits = [ ["89058ecd0c6f01b841f330a0c279a6061bd6cd4a446e04004b1c8169faec766374c46769a766566483e8370541b2b549", "12D3KooWPBc68cwv23Zikeuaqv8Lmqu9VNnfuYsmWFqsFD9rs91e", "100_000_000_000_000_000_000_000_000", "0x3b5cf50bb3ed8d77d1895084092156c7549be7df"] ] # Reward parameters consensus.rewards_per_hour = "51_000_000_000_000_000_000_000" diff --git a/z2/resources/config.tera.toml b/z2/resources/config.tera.toml index d3c3b740f..a6772b823 100644 --- a/z2/resources/config.tera.toml +++ b/z2/resources/config.tera.toml @@ -9,7 +9,7 @@ eth_chain_id = {{ eth_chain_id }} allowed_timestamp_skew = { secs = 60, nanos = 0 } data_dir = "/data" consensus.genesis_accounts = [ ["{{ genesis_address }}", "21_000_000_000_000_000_000_000_000_000"] ] -consensus.genesis_deposits = [ ["{{ bootstrap_bls_public_key }}", "{{ bootstrap_peer_id }}", "100_000_000_000_000_000_000_000_000", "{{ genesis_address }}"] ] +consensus.genesis_deposits = [ ["{{ validator_0_bls_public_key }}", "{{ validator_0_peer_id }}", "100_000_000_000_000_000_000_000_000", "{{ genesis_address }}"] ] # Reward parameters consensus.rewards_per_hour = "51_000_000_000_000_000_000_000" diff --git a/z2/src/chain/instance.rs b/z2/src/chain/instance.rs index bd4d468ce..1c37cc267 100644 --- a/z2/src/chain/instance.rs +++ b/z2/src/chain/instance.rs @@ -126,6 +126,7 @@ impl ChainInstance { let bootstrap_public_ip = self.bootstrap_public_ip()?; let bootstrap_private_key = self.bootstrap_private_key().await?; let genesis_wallet_private_key = self.genesis_wallet_private_key().await?; + let validator_private_keys = self.validator_private_keys().await?; for node_role in node_roles { let instances = self.machines_by_role(node_role.clone()); @@ -141,6 +142,7 @@ impl ChainInstance { bootstrap_public_ip.clone(), bootstrap_private_key.clone(), genesis_wallet_private_key.clone(), + validator_private_keys.clone(), ) }) .collect::>(); @@ -178,6 +180,21 @@ impl ChainInstance { } } + pub async fn validator_private_keys(&self) -> Result> { + let private_keys = + retrieve_secret_by_role(&self.config.name, &self.config.project_id, "validator") + .await?; + + if private_keys.is_empty() { + return Err(anyhow!( + "No secrets with role validator found in the network {}", + &self.name() + )); + } + + Ok(private_keys) + } + pub async fn genesis_wallet_private_key(&self) -> Result { let private_keys = retrieve_secret_by_role(&self.config.name, &self.config.project_id, "genesis").await?; diff --git a/z2/src/chain/node.rs b/z2/src/chain/node.rs index 36fdf10b3..17445cc56 100644 --- a/z2/src/chain/node.rs +++ b/z2/src/chain/node.rs @@ -264,6 +264,7 @@ pub struct ChainNode { bootstrap_public_ip: String, bootstrap_private_key: String, genesis_wallet_private_key: String, + validator_private_keys: Vec, } #[allow(clippy::too_many_arguments)] @@ -277,6 +278,7 @@ impl ChainNode { bootstrap_public_ip: String, bootstrap_private_key: String, genesis_wallet_private_key: String, + validator_private_keys: Vec, ) -> Self { Self { chain_name, @@ -287,6 +289,7 @@ impl ChainNode { bootstrap_public_ip, bootstrap_private_key, genesis_wallet_private_key, + validator_private_keys, } } @@ -534,6 +537,12 @@ impl ChainNode { pub fn get_config_toml(&self) -> Result { let spec_config = include_str!("../../resources/config.tera.toml"); + let validator_node = if let Some(pk) = self.validator_private_keys.first() { + EthereumAddress::from_private_key(pk)? + } else { + return Err(anyhow!("Validator private keys not found")); + }; + let genesis_wallet = EthereumAddress::from_private_key(&self.genesis_wallet_private_key)?; let bootstrap_node = EthereumAddress::from_private_key(&self.bootstrap_private_key)?; let role_name = self.role.to_string(); @@ -544,8 +553,9 @@ impl ChainNode { var_map.insert("eth_chain_id", ð_chain_id); var_map.insert("bootstrap_public_ip", &self.bootstrap_public_ip); var_map.insert("bootstrap_peer_id", &bootstrap_node.peer_id); - var_map.insert("bootstrap_bls_public_key", &bootstrap_node.bls_public_key); var_map.insert("genesis_address", &genesis_wallet.address); + var_map.insert("validator_0_bls_public_key", &validator_node.bls_public_key); + var_map.insert("validator_0_peer_id", &validator_node.peer_id); let ctx = Context::from_serialize(var_map)?; Ok(Tera::one_off(spec_config, &ctx, false)?) From 456e558da561f3c9e17b08ac290ae964116b5f96 Mon Sep 17 00:00:00 2001 From: Francesco Medas Date: Thu, 26 Sep 2024 11:12:54 +0400 Subject: [PATCH 2/2] update config files --- z2/resources/chain-specs/zq2-perftest.toml | 2 +- z2/resources/chain-specs/zq2-uccbtest.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/z2/resources/chain-specs/zq2-perftest.toml b/z2/resources/chain-specs/zq2-perftest.toml index 3fe74b541..6f9925807 100644 --- a/z2/resources/chain-specs/zq2-perftest.toml +++ b/z2/resources/chain-specs/zq2-perftest.toml @@ -6,7 +6,7 @@ eth_chain_id = 33469 allowed_timestamp_skew = { secs = 60, nanos = 0 } data_dir = "/data" consensus.genesis_accounts = [ ["0xd4b13a10f43be60f8df150c0996f6de377cd770c", "21_000_000_000_000_000_000_000_000_000"] ] -consensus.genesis_deposits = [ ["b6f185408f3f50c4021d4a000295653c8d42c641ab4bde5e04fcb739888e6a976eb3b62b5b4b404c5c3dfe2aa53e7ac8", "12D3KooWLQErYMNECpTd22VtTQeGXRf18yeeEM32rVAWZ9qXdLUB", "100_000_000_000_000_000_000_000_000", "0xd4b13a10f43be60f8df150c0996f6de377cd770c"] ] +consensus.genesis_deposits = [ ["866d272c4f6ab40c7116550baaa465a62352a517d46c91b0e74ca0bb46e4face5ff77483cce64334c5843caf535dbd88", "12D3KooWNSQJTx9CyEbd7wSVUwtJ9rc6EeQACineE1WSH34NqUCB", "100_000_000_000_000_000_000_000_000", "0xd4b13a10f43be60f8df150c0996f6de377cd770c"] ] # Reward parameters consensus.rewards_per_hour = "51_000_000_000_000_000_000_000" diff --git a/z2/resources/chain-specs/zq2-uccbtest.toml b/z2/resources/chain-specs/zq2-uccbtest.toml index f945e5599..314bfd5bd 100644 --- a/z2/resources/chain-specs/zq2-uccbtest.toml +++ b/z2/resources/chain-specs/zq2-uccbtest.toml @@ -6,7 +6,7 @@ eth_chain_id = 33469 allowed_timestamp_skew = { secs = 60, nanos = 0 } data_dir = "/data" consensus.genesis_accounts = [ ["0xc36ca59822f80b8b55cd033007cc46d5205cca3e", "21_000_000_000_000_000_000_000_000_000"] ] -consensus.genesis_deposits = [ ["b3256475ab58e0964b748ba90c7b19d39496ffc93345db7f2d23abf38f981f9654f08882ce415d5588530bb4861a09c4", "12D3KooWReRperXgN12FUH6yRTXrcV3u98E753356AR1sAEJefup", "100_000_000_000_000_000_000_000_000", "0xc36ca59822f80b8b55cd033007cc46d5205cca3e"] ] +consensus.genesis_deposits = [ ["807da9d051ac7d449ecacbc0e81cc26372baf5804bb9c3593305ba0a8c5877cc18d353e2bff8afc30c0502c8bfe86251", "12D3KooWATa3pVrPHb6TKr5Af1nzBszoW3QHgUCu18B9F27NVqnL", "100_000_000_000_000_000_000_000_000", "0xc36ca59822f80b8b55cd033007cc46d5205cca3e"] ] # Reward parameters consensus.rewards_per_hour = "51_000_000_000_000_000_000_000"