From e86f24244a225cf119697368c1cfbb977672c440 Mon Sep 17 00:00:00 2001 From: Aner Ben Efraim Date: Tue, 29 Oct 2024 13:31:38 +0200 Subject: [PATCH] chore(blockifier): add transaction_serde serialize and deserialize to several objects --- crates/blockifier/src/blockifier/block.rs | 2 ++ crates/blockifier/src/state/cached_state.rs | 1 + crates/starknet_api/src/block.rs | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/blockifier/src/blockifier/block.rs b/crates/blockifier/src/blockifier/block.rs index 9e404fd509..d4f1b766bf 100644 --- a/crates/blockifier/src/blockifier/block.rs +++ b/crates/blockifier/src/blockifier/block.rs @@ -22,6 +22,7 @@ use crate::versioned_constants::VersionedConstants; #[path = "block_test.rs"] pub mod block_test; +#[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct BlockInfo { pub block_number: BlockNumber, @@ -33,6 +34,7 @@ pub struct BlockInfo { pub use_kzg_da: bool, } +#[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug)] pub struct GasPrices { eth_gas_prices: GasPriceVector, // In wei. diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index cf0975c574..ab51525b8d 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -534,6 +534,7 @@ impl<'a, U: UpdatableState> TransactionalState<'a, U> { type StorageDiff = IndexMap>; /// Holds uncommitted changes induced on Starknet contracts. +#[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(any(feature = "testing", test), derive(Clone))] #[derive(Debug, Default, Eq, PartialEq)] pub struct CommitmentStateDiff { diff --git a/crates/starknet_api/src/block.rs b/crates/starknet_api/src/block.rs index 9910da6728..fe464345ea 100644 --- a/crates/starknet_api/src/block.rs +++ b/crates/starknet_api/src/block.rs @@ -370,7 +370,7 @@ impl GasPrice { /// Utility struct representing a non-zero gas price. Useful when a gas amount must be computed by /// taking a fee amount and dividing by the gas price. -#[derive(Copy, Clone, Debug, derive_more::Display)] +#[derive(Copy, Clone, Debug, Deserialize, Serialize, derive_more::Display)] pub struct NonzeroGasPrice(GasPrice); impl NonzeroGasPrice { @@ -433,7 +433,7 @@ macro_rules! impl_try_from_uint_for_nonzero_gas_price { impl_try_from_uint_for_nonzero_gas_price!(u8, u16, u32, u64, u128); -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub struct GasPriceVector { pub l1_gas_price: NonzeroGasPrice, pub l1_data_gas_price: NonzeroGasPrice,