From 11a519c54c68797c376a131d24e5d9f6ed4e1340 Mon Sep 17 00:00:00 2001 From: Krisztian Kovacs Date: Tue, 5 Nov 2024 16:56:23 +0100 Subject: [PATCH] fix(p2p): make `strk_l2_gas_price` and `eth_l2_gas_price` fields optional These fields are Pathfinder-specific extensions at this point, so we should handle them as optional. --- crates/p2p/src/client/conv.rs | 4 ++-- crates/p2p/src/client/types.rs | 4 ++-- crates/p2p_proto/src/header.rs | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/p2p/src/client/conv.rs b/crates/p2p/src/client/conv.rs index dde63a667..0fdde1d21 100644 --- a/crates/p2p/src/client/conv.rs +++ b/crates/p2p/src/client/conv.rs @@ -132,8 +132,8 @@ impl ToDto 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, diff --git a/crates/p2p/src/client/types.rs b/crates/p2p/src/client/types.rs index 2dc254c5e..a3b28157f 100644 --- a/crates/p2p/src/client/types.rs +++ b/crates/p2p/src/client/types.rs @@ -101,8 +101,8 @@ impl TryFromDto 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), diff --git a/crates/p2p_proto/src/header.rs b/crates/p2p_proto/src/header.rs index 61b6c685b..792953d3c 100644 --- a/crates/p2p_proto/src/header.rs +++ b/crates/p2p_proto/src/header.rs @@ -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, + #[optional] + pub l2_gas_price_wei: Option, pub l1_data_availability_mode: L1DataAvailabilityMode, pub signatures: Vec, }