diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index 948699544d..a586b3fd96 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -27,34 +27,30 @@ macro_rules! retdata { }; } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] -#[derive(Debug, Default, Eq, PartialEq, Serialize)] +#[derive(Debug, Default, Eq, PartialEq, Serialize, Clone)] pub struct OrderedEvent { pub order: usize, pub event: EventContent, } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] -#[derive(Debug, Default, Eq, PartialEq, Serialize)] +#[derive(Debug, Default, Eq, PartialEq, Serialize, Clone)] pub struct MessageToL1 { pub to_address: EthAddress, pub payload: L2ToL1Payload, } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] -#[derive(Debug, Default, Eq, PartialEq, Serialize)] +#[derive(Debug, Default, Eq, PartialEq, Serialize, Clone)] pub struct OrderedL2ToL1Message { pub order: usize, pub message: MessageToL1, } /// Represents the effects of executing a single entry point. -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] -#[derive(Debug, Default, Eq, PartialEq, Serialize)] +#[derive(Debug, Default, Eq, PartialEq, Serialize, Clone)] pub struct CallExecution { pub retdata: Retdata, pub events: Vec, @@ -138,9 +134,8 @@ impl AddAssign<&ChargedResources> for ChargedResources { } /// Represents the full effects of executing an entry point, including the inner calls it invoked. -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] -#[derive(Debug, Default, Eq, PartialEq, Serialize)] +#[derive(Debug, Default, Eq, PartialEq, Serialize, Clone)] pub struct CallInfo { pub call: CallEntryPoint, pub execution: CallExecution, diff --git a/crates/blockifier/src/execution/stack_trace.rs b/crates/blockifier/src/execution/stack_trace.rs index 1b90caad70..eba2fe9066 100644 --- a/crates/blockifier/src/execution/stack_trace.rs +++ b/crates/blockifier/src/execution/stack_trace.rs @@ -41,9 +41,8 @@ impl PreambleType { } } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub struct EntryPointErrorFrame { pub depth: usize, pub preamble_type: PreambleType, @@ -75,9 +74,8 @@ impl From<&EntryPointErrorFrame> for String { } } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub struct VmExceptionFrame { pub pc: Relocatable, pub error_attr_value: Option, @@ -100,9 +98,8 @@ impl From<&VmExceptionFrame> for String { } } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, PartialEq, derive_more::From)] +#[derive(Debug, PartialEq, derive_more::From, Clone)] pub enum ErrorStackSegment { EntryPoint(EntryPointErrorFrame), Cairo1RevertSummary(Cairo1RevertSummary), @@ -148,9 +145,8 @@ impl Display for ErrorStackHeader { } } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Clone)] pub struct ErrorStack { pub header: ErrorStackHeader, pub stack: Vec, diff --git a/crates/blockifier/src/fee/receipt.rs b/crates/blockifier/src/fee/receipt.rs index 0c7a13d4d9..67ed3dad74 100644 --- a/crates/blockifier/src/fee/receipt.rs +++ b/crates/blockifier/src/fee/receipt.rs @@ -35,9 +35,8 @@ struct TransactionReceiptParameters<'a> { // TODO(Gilad): Use everywhere instead of passing the `actual_{fee,resources}` tuple, which often // get passed around together. -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Default, Debug, PartialEq)] +#[derive(Default, Debug, PartialEq, Clone)] pub struct TransactionReceipt { pub fee: Fee, pub gas: GasVector, diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index f7b2a6b9b6..be7e137397 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -609,8 +609,7 @@ 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)] +#[derive(Debug, Default, Eq, PartialEq, Clone)] pub struct CommitmentStateDiff { // Contract instance attributes (per address). pub address_to_class_hash: IndexMap, diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index 4cfef890e6..0d580508cd 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -170,9 +170,8 @@ pub struct CommonAccountFields { pub only_query: bool, } -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, derive_more::Display, PartialEq)] +#[derive(Debug, derive_more::Display, PartialEq, Clone)] pub enum RevertError { Execution(ErrorStack), PostExecution(FeeCheckError), @@ -191,9 +190,8 @@ impl From for RevertError { } /// Contains the information gathered by the execution of a transaction. -#[cfg_attr(any(test, feature = "testing"), derive(Clone))] #[cfg_attr(feature = "transaction_serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Clone)] pub struct TransactionExecutionInfo { /// Transaction validation call info; [None] for `L1Handler`. pub validate_call_info: Option, diff --git a/crates/starknet_batcher/src/batcher.rs b/crates/starknet_batcher/src/batcher.rs index 016be04882..3a4edf9146 100644 --- a/crates/starknet_batcher/src/batcher.rs +++ b/crates/starknet_batcher/src/batcher.rs @@ -369,6 +369,7 @@ impl Batcher { self.commit_proposal_and_block(state_diff, address_to_nonce, tx_hashes).await } + // TODO(dvir): return `BlockExecutionArtifacts` #[instrument(skip(self), err)] pub async fn decision_reached(&mut self, input: DecisionReachedInput) -> BatcherResult<()> { let proposal_id = input.proposal_id; diff --git a/crates/starknet_batcher/src/batcher_test.rs b/crates/starknet_batcher/src/batcher_test.rs index 751c3cd264..1666dc61a6 100644 --- a/crates/starknet_batcher/src/batcher_test.rs +++ b/crates/starknet_batcher/src/batcher_test.rs @@ -526,6 +526,7 @@ async fn decision_reached() { commitment: ProposalCommitment::default(), tx_hashes: test_tx_hashes(), nonces: test_contract_nonces(), + block_execution_artifacts: Default::default(), })) } .boxed() diff --git a/crates/starknet_batcher/src/block_builder.rs b/crates/starknet_batcher/src/block_builder.rs index c2e83e96b1..5f82b27066 100644 --- a/crates/starknet_batcher/src/block_builder.rs +++ b/crates/starknet_batcher/src/block_builder.rs @@ -62,8 +62,7 @@ pub enum FailOnErrorCause { TransactionFailed(BlockifierTransactionExecutorError), } -#[cfg_attr(test, derive(Clone))] -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone, Default)] pub struct BlockExecutionArtifacts { pub execution_infos: IndexMap, pub commitment_state_diff: CommitmentStateDiff, diff --git a/crates/starknet_batcher/src/utils.rs b/crates/starknet_batcher/src/utils.rs index 1d656d8eda..0fde2710a8 100644 --- a/crates/starknet_batcher/src/utils.rs +++ b/crates/starknet_batcher/src/utils.rs @@ -29,10 +29,14 @@ pub(crate) struct ProposalOutput { pub commitment: ProposalCommitment, pub tx_hashes: HashSet, pub nonces: HashMap, + // Needed for writing to Aerospoke. + pub block_execution_artifacts: BlockExecutionArtifacts, } impl From for ProposalOutput { fn from(artifacts: BlockExecutionArtifacts) -> Self { + let cloned_artifacts = artifacts.clone(); + let commitment_state_diff = artifacts.commitment_state_diff; let nonces = HashMap::from_iter( commitment_state_diff @@ -57,7 +61,13 @@ impl From for ProposalOutput { ProposalCommitment { state_diff_commitment: calculate_state_diff_hash(&state_diff) }; let tx_hashes = HashSet::from_iter(artifacts.execution_infos.keys().copied()); - Self { state_diff, commitment, tx_hashes, nonces } + Self { + state_diff, + commitment, + tx_hashes, + nonces, + block_execution_artifacts: cloned_artifacts, + } } }