Documentation
¶
Index ¶
- Variables
- type AccessList
- type BlockEnv
- type ExecutionResult
- type Halt
- type InvalidRequest
- type InvalidResponse
- type Iterator
- type KVStore
- type Log
- type LogData
- type NoSuchCode
- type NoSuchContract
- type Output
- type OutputType
- type Result
- type Revert
- type SerializedBlock
- type SerializedTransaction
- type Success
- type SystemError
- type TransactionEnv
- type Unknown
- type UnsupportedRequest
Constants ¶
This section is empty.
Variables ¶
var ( AccountPrefix = []byte{0x01} CodePrefix = []byte{0x02} StoragePrefix = []byte{0x03} BlockPrefix = []byte{0x04} )
var (
VMStorePrefix = []byte{0x20}
)
KV Store Prefix ACCOUNT_PREFIX(B1) + {address(B20)} => ACCOUNT INFO {balance(B64)(0) | nonce(B256)(1) | code_hash(B256)(2)} CODE_PREFIX(B1) + {code_hash(B32)} => vm bytecode STORAGE_PREFIX(B1) + {address(B20)} + {index(B32)} => [32]byte(value) BLOCK_PREFIX(B1) + block_num(B8) => block_hash
Functions ¶
This section is empty.
Types ¶
type BlockEnv ¶
type BlockEnv struct { /// The number of ancestor blocks of this block (block height). Number common.Hash /// Coinbase or miner or address that created and signed the block. /// /// This is the receiver address of all the gas spent in the block. Coinbase common.Address /// The timestamp of the block in seconds since the UNIX epoch. Timestamp common.Hash /// The gas limit of the block. GasLimit common.Hash /// The base fee per gas added in the London upgrade with [EIP-1559]. /// /// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559 Basefee common.Hash }
func (BlockEnv) ToSerialized ¶ added in v0.0.5
func (block BlockEnv) ToSerialized() SerializedBlock
type ExecutionResult ¶
type ExecutionResult []byte
func (ExecutionResult) ProcessExecutionResult ¶ added in v0.0.5
func (res ExecutionResult) ProcessExecutionResult() (Result, error)
type InvalidRequest ¶
func (InvalidRequest) Error ¶
func (e InvalidRequest) Error() string
type InvalidResponse ¶
func (InvalidResponse) Error ¶
func (e InvalidResponse) Error() string
type Iterator ¶
type Iterator interface { // Domain returns the start (inclusive) and end (exclusive) limits of the iterator. // CONTRACT: start, end readonly []byte Domain() (start []byte, end []byte) // Valid returns whether the current iterator is valid. Once invalid, the Iterator remains // invalid forever. Valid() bool // Next moves the iterator to the next key in the database, as defined by order of iteration. // If Valid returns false, this method will panic. Next() // Key returns the key at the current position. Panics if the iterator is invalid. // CONTRACT: key readonly []byte Key() (key []byte) // Value returns the value at the current position. Panics if the iterator is invalid. // CONTRACT: value readonly []byte Value() (value []byte) // Error returns the last error encountered by the iterator, if any. Error() error // Close closes the iterator, releasing any allocated resources. Close() error }
Iterator represents an iterator over a domain of keys. Callers must call Close when done. No writes can happen to a domain while there exists an iterator over it, some backends may take out database locks to ensure this will not happen.
Callers must make sure the iterator is valid before calling any methods on it, otherwise these methods will panic. This is in part caused by most backend databases using this convention.
As with DB, keys and values should be considered read-only, and must be copied before they are modified.
Typical usage:
var itr Iterator = ... defer itr.Close()
for ; itr.Valid(); itr.Next() { k, v := itr.Key(); itr.Value() ... } if err := itr.Error(); err != nil { ... }
Copied from https://github.com/tendermint/tm-db/blob/v0.6.7/types.go#L121
type KVStore ¶
type KVStore interface { Get(key []byte) []byte Set(key, value []byte) Delete(key []byte) // Iterator over a domain of keys in ascending order. End is exclusive. // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. // To iterate over entire domain, use store.Iterator(nil, nil) Iterator(start, end []byte) Iterator // ReverseIterator iterator over a domain of keys in descending order. End is exclusive. // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. ReverseIterator(start, end []byte) Iterator }
KVStore copies a subset of types from cosmos-sdk We may wish to make this more generic sometime in the future, but not now https://github.com/cosmos/cosmos-sdk/blob/bef3689245bab591d7d169abd6bea52db97a70c7/store/types/store.go#L170
type NoSuchCode ¶
type NoSuchCode struct {
CodeID uint64 `json:"code_id,omitempty"`
}
func (NoSuchCode) Error ¶
func (e NoSuchCode) Error() string
type NoSuchContract ¶
type NoSuchContract struct {
Addr string `json:"addr,omitempty"`
}
func (NoSuchContract) Error ¶
func (e NoSuchContract) Error() string
type OutputType ¶
type OutputType uint8
type SerializedBlock ¶ added in v0.0.5
type SerializedBlock = []byte
type SerializedTransaction ¶ added in v0.0.5
type SerializedTransaction = []byte
type SystemError ¶
type SystemError struct { InvalidRequest *InvalidRequest `json:"invalid_request,omitempty"` InvalidResponse *InvalidResponse `json:"invalid_response,omitempty"` NoSuchContract *NoSuchContract `json:"no_such_contract,omitempty"` NoSuchCode *NoSuchCode `json:"no_such_code,omitempty"` Unknown *Unknown `json:"unknown,omitempty"` UnsupportedRequest *UnsupportedRequest `json:"unsupported_request,omitempty"` }
SystemError captures all errors returned from the Rust code as SystemError. Exactly one of the fields should be set.
func ToSystemError ¶
func ToSystemError(err error) *SystemError
ToSystemError will try to convert the given error to an SystemError. This is important to returning any Go error back to Rust.
If it is already StdError, return self. If it is an error, which could be a sub-field of StdError, embed it. If it is anything else, **return nil**
This may return nil on an unknown error, whereas ToStdError will always create a valid error type.
func (SystemError) Error ¶
func (a SystemError) Error() string
type TransactionEnv ¶
type TransactionEnv struct { /// Caller aka Author aka transaction signer. Caller common.Address /// The gas limit of the transaction. GasLimit uint64 /// The gas price of the transaction. GasPrice common.Hash /// The destination of the transaction. TransactTo common.Address /// The value sent to `transact_to`. Value common.Hash Data []byte /// The nonce of the transaction. Nonce uint64 /// The chain ID of the transaction. If set to `None` no checks are performed. /// /// Incorporated as part of the Spurious Dragon upgrade via [EIP-155]. /// /// [EIP-155] https://eips.ethereum.org/EIPS/eip-155 ChainId uint64 /// A list of addresses and storage keys that the transaction plans to access. /// /// Added in [EIP-2930]. /// /// [EIP-2930] https://eips.ethereum.org/EIPS/eip-2930 AccessList AccessList /// The priority fee per gas. /// /// Incorporated as part of the London upgrade via [EIP-1559]. /// /// [EIP-1559] https://eips.ethereum.org/EIPS/eip-1559 // optinal GasPriorityFee common.Hash }
func (TransactionEnv) ToSerialized ¶ added in v0.0.5
func (transaction TransactionEnv) ToSerialized() SerializedTransaction
type UnsupportedRequest ¶
type UnsupportedRequest struct {
Kind string `json:"kind,omitempty"`
}
func (UnsupportedRequest) Error ¶
func (e UnsupportedRequest) Error() string