Skip to content

Commit

Permalink
chore(starknet_batcher): remove sequncer address from block builder c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
ArniStarkware committed Dec 3, 2024
1 parent 998a21e commit 2b3c009
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/papyrus/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"consensus.validator_id": {
"description": "The validator id of the node.",
"privacy": "Public",
"value": "0x0"
"value": "0x7c7"
},
"monitoring_gateway.collect_metrics": {
"description": "If true, collect and return metrics in the monitoring gateway.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ expression: dumped_default_config
},
"consensus.validator_id": {
"description": "The validator id of the node.",
"value": "0x0",
"value": "0x7c7",
"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 @@ -90,7 +90,7 @@ impl Default for ConsensusConfig {
..Default::default()
};
Self {
validator_id: ValidatorId::default(),
validator_id: ValidatorId::from(1991_u128),
network_topic: "consensus".to_string(),
start_height: BlockNumber::default(),
num_validators: 1,
Expand Down
26 changes: 21 additions & 5 deletions crates/sequencing/papyrus_consensus/src/single_height_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,21 @@ impl SingleHeightConsensus {
) -> Result<ShcReturn, ConsensusError> {
info!("Starting consensus with validators {:?}", self.validators);
context
.set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default())
.set_height_and_round(
self.height,
self.state_machine.round(),
ValidatorId::from(1991_u32),
)
.await;
let leader_fn = |round: Round| -> ValidatorId { context.proposer(self.height, round) };
let events = self.state_machine.start(&leader_fn);
let ret = self.handle_state_machine_events(context, events).await;
context
.set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default())
.set_height_and_round(
self.height,
self.state_machine.round(),
ValidatorId::from(1991_u32),
)
.await;
ret
}
Expand Down Expand Up @@ -239,7 +247,11 @@ impl SingleHeightConsensus {
)
.await;
context
.set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default())
.set_height_and_round(
self.height,
self.state_machine.round(),
ValidatorId::from(1991_u32),
)
.await;
Ok(ShcReturn::Tasks(vec![ShcTask::ValidateProposal(init, block_receiver)]))
}
Expand Down Expand Up @@ -272,7 +284,7 @@ impl SingleHeightConsensus {
.set_height_and_round(
self.height,
self.state_machine.round(),
ValidatorId::default(),
ValidatorId::from(1991_u32),
)
.await;
ret
Expand Down Expand Up @@ -368,7 +380,11 @@ impl SingleHeightConsensus {
_ => unimplemented!("Unexpected event: {:?}", event),
};
context
.set_height_and_round(self.height, self.state_machine.round(), ValidatorId::default())
.set_height_and_round(
self.height,
self.state_machine.round(),
ValidatorId::from(1991_u32),
)
.await;
ret
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ use tokio::task::JoinHandle;
use tracing::{debug, debug_span, error, info, trace, warn, Instrument};

// TODO(Dan, Matan): Remove these and replace with real gas prices and real sequencer address.
const TEMPORARY_SEQUENCER_ADDRESS: u16 = 1991;
const TEMPORARY_GAS_PRICES: GasPrices = GasPrices {
eth_gas_prices: GasPriceVector {
l1_gas_price: NonzeroGasPrice::MIN,
Expand Down Expand Up @@ -180,7 +179,7 @@ impl ConsensusContext for SequencerConsensusContext {
now.timestamp().try_into().expect("Failed to convert timestamp"),
),
use_kzg_da: true,
sequencer_address: ValidatorId::from(TEMPORARY_SEQUENCER_ADDRESS),
sequencer_address: proposal_init.proposer,
},
};
// TODO: Should we be returning an error?
Expand Down Expand Up @@ -364,7 +363,7 @@ impl SequencerConsensusContext {
async fn validate_current_round_proposal(
&mut self,
height: BlockNumber,
_proposer: ValidatorId,
proposer: ValidatorId,
timeout: Duration,
content_receiver: mpsc::Receiver<ProposalPart>,
fin_sender: oneshot::Sender<(ProposalContentId, ProposalFin)>,
Expand Down Expand Up @@ -395,7 +394,7 @@ impl SequencerConsensusContext {
now.timestamp().try_into().expect("Failed to convert timestamp"),
),
use_kzg_da: true,
sequencer_address: ValidatorId::from(TEMPORARY_SEQUENCER_ADDRESS),
sequencer_address: proposer,
},
};
batcher.validate_block(input).await.expect("Failed to initiate proposal validation");
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 @@ -65,7 +65,7 @@ async fn listen_to_broadcasted_messages(
height: BlockNumber(1),
round: 0,
valid_round: None,
proposer: ContractAddress::default(),
proposer: ValidatorId::from(1991_u32),
};
let expected_proposal_fin = ProposalFin {
proposal_content_id: BlockHash(Felt::from_hex_unchecked(
Expand Down

0 comments on commit 2b3c009

Please sign in to comment.