Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Sep 1, 2023
1 parent f0485c2 commit 206c353
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions crates/revm/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ impl<'a> EVMProcessor<'a> {
///
/// If cancun is not activated or the block is the genesis block, then this is a no-op, and no
/// state changes are made.
pub fn apply_pre_block_call(
&mut self,
block: &Block,
) -> Result<(), BlockExecutionError> {
pub fn apply_pre_block_call(&mut self, block: &Block) -> Result<(), BlockExecutionError> {
if self.chain_spec.fork(Hardfork::Cancun).active_at_timestamp(block.timestamp) {
// if the block number is zero (genesis block) then the parent beacon block root must
// be 0x0 and no system transaction may occur as per EIP-4788
Expand Down Expand Up @@ -457,11 +454,15 @@ pub fn verify_receipt<'a>(
#[cfg(test)]
mod tests {
use reth_interfaces::test_utils::generators::sign_tx_with_key_pair;
use reth_primitives::{constants::BEACON_ROOTS_ADDRESS, keccak256, Bytecode, Bytes, public_key_to_address, ChainSpecBuilder, ForkCondition, MAINNET, StorageKey, Account, Transaction, TxLegacy, TransactionKind};
use reth_primitives::{
constants::BEACON_ROOTS_ADDRESS, keccak256, public_key_to_address, Account, Bytecode,
Bytes, ChainSpecBuilder, ForkCondition, StorageKey, Transaction, TransactionKind, TxLegacy,
MAINNET,
};
use reth_provider::{AccountReader, BlockHashReader, StateRootProvider};
use reth_revm_primitives::TransitionState;
use secp256k1::{KeyPair, Secp256k1, rand};
use std::{str::FromStr, collections::HashMap};
use secp256k1::{rand, KeyPair, Secp256k1};
use std::{collections::HashMap, str::FromStr};

use super::*;

Expand Down Expand Up @@ -517,7 +518,10 @@ mod tests {
}

impl StateRootProvider for StateProviderTest {
fn state_root(&self, _bundle_state: BundleStateWithReceipts) -> reth_interfaces::Result<H256> {
fn state_root(
&self,
_bundle_state: BundleStateWithReceipts,
) -> reth_interfaces::Result<H256> {
todo!()
}
}
Expand Down Expand Up @@ -639,7 +643,10 @@ mod tests {
.unwrap();

// check the receipts to ensure that the transaction didn't fail
let receipts = executor.receipts.last().expect("there should be receipts for the block we just executed");
let receipts = executor
.receipts
.last()
.expect("there should be receipts for the block we just executed");
assert_eq!(receipts.len(), 1);
let receipt = receipts.first().expect("there is one receipt");
assert!(receipt.success);
Expand All @@ -655,8 +662,11 @@ mod tests {
timestamp_index % history_buffer_length + history_buffer_length;

// get timestamp storage and compare
let timestamp_storage =
executor.db().database.storage(BEACON_ROOTS_ADDRESS, U256::from(timestamp_index)).unwrap();
let timestamp_storage = executor
.db()
.database
.storage(BEACON_ROOTS_ADDRESS, U256::from(timestamp_index))
.unwrap();
assert_eq!(timestamp_storage, U256::from(header.timestamp));

// get parent beacon block root storage and compare
Expand Down Expand Up @@ -761,7 +771,8 @@ mod tests {
// there is no system contract call so there should be NO STORAGE CHANGES
// this means we'll check the transition state
let state = executor.evm.db().unwrap();
let transition_state = state.transition_state.expect("the evm should be initialized with bundle updates");
let transition_state =
state.transition_state.expect("the evm should be initialized with bundle updates");

// assert that it is the default (empty) transition state
assert_eq!(transition_state, TransitionState::default());
Expand Down

0 comments on commit 206c353

Please sign in to comment.