Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(batcher): add block info to block proposal input #2237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");

Expand Down
7 changes: 4 additions & 3 deletions crates/starknet_api/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions crates/starknet_batcher/src/batcher_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 4 additions & 5 deletions crates/starknet_batcher_types/src/batcher_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -35,9 +35,7 @@ pub struct ProposeBlockInput {
pub proposal_id: ProposalId,
pub deadline: chrono::DateTime<Utc>,
pub retrospective_block_hash: Option<BlockHashAndNumber>,
// 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)]
Expand All @@ -63,6 +61,7 @@ pub struct ValidateBlockInput {
pub proposal_id: ProposalId,
pub deadline: chrono::DateTime<Utc>,
pub retrospective_block_hash: Option<BlockHashAndNumber>,
pub block_info: BlockInfo,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -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,
}

Expand Down
Loading