Skip to content

Commit

Permalink
chore(consensus): move const to consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
ArniStarkware committed Dec 19, 2024
1 parent 093eb7d commit a422bb3
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions crates/papyrus_protobuf/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ pub struct ProposalInit {
pub proposer: ContractAddress,
}

/// A temporary constant to use as a validator ID. Zero is not a valid contract address.
// TODO(Matan): Remove this once we have a proper validator set.
pub const DEFAULT_VALIDATOR_ID: u64 = 100;

impl Default for ProposalInit {
fn default() -> Self {
ProposalInit {
height: Default::default(),
round: Default::default(),
valid_round: Default::default(),
// TODO(Arni): Use DEFAULT_VALIDATOR_ID instead of 100.
proposer: ContractAddress::from(100_u64),
proposer: ContractAddress::from(DEFAULT_VALIDATOR_ID),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/sequencing/papyrus_consensus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use papyrus_config::converters::{
use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig};
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use papyrus_network::NetworkConfig;
use papyrus_protobuf::consensus::DEFAULT_VALIDATOR_ID;
use serde::{Deserialize, Serialize};
use starknet_api::block::BlockNumber;
use starknet_api::core::ChainId;
use validator::Validate;

use super::types::ValidatorId;
use crate::types::DEFAULT_VALIDATOR_ID;
use crate::types::ValidatorId;

const CONSENSUS_TCP_PORT: u16 = 10100;
const CONSENSUS_QUIC_PORT: u16 = 10101;
Expand Down
10 changes: 2 additions & 8 deletions crates/sequencing/papyrus_consensus/src/manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use papyrus_protobuf::consensus::{
ProposalInit,
ProposalPart,
Vote,
DEFAULT_VALIDATOR_ID,
};
use papyrus_test_utils::{get_rng, GetTestInstance};
use starknet_api::block::{BlockHash, BlockNumber};
Expand All @@ -29,14 +30,7 @@ use tokio::sync::Notify;
use super::{run_consensus, MultiHeightManager, RunHeightRes};
use crate::config::TimeoutsConfig;
use crate::test_utils::{precommit, prevote, proposal_init};
use crate::types::{
ConsensusContext,
ConsensusError,
ProposalContentId,
Round,
ValidatorId,
DEFAULT_VALIDATOR_ID,
};
use crate::types::{ConsensusContext, ConsensusError, ProposalContentId, Round, ValidatorId};

lazy_static! {
static ref PROPOSER_ID: ValidatorId = DEFAULT_VALIDATOR_ID.into();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use futures::channel::{mpsc, oneshot};
use futures::SinkExt;
use lazy_static::lazy_static;
use papyrus_protobuf::consensus::{ConsensusMessage, ProposalFin, ProposalInit};
use papyrus_protobuf::consensus::{
ConsensusMessage,
ProposalFin,
ProposalInit,
DEFAULT_VALIDATOR_ID,
};
use starknet_api::block::{BlockHash, BlockNumber};
use starknet_types_core::felt::Felt;
use test_case::test_case;
Expand All @@ -12,7 +17,7 @@ use crate::config::TimeoutsConfig;
use crate::single_height_consensus::{ShcEvent, ShcReturn, ShcTask};
use crate::state_machine::StateMachineEvent;
use crate::test_utils::{precommit, prevote, MockProposalPart, MockTestContext, TestBlock};
use crate::types::{ConsensusError, ValidatorId, DEFAULT_VALIDATOR_ID};
use crate::types::{ConsensusError, ValidatorId};

lazy_static! {
static ref PROPOSER_ID: ValidatorId = DEFAULT_VALIDATOR_ID.into();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::collections::VecDeque;

use lazy_static::lazy_static;
use papyrus_protobuf::consensus::DEFAULT_VALIDATOR_ID;
use starknet_api::block::BlockHash;
use starknet_types_core::felt::Felt;
use test_case::test_case;

use super::Round;
use crate::state_machine::{StateMachine, StateMachineEvent};
use crate::types::{ProposalContentId, ValidatorId, DEFAULT_VALIDATOR_ID};
use crate::types::{ProposalContentId, ValidatorId};

lazy_static! {
static ref PROPOSER_ID: ValidatorId = DEFAULT_VALIDATOR_ID.into();
Expand Down
4 changes: 0 additions & 4 deletions crates/sequencing/papyrus_consensus/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ pub type ValidatorId = ContractAddress;
pub type Round = u32;
pub type ProposalContentId = BlockHash;

/// A temporary constant to use as a validator ID. Zero is not a valid contract address.
// TODO(Matan): Remove this once we have a proper validator set.
pub const DEFAULT_VALIDATOR_ID: u64 = 100;

/// Interface for consensus to call out to the node.
///
/// Function calls should be assumed to not be cancel safe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use papyrus_consensus::types::{
ProposalContentId,
Round,
ValidatorId,
DEFAULT_VALIDATOR_ID,
};
use papyrus_network::network_manager::{BroadcastTopicClient, BroadcastTopicClientTrait};
use papyrus_protobuf::consensus::{
Expand All @@ -32,6 +31,7 @@ use papyrus_protobuf::consensus::{
ProposalPart,
TransactionBatch,
Vote,
DEFAULT_VALIDATOR_ID,
};
use papyrus_storage::body::BodyStorageReader;
use papyrus_storage::header::HeaderStorageReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use papyrus_consensus::types::{
ProposalContentId,
Round,
ValidatorId,
DEFAULT_VALIDATOR_ID,
};
use papyrus_network::network_manager::{BroadcastTopicClient, BroadcastTopicClientTrait};
use papyrus_protobuf::consensus::{
Expand All @@ -28,6 +27,7 @@ use papyrus_protobuf::consensus::{
ProposalPart,
TransactionBatch,
Vote,
DEFAULT_VALIDATOR_ID,
};
use starknet_api::block::{
BlockHash,
Expand Down
4 changes: 2 additions & 2 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use blockifier::test_utils::contracts::FeatureContract;
use blockifier::test_utils::{CairoVersion, RunnableCairo1};
use mempool_test_utils::starknet_api_test_utils::{AccountId, MultiAccountTransactionGenerator};
use papyrus_consensus::config::ConsensusConfig;
use papyrus_consensus::types::{ValidatorId, DEFAULT_VALIDATOR_ID};
use papyrus_consensus::types::ValidatorId;
use papyrus_network::network_manager::test_utils::{
create_connected_network_configs,
create_network_configs_connected_to_broadcast_channels,
};
use papyrus_network::network_manager::BroadcastTopicChannels;
use papyrus_protobuf::consensus::{ProposalPart, StreamMessage};
use papyrus_protobuf::consensus::{ProposalPart, StreamMessage, DEFAULT_VALIDATOR_ID};
use papyrus_storage::StorageConfig;
use starknet_api::block::BlockNumber;
use starknet_api::core::{ChainId, ContractAddress};
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_sequencer_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const_format.workspace = true
futures.workspace = true
infra_utils.workspace = true
papyrus_config.workspace = true
papyrus_consensus.workspace = true
papyrus_proc_macros = { workspace = true, optional = true }
papyrus_protobuf.workspace = true
rstest.workspace = true
serde.workspace = true
starknet_api.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_sequencer_node/src/config/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::vec::Vec; // Used by #[gen_field_names_fn].

use papyrus_consensus::types::DEFAULT_VALIDATOR_ID;
use papyrus_proc_macros::gen_field_names_and_cli_args_fn;
use papyrus_protobuf::consensus::DEFAULT_VALIDATOR_ID;
use starknet_api::core::{ChainId, ContractAddress};

use crate::config::node_config::node_command;
Expand Down

0 comments on commit a422bb3

Please sign in to comment.