Skip to content

Commit

Permalink
fix(p2p): make strk_l2_gas_price and eth_l2_gas_price fields opti…
Browse files Browse the repository at this point in the history
…onal

These fields are Pathfinder-specific extensions at this point, so we
should handle them as optional.
  • Loading branch information
kkovaacs committed Nov 5, 2024
1 parent 29f93d0 commit 11a519c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/p2p/src/client/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ impl ToDto<p2p_proto::header::SignedBlockHeader> for SignedBlockHeader {
gas_price_wei: self.header.eth_l1_gas_price.0,
data_gas_price_fri: self.header.strk_l1_data_gas_price.0,
data_gas_price_wei: self.header.eth_l1_data_gas_price.0,
l2_gas_price_fri: self.header.strk_l2_gas_price.0,
l2_gas_price_wei: self.header.eth_l2_gas_price.0,
l2_gas_price_fri: Some(self.header.strk_l2_gas_price.0),
l2_gas_price_wei: Some(self.header.eth_l2_gas_price.0),
l1_data_availability_mode: self.header.l1_da_mode.to_dto(),
signatures: vec![p2p_proto::common::ConsensusSignature {
r: self.signature.r.0,
Expand Down
4 changes: 2 additions & 2 deletions crates/p2p/src/client/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ impl TryFromDto<p2p_proto::header::SignedBlockHeader> for SignedBlockHeader {
strk_l1_gas_price: GasPrice(dto.gas_price_fri),
eth_l1_data_gas_price: GasPrice(dto.data_gas_price_wei),
strk_l1_data_gas_price: GasPrice(dto.data_gas_price_fri),
eth_l2_gas_price: GasPrice(dto.l2_gas_price_wei),
strk_l2_gas_price: GasPrice(dto.l2_gas_price_fri),
eth_l2_gas_price: GasPrice(dto.l2_gas_price_wei.unwrap_or_default()),
strk_l2_gas_price: GasPrice(dto.l2_gas_price_fri.unwrap_or_default()),
sequencer_address: SequencerAddress(dto.sequencer_address.0),
starknet_version: dto.protocol_version.parse()?,
event_commitment: EventCommitment(dto.events.root.0),
Expand Down
6 changes: 4 additions & 2 deletions crates/p2p_proto/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ pub struct SignedBlockHeader {
pub gas_price_wei: u128,
pub data_gas_price_fri: u128,
pub data_gas_price_wei: u128,
pub l2_gas_price_fri: u128,
pub l2_gas_price_wei: u128,
#[optional]
pub l2_gas_price_fri: Option<u128>,
#[optional]
pub l2_gas_price_wei: Option<u128>,
pub l1_data_availability_mode: L1DataAvailabilityMode,
pub signatures: Vec<ConsensusSignature>,
}
Expand Down

0 comments on commit 11a519c

Please sign in to comment.