This module implements the Ethereum Virtual Machine (EVM), a stack-based virtual machine that executes Ethereum smart contracts.

At the core there is this the EVMImpl struct:

pub struct EVMImpl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> {
    data: EVMData<'a, DB>,
    inspector: &'a mut dyn Inspector<DB>,
    _phantomdata: PhantomData<GSPEC>,
}

Then there is this trait Transact<DBError> that EVMImpl implements.

pub trait Transact<DBError> {
    /// Do checks that could make transaction fail before call/create
    fn preverify_transaction(&mut self) -> Result<(), EVMError<DBError>>;

    /// Skip preverification steps and do transaction
    fn transact_preverified(&mut self) -> EVMResult<DBError>;

    /// Do transaction.
    /// InstructionResult InstructionResult, Output for call or Address if we are creating
    /// contract, gas spend, gas refunded, State that needs to be applied.
    fn transact(&mut self) -> EVMResult<DBError>;
}

The most important function, as you can see, is transact:

fn transact(&mut self) -> EVMResult<DB::Error> {
    self.preverify_transaction()
        .and_then(|_| self.transact_preverified())
}

It first calls preverify_transaction that does some static checks and if it passes it then calls transact_preverified which does the following operation:

Here is a full workflow:

https://www.figma.com/file/T5JZBavzbQ5ORGrnFhW99m/Welcome-to-FigJam?type=whiteboard&node-id=35-2049&t=QiTxEclSR80GqFnA-4