Skip to content

Commit e9914f7

Browse files
apollo_protobuf: add fee_proposal_fri to sync proto SignedBlockHeader
1 parent 9142e23 commit e9914f7

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

crates/apollo_protobuf/src/converters/header.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use starknet_api::block::{
99
BlockHeaderWithoutHash,
1010
BlockNumber,
1111
BlockSignature,
12+
GasPrice,
1213
GasPricePerToken,
1314
StarknetVersion,
1415
};
@@ -175,6 +176,7 @@ impl TryFrom<protobuf::SignedBlockHeader> for SignedBlockHeader {
175176
value.next_l2_gas_price.ok_or(missing("SignedBlockHeader::next_l2_gas_price"))?,
176177
)
177178
.into();
179+
let fee_proposal_fri = value.fee_proposal_fri.map(|v| GasPrice(u128::from(v)));
178180

179181
let receipt_commitment = value
180182
.receipts
@@ -205,7 +207,7 @@ impl TryFrom<protobuf::SignedBlockHeader> for SignedBlockHeader {
205207
timestamp,
206208
l1_da_mode,
207209
starknet_version,
208-
fee_proposal_fri: None,
210+
fee_proposal_fri,
209211
},
210212
state_diff_commitment,
211213
state_diff_length,
@@ -287,6 +289,10 @@ impl From<(BlockHeader, Vec<BlockSignature>)> for protobuf::SignedBlockHeader {
287289
),
288290
l2_gas_consumed: header.block_header_without_hash.l2_gas_consumed.0,
289291
next_l2_gas_price: Some(header.block_header_without_hash.next_l2_gas_price.0.into()),
292+
fee_proposal_fri: header
293+
.block_header_without_hash
294+
.fee_proposal_fri
295+
.map(|gp| gp.0.into()),
290296
signatures: signatures.iter().map(|signature| (*signature).into()).collect(),
291297
}
292298
}

crates/apollo_protobuf/src/converters/header_test.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ use apollo_test_utils::{get_rng, GetTestInstance};
22

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

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

21-
// TODO(AndrewL): see the TODO above `block_header_to_bytes_and_back`.
2215
#[test]
23-
#[should_panic(expected = "fee_proposal_fri")]
2416
fn block_header_without_commitments_to_bytes_and_back() {
2517
let mut rng = get_rng();
2618
let mut signed_block_header = SignedBlockHeader::get_test_instance(&mut rng);

crates/apollo_protobuf/src/proto/p2p/proto/sync/header.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ message SignedBlockHeader {
3131
L1DataAvailabilityMode l1_data_availability_mode = 20;
3232
// for now, we assume a small consensus, so this fits in 1M. Else, these will be repeated and extracted from this message.
3333
repeated ConsensusSignature signatures = 21;
34+
// SNIP-35: proposer's oracle-derived recommended fee. Absent for pre-V0_14_3 blocks.
35+
optional Uint128 fee_proposal_fri = 22;
3436
// can be more explicit here about the signature structure as this is not part of account abstraction
3537
}
3638

crates/apollo_protobuf/src/protobuf/protoc_output.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,10 +1218,13 @@ pub struct SignedBlockHeader {
12181218
#[prost(enumeration = "L1DataAvailabilityMode", tag = "20")]
12191219
pub l1_data_availability_mode: i32,
12201220
/// for now, we assume a small consensus, so this fits in 1M. Else, these will be repeated and extracted from this message.
1221-
///
1222-
/// can be more explicit here about the signature structure as this is not part of account abstraction
12231221
#[prost(message, repeated, tag = "21")]
12241222
pub signatures: ::prost::alloc::vec::Vec<ConsensusSignature>,
1223+
/// SNIP-35: proposer's oracle-derived recommended fee. Absent for pre-V0_14_3 blocks.
1224+
///
1225+
/// can be more explicit here about the signature structure as this is not part of account abstraction
1226+
#[prost(message, optional, tag = "22")]
1227+
pub fee_proposal_fri: ::core::option::Option<Uint128>,
12251228
}
12261229
/// sent to all peers (except the ones this was received from, if any).
12271230
/// for a fraction of peers, also send the GetBlockHeaders response (as if they asked for it for this block)

0 commit comments

Comments
 (0)