Documentation ¶
Index ¶
- Variables
- func ApplyMessage(evm *evm.EVM, msg Message, feeReceiver web3.Address) (*web3.ExecutionResult, error)
- func ApplyTransaction(config *params.ChainConfig, bc *remotedb.RemoteDB, statedb *storage.StateDB, ...) (*web3.ExecutionResult, *web3.Receipt, error)
- func CanTransfer(db evm.StateDB, addr web3.Address, amount *big.Int) bool
- func IntrinsicGas(data []byte, contractCreation, isHomestead bool, isEIP2028 bool) uint64
- func NewEVMBlockContext(height, timestamp uint64, hashFn evm.GetHashFunc) evm.BlockContext
- func NewEVMTxContext(msg Message) evm.TxContext
- func Transfer(db evm.StateDB, sender, recipient web3.Address, amount *big.Int)
- type Eip155Context
- type Executor
- type Message
- type StateTransition
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNonceTooLow is returned if the nonce of a transaction is lower than the // one present in the local chain. ErrNonceTooLow = errors.New("nonce too low") // ErrNonceTooHigh is returned if the nonce of a transaction is higher than the // next one expected based on the local chain. ErrNonceTooHigh = errors.New("nonce too high") // ErrGasLimitReached is returned by the gas pool if the amount of gas required // by a transaction is higher than what's left in the block. ErrGasLimitReached = errors.New("gas limit reached") // ErrInsufficientFundsForTransfer is returned if the transaction sender doesn't // have enough funds for transfer(topmost call only). ErrInsufficientFundsForTransfer = errors.New("insufficient funds for transfer") // ErrInsufficientFunds is returned if the total cost of executing a transaction // is higher than the balance of the user's account. ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") // ErrGasUintOverflow is returned when calculating gas usage. ErrGasUintOverflow = errors.New("gas uint64 overflow") // ErrIntrinsicGas is returned if the transaction is specified to use less gas // than required to start the invocation. ErrIntrinsicGas = errors.New("intrinsic gas too low") )
List of evm-call-message pre-checking errors. All state transition messages will be pre-checked before execution. If any invalidation detected, the corresponding error should be returned which is defined here.
- If the pre-checking happens in the miner, then the transaction won't be packed. - If the pre-checking happens in the block processing procedure, then a "BAD BLOCk" error should be emitted.
Functions ¶
func ApplyMessage ¶
func ApplyMessage(evm *evm.EVM, msg Message, feeReceiver web3.Address) (*web3.ExecutionResult, error)
ApplyMessage computes the new state by applying the given message against the old state within the environment.
ApplyMessage returns the bytes returned by any EVM execution (if it took place), the gas used (which includes gas refunds) and an error if it failed. An error always indicates a core error meaning that the message would always fail for that particular state and would never be accepted within a block.
func ApplyTransaction ¶
func ApplyTransaction(config *params.ChainConfig, bc *remotedb.RemoteDB, statedb *storage.StateDB, blockHeight, timestamp uint64, tx *web3.Transaction, usedGas *uint64, feeReceiver web3.Address, cfg evm.Config, checkNonce bool) (*web3.ExecutionResult, *web3.Receipt, error)
ApplyTransaction attempts to apply a transaction to the given state database and uses the input parameters for its environment. It returns the receipt for the transaction, gas used and an error if the transaction failed, indicating the block was invalid.
func CanTransfer ¶
CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.
func IntrinsicGas ¶
IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
func NewEVMBlockContext ¶
func NewEVMBlockContext(height, timestamp uint64, hashFn evm.GetHashFunc) evm.BlockContext
NewEVMBlockContext creates a new context for use in the EVM.
func NewEVMTxContext ¶
NewEVMTxContext creates a new transaction context for a single transaction.
Types ¶
type Eip155Context ¶
type Executor ¶
type Executor struct { Trace bool // contains filtered or unexported fields }
func NewExecutor ¶
func (*Executor) ExecuteTransaction ¶
func (self *Executor) ExecuteTransaction(tx *web3.Transaction, ctx Eip155Context) (*web3.ExecutionResult, *web3.Receipt, error)
func (*Executor) ResetOverlay ¶
func (self *Executor) ResetOverlay()
type Message ¶
type Message interface { From() web3.Address To() *web3.Address GasPrice() *big.Int Gas() uint64 Value() *big.Int Nonce() uint64 CheckNonce() bool Data() []byte }
Message represents a message sent to a contract.
func MessageFromTx ¶
func MessageFromTx(tx *web3.Transaction, checkNonce bool) Message
type StateTransition ¶
The State Transitioning Model
A state transition is a change made when a transaction is applied to the current world state The state transitioning model does all the necessary work to work out a valid new state root.
1) Nonce handling 2) Pre pay gas 3) Create a new state object if the recipient is \0*32 4) Value transfer == If contract creation ==
4a) Attempt to run transaction data 4b) If valid, use result as code for the new state object
== end == 5) Run Script section 6) Derive new state root
func NewStateTransition ¶
NewStateTransition initialises and returns a new state transition object.
func (*StateTransition) TransitionDb ¶
func (st *StateTransition) TransitionDb() (*web3.ExecutionResult, error)
TransitionDb will transition the state by applying the current message and returning the evm execution result with following fields.
- used gas: total gas used (including gas being refunded)
- returndata: the returned data from evm
- concrete execution error: various **EVM** error which aborts the execution, e.g. ErrOutOfGas, ErrExecutionReverted
However if any consensus issue encountered, return the error directly with nil evm execution result.