Skip to content
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

feat: DEVOPS-1568 bootstrap node should not be a validator #1497

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion z2/resources/chain-specs/zq2-devnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion z2/resources/chain-specs/zq2-perftest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion z2/resources/chain-specs/zq2-prototestnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion z2/resources/chain-specs/zq2-uccbtest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion z2/resources/config.tera.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions z2/src/chain/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -141,6 +142,7 @@ impl ChainInstance {
bootstrap_public_ip.clone(),
bootstrap_private_key.clone(),
genesis_wallet_private_key.clone(),
validator_private_keys.clone(),
)
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -178,6 +180,21 @@ impl ChainInstance {
}
}

pub async fn validator_private_keys(&self) -> Result<Vec<String>> {
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<String> {
let private_keys =
retrieve_secret_by_role(&self.config.name, &self.config.project_id, "genesis").await?;
Expand Down
12 changes: 11 additions & 1 deletion z2/src/chain/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ pub struct ChainNode {
bootstrap_public_ip: String,
bootstrap_private_key: String,
genesis_wallet_private_key: String,
validator_private_keys: Vec<String>,
}

#[allow(clippy::too_many_arguments)]
Expand All @@ -277,6 +278,7 @@ impl ChainNode {
bootstrap_public_ip: String,
bootstrap_private_key: String,
genesis_wallet_private_key: String,
validator_private_keys: Vec<String>,
) -> Self {
Self {
chain_name,
Expand All @@ -287,6 +289,7 @@ impl ChainNode {
bootstrap_public_ip,
bootstrap_private_key,
genesis_wallet_private_key,
validator_private_keys,
}
}

Expand Down Expand Up @@ -534,6 +537,12 @@ impl ChainNode {
pub fn get_config_toml(&self) -> Result<String> {
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();
Expand All @@ -544,8 +553,9 @@ impl ChainNode {
var_map.insert("eth_chain_id", &eth_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)?)
Expand Down