Skip to content

Commit

Permalink
Pass extra fields receipts and revert state
Browse files Browse the repository at this point in the history
  • Loading branch information
guilledk committed Sep 30, 2024
1 parent 5a0f3fc commit 63984ef
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ where
#[cfg(feature = "telos")]
let mut new_addresses_using_create_iter = unwrapped_telos_extra_fields.new_addresses_using_create.as_ref().unwrap().into_iter().peekable();

let pre_exec_state = evm.context.evm.journaled_state.checkpoint();

// execute transactions
let mut cumulative_gas_used = 0;
let mut receipts = Vec::with_capacity(block.body.len());
// let mut receipts = Vec::with_capacity(block.body.len());
for (sender, transaction) in block.transactions_with_sender() {
#[cfg(feature = "telos")]
while new_addresses_using_create_iter.peek().is_some() && new_addresses_using_create_iter.peek().unwrap().0 == tx_index {
Expand Down Expand Up @@ -229,20 +231,20 @@ where
// append gas used
cumulative_gas_used += result.gas_used();

// Push transaction changeset and calculate header bloom filter for receipt.
receipts.push(
#[allow(clippy::needless_update)] // side-effect of optimism fields
Receipt {
tx_type: transaction.tx_type(),
// Success flag was added in `EIP-658: Embedding transaction status code in
// receipts`.
success: result.is_success(),
cumulative_gas_used,
// convert to reth log
logs: result.into_logs(),
..Default::default()
},
);
// // Push transaction changeset and calculate header bloom filter for receipt.
// receipts.push(
// #[allow(clippy::needless_update)] // side-effect of optimism fields
// Receipt {
// tx_type: transaction.tx_type(),
// // Success flag was added in `EIP-658: Embedding transaction status code in
// // receipts`.
// success: result.is_success(),
// cumulative_gas_used,
// // convert to reth log
// logs: result.into_logs(),
// ..Default::default()
// },
// );
}

#[cfg(feature = "telos")]
Expand Down Expand Up @@ -272,6 +274,12 @@ where
);
}

let receipts = if unwrapped_telos_extra_fields.receipts.is_some() {
unwrapped_telos_extra_fields.receipts.unwrap().clone()
} else {
vec![]
};

let requests = if self.chain_spec.is_prague_active_at_timestamp(block.timestamp) {
// Collect all EIP-6110 deposits
let deposit_requests =
Expand All @@ -290,7 +298,13 @@ where
vec![]
};

Ok(EthExecuteOutput { receipts, requests, gas_used: cumulative_gas_used })
evm.context.evm.journaled_state.checkpoint_revert(pre_exec_state);

Ok(EthExecuteOutput {
receipts,
requests,
gas_used: cumulative_gas_used
})
}
}

Expand Down

0 comments on commit 63984ef

Please sign in to comment.