Documentation ¶
Index ¶
- Constants
- Variables
- func StringToHash(str string) evmc.Hash
- func TransactionGasCost(msg *Message, isHomestead, isIstanbul bool) (uint64, error)
- type Account
- type Cheatcode
- type Config
- type ConfigOption
- type Contract
- func NewContract(typ evmc.CallKind, depth int, from evmc.Address, to evmc.Address, ...) *Contract
- func NewContractCall(depth int, from evmc.Address, to evmc.Address, value *big.Int, gas uint64, ...) *Contract
- func NewContractCreation(depth int, from evmc.Address, to evmc.Address, value *big.Int, gas uint64, ...) *Contract
- type EmptyState
- type GetHashByNumber
- type Log
- type Message
- type Object
- type Output
- type Snapshot
- type StorageObject
- type Transition
- func (t *Transition) AccessAccount(addr evmc.Address) evmc.AccessStatus
- func (t *Transition) AccessStorage(addr evmc.Address, key evmc.Hash) evmc.AccessStatus
- func (t *Transition) AccountExists(addr evmc.Address) bool
- func (t *Transition) Apply(msg *Message) *Output
- func (t *Transition) Call(kind evmc.CallKind, recipient evmc.Address, sender evmc.Address, ...) ([]byte, int64, evmc.Address, error)
- func (t *Transition) Callx(c *Contract) ([]byte, int64, evmc.Address, error)
- func (e *Transition) Commit() []*Object
- func (t *Transition) EmitLog(addr evmc.Address, topics []evmc.Hash, data []byte)
- func (t *Transition) GetBalance(addr evmc.Address) evmc.Hash
- func (t *Transition) GetBlockHash(number int64) (res evmc.Hash)
- func (t *Transition) GetCode(addr evmc.Address) []byte
- func (t *Transition) GetCodeHash(addr evmc.Address) (res evmc.Hash)
- func (t *Transition) GetCodeSize(addr evmc.Address) int
- func (t *Transition) GetNonce(addr evmc.Address) uint64
- func (t *Transition) GetStorage(addr evmc.Address, key evmc.Hash) evmc.Hash
- func (t *Transition) GetTxContext() evmc.TxContext
- func (t *Transition) Selfdestruct(addr evmc.Address, beneficiary evmc.Address)
- func (t *Transition) SetStorage(addr evmc.Address, key evmc.Hash, value evmc.Hash) evmc.StorageStatus
- func (t *Transition) Txn() *Txn
- func (t *Transition) Write(msg *Message) (*Output, error)
- type TxContext
- type Txn
- func (txn *Txn) AccountExists(addr evmc.Address) bool
- func (txn *Txn) AddBalance(addr evmc.Address, balance *big.Int)
- func (txn *Txn) AddRefund(gas uint64)
- func (txn *Txn) AddSealingReward(addr evmc.Address, balance *big.Int)
- func (txn *Txn) CleanDeleteObjects(deleteEmptyObjects bool)
- func (txn *Txn) Commit() []*Object
- func (txn *Txn) CreateAccount(addr evmc.Address)
- func (txn *Txn) EmitLog(addr evmc.Address, topics []evmc.Hash, data []byte)
- func (txn *Txn) GetAccount(addr evmc.Address) (*Account, bool)
- func (txn *Txn) GetBalance(addr evmc.Address) *big.Int
- func (txn *Txn) GetCode(addr evmc.Address) []byte
- func (txn *Txn) GetCodeHash(addr evmc.Address) (res evmc.Hash)
- func (txn *Txn) GetCodeSize(addr evmc.Address) int
- func (txn *Txn) GetCommittedState(addr evmc.Address, key evmc.Hash) evmc.Hash
- func (txn *Txn) GetNonce(addr evmc.Address) uint64
- func (txn *Txn) GetRefund() uint64
- func (txn *Txn) GetState(addr evmc.Address, key evmc.Hash) evmc.Hash
- func (txn *Txn) HasSuicided(addr evmc.Address) bool
- func (txn *Txn) IncrNonce(addr evmc.Address)
- func (txn *Txn) Logs() []*Log
- func (txn *Txn) RevertToSnapshot(id int)
- func (txn *Txn) SetBalance(addr evmc.Address, balance *big.Int)
- func (txn *Txn) SetCode(addr evmc.Address, code []byte)
- func (txn *Txn) SetNonce(addr evmc.Address, nonce uint64)
- func (txn *Txn) SetState(addr evmc.Address, key, value evmc.Hash)
- func (txn *Txn) SetStorage(addr evmc.Address, key evmc.Hash, value evmc.Hash) (status evmc.StorageStatus)
- func (txn *Txn) Snapshot() int
- func (txn *Txn) SubBalance(addr evmc.Address, amount *big.Int) error
- func (txn *Txn) SubRefund(gas uint64)
- func (txn *Txn) Suicide(addr evmc.Address) bool
- func (txn *Txn) TouchAccount(addr evmc.Address)
Constants ¶
View Source
const ( // Per transaction not creating a contract TxGas uint64 = 21000 // Per transaction that creates a contract TxGasContractCreation uint64 = 53000 )
View Source
const HashLength = 32
Variables ¶
View Source
var ( EmptyCodeHash = bytesToHash(ethgo.Keccak256(nil)) // EmptyRootHash is the root when there are no transactions EmptyRootHash = StringToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") )
Functions ¶
func StringToHash ¶
Types ¶
type Config ¶
type Config struct { GetHash GetHashByNumber Ctx TxContext Rev evmc.Revision State Snapshot Cheatcodes []Cheatcode }
func DefaultConfig ¶
func DefaultConfig() *Config
type ConfigOption ¶
type ConfigOption func(*Config)
func WithCheatcode ¶
func WithCheatcode(cheat Cheatcode) ConfigOption
func WithContext ¶
func WithContext(ctx TxContext) ConfigOption
func WithGetHash ¶
func WithGetHash(hash GetHashByNumber) ConfigOption
func WithRevision ¶
func WithRevision(rev evmc.Revision) ConfigOption
func WithState ¶
func WithState(state Snapshot) ConfigOption
type Contract ¶
type Contract struct { Type evmc.CallKind CodeAddress evmc.Address Address evmc.Address Caller evmc.Address Depth int Value *big.Int Input []byte Gas uint64 Static bool Salt evmc.Hash }
Contract is the instance being called
func NewContract ¶
func NewContractCall ¶
type EmptyState ¶
type EmptyState struct { }
func (*EmptyState) GetAccount ¶
func (e *EmptyState) GetAccount(addr evmc.Address) (*Account, error)
type GetHashByNumber ¶
getHashByNumber returns the hash function of a block number
type Message ¶
type Message struct { Nonce uint64 GasPrice *big.Int Gas uint64 To *evmc.Address Value *big.Int Input []byte From evmc.Address }
func (*Message) IsContractCreation ¶
type Object ¶
type Object struct { Address evmc.Address CodeHash evmc.Hash Balance *big.Int Root evmc.Hash Nonce uint64 Deleted bool DirtyCode bool Code []byte Storage []*StorageObject }
Object is the serialization of the radix object (can be merged to StateObject?).
type StorageObject ¶
StorageObject is an entry in the storage
type Transition ¶
type Transition struct {
// contains filtered or unexported fields
}
func NewTransition ¶
func NewTransition(opts ...ConfigOption) *Transition
NewExecutor creates a new executor
func (*Transition) AccessAccount ¶
func (t *Transition) AccessAccount(addr evmc.Address) evmc.AccessStatus
func (*Transition) AccessStorage ¶
func (t *Transition) AccessStorage(addr evmc.Address, key evmc.Hash) evmc.AccessStatus
func (*Transition) AccountExists ¶
func (t *Transition) AccountExists(addr evmc.Address) bool
func (*Transition) Apply ¶
func (t *Transition) Apply(msg *Message) *Output
func (*Transition) Commit ¶
func (e *Transition) Commit() []*Object
func (*Transition) GetBalance ¶
func (t *Transition) GetBalance(addr evmc.Address) evmc.Hash
func (*Transition) GetBlockHash ¶
func (t *Transition) GetBlockHash(number int64) (res evmc.Hash)
func (*Transition) GetCodeHash ¶
func (t *Transition) GetCodeHash(addr evmc.Address) (res evmc.Hash)
func (*Transition) GetCodeSize ¶
func (t *Transition) GetCodeSize(addr evmc.Address) int
func (*Transition) GetStorage ¶
func (*Transition) GetTxContext ¶
func (t *Transition) GetTxContext() evmc.TxContext
func (*Transition) Selfdestruct ¶
func (t *Transition) Selfdestruct(addr evmc.Address, beneficiary evmc.Address)
func (*Transition) SetStorage ¶
func (t *Transition) SetStorage(addr evmc.Address, key evmc.Hash, value evmc.Hash) evmc.StorageStatus
func (*Transition) Txn ¶
func (t *Transition) Txn() *Txn
type TxContext ¶
type TxContext struct { Hash evmc.Hash GasPrice evmc.Hash Origin evmc.Address Coinbase evmc.Address Number int64 Timestamp int64 GasLimit int64 ChainID int64 Difficulty evmc.Hash }
TxContext is the context of the transaction
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
func (*Txn) TouchAccount ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.