Skip to content
Merged
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
2 changes: 2 additions & 0 deletions crates/apollo_p2p_sync/src/client/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ fn create_random_sync_block(
sequencer,
l1_da_mode,
starknet_version,
fee_proposal_fri,
} = BlockHeaderWithoutHash::get_test_instance(&mut rng);
let block_header_without_hash = BlockHeaderWithoutHash {
block_number,
Expand All @@ -359,6 +360,7 @@ fn create_random_sync_block(
sequencer,
l1_da_mode,
starknet_version,
fee_proposal_fri,
};
let block_header_commitments = BlockHeaderCommitments::get_test_instance(&mut rng);
SyncBlock {
Expand Down
1 change: 1 addition & 0 deletions crates/apollo_protobuf/src/converters/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ impl TryFrom<protobuf::SignedBlockHeader> for SignedBlockHeader {
timestamp,
l1_da_mode,
starknet_version,
fee_proposal_fri: None,
},
state_diff_commitment,
state_diff_length,
Expand Down
8 changes: 8 additions & 0 deletions crates/apollo_protobuf/src/converters/header_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ use apollo_test_utils::{get_rng, GetTestInstance};

use crate::sync::{DataOrFin, HeaderQuery, SignedBlockHeader};

// TODO(AndrewL): the sync proto's `SignedBlockHeader` does not carry `fee_proposal_fri`,
// so the field is dropped on roundtrip and the equality assertion fails. Remove the
// `#[should_panic]` (and this comment) in the follow-up PR that adds `fee_proposal_fri = 22`
// to `apollo_protobuf/src/proto/p2p/proto/sync/header.proto` and plumbs it through the
// converter at `apollo_protobuf/src/converters/header.rs`.
#[test]
#[should_panic(expected = "fee_proposal_fri")]
fn block_header_to_bytes_and_back() {
let mut rng = get_rng();
let signed_block_header = SignedBlockHeader::get_test_instance(&mut rng);
Expand All @@ -12,7 +18,9 @@ fn block_header_to_bytes_and_back() {
assert_eq!(res_data, data);
}

// TODO(AndrewL): see the TODO above `block_header_to_bytes_and_back`.
#[test]
#[should_panic(expected = "fee_proposal_fri")]
fn block_header_without_commitments_to_bytes_and_back() {
let mut rng = get_rng();
let mut signed_block_header = SignedBlockHeader::get_test_instance(&mut rng);
Expand Down
1 change: 1 addition & 0 deletions crates/apollo_starknet_client/src/reader/objects/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ impl Block {
l1_data_gas_price: self.l1_data_gas_price(),
l1_da_mode: self.l1_da_mode(),
starknet_version: self.starknet_version(),
fee_proposal_fri: None,
},
state_diff_commitment: self.state_diff_commitment(),
transaction_commitment,
Expand Down
5 changes: 5 additions & 0 deletions crates/apollo_storage/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ pub struct StorageBlockHeader {
pub n_transactions: usize,
/// The number of events in this block.
pub n_events: usize,
/// SNIP-35: proposer's oracle-derived recommended fee. `None` for pre-V0_14_3 blocks.
pub fee_proposal_fri: Option<GasPrice>,
}

type BlockHashToNumberTable<'env> =
Expand Down Expand Up @@ -225,6 +227,7 @@ impl<Mode: TransactionKind> HeaderStorageReader for StorageTxn<'_, Mode> {
timestamp: block_header.timestamp,
l1_da_mode: block_header.l1_da_mode,
starknet_version,
fee_proposal_fri: block_header.fee_proposal_fri,
},
state_diff_commitment: block_header.state_diff_commitment,
transaction_commitment: block_header.transaction_commitment,
Expand Down Expand Up @@ -322,6 +325,7 @@ impl HeaderStorageWriter for StorageTxn<'_, RW> {
state_diff_length: block_header.state_diff_length,
n_transactions: block_header.n_transactions,
n_events: block_header.n_events,
fee_proposal_fri: block_header.block_header_without_hash.fee_proposal_fri,
};

headers_table.append(&self.txn, &block_number, &storage_block_header)?;
Expand Down Expand Up @@ -429,6 +433,7 @@ impl HeaderStorageWriter for StorageTxn<'_, RW> {
timestamp: reverted_header.timestamp,
l1_da_mode: reverted_header.l1_da_mode,
starknet_version,
fee_proposal_fri: reverted_header.fee_proposal_fri,
},
state_diff_commitment: reverted_header.state_diff_commitment,
transaction_commitment: reverted_header.transaction_commitment,
Expand Down
1 change: 1 addition & 0 deletions crates/apollo_storage/src/serialization/serializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ auto_storage_serde! {
pub state_diff_length: Option<usize>,
pub n_transactions: usize,
pub n_events: usize,
pub fee_proposal_fri: Option<GasPrice>,
}
pub struct BlockHeaderCommitments {
pub transaction_commitment: TransactionCommitment,
Expand Down
1 change: 1 addition & 0 deletions crates/apollo_storage/src/test_instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ auto_impl_get_test_instance! {
pub state_diff_length: Option<usize>,
pub n_transactions: usize,
pub n_events: usize,
pub fee_proposal_fri: Option<GasPrice>,
}

struct EventIndex(pub TransactionIndex, pub EventIndexInTransactionOutput);
Expand Down
1 change: 1 addition & 0 deletions crates/apollo_test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ auto_impl_get_test_instance! {
pub timestamp: BlockTimestamp,
pub l1_da_mode: L1DataAvailabilityMode,
pub starknet_version: StarknetVersion,
pub fee_proposal_fri: Option<GasPrice>,
}
pub struct BlockHeaderCommitments {
pub transaction_commitment: TransactionCommitment,
Expand Down
3 changes: 3 additions & 0 deletions crates/starknet_api/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ pub struct BlockHeaderWithoutHash {
pub timestamp: BlockTimestamp,
pub l1_da_mode: L1DataAvailabilityMode,
pub starknet_version: StarknetVersion,
// TODO(AndrewL): Add this field into the block hash.
/// SNIP-35: proposer's oracle-derived recommended fee. `None` for pre-V0_14_3 blocks.
pub fee_proposal_fri: Option<GasPrice>,
}

/// The [transactions](`crate::transaction::Transaction`) and their
Expand Down
Loading