Skip to content

Commit

Permalink
chore: remove the use of zero as a validator id (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 authored Dec 5, 2024
1 parent fa2439b commit 7333bc8
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions config/papyrus/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"consensus.validator_id": {
"description": "The validator id of the node.",
"privacy": "Public",
"value": "0x0"
"value": "0x64"
},
"monitoring_gateway.collect_metrics": {
"description": "If true, collect and return metrics in the monitoring gateway.",
Expand Down Expand Up @@ -514,4 +514,4 @@
"privacy": "Public",
"value": true
}
}
}
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": "0x64"
},
"eth_fee_token_address": {
"description": "A required param! Address of the ETH fee token.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: crates/papyrus_node/src/config/config_test.rs
expression: dumped_default_config
snapshot_kind: text
---
{
"base_layer.node_url": {
Expand Down Expand Up @@ -243,7 +244,7 @@ expression: dumped_default_config
},
"consensus.validator_id": {
"description": "The validator id of the node.",
"value": "0x0",
"value": "0x64",
"privacy": "Public"
},
"monitoring_gateway.collect_metrics": {
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 @@ -100,7 +100,7 @@ impl Default for ConsensusConfig {
};
Self {
chain_id: ChainId::Other("0x0".to_string()),
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_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 @@ -69,7 +69,8 @@ impl PapyrusConsensusContext {
storage_reader,
network_broadcast_client,
network_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(),
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 @@ -39,7 +39,7 @@ async fn build_proposal() {
let proposal_init = ProposalInit {
height: block_number,
round: 0,
proposer: ValidatorId::default(),
proposer: ValidatorId::from(100_u32),
valid_round: None,
};
// TODO(Asmaa): Test proposal content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ impl SequencerConsensusContext {
_proposal_streaming_client,
outbound_proposal_sender,
vote_broadcast_client,
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 7333bc8

Please sign in to comment.