Gas calculation and Transaction execution on E Money Network
Nodes execute the previous block and run the EndBlock hook. As part of this hook, the FeeMarket (EIP-1559) module tracks the total TransientGasWanted from the transactions on this block. This will be used for the next block’s BaseFee.
Nodes receive transactions for a subsequent block and gossip these transactions to peers. These can be sorted and prioritised by the included fee price (using EIP-1559 fee priority mechanics for EVM transactions - code snippet), to be included in the next block
Nodes run BeginBlock for the subsequent block. The FeeMarket module calculates the BaseFee (code snippet) to be applied for this block using the total GasWanted from the previous block. The Distribution module distributes the previous block’s fee rewards to validators and delegators
For each valid transaction that will be included in this block, nodes perform the following:
An AnteHandler process corresponding to the transaction type is initiated. This process:
Performs basic transaction validation.
Verifies the fees provided are greater than the global and local minimum validator values and greater than the BaseFee calculated (For Ethereum transactions).
Preemptively consumes gas for the EVM transaction.
Deducts the transaction fees from the user and transfers them to the fee_collector module.
Increments the TransientGasWanted in the current block, to be used to calculate the next block’s BaseFee.
Then, for standard Cosmos Transactions, nodes:
Execute the transaction and update the state Consume gas for the transaction
For Ethereum Transactions, nodes:
Execute the transaction and update the state Calculate the gas used and compare it to the gas supplied, then refund a designated portion of the surplus.
Send a fraction of the fees used as revenue to contract developers as part of the Revenue Module, if the transaction interacts with a registered smart contract
Nodes run EndBlock for this block and store the block’s GasWanted.
Last updated