Documentation ¶
Index ¶
- Variables
- func AccumulateRewards(statedb *state.StateDB, header *types.Header, uncles []*types.Header)
- func ApplyMessage(env *vm.EVM, msg Message, gp *GasPool) ([]byte, *big.Int, error)
- func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, gp *GasPool, ...) (*types.Receipt, *big.Int, error)
- func CanTransfer(db vm.StateDB, addr common.Address, amount *big.Int) bool
- func GetHashFn(ref *types.Header, chain HeaderFetcher) func(n uint64) common.Hash
- func IntrinsicGas(data []byte, contractCreation, homestead bool) *big.Int
- func IsBadHashError(err error) bool
- func IsBlockNonceErr(err error) bool
- func IsGasLimitErr(err error) bool
- func IsInvalidTxErr(err error) bool
- func IsKnownBlockErr(e error) bool
- func IsNonceErr(err error) bool
- func IsParentErr(err error) bool
- func IsTDError(e error) bool
- func IsUncleErr(err error) bool
- func IsValidationErr(err error) bool
- func IsValueTransferErr(e error) bool
- func MessageCreatesContract(msg Message) bool
- func NewEVMContext(msg Message, header *types.Header, chain HeaderFetcher) vm.Context
- func ParentError(hash common.Hash) error
- func Transfer(db vm.StateDB, sender, recipient common.Address, amount *big.Int)
- func UncleError(format string, v ...interface{}) error
- type BadHashError
- type BlockChain
- type BlockNonceErr
- type GasLimitErr
- type GasPool
- type HeaderFetcher
- type InvalidTxErr
- type KnownBlockError
- type Message
- type NonceErr
- type ParentErr
- type StateTransition
- type TDError
- type UncleErr
- type ValidationErr
- type ValueTransferError
Constants ¶
This section is empty.
Variables ¶
var ( BlockNumberErr = errors.New("block number invalid") BlockFutureErr = errors.New("block time is in the future") BlockTSTooBigErr = errors.New("block time too big") BlockEqualTSErr = errors.New("block time stamp equal to previous") )
var (
Big0 = big.NewInt(0)
)
var BlockReward *big.Int = big.NewInt(5e+18)
Functions ¶
func AccumulateRewards ¶
AccumulateRewards credits the coinbase of the given block with the mining reward. The total reward consists of the static block reward and rewards for included uncles. The coinbase of each uncle block is also rewarded.
func ApplyMessage ¶
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 *BlockChain, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, txHash []byte, usedGas *big.Int, cfg vm.Config) (*types.Receipt, *big.Int, 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 wether 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 IsBadHashError ¶
func IsBlockNonceErr ¶
IsBlockNonceErr returns true for invalid block nonce errors.
func IsGasLimitErr ¶
func IsInvalidTxErr ¶
func IsKnownBlockErr ¶
func IsNonceErr ¶
func IsParentErr ¶
func IsUncleErr ¶
func IsValidationErr ¶
func IsValueTransferErr ¶
func MessageCreatesContract ¶
func NewEVMContext ¶
NewEVMContext creates a new context for use in the EVM.
func ParentError ¶
func Transfer ¶
Transfer subtracts amount from sender and adds amount to recipient using the given Db
func UncleError ¶
Types ¶
type BadHashError ¶
func (BadHashError) Error ¶
func (h BadHashError) Error() string
type BlockChain ¶
type BlockChain struct{}
type BlockNonceErr ¶
BlockNonceErr indicates that a block's nonce is invalid.
func (*BlockNonceErr) Error ¶
func (err *BlockNonceErr) Error() string
type GasLimitErr ¶
func (*GasLimitErr) Error ¶
func (err *GasLimitErr) Error() string
type GasPool ¶
GasPool tracks the amount of gas available during execution of the transactions in a block. The zero value is a pool with zero gas available.
type HeaderFetcher ¶
type HeaderFetcher interface { // GetHeader returns the hash corresponding to their hash GetHeader(common.Hash, uint64) *types.Header }
BlockFetcher retrieves headers by their hash
type InvalidTxErr ¶
type InvalidTxErr struct {
Message string
}
func InvalidTxError ¶
func InvalidTxError(err error) *InvalidTxErr
func (*InvalidTxErr) Error ¶
func (err *InvalidTxErr) Error() string
type KnownBlockError ¶
type KnownBlockError struct {
// contains filtered or unexported fields
}
func (*KnownBlockError) Error ¶
func (self *KnownBlockError) Error() string
type Message ¶
type Message interface { From() common.Address //FromFrontier() (common.Address, error) To() *common.Address GasPrice() *big.Int Gas() *big.Int Value() *big.Int Nonce() uint64 CheckNonce() bool Data() []byte }
Message represents a message sent to a contract.
type NonceErr ¶
func NonceError ¶
type ParentErr ¶
type ParentErr struct {
Message string
}
Parent error. In case a parent is unknown this error will be thrown by the block manager
type StateTransition ¶
type StateTransition struct {
// 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 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 ¶
func NewStateTransition(env *vm.EVM, msg Message, gp *GasPool) *StateTransition
NewStateTransition initialises and returns a new state transition object.
func (*StateTransition) TransitionDb ¶
func (self *StateTransition) TransitionDb() (ret []byte, requiredGas, usedGas *big.Int, err error)
TransitionDb will move the state by applying the message against the given environment.
type ValidationErr ¶
type ValidationErr struct {
Message string
}
Block validation error. If any validation fails, this error will be thrown
func ValidationError ¶
func ValidationError(format string, v ...interface{}) *ValidationErr
func (*ValidationErr) Error ¶
func (err *ValidationErr) Error() string
type ValueTransferError ¶
type ValueTransferError struct {
// contains filtered or unexported fields
}
func ValueTransferErr ¶
func ValueTransferErr(str string, v ...interface{}) *ValueTransferError
func (*ValueTransferError) Error ¶
func (self *ValueTransferError) Error() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |
Package types contains data types related to Ethereum consensus.
|
Package types contains data types related to Ethereum consensus. |
Package vm implements the Ethereum Virtual Machine.
|
Package vm implements the Ethereum Virtual Machine. |
runtime
Package runtime provides a basic execution model for executing EVM code.
|
Package runtime provides a basic execution model for executing EVM code. |