Documentation ¶
Index ¶
- Constants
- Variables
- func TestState(t *testing.T, buildPreState buildPreState)
- func TransactionGasCost(msg *types.Transaction, isHomestead, isIstanbul bool) (uint64, error)
- type Account
- type AllGasUsedError
- type BlockResult
- type Executor
- func (e *Executor) BeginTxn(parentRoot types.Hash, header *types.Header, coinbaseReceiver types.Address) (*Transition, error)
- func (e *Executor) GetForksInTime(blockNumber uint64) chain.ForksInTime
- func (e *Executor) IsStopped() bool
- func (e *Executor) ProcessBlock(parentRoot types.Hash, block *types.Block, blockCreator types.Address) (*Transition, error)
- func (e *Executor) ProcessTransactions(txn *Transition, gasLimit uint64, transactions []*types.Transaction) (*Transition, error)
- func (e *Executor) SetRuntime(r runtime.Runtime)
- func (e *Executor) State() State
- func (e *Executor) StateAt(root types.Hash) (Snapshot, error)
- func (e *Executor) Stop()
- func (e *Executor) WriteGenesis(alloc map[types.Address]*chain.GenesisAccount) (types.Hash, error)
- type GasLimitReachedTransitionApplicationError
- type GetHashByNumber
- type GetHashByNumberHelper
- type NonceTooHighError
- type NonceTooLowError
- type Object
- type PreState
- type PreStates
- type Snapshot
- type State
- type StateObject
- type StorageObject
- type Transition
- func (t *Transition) AccountExists(addr types.Address) bool
- func (t *Transition) Apply(msg *types.Transaction) (*runtime.ExecutionResult, error)
- func (t *Transition) Call2(caller types.Address, to types.Address, input []byte, value *big.Int, ...) *runtime.ExecutionResult
- func (t *Transition) Callx(c *runtime.Contract, h runtime.Host) *runtime.ExecutionResult
- func (t *Transition) Commit() (Snapshot, types.Hash, error)
- func (t *Transition) ContextPtr() *runtime.TxContext
- func (t *Transition) Create2(caller types.Address, code []byte, value *big.Int, gas uint64) *runtime.ExecutionResult
- func (t *Transition) EmitLog(addr types.Address, topics []types.Hash, data []byte)
- func (t *Transition) Empty(addr types.Address) bool
- func (t *Transition) GetBalance(addr types.Address) *big.Int
- func (t *Transition) GetBlockHash(number int64) (res types.Hash)
- func (t *Transition) GetCode(addr types.Address) []byte
- func (t *Transition) GetCodeHash(addr types.Address) (res types.Hash)
- func (t *Transition) GetCodeSize(addr types.Address) int
- func (t *Transition) GetEVMLogger() runtime.EVMLogger
- func (t *Transition) GetNonce(addr types.Address) uint64
- func (t *Transition) GetStorage(addr types.Address, key types.Hash) (types.Hash, error)
- func (t *Transition) GetTxContext() runtime.TxContext
- func (t *Transition) HookTotalGas(fn func() uint64)
- func (t *Transition) IncreaseSystemTransactionGas(amount uint64)
- func (t *Transition) Receipts() []*types.Receipt
- func (t *Transition) Selfdestruct(addr types.Address, beneficiary types.Address)
- func (t *Transition) SetAccountDirectly(addr types.Address, account *chain.GenesisAccount) error
- func (t *Transition) SetEVMLogger(logger runtime.EVMLogger)
- func (t *Transition) SetStorage(addr types.Address, key types.Hash, value types.Hash, ...) runtime.StorageStatus
- func (t *Transition) SetTxn(txn *Txn)
- func (t *Transition) TotalGas() uint64
- func (t *Transition) Txn() *Txn
- func (t *Transition) Write(txn *types.Transaction) error
- func (t *Transition) WriteFailedReceipt(txn *types.Transaction) error
- type TransitionApplicationError
- type Txn
- func (txn *Txn) AddBalance(addr types.Address, balance *big.Int)
- func (txn *Txn) AddLog(log *types.Log)
- func (txn *Txn) AddRefund(gas uint64)
- func (txn *Txn) AddSealingReward(addr types.Address, balance *big.Int)
- func (txn *Txn) CleanDeleteObjects(deleteEmptyObjects bool)
- func (txn *Txn) Commit(deleteEmptyObjects bool) []*Object
- func (txn *Txn) CreateAccount(addr types.Address)
- func (txn *Txn) EmitLog(addr types.Address, topics []types.Hash, data []byte)
- func (txn *Txn) Empty(addr types.Address) bool
- func (txn *Txn) Exist(addr types.Address) bool
- func (txn *Txn) GetAccount(addr types.Address) (*Account, bool)
- func (txn *Txn) GetBalance(addr types.Address) *big.Int
- func (txn *Txn) GetCode(addr types.Address) []byte
- func (txn *Txn) GetCodeHash(addr types.Address) types.Hash
- func (txn *Txn) GetCodeSize(addr types.Address) int
- func (txn *Txn) GetCommittedState(addr types.Address, key types.Hash) (types.Hash, error)
- func (txn *Txn) GetNonce(addr types.Address) uint64
- func (txn *Txn) GetRefund() uint64
- func (txn *Txn) GetState(addr types.Address, slot types.Hash) (types.Hash, error)
- func (txn *Txn) HasSuicided(addr types.Address) bool
- func (txn *Txn) IncrNonce(addr types.Address)
- func (txn *Txn) Logs() []*types.Log
- func (txn *Txn) RevertToSnapshot(id int)
- func (txn *Txn) SetBalance(addr types.Address, balance *big.Int)
- func (txn *Txn) SetCode(addr types.Address, code []byte)
- func (txn *Txn) SetNonce(addr types.Address, nonce uint64)
- func (txn *Txn) SetState(addr types.Address, key, value types.Hash)
- func (txn *Txn) SetStorage(addr types.Address, key types.Hash, value types.Hash, ...) runtime.StorageStatus
- func (txn *Txn) Snapshot() int
- func (txn *Txn) SubBalance(addr types.Address, amount *big.Int) error
- func (txn *Txn) SubRefund(gas uint64)
- func (txn *Txn) Suicide(addr types.Address) bool
- func (txn *Txn) TouchAccount(addr types.Address)
Constants ¶
const ( TxGas uint64 = 21000 // Per transaction not creating a contract TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract )
Variables ¶
var ( ErrNonceIncorrect = errors.New("incorrect nonce") ErrNotEnoughFundsForGas = errors.New("not enough funds to cover gas costs") ErrBlockLimitReached = errors.New("gas limit reached in the pool") ErrIntrinsicGasOverflow = errors.New("overflow in intrinsic gas calculation") ErrNotEnoughIntrinsicGas = errors.New("not enough gas supplied for intrinsic gas costs") ErrNotEnoughFunds = errors.New("not enough funds for transfer with given value") ErrAllGasUsed = errors.New("all gas used") ErrExecutionStop = errors.New("execution stop") )
Functions ¶
func TransactionGasCost ¶
func TransactionGasCost(msg *types.Transaction, isHomestead, isIstanbul bool) (uint64, error)
Types ¶
type Account ¶
Account is the account reference in the ethereum state
func (*Account) UnmarshalRlp ¶
type AllGasUsedError ¶ added in v1.0.2
type AllGasUsedError struct {
TransitionApplicationError
}
func NewAllGasUsedError ¶ added in v1.0.2
func NewAllGasUsedError(err error) *AllGasUsedError
type BlockResult ¶
type Executor ¶
type Executor struct { GetHash GetHashByNumberHelper PostHook func(txn *Transition) // contains filtered or unexported fields }
Executor is the main entity
func NewExecutor ¶
NewExecutor creates a new executor
func (*Executor) BeginTxn ¶
func (e *Executor) BeginTxn( parentRoot types.Hash, header *types.Header, coinbaseReceiver types.Address, ) (*Transition, error)
TODO: It knows too much knowledge of the blockchain. Should limit its knowledge range, beginning from parameters.
func (*Executor) GetForksInTime ¶
func (e *Executor) GetForksInTime(blockNumber uint64) chain.ForksInTime
GetForksInTime returns the active forks at the given block height
func (*Executor) ProcessBlock ¶
func (e *Executor) ProcessBlock( parentRoot types.Hash, block *types.Block, blockCreator types.Address, ) (*Transition, error)
ProcessBlock already does all the handling of the whole process
func (*Executor) ProcessTransactions ¶ added in v1.2.0
func (e *Executor) ProcessTransactions( txn *Transition, gasLimit uint64, transactions []*types.Transaction, ) (*Transition, error)
ProcessBlock already does all the handling of the whole process
func (*Executor) SetRuntime ¶
SetRuntime adds a runtime to the runtime set
func (*Executor) WriteGenesis ¶
type GasLimitReachedTransitionApplicationError ¶
type GasLimitReachedTransitionApplicationError struct {
TransitionApplicationError
}
func NewGasLimitReachedTransitionApplicationError ¶
func NewGasLimitReachedTransitionApplicationError(err error) *GasLimitReachedTransitionApplicationError
type GetHashByNumber ¶
GetHashByNumber returns the hash function of a block number
type GetHashByNumberHelper ¶
type GetHashByNumberHelper = func(*types.Header) GetHashByNumber
type NonceTooHighError ¶ added in v1.1.0
type NonceTooHighError struct { TransitionApplicationError CorrectNonce uint64 }
func NewNonceTooHighError ¶ added in v1.1.0
func NewNonceTooHighError(err error, correctNonce uint64) *NonceTooHighError
type NonceTooLowError ¶ added in v1.1.0
type NonceTooLowError struct { TransitionApplicationError CorrectNonce uint64 }
func NewNonceTooLowError ¶ added in v1.1.0
func NewNonceTooLowError(err error, correctNonce uint64) *NonceTooLowError
type Object ¶
type Object struct { Address types.Address CodeHash types.Hash Balance *big.Int Root types.Hash Nonce uint64 Deleted bool // TODO: Move this to executor DirtyCode bool Code []byte Storage []*StorageObject }
Object is the serialization of the radix object (can be merged to StateObject?).
type StateObject ¶
type StateObject struct { Account *Account Code []byte Suicide bool Deleted bool DirtyCode bool Txn *iradix.Txn }
StateObject is the internal representation of the account
func (*StateObject) Copy ¶
func (s *StateObject) Copy() *StateObject
Copy makes a copy of the state object
func (*StateObject) Empty ¶
func (s *StateObject) Empty() bool
type StorageObject ¶
StorageObject is an entry in the storage
type Transition ¶
type Transition struct {
// contains filtered or unexported fields
}
func (*Transition) AccountExists ¶
func (t *Transition) AccountExists(addr types.Address) bool
func (*Transition) Apply ¶
func (t *Transition) Apply(msg *types.Transaction) (*runtime.ExecutionResult, error)
Apply applies a new transaction
func (*Transition) Callx ¶
func (t *Transition) Callx(c *runtime.Contract, h runtime.Host) *runtime.ExecutionResult
func (*Transition) Commit ¶
func (t *Transition) Commit() (Snapshot, types.Hash, error)
Commit commits the final result
func (*Transition) ContextPtr ¶
func (t *Transition) ContextPtr() *runtime.TxContext
ContextPtr returns reference of context This method is called only by test
func (*Transition) Create2 ¶
func (t *Transition) Create2( caller types.Address, code []byte, value *big.Int, gas uint64, ) *runtime.ExecutionResult
func (*Transition) GetBalance ¶
func (t *Transition) GetBalance(addr types.Address) *big.Int
func (*Transition) GetBlockHash ¶
func (t *Transition) GetBlockHash(number int64) (res types.Hash)
func (*Transition) GetCodeHash ¶
func (t *Transition) GetCodeHash(addr types.Address) (res types.Hash)
func (*Transition) GetCodeSize ¶
func (t *Transition) GetCodeSize(addr types.Address) int
func (*Transition) GetEVMLogger ¶ added in v1.1.4
func (t *Transition) GetEVMLogger() runtime.EVMLogger
func (*Transition) GetStorage ¶
func (*Transition) GetTxContext ¶
func (t *Transition) GetTxContext() runtime.TxContext
func (*Transition) HookTotalGas ¶ added in v1.2.0
func (t *Transition) HookTotalGas(fn func() uint64)
HookTotalGas uses hook to return total gas
Use it for testing
func (*Transition) IncreaseSystemTransactionGas ¶ added in v1.2.0
func (t *Transition) IncreaseSystemTransactionGas(amount uint64)
IncreaseSystemTransactionGas updates gas pool so that system contract transactions can be sealed.
func (*Transition) Receipts ¶
func (t *Transition) Receipts() []*types.Receipt
func (*Transition) Selfdestruct ¶
func (t *Transition) Selfdestruct(addr types.Address, beneficiary types.Address)
func (*Transition) SetAccountDirectly ¶
func (t *Transition) SetAccountDirectly(addr types.Address, account *chain.GenesisAccount) error
SetAccountDirectly sets an account to the given address NOTE: SetAccountDirectly changes the world state without a transaction
func (*Transition) SetEVMLogger ¶ added in v1.1.4
func (t *Transition) SetEVMLogger(logger runtime.EVMLogger)
SetEVMLogger sets a non nil tracer to it
func (*Transition) SetStorage ¶
func (t *Transition) SetStorage( addr types.Address, key types.Hash, value types.Hash, config *chain.ForksInTime, ) runtime.StorageStatus
func (*Transition) SetTxn ¶
func (t *Transition) SetTxn(txn *Txn)
func (*Transition) TotalGas ¶
func (t *Transition) TotalGas() uint64
func (*Transition) Txn ¶
func (t *Transition) Txn() *Txn
func (*Transition) Write ¶
func (t *Transition) Write(txn *types.Transaction) error
Write writes another transaction to the executor
func (*Transition) WriteFailedReceipt ¶
func (t *Transition) WriteFailedReceipt(txn *types.Transaction) error
type TransitionApplicationError ¶
type TransitionApplicationError struct { Err error IsRecoverable bool // Should the transaction be discarded, or put back in the queue. }
func NewTransitionApplicationError ¶
func NewTransitionApplicationError(err error, isRecoverable bool) *TransitionApplicationError
func (*TransitionApplicationError) Error ¶
func (e *TransitionApplicationError) Error() string
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn is a reference of the state
func (*Txn) AddBalance ¶
AddBalance adds balance
func (*Txn) AddSealingReward ¶
func (*Txn) CleanDeleteObjects ¶
func (*Txn) CreateAccount ¶
func (*Txn) GetAccount ¶
GetAccount returns an account
func (*Txn) GetBalance ¶
GetBalance returns the balance of an address
func (*Txn) GetCommittedState ¶
GetCommittedState returns the state of the address in the trie
func (*Txn) HasSuicided ¶
HasSuicided returns true if the account suicided
func (*Txn) RevertToSnapshot ¶
RevertToSnapshot reverts to a given snapshot
func (*Txn) SetBalance ¶
SetBalance sets the balance
func (*Txn) SetStorage ¶
func (*Txn) SubBalance ¶
SubBalance reduces the balance at address addr by amount