diff --git a/crates/blockifier/Cargo.toml b/crates/blockifier/Cargo.toml index 46273c3d3e..906b0056c5 100644 --- a/crates/blockifier/Cargo.toml +++ b/crates/blockifier/Cargo.toml @@ -13,6 +13,7 @@ workspace = true concurrency = [] jemalloc = ["dep:tikv-jemallocator"] testing = ["rand", "rstest"] +transaction_serde = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index 1efef68115..cd61cd4605 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -14,6 +14,7 @@ use crate::execution::entry_point::CallEntryPoint; use crate::fee::gas_usage::get_message_segment_length; use crate::state::cached_state::StorageEntry; +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)] pub struct Retdata(pub Vec); @@ -25,12 +26,14 @@ macro_rules! retdata { } #[cfg_attr(test, derive(Clone))] +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Debug, Default, Eq, PartialEq, Serialize)] pub struct OrderedEvent { pub order: usize, pub event: EventContent, } +#[cfg_attr(feature = "transaction_serde", derive(Serialize, serde::Deserialize))] #[derive(Debug, Default, Eq, PartialEq, Clone)] pub struct MessageL1CostInfo { pub l2_to_l1_payload_lengths: Vec, @@ -55,6 +58,7 @@ impl MessageL1CostInfo { } #[cfg_attr(test, derive(Clone))] +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Debug, Default, Eq, PartialEq, Serialize)] pub struct MessageToL1 { pub to_address: EthAddress, @@ -62,6 +66,7 @@ pub struct MessageToL1 { } #[cfg_attr(test, derive(Clone))] +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Debug, Default, Eq, PartialEq, Serialize)] pub struct OrderedL2ToL1Message { pub order: usize, @@ -74,6 +79,7 @@ pub fn get_payload_lengths(l2_to_l1_messages: &[OrderedL2ToL1Message]) -> Vec = Result; pub type ConstructorEntryPointExecutionResult = Result; /// Represents a the type of the call (used for debugging). +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq, Serialize)] pub enum CallType { #[default] @@ -45,6 +46,7 @@ pub enum CallType { Delegate = 1, } /// Represents a call to an entry point of a Starknet contract. +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)] pub struct CallEntryPoint { // The class hash is not given if it can be deduced from the storage address. diff --git a/crates/blockifier/src/fee/actual_cost.rs b/crates/blockifier/src/fee/actual_cost.rs index 1e4802216f..301c91da38 100644 --- a/crates/blockifier/src/fee/actual_cost.rs +++ b/crates/blockifier/src/fee/actual_cost.rs @@ -36,6 +36,7 @@ struct TransactionReceiptParameters<'a, T: Iterator + Clone // TODO(Gilad): Use everywhere instead of passing the `actual_{fee,resources}` tuple, which often // get passed around together. +#[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Default, Debug, PartialEq)] pub struct TransactionReceipt { pub fee: Fee, diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index 93201f3456..deff9cc9c7 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -721,6 +721,7 @@ impl From for StateChanges { } /// Holds the number of state changes. +#[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] pub struct StateChangesCount { pub n_storage_updates: usize, diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index 0a8a5b4f17..a542a35834 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -152,6 +152,7 @@ pub struct DeprecatedTransactionInfo { pub max_fee: Fee, } +#[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive( derive_more::Add, derive_more::Sum, Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, )] @@ -211,6 +212,7 @@ pub struct CommonAccountFields { } /// Contains the information gathered by the execution of a transaction. +#[cfg_attr(feature = "transaction_serde", derive(Serialize, serde::Deserialize))] #[derive(Debug, Default, PartialEq)] pub struct TransactionExecutionInfo { /// Transaction validation call info; [None] for `L1Handler`. @@ -269,7 +271,8 @@ impl ResourcesMapping { } } -/// Containes all the L2 resources consumed by a transaction +/// Contains all the L2 resources consumed by a transaction +#[cfg_attr(feature = "transaction_serde", derive(Serialize, serde::Deserialize))] #[derive(Clone, Debug, Default, PartialEq)] pub struct StarknetResources { pub calldata_length: usize, @@ -436,6 +439,7 @@ impl StarknetResources { } } +#[cfg_attr(feature = "transaction_serde", derive(Serialize, serde::Deserialize))] #[derive(Default, Clone, Debug, PartialEq)] pub struct TransactionResources { pub starknet_resources: StarknetResources,