Skip to content

Commit

Permalink
chore: remove the use of zero as a validator id
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Dec 3, 2024
1 parent dee0a42 commit dca77f0
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@
"consensus_manager_config.consensus_config.validator_id": {
"description": "The validator id of the node.",
"privacy": "Public",
"value": "0x0"
"value": "0x100"
},
"eth_fee_token_address": {
"description": "A required param! Address of the ETH fee token.",
Expand Down
2 changes: 1 addition & 1 deletion crates/sequencing/papyrus_consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Default for ConsensusConfig {
..Default::default()
};
Self {
validator_id: ValidatorId::default(),
validator_id: ValidatorId::from(100_u32),
network_topic: "consensus".to_string(),
start_height: BlockNumber::default(),
num_validators: 1,
Expand Down
8 changes: 4 additions & 4 deletions crates/sequencing/papyrus_consensus/src/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ use crate::test_utils::{precommit, prevote, proposal, proposal_init};
use crate::types::{ConsensusContext, ConsensusError, ProposalContentId, Round, ValidatorId};

lazy_static! {
static ref PROPOSER_ID: ValidatorId = 0_u32.into();
static ref VALIDATOR_ID: ValidatorId = 1_u32.into();
static ref VALIDATOR_ID_2: ValidatorId = 2_u32.into();
static ref VALIDATOR_ID_3: ValidatorId = 3_u32.into();
static ref PROPOSER_ID: ValidatorId = 100_u32.into();
static ref VALIDATOR_ID: ValidatorId = 101_u32.into();
static ref VALIDATOR_ID_2: ValidatorId = 102_u32.into();
static ref VALIDATOR_ID_3: ValidatorId = 103_u32.into();
static ref TIMEOUTS: TimeoutsConfig = TimeoutsConfig::default();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use crate::test_utils::{precommit, prevote, MockProposalPart, MockTestContext, T
use crate::types::{ConsensusError, ValidatorId};

lazy_static! {
static ref PROPOSER_ID: ValidatorId = 0_u32.into();
static ref VALIDATOR_ID_1: ValidatorId = 1_u32.into();
static ref VALIDATOR_ID_2: ValidatorId = 2_u32.into();
static ref VALIDATOR_ID_3: ValidatorId = 3_u32.into();
static ref PROPOSER_ID: ValidatorId = 100_u32.into();
static ref VALIDATOR_ID_1: ValidatorId = 101_u32.into();
static ref VALIDATOR_ID_2: ValidatorId = 102_u32.into();
static ref VALIDATOR_ID_3: ValidatorId = 103_u32.into();
static ref VALIDATORS: Vec<ValidatorId> =
vec![*PROPOSER_ID, *VALIDATOR_ID_1, *VALIDATOR_ID_2, *VALIDATOR_ID_3];
static ref BLOCK: TestBlock = TestBlock { content: vec![1, 2, 3], id: BlockHash(Felt::ONE) };
Expand Down
4 changes: 2 additions & 2 deletions crates/sequencing/papyrus_consensus/src/state_machine_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::state_machine::{StateMachine, StateMachineEvent};
use crate::types::{ProposalContentId, ValidatorId};

lazy_static! {
static ref PROPOSER_ID: ValidatorId = 0_u32.into();
static ref VALIDATOR_ID: ValidatorId = 1_u32.into();
static ref PROPOSER_ID: ValidatorId = 100_u32.into();
static ref VALIDATOR_ID: ValidatorId = 101_u32.into();
}

const PROPOSAL_ID: Option<ProposalContentId> = Some(BlockHash(Felt::ONE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use papyrus_storage::body::BodyStorageReader;
use papyrus_storage::header::HeaderStorageReader;
use papyrus_storage::{StorageError, StorageReader};
use starknet_api::block::BlockNumber;
use starknet_api::core::ContractAddress;
use starknet_api::transaction::Transaction;
use tracing::{debug, debug_span, info, warn, Instrument};

Expand Down Expand Up @@ -70,7 +69,8 @@ impl PapyrusConsensusContext {
storage_reader,
network_broadcast_client,
network_proposal_sender,
validators: (0..num_validators).map(ContractAddress::from).collect(),
// TODO(Matan): Set the actual validator IDs (contract addresses).
validators: (100..100 + num_validators).map(ValidatorId::from).collect(),
sync_broadcast_sender,
valid_proposals: Arc::new(Mutex::new(BTreeMap::new())),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ impl SequencerConsensusContext {
batcher,
_proposal_streaming_client,
outbound_proposal_sender,
validators: (0..num_validators).map(ValidatorId::from).collect(),
// TODO(Matan): Set the actual validator IDs (contract addresses).
validators: (100..100 + num_validators).map(ValidatorId::from).collect(),
valid_proposals: Arc::new(Mutex::new(HeightToIdToContent::new())),
proposal_id: 0,
current_height: None,
Expand Down
1 change: 1 addition & 0 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn create_consensus_manager_configs_and_channels(

let consensus_manager_configs = network_configs
.into_iter()
// TODO(Matan): Get config from default config file.
.map(|network_config| ConsensusManagerConfig {
consensus_config: ConsensusConfig {
start_height: BlockNumber(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashSet;

use futures::StreamExt;
use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerator;
use papyrus_consensus::types::ValidatorId;
use papyrus_network::network_manager::BroadcastTopicChannels;
use papyrus_protobuf::consensus::{
ProposalFin,
Expand All @@ -14,7 +15,6 @@ use papyrus_storage::test_utils::CHAIN_ID_FOR_TESTS;
use pretty_assertions::assert_eq;
use rstest::{fixture, rstest};
use starknet_api::block::{BlockHash, BlockNumber};
use starknet_api::core::ContractAddress;
use starknet_api::transaction::TransactionHash;
use starknet_integration_tests::flow_test_setup::FlowTestSetup;
use starknet_integration_tests::utils::{
Expand Down Expand Up @@ -89,7 +89,7 @@ async fn listen_to_broadcasted_messages(
height: expected_height,
round: 0,
valid_round: None,
proposer: ContractAddress::default(),
proposer: ValidatorId::from(100_u32),
};
let expected_proposal_fin = ProposalFin { proposal_content_id: BlockHash(expected_content_id) };

Expand Down

0 comments on commit dca77f0

Please sign in to comment.