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 13cbc8302d..f212fcb85b 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: 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: 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 36f9baebe7..b8f670a076 100644 --- a/crates/starknet_batcher/src/batcher_test.rs +++ b/crates/starknet_batcher/src/batcher_test.rs @@ -200,6 +200,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)); @@ -209,6 +210,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)); @@ -229,6 +231,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(); @@ -347,6 +350,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(); @@ -379,6 +383,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(); @@ -438,6 +443,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, }