diff --git a/node/actors/bft/src/testonly/make.rs b/node/actors/bft/src/testonly/make.rs index 74e9a1b6..c87fbd78 100644 --- a/node/actors/bft/src/testonly/make.rs +++ b/node/actors/bft/src/testonly/make.rs @@ -59,8 +59,9 @@ pub fn make_genesis( keys: &[validator::SecretKey], protocol_version: validator::ProtocolVersion, payload: validator::Payload, + block_number: validator::BlockNumber, ) -> (validator::FinalBlock, validator::ValidatorSet) { - let header = validator::BlockHeader::genesis(payload.hash()); + let header = validator::BlockHeader::genesis(payload.hash(), block_number); let validator_set = validator::ValidatorSet::new(keys.iter().map(|k| k.public())).unwrap(); let signed_messages: Vec<_> = keys .iter() diff --git a/node/actors/bft/src/testonly/run.rs b/node/actors/bft/src/testonly/run.rs index 8a830641..63384362 100644 --- a/node/actors/bft/src/testonly/run.rs +++ b/node/actors/bft/src/testonly/run.rs @@ -36,6 +36,7 @@ impl Test { &keys, validator::ProtocolVersion::EARLIEST, validator::Payload(vec![]), + validator::BlockNumber(0), ); let nodes: Vec<_> = nodes .into_iter() diff --git a/node/actors/bft/src/testonly/ut_harness.rs b/node/actors/bft/src/testonly/ut_harness.rs index 3ffddff3..dc47f46e 100644 --- a/node/actors/bft/src/testonly/ut_harness.rs +++ b/node/actors/bft/src/testonly/ut_harness.rs @@ -36,6 +36,7 @@ impl UTHarness { &keys, validator::ProtocolVersion::EARLIEST, Payload(vec![]), + validator::BlockNumber(0), ); let (mut consensus, pipe) = crate::testonly::make_consensus(ctx, &keys[0], &val_set, &genesis).await; diff --git a/node/actors/executor/src/testonly.rs b/node/actors/executor/src/testonly.rs index 3ee0a2eb..d88264cd 100644 --- a/node/actors/executor/src/testonly.rs +++ b/node/actors/executor/src/testonly.rs @@ -5,10 +5,7 @@ use std::collections::HashMap; use zksync_concurrency::net; use zksync_consensus_bft::testonly::make_genesis; use zksync_consensus_network::{consensus, testonly::Instance}; -use zksync_consensus_roles::{ - node, - validator::{self, Payload}, -}; +use zksync_consensus_roles::{node, validator}; impl ConsensusConfig { fn from_network_config( @@ -44,7 +41,8 @@ impl FullValidatorConfig { pub fn for_single_validator( rng: &mut impl Rng, protocol_version: validator::ProtocolVersion, - genesis_block_payload: Payload, + genesis_block_payload: validator::Payload, + genesis_block_number: validator::BlockNumber, ) -> Self { let mut net_configs = Instance::new_configs(rng, 1, 0); assert_eq!(net_configs.len(), 1); @@ -58,6 +56,7 @@ impl FullValidatorConfig { &[validator_key.clone()], protocol_version, genesis_block_payload, + genesis_block_number, ); let node_key = net_config.gossip.key.clone(); let node_config = ExecutorConfig { diff --git a/node/actors/executor/src/tests.rs b/node/actors/executor/src/tests.rs index db2fa1d8..0e035355 100644 --- a/node/actors/executor/src/tests.rs +++ b/node/actors/executor/src/tests.rs @@ -77,6 +77,7 @@ async fn executor_misconfiguration(name: &str, mutation: fn(&mut FinalBlock)) { rng, validator::ProtocolVersion::EARLIEST, Payload(vec![]), + BlockNumber(0), ); let genesis_block = &mut validator.node_config.genesis_block; mutation(genesis_block); @@ -98,6 +99,7 @@ async fn genesis_block_mismatch() { rng, validator::ProtocolVersion::EARLIEST, Payload(vec![]), + BlockNumber(0), ); let mut genesis_block = validator.node_config.genesis_block.clone(); genesis_block.header.number = BlockNumber(1); @@ -119,6 +121,7 @@ async fn executing_single_validator() { rng, validator::ProtocolVersion::EARLIEST, Payload(vec![]), + BlockNumber(0), ); let genesis_block = &validator.node_config.genesis_block; let storage = InMemoryStorage::new(genesis_block.clone()); @@ -148,6 +151,7 @@ async fn executing_validator_and_full_node() { rng, validator::ProtocolVersion::EARLIEST, Payload(vec![]), + BlockNumber(0), ); let full_node = validator.connect_full_node(rng); @@ -194,6 +198,7 @@ async fn syncing_full_node_from_snapshot(delay_block_storage: bool) { rng, validator::ProtocolVersion::EARLIEST, Payload(vec![]), + BlockNumber(0), ); let mut full_node = validator.connect_full_node(rng); diff --git a/node/actors/sync_blocks/src/tests/mod.rs b/node/actors/sync_blocks/src/tests/mod.rs index 154c2e0b..f88007b2 100644 --- a/node/actors/sync_blocks/src/tests/mod.rs +++ b/node/actors/sync_blocks/src/tests/mod.rs @@ -48,7 +48,7 @@ impl TestValidators { }; let payload = Payload(vec![]); - let mut latest_block = BlockHeader::genesis(payload.hash()); + let mut latest_block = BlockHeader::genesis(payload.hash(), BlockNumber(0)); let final_blocks = (0..block_count).map(|_| { let final_block = FinalBlock { header: latest_block, diff --git a/node/libs/roles/src/validator/messages/block.rs b/node/libs/roles/src/validator/messages/block.rs index 5fae9ec4..adc3fe7b 100644 --- a/node/libs/roles/src/validator/messages/block.rs +++ b/node/libs/roles/src/validator/messages/block.rs @@ -131,10 +131,10 @@ impl BlockHeader { } /// Creates a genesis block. - pub fn genesis(payload: PayloadHash) -> Self { + pub fn genesis(payload: PayloadHash, number: BlockNumber) -> Self { Self { parent: BlockHeaderHash(Keccak256::default()), - number: BlockNumber(0), + number, payload, } } diff --git a/node/libs/roles/src/validator/testonly.rs b/node/libs/roles/src/validator/testonly.rs index 038aae2e..dfe1e0f4 100644 --- a/node/libs/roles/src/validator/testonly.rs +++ b/node/libs/roles/src/validator/testonly.rs @@ -36,7 +36,7 @@ pub fn make_justification( /// WARNING: it is not a fully correct FinalBlock. pub fn make_genesis_block(rng: &mut R, protocol_version: ProtocolVersion) -> FinalBlock { let payload: Payload = rng.gen(); - let header = BlockHeader::genesis(payload.hash()); + let header = BlockHeader::genesis(payload.hash(), BlockNumber(0)); let justification = make_justification(rng, &header, protocol_version); FinalBlock { header, diff --git a/node/libs/storage/src/tests/mod.rs b/node/libs/storage/src/tests/mod.rs index 229209d1..ffcb4744 100644 --- a/node/libs/storage/src/tests/mod.rs +++ b/node/libs/storage/src/tests/mod.rs @@ -31,7 +31,7 @@ impl InitStore for () { fn genesis_block(rng: &mut impl Rng) -> FinalBlock { let payload = Payload(vec![]); FinalBlock { - header: BlockHeader::genesis(payload.hash()), + header: BlockHeader::genesis(payload.hash(), BlockNumber(0)), payload, justification: rng.gen(), } diff --git a/node/tools/src/bin/localnet_config.rs b/node/tools/src/bin/localnet_config.rs index 3b5461ed..bbeffebf 100644 --- a/node/tools/src/bin/localnet_config.rs +++ b/node/tools/src/bin/localnet_config.rs @@ -71,6 +71,7 @@ fn main() -> anyhow::Result<()> { &validator_keys, protocol_version, validator::Payload(vec![]), + validator::BlockNumber(0), ); // Each node will have `gossip_peers` outbound peers.