From 998a21e56d711f10d02e920140f92bafa42a2719 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Mon, 2 Dec 2024 15:22:23 +0200 Subject: [PATCH] chore(starknet_batcher): in block builder use the consensus suplied sequncer address --- config/sequencer/default_config.json | 10 ---------- config/sequencer/presets/config-batcher.json | 1 - .../src/sequencer_consensus_context.rs | 9 +++++---- crates/starknet_batcher/src/block_builder.rs | 15 +-------------- .../src/config_utils.rs | 1 - crates/starknet_integration_tests/src/utils.rs | 11 +---------- .../src/config/node_config.rs | 9 --------- .../src/config/test_utils.rs | 2 -- 8 files changed, 7 insertions(+), 51 deletions(-) diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index 1483b2410b..ce688908af 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -104,11 +104,6 @@ "privacy": "Public", "value": 0 }, - "batcher_config.block_builder_config.sequencer_address": { - "description": "The address of the sequencer.", - "pointer_target": "sequencer_address", - "privacy": "Public" - }, "batcher_config.block_builder_config.tx_chunk_size": { "description": "The size of the transaction chunk.", "privacy": "Public", @@ -944,11 +939,6 @@ "privacy": "Public", "value": "" }, - "sequencer_address": { - "description": "A required param! The sequencer address.", - "param_type": "String", - "privacy": "TemporaryValue" - }, "strk_fee_token_address": { "description": "A required param! Address of the STRK fee token.", "param_type": "String", diff --git a/config/sequencer/presets/config-batcher.json b/config/sequencer/presets/config-batcher.json index f2bda32063..43508b8211 100644 --- a/config/sequencer/presets/config-batcher.json +++ b/config/sequencer/presets/config-batcher.json @@ -4,5 +4,4 @@ "strk_fee_token_address": "0x7", "batcher_config.storage.db_config.path_prefix": "/data", "batcher_config.storage.db_config.enforce_file_exists": false, - "sequencer_address": "0x1" } diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs index 6fc77d77af..e1db995b78 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -57,7 +57,8 @@ use tokio::sync::Notify; use tokio::task::JoinHandle; use tracing::{debug, debug_span, error, info, trace, warn, Instrument}; -// TODO(Dan, Matan): Remove this once and replace with real gas prices. +// 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, @@ -179,7 +180,7 @@ impl ConsensusContext for SequencerConsensusContext { now.timestamp().try_into().expect("Failed to convert timestamp"), ), use_kzg_da: true, - sequencer_address: proposal_init.proposer, + sequencer_address: ValidatorId::from(TEMPORARY_SEQUENCER_ADDRESS), }, }; // TODO: Should we be returning an error? @@ -363,7 +364,7 @@ impl SequencerConsensusContext { async fn validate_current_round_proposal( &mut self, height: BlockNumber, - proposer: ValidatorId, + _proposer: ValidatorId, timeout: Duration, content_receiver: mpsc::Receiver, fin_sender: oneshot::Sender<(ProposalContentId, ProposalFin)>, @@ -394,7 +395,7 @@ impl SequencerConsensusContext { now.timestamp().try_into().expect("Failed to convert timestamp"), ), use_kzg_da: true, - sequencer_address: proposer, + sequencer_address: ValidatorId::from(TEMPORARY_SEQUENCER_ADDRESS), }, }; batcher.validate_block(input).await.expect("Failed to initiate proposal validation"); diff --git a/crates/starknet_batcher/src/block_builder.rs b/crates/starknet_batcher/src/block_builder.rs index 720350da58..e649548e7e 100644 --- a/crates/starknet_batcher/src/block_builder.rs +++ b/crates/starknet_batcher/src/block_builder.rs @@ -26,7 +26,6 @@ use papyrus_state_reader::papyrus_state::PapyrusReader; use papyrus_storage::StorageReader; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockHashAndNumber, BlockInfo}; -use starknet_api::core::ContractAddress; use starknet_api::executable_transaction::Transaction; use starknet_api::transaction::TransactionHash; use thiserror::Error; @@ -238,7 +237,6 @@ pub struct BlockBuilderConfig { pub chain_info: ChainInfo, pub execute_config: TransactionExecutorConfig, pub bouncer_config: BouncerConfig, - pub sequencer_address: ContractAddress, pub tx_chunk_size: usize, pub versioned_constants_overrides: VersionedConstantsOverrides, } @@ -250,7 +248,6 @@ impl Default for BlockBuilderConfig { chain_info: ChainInfo::default(), execute_config: TransactionExecutorConfig::default(), bouncer_config: BouncerConfig::default(), - sequencer_address: ContractAddress::default(), tx_chunk_size: 100, versioned_constants_overrides: VersionedConstantsOverrides::default(), } @@ -262,12 +259,6 @@ impl SerializeConfig for BlockBuilderConfig { let mut dump = append_sub_config_name(self.chain_info.dump(), "chain_info"); dump.append(&mut append_sub_config_name(self.execute_config.dump(), "execute_config")); dump.append(&mut append_sub_config_name(self.bouncer_config.dump(), "bouncer_config")); - dump.append(&mut BTreeMap::from([ser_param( - "sequencer_address", - &self.sequencer_address, - "The address of the sequencer.", - ParamPrivacyInput::Public, - )])); dump.append(&mut BTreeMap::from([ser_param( "tx_chunk_size", &self.tx_chunk_size, @@ -295,15 +286,11 @@ impl BlockBuilderFactory { ) -> BlockBuilderResult> { let height = block_metadata.block_info.block_number; let block_builder_config = self.block_builder_config.clone(); - let block_info = BlockInfo { - sequencer_address: block_builder_config.sequencer_address, - ..block_metadata.block_info - }; let versioned_constants = VersionedConstants::get_versioned_constants( block_builder_config.versioned_constants_overrides, ); let block_context = BlockContext::new( - block_info, + block_metadata.block_info, block_builder_config.chain_info, versioned_constants, block_builder_config.bouncer_config, diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index 40f3f90434..bdab8d0c89 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -46,7 +46,6 @@ pub(crate) fn dump_config_file_changes( required_params.chain_id, required_params.eth_fee_token_address, required_params.strk_fee_token_address, - required_params.sequencer_address, config.rpc_state_reader_config.json_rpc_version, config.rpc_state_reader_config.url, config.batcher_config.storage.db_config.path_prefix, diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index 44728d293f..d8ce9df56a 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -12,8 +12,6 @@ use papyrus_network::network_manager::BroadcastTopicChannels; use papyrus_protobuf::consensus::{ProposalPart, StreamMessage}; use papyrus_storage::StorageConfig; use starknet_api::block::BlockNumber; -use starknet_api::contract_address; -use starknet_api::core::ContractAddress; use starknet_api::rpc_transaction::RpcTransaction; use starknet_api::transaction::TransactionHash; use starknet_batcher::block_builder::BlockBuilderConfig; @@ -64,7 +62,6 @@ pub async fn create_config( chain_id: chain_info.chain_id, eth_fee_token_address: fee_token_addresses.eth_fee_token_address, strk_fee_token_address: fee_token_addresses.strk_fee_token_address, - sequencer_address: ContractAddress::from(1312_u128), // Arbitrary non-zero value. }, consensus_proposals_channels, ) @@ -224,15 +221,9 @@ pub fn create_batcher_config( chain_info: ChainInfo, ) -> BatcherConfig { // TODO(Arni): Create BlockBuilderConfig create for testing method and use here. - const SEQUENCER_ADDRESS_FOR_TESTING: u128 = 1991; - BatcherConfig { storage: batcher_storage_config, - block_builder_config: BlockBuilderConfig { - chain_info, - sequencer_address: contract_address!(SEQUENCER_ADDRESS_FOR_TESTING), - ..Default::default() - }, + block_builder_config: BlockBuilderConfig { chain_info, ..Default::default() }, ..Default::default() } } diff --git a/crates/starknet_sequencer_node/src/config/node_config.rs b/crates/starknet_sequencer_node/src/config/node_config.rs index 2679e234e7..99a865e7fb 100644 --- a/crates/starknet_sequencer_node/src/config/node_config.rs +++ b/crates/starknet_sequencer_node/src/config/node_config.rs @@ -75,15 +75,6 @@ pub static CONFIG_POINTERS: LazyLock = LazyLock::new(|| { "gateway_config.chain_info.fee_token_addresses.strk_fee_token_address", ]), ), - // TODO(tsabary): set as a regular required parameter. - ( - ser_pointer_target_required_param( - "sequencer_address", - SerializationType::String, - "The sequencer address.", - ), - set_pointing_param_paths(&["batcher_config.block_builder_config.sequencer_address"]), - ), ]; let mut common_execution_config = generate_struct_pointer( "versioned_constants_overrides".to_owned(), diff --git a/crates/starknet_sequencer_node/src/config/test_utils.rs b/crates/starknet_sequencer_node/src/config/test_utils.rs index ee3d372338..ecbe6027a4 100644 --- a/crates/starknet_sequencer_node/src/config/test_utils.rs +++ b/crates/starknet_sequencer_node/src/config/test_utils.rs @@ -11,7 +11,6 @@ pub struct RequiredParams { pub chain_id: ChainId, pub eth_fee_token_address: ContractAddress, pub strk_fee_token_address: ContractAddress, - pub sequencer_address: ContractAddress, } impl RequiredParams { @@ -20,7 +19,6 @@ impl RequiredParams { chain_id: ChainId::create_for_testing(), eth_fee_token_address: ContractAddress::from(2_u128), strk_fee_token_address: ContractAddress::from(3_u128), - sequencer_address: ContractAddress::from(17_u128), } } }