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 e6715231bc..40ba503591 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -131,6 +131,8 @@ impl ConsensusContext for SequencerConsensusContext { number: BlockNumber::default(), hash: BlockHash::default(), }), + // TODO(Dan, Matan): Fill block info. + block_info: Default::default(), }; // TODO: Should we be returning an error? // I think this implies defining an error type in this crate and moving the trait definition @@ -307,6 +309,8 @@ impl SequencerConsensusContext { number: BlockNumber::default(), hash: BlockHash::default(), }), + // TODO(Dan, Matan): Fill block info. + block_info: Default::default(), }; batcher.validate_block(input).await.expect("Failed to initiate proposal validation"); diff --git a/crates/starknet_api/src/block.rs b/crates/starknet_api/src/block.rs index cef053fd29..74f72a462d 100644 --- a/crates/starknet_api/src/block.rs +++ b/crates/starknet_api/src/block.rs @@ -439,7 +439,7 @@ 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, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct GasPriceVector { pub l1_gas_price: NonzeroGasPrice, pub l1_data_gas_price: NonzeroGasPrice, @@ -452,7 +452,8 @@ pub enum FeeType { Eth, } -#[derive(Clone, Debug, Deserialize, Serialize)] +// TODO(Arni): Remove derive of Default. Gas prices should always be set. +#[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct GasPrices { pub eth_gas_prices: GasPriceVector, // In wei. pub strk_gas_prices: GasPriceVector, // In fri. @@ -485,7 +486,7 @@ impl GasPrices { )] pub struct BlockTimestamp(pub u64); -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Deserialize, Default, Serialize)] pub struct BlockInfo { pub block_number: BlockNumber, pub block_timestamp: BlockTimestamp, diff --git a/crates/starknet_batcher/src/batcher_test.rs b/crates/starknet_batcher/src/batcher_test.rs index 79cab97a12..a0e11bef26 100644 --- a/crates/starknet_batcher/src/batcher_test.rs +++ b/crates/starknet_batcher/src/batcher_test.rs @@ -230,6 +230,7 @@ async fn no_active_height() { proposal_id: ProposalId(0), retrospective_block_hash: None, deadline: chrono::Utc::now() + chrono::Duration::seconds(1), + block_info: Default::default(), }) .await; assert_eq!(result, Err(BatcherError::NoActiveHeight)); @@ -239,6 +240,7 @@ async fn no_active_height() { proposal_id: ProposalId(0), retrospective_block_hash: None, deadline: chrono::Utc::now() + chrono::Duration::seconds(1), + block_info: Default::default(), }) .await; assert_eq!(result, Err(BatcherError::NoActiveHeight)); @@ -261,6 +263,7 @@ async fn validate_block_full_flow() { proposal_id: PROPOSAL_ID, deadline: deadline(), retrospective_block_hash: None, + block_info: Default::default(), }; batcher.validate_block(validate_block_input).await.unwrap(); @@ -384,6 +387,7 @@ async fn send_finish_to_an_invalid_proposal() { proposal_id: PROPOSAL_ID, deadline: deadline(), retrospective_block_hash: None, + block_info: Default::default(), }; batcher.validate_block(validate_block_input).await.unwrap(); @@ -420,6 +424,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: Default::default(), }) .await .unwrap(); @@ -475,6 +480,7 @@ async fn propose_block_without_retrospective_block_hash() { proposal_id: PROPOSAL_ID, retrospective_block_hash: None, deadline: deadline(), + block_info: Default::default(), }) .await; diff --git a/crates/starknet_batcher_types/src/batcher_types.rs b/crates/starknet_batcher_types/src/batcher_types.rs index f12bb25513..53d11e3ade 100644 --- a/crates/starknet_batcher_types/src/batcher_types.rs +++ b/crates/starknet_batcher_types/src/batcher_types.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use chrono::prelude::*; use serde::{Deserialize, Serialize}; -use starknet_api::block::{BlockHashAndNumber, BlockNumber}; +use starknet_api::block::{BlockHashAndNumber, BlockInfo, BlockNumber}; use starknet_api::core::StateDiffCommitment; use starknet_api::executable_transaction::Transaction; @@ -35,9 +35,7 @@ pub struct ProposeBlockInput { pub proposal_id: ProposalId, pub deadline: chrono::DateTime, pub retrospective_block_hash: Option, - // TODO: Should we get the gas price here? - // TODO: add proposer address. - // TODO: add whether the kzg mechanism is used for DA. + pub block_info: BlockInfo, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -63,6 +61,7 @@ pub struct ValidateBlockInput { pub proposal_id: ProposalId, pub deadline: chrono::DateTime, pub retrospective_block_hash: Option, + pub block_info: BlockInfo, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -92,7 +91,7 @@ pub enum ProposalStatus { // Only sent in response to `Abort`. Aborted, // May be caused due to handling of a previous item of the new proposal. - // In this case, the propsal is aborted and no additional content will be processed. + // In this case, the proposal is aborted and no additional content will be processed. InvalidProposal, }