diff --git a/config/papyrus/default_config.json b/config/papyrus/default_config.json index ab8323e8ad..0673d4e6b3 100644 --- a/config/papyrus/default_config.json +++ b/config/papyrus/default_config.json @@ -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.", diff --git a/config/sequencer/default_config.json b/config/sequencer/default_config.json index dfbb72e416..ce688908af 100644 --- a/config/sequencer/default_config.json +++ b/config/sequencer/default_config.json @@ -104,21 +104,11 @@ "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", "value": 100 }, - "batcher_config.block_builder_config.use_kzg_da": { - "description": "Indicates whether the kzg mechanism is used for data availability.", - "privacy": "Public", - "value": true - }, "batcher_config.block_builder_config.versioned_constants_overrides.invoke_tx_max_n_steps": { "description": "Maximum number of steps the invoke function is allowed to run.", "pointer_target": "versioned_constants_overrides.invoke_tx_max_n_steps", @@ -949,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/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap index bc2248761a..1499f60e01 100644 --- a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap +++ b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap @@ -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": { diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index 97ed7f4656..0ebeb4ae88 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -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, 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 11fc4b7b33..7be9bbe89a 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,7 @@ 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_GAS_PRICES: GasPrices = GasPrices { eth_gas_prices: GasPriceVector { l1_gas_price: NonzeroGasPrice::MIN, diff --git a/crates/starknet_api/src/block.rs b/crates/starknet_api/src/block.rs index b2e31e8bde..dbd0fe7896 100644 --- a/crates/starknet_api/src/block.rs +++ b/crates/starknet_api/src/block.rs @@ -376,7 +376,7 @@ impl GasPrice { /// Utility struct representing a non-zero gas price. Useful when a gas amount must be computed by /// taking a fee amount and dividing by the gas price. -#[derive(Copy, Clone, Debug, Deserialize, Serialize, derive_more::Display)] +#[derive(Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize, derive_more::Display)] pub struct NonzeroGasPrice(GasPrice); impl NonzeroGasPrice { @@ -439,7 +439,8 @@ macro_rules! impl_try_from_uint_for_nonzero_gas_price { impl_try_from_uint_for_nonzero_gas_price!(u8, u16, u32, u64, u128); -#[derive(Clone, Debug, Default, Deserialize, Serialize)] +// TODO(Arni): Remove derive of Default. Gas prices should always be set. +#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] pub struct GasPriceVector { pub l1_gas_price: NonzeroGasPrice, pub l1_data_gas_price: NonzeroGasPrice, @@ -453,7 +454,7 @@ pub enum FeeType { } // TODO(Arni): Remove derive of Default. Gas prices should always be set. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] pub struct GasPrices { pub eth_gas_prices: GasPriceVector, // In wei. pub strk_gas_prices: GasPriceVector, // In fri. @@ -486,7 +487,7 @@ impl GasPrices { )] pub struct BlockTimestamp(pub u64); -#[derive(Clone, Debug, Default, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)] pub struct BlockInfo { pub block_number: BlockNumber, pub block_timestamp: BlockTimestamp, diff --git a/crates/starknet_batcher/src/batcher.rs b/crates/starknet_batcher/src/batcher.rs index 320681a756..0ffcc0fb62 100644 --- a/crates/starknet_batcher/src/batcher.rs +++ b/crates/starknet_batcher/src/batcher.rs @@ -150,7 +150,7 @@ impl Batcher { .block_builder_factory .create_block_builder( BlockMetadata { - height: active_height, + block_info: propose_block_input.block_info, retrospective_block_hash: propose_block_input.retrospective_block_hash, }, BlockBuilderExecutionParams { @@ -196,7 +196,7 @@ impl Batcher { .block_builder_factory .create_block_builder( BlockMetadata { - height: active_height, + block_info: validate_block_input.block_info, retrospective_block_hash: validate_block_input.retrospective_block_hash, }, BlockBuilderExecutionParams { @@ -465,7 +465,6 @@ fn verify_block_input( ) -> BatcherResult<()> { verify_non_empty_retrospective_block_hash(height, retrospective_block_hash)?; verify_block_number(height, block_number)?; - Ok(()) } @@ -478,7 +477,6 @@ fn verify_non_empty_retrospective_block_hash( { return Err(BatcherError::MissingRetrospectiveBlockHash); } - Ok(()) } @@ -486,6 +484,5 @@ fn verify_block_number(height: BlockNumber, block_number: BlockNumber) -> Batche if block_number != height { return Err(BatcherError::InvalidBlockNumber { active_height: height, block_number }); } - Ok(()) } diff --git a/crates/starknet_batcher/src/batcher_test.rs b/crates/starknet_batcher/src/batcher_test.rs index c81dea80e3..e6ca53d1e1 100644 --- a/crates/starknet_batcher/src/batcher_test.rs +++ b/crates/starknet_batcher/src/batcher_test.rs @@ -4,6 +4,7 @@ use std::sync::Arc; use assert_matches::assert_matches; use async_trait::async_trait; use blockifier::abi::constants; +use blockifier::test_utils::struct_impls::BlockInfoExt; use chrono::Utc; use futures::future::BoxFuture; use futures::FutureExt; @@ -62,6 +63,10 @@ const STREAMING_CHUNK_SIZE: usize = 3; const BLOCK_GENERATION_TIMEOUT: tokio::time::Duration = tokio::time::Duration::from_secs(1); const PROPOSAL_ID: ProposalId = ProposalId(0); +fn initial_block_info() -> BlockInfo { + BlockInfo { block_number: INITIAL_HEIGHT, ..BlockInfo::create_for_testing() } +} + fn proposal_commitment() -> ProposalCommitment { ProposalCommitment { state_diff_commitment: StateDiffCommitment(PoseidonHash(felt!(u128::try_from(7).unwrap()))), @@ -263,7 +268,7 @@ async fn validate_block_full_flow() { proposal_id: PROPOSAL_ID, deadline: deadline(), retrospective_block_hash: None, - block_info: BlockInfo { block_number: INITIAL_HEIGHT, ..Default::default() }, + block_info: initial_block_info(), }; batcher.validate_block(validate_block_input).await.unwrap(); @@ -387,7 +392,7 @@ async fn send_finish_to_an_invalid_proposal() { proposal_id: PROPOSAL_ID, deadline: deadline(), retrospective_block_hash: None, - block_info: BlockInfo { block_number: INITIAL_HEIGHT, ..Default::default() }, + block_info: initial_block_info(), }; batcher.validate_block(validate_block_input).await.unwrap(); @@ -424,7 +429,7 @@ async fn propose_block_full_flow() { proposal_id: PROPOSAL_ID, retrospective_block_hash: None, deadline: chrono::Utc::now() + chrono::Duration::seconds(1), - block_info: BlockInfo { block_number: INITIAL_HEIGHT, ..Default::default() }, + block_info: initial_block_info(), }) .await .unwrap(); diff --git a/crates/starknet_batcher/src/block_builder.rs b/crates/starknet_batcher/src/block_builder.rs index b900f35d9c..9d74548888 100644 --- a/crates/starknet_batcher/src/block_builder.rs +++ b/crates/starknet_batcher/src/block_builder.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use async_trait::async_trait; -use blockifier::blockifier::block::validated_gas_prices; use blockifier::blockifier::config::TransactionExecutorConfig; use blockifier::blockifier::transaction_executor::{ TransactionExecutor, @@ -27,14 +26,7 @@ use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_state_reader::papyrus_state::PapyrusReader; use papyrus_storage::StorageReader; use serde::{Deserialize, Serialize}; -use starknet_api::block::{ - BlockHashAndNumber, - BlockInfo, - BlockNumber, - BlockTimestamp, - NonzeroGasPrice, -}; -use starknet_api::core::ContractAddress; +use starknet_api::block::{BlockHashAndNumber, BlockInfo}; use starknet_api::executable_transaction::Transaction; use starknet_api::transaction::TransactionHash; use thiserror::Error; @@ -45,8 +37,6 @@ use crate::transaction_provider::{NextTxs, TransactionProvider, TransactionProvi #[derive(Debug, Error)] pub enum BlockBuilderError { - #[error(transparent)] - BadTimestamp(#[from] std::num::TryFromIntError), #[error(transparent)] BlockifierStateError(#[from] StateError), #[error(transparent)] @@ -238,7 +228,7 @@ async fn collect_execution_results_and_stream_txs( } pub struct BlockMetadata { - pub height: BlockNumber, + pub block_info: BlockInfo, pub retrospective_block_hash: Option, } @@ -262,8 +252,6 @@ pub struct BlockBuilderConfig { pub chain_info: ChainInfo, pub execute_config: TransactionExecutorConfig, pub bouncer_config: BouncerConfig, - pub sequencer_address: ContractAddress, - pub use_kzg_da: bool, pub tx_chunk_size: usize, pub versioned_constants_overrides: VersionedConstantsOverrides, } @@ -275,8 +263,6 @@ impl Default for BlockBuilderConfig { chain_info: ChainInfo::default(), execute_config: TransactionExecutorConfig::default(), bouncer_config: BouncerConfig::default(), - sequencer_address: ContractAddress::default(), - use_kzg_da: true, tx_chunk_size: 100, versioned_constants_overrides: VersionedConstantsOverrides::default(), } @@ -288,18 +274,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( - "use_kzg_da", - &self.use_kzg_da, - "Indicates whether the kzg mechanism is used for data availability.", - ParamPrivacyInput::Public, - )])); dump.append(&mut BTreeMap::from([ser_param( "tx_chunk_size", &self.tx_chunk_size, @@ -323,25 +297,15 @@ pub struct BlockBuilderFactory { impl BlockBuilderFactory { fn preprocess_and_create_transaction_executor( &self, - block_metadata: &BlockMetadata, + block_metadata: BlockMetadata, ) -> BlockBuilderResult> { + let height = block_metadata.block_info.block_number; let block_builder_config = self.block_builder_config.clone(); - let next_block_info = BlockInfo { - block_number: block_metadata.height, - block_timestamp: BlockTimestamp(chrono::Utc::now().timestamp().try_into()?), - sequencer_address: block_builder_config.sequencer_address, - // TODO (yael 7/10/2024): add logic to compute gas prices - gas_prices: { - let tmp_val = NonzeroGasPrice::MIN; - validated_gas_prices(tmp_val, tmp_val, tmp_val, tmp_val, tmp_val, tmp_val) - }, - use_kzg_da: block_builder_config.use_kzg_da, - }; let versioned_constants = VersionedConstants::get_versioned_constants( block_builder_config.versioned_constants_overrides, ); let block_context = BlockContext::new( - next_block_info, + block_metadata.block_info, block_builder_config.chain_info, versioned_constants, block_builder_config.bouncer_config, @@ -349,7 +313,7 @@ impl BlockBuilderFactory { let state_reader = PapyrusReader::new( self.storage_reader.clone(), - block_metadata.height, + height, self.global_class_hash_to_class.clone(), ); @@ -372,7 +336,7 @@ impl BlockBuilderFactoryTrait for BlockBuilderFactory { tx_provider: Box, output_content_sender: Option>, ) -> BlockBuilderResult<(Box, AbortSignalSender)> { - let executor = self.preprocess_and_create_transaction_executor(&block_metadata)?; + let executor = self.preprocess_and_create_transaction_executor(block_metadata)?; let (abort_signal_sender, abort_signal_receiver) = tokio::sync::oneshot::channel(); let block_builder = Box::new(BlockBuilder::new( Box::new(executor), diff --git a/crates/starknet_batcher/src/proposal_manager.rs b/crates/starknet_batcher/src/proposal_manager.rs index 56c72ab437..d588861c10 100644 --- a/crates/starknet_batcher/src/proposal_manager.rs +++ b/crates/starknet_batcher/src/proposal_manager.rs @@ -86,7 +86,7 @@ struct ProposalTask { /// Taking care of: /// - Proposing new blocks. /// - Validating incoming proposals. -/// - Commiting accepted proposals to the storage. +/// - Committing accepted proposals to the storage. /// /// Triggered by the consensus. pub(crate) struct ProposalManager { 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 663b118b3d..1ec2765732 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_integration_tests/tests/end_to_end_flow_test.rs b/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs index 2a808996ce..726eb73bbe 100644 --- a/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs +++ b/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs @@ -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, @@ -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::{ @@ -89,7 +89,7 @@ async fn listen_to_broadcasted_messages( height: expected_height, round: 0, valid_round: None, - proposer: ContractAddress::default(), + proposer: ValidatorId::from(1991_u32), }; let expected_proposal_fin = ProposalFin { proposal_content_id: BlockHash(expected_content_id) }; 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), } } }