Skip to content
Closed
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
7 changes: 5 additions & 2 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.
pub fee_proposal: GasPrice,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing storage version bump for schema change

High Severity

Adding fee_proposal: GasPrice to StorageBlockHeader changes the binary serialization format generated by auto_storage_serde!, but STORAGE_VERSION_BLOCKS in lib.rs is not bumped. Existing database records serialized without this field will fail to deserialize (the macro's deserialize_from returns None when bytes are exhausted), silently making all previously stored block headers unreadable. A major version bump is needed to force a re-sync for existing databases.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8a9ab4a. Configure here.

}

type BlockHashToNumberTable<'env> =
Expand Down Expand Up @@ -225,7 +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: GasPrice::default(),
fee_proposal: block_header.fee_proposal,
},
state_diff_commitment: block_header.state_diff_commitment,
transaction_commitment: block_header.transaction_commitment,
Expand Down Expand Up @@ -323,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: block_header.block_header_without_hash.fee_proposal,
};

headers_table.append(&self.txn, &block_number, &storage_block_header)?;
Expand Down Expand Up @@ -430,7 +433,7 @@ impl HeaderStorageWriter for StorageTxn<'_, RW> {
timestamp: reverted_header.timestamp,
l1_da_mode: reverted_header.l1_da_mode,
starknet_version,
fee_proposal: GasPrice::default(),
fee_proposal: reverted_header.fee_proposal,
},
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: GasPrice,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing storage version bump for format change

High Severity

Adding fee_proposal to StorageBlockHeader changes the binary serialization format (via auto_storage_serde), but STORAGE_VERSION_BLOCKS is not bumped. The VersionZeroWrapper deserializer reads fields sequentially and returns None when bytes are exhausted, so all block headers stored before this change will silently fail to deserialize. A major version bump is needed to force a re-sync.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a87a8b7. Configure here.

}
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: GasPrice,
}

struct EventIndex(pub TransactionIndex, pub EventIndexInTransactionOutput);
Expand Down
Loading