Skip to content

Commit 4f8ff9e

Browse files
starknet_api: add fee_proposal_fri to BlockHeaderWithoutHash
1 parent ae5066a commit 4f8ff9e

9 files changed

Lines changed: 19 additions & 1 deletion

File tree

crates/apollo_p2p_sync/src/client/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ fn create_random_sync_block(
345345
sequencer,
346346
l1_da_mode,
347347
starknet_version,
348+
fee_proposal_fri,
348349
} = BlockHeaderWithoutHash::get_test_instance(&mut rng);
349350
let block_header_without_hash = BlockHeaderWithoutHash {
350351
block_number,
@@ -359,6 +360,7 @@ fn create_random_sync_block(
359360
sequencer,
360361
l1_da_mode,
361362
starknet_version,
363+
fee_proposal_fri,
362364
};
363365
let block_header_commitments = BlockHeaderCommitments::get_test_instance(&mut rng);
364366
SyncBlock {

crates/apollo_protobuf/src/converters/header.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ impl TryFrom<protobuf::SignedBlockHeader> for SignedBlockHeader {
205205
timestamp,
206206
l1_da_mode,
207207
starknet_version,
208+
fee_proposal_fri: None,
208209
},
209210
state_diff_commitment,
210211
state_diff_length,

crates/apollo_protobuf/src/converters/header_test.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use crate::sync::{DataOrFin, HeaderQuery, SignedBlockHeader};
55
#[test]
66
fn block_header_to_bytes_and_back() {
77
let mut rng = get_rng();
8-
let signed_block_header = SignedBlockHeader::get_test_instance(&mut rng);
8+
let mut signed_block_header = SignedBlockHeader::get_test_instance(&mut rng);
9+
// The sync proto does not carry `fee_proposal_fri`; drop it to match the roundtrip.
10+
signed_block_header.block_header.block_header_without_hash.fee_proposal_fri = None;
911
let data = DataOrFin(Some(signed_block_header.clone()));
1012
let bytes_data = Vec::<u8>::from(data.clone());
1113
let res_data = DataOrFin::try_from(bytes_data).unwrap();
@@ -20,6 +22,8 @@ fn block_header_without_commitments_to_bytes_and_back() {
2022
signed_block_header.block_header.transaction_commitment = None;
2123
signed_block_header.block_header.event_commitment = None;
2224
signed_block_header.block_header.receipt_commitment = None;
25+
// The sync proto does not carry `fee_proposal_fri`; drop it to match the roundtrip.
26+
signed_block_header.block_header.block_header_without_hash.fee_proposal_fri = None;
2327

2428
let data = DataOrFin(Some(signed_block_header.clone()));
2529
let bytes_data = Vec::<u8>::from(data.clone());

crates/apollo_starknet_client/src/reader/objects/block.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ impl Block {
342342
l1_data_gas_price: self.l1_data_gas_price(),
343343
l1_da_mode: self.l1_da_mode(),
344344
starknet_version: self.starknet_version(),
345+
fee_proposal_fri: None,
345346
},
346347
state_diff_commitment: self.state_diff_commitment(),
347348
transaction_commitment,

crates/apollo_storage/src/header.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ pub struct StorageBlockHeader {
109109
pub n_transactions: usize,
110110
/// The number of events in this block.
111111
pub n_events: usize,
112+
/// SNIP-35: proposer's oracle-derived recommended fee. `None` for pre-V0_14_3 blocks.
113+
pub fee_proposal_fri: Option<GasPrice>,
112114
}
113115

114116
type BlockHashToNumberTable<'env> =
@@ -225,6 +227,7 @@ impl<Mode: TransactionKind> HeaderStorageReader for StorageTxn<'_, Mode> {
225227
timestamp: block_header.timestamp,
226228
l1_da_mode: block_header.l1_da_mode,
227229
starknet_version,
230+
fee_proposal_fri: block_header.fee_proposal_fri,
228231
},
229232
state_diff_commitment: block_header.state_diff_commitment,
230233
transaction_commitment: block_header.transaction_commitment,
@@ -322,6 +325,7 @@ impl HeaderStorageWriter for StorageTxn<'_, RW> {
322325
state_diff_length: block_header.state_diff_length,
323326
n_transactions: block_header.n_transactions,
324327
n_events: block_header.n_events,
328+
fee_proposal_fri: block_header.block_header_without_hash.fee_proposal_fri,
325329
};
326330

327331
headers_table.append(&self.txn, &block_number, &storage_block_header)?;
@@ -429,6 +433,7 @@ impl HeaderStorageWriter for StorageTxn<'_, RW> {
429433
timestamp: reverted_header.timestamp,
430434
l1_da_mode: reverted_header.l1_da_mode,
431435
starknet_version,
436+
fee_proposal_fri: reverted_header.fee_proposal_fri,
432437
},
433438
state_diff_commitment: reverted_header.state_diff_commitment,
434439
transaction_commitment: reverted_header.transaction_commitment,

crates/apollo_storage/src/serialization/serializers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ auto_storage_serde! {
183183
pub state_diff_length: Option<usize>,
184184
pub n_transactions: usize,
185185
pub n_events: usize,
186+
pub fee_proposal_fri: Option<GasPrice>,
186187
}
187188
pub struct BlockHeaderCommitments {
188189
pub transaction_commitment: TransactionCommitment,

crates/apollo_storage/src/test_instances.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ auto_impl_get_test_instance! {
4646
pub state_diff_length: Option<usize>,
4747
pub n_transactions: usize,
4848
pub n_events: usize,
49+
pub fee_proposal_fri: Option<GasPrice>,
4950
}
5051

5152
struct EventIndex(pub TransactionIndex, pub EventIndexInTransactionOutput);

crates/apollo_test_utils/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ auto_impl_get_test_instance! {
450450
pub timestamp: BlockTimestamp,
451451
pub l1_da_mode: L1DataAvailabilityMode,
452452
pub starknet_version: StarknetVersion,
453+
pub fee_proposal_fri: Option<GasPrice>,
453454
}
454455
pub struct BlockHeaderCommitments {
455456
pub transaction_commitment: TransactionCommitment,

crates/starknet_api/src/block.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ pub struct BlockHeaderWithoutHash {
241241
pub timestamp: BlockTimestamp,
242242
pub l1_da_mode: L1DataAvailabilityMode,
243243
pub starknet_version: StarknetVersion,
244+
/// SNIP-35: proposer's oracle-derived recommended fee. `None` for pre-V0_14_3 blocks.
245+
pub fee_proposal_fri: Option<GasPrice>,
244246
}
245247

246248
/// The [transactions](`crate::transaction::Transaction`) and their

0 commit comments

Comments
 (0)