Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyMessage(evm *evm.EVM, msg Message, feeReceiver common.Address) (*types.ExecutionResult, error)
- func ApplyTransaction(config *params.ChainConfig, bc store.LedgerStore, statedb *storage.StateDB, ...) (*types2.ExecutionResult, *otypes.Receipt, error)
- func CanTransfer(db evm.StateDB, addr common.Address, amount *big.Int) bool
- func GetHashFn(chain store.LedgerStore) func(n uint64) common.Hash
- func IntrinsicGas(data []byte, contractCreation, isHomestead bool, isEIP2028 bool) uint64
- func NewEVMBlockContext(height, timestamp uint32, chain store.LedgerStore) evm.BlockContext
- func NewEVMTxContext(msg Message) evm.TxContext
- func Transfer(db evm.StateDB, sender, recipient common.Address, amount *big.Int)
- type Message
- type StateTransition
Constants ¶
const RefundHeight = 13920628
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.
var RefundValue, _ = big.NewInt(0).SetString("429567499999828173", 10)
Functions ¶
func ApplyMessage ¶
func ApplyMessage(evm *evm.EVM, msg Message, feeReceiver common.Address) (*types.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 store.LedgerStore, statedb *storage.StateDB, blockHeight, timestamp uint32, tx *types.Transaction, usedGas *uint64, feeReceiver common.Address, cfg evm.Config, checkNonce bool) (*types2.ExecutionResult, *otypes.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 GetHashFn ¶
func GetHashFn(chain store.LedgerStore) func(n uint64) common.Hash
GetHashFn returns a GetHashFunc which retrieves header hashes by number
func IntrinsicGas ¶
IntrinsicGas computes the 'intrinsic gas' for a message with the given data.
func NewEVMBlockContext ¶
func NewEVMBlockContext(height, timestamp uint32, chain store.LedgerStore) 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 Message ¶
type Message interface { From() common.Address To() *common.Address GasPrice() *big.Int Gas() uint64 Value() *big.Int Nonce() uint64 CheckNonce() bool Data() []byte }
Message represents a message sent to a contract.
type StateTransition ¶
type StateTransition struct { GasReceiver common.Address // contains filtered or unexported fields }
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() (*types.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.