types

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessList

type AccessList map[AccountAddress][]U256

address => []storageKey

type AccountAddress

type AccountAddress [20]uint8

func NewAccountAddress

func NewAccountAddress(s string) (AccountAddress, error)

func ZeroAddress

func ZeroAddress() AccountAddress

type AccountInfo

type AccountInfo struct {
	Balance  *big.Int
	Nonce    uint64
	CodeHash [32]byte
}

72 Byte

func AccountInfoFromBytes

func AccountInfoFromBytes(data []byte) (AccountInfo, error)

func (AccountInfo) ToBytes

func (accountInfo AccountInfo) ToBytes() []byte

type BlockEnv

type BlockEnv struct {
	/// The number of ancestor blocks of this block (block height).
	Number U256
	/// 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 AccountAddress

	/// The timestamp of the block in seconds since the UNIX epoch.
	Timestamp U256
	/// The gas limit of the block.
	GasLimit U256
	/// The base fee per gas added in the London upgrade with [EIP-1559].
	///
	/// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559
	Basefee U256
}

type Bytecode

type Bytecode []byte

type ExecutionResult

type ExecutionResult []byte

type Halt

type Halt struct {
	Reason  string
	GasUsed uint64
}

Halt variant of ExecutionResult

type HaltReason

type HaltReason uint
const (
	OutOfGas HaltReason = iota
	OpcodeNotFound
	InvalidFEOpcode
	InvalidJump
	NotActivated
	StackUnderflow
	StackOverflow
	OutOfOffset
	CreateCollision
	PrecompileError
	NonceOverflow
	CreateContractSizeLimit
	CreateContractStartingWithEF
	CreateInitCodeSizeLimit

	// Internal Halts
	OverflowPayment
	StateChangeDuringStaticCall
	CallNotAllowedInsideStatic
	OutOfFunds
	CallTooDeep

	EOFSubroutineStackOverflow
	InvalidEXTCALLTarget
	EofAuxDataOverflow
	EofAuxDataTooSmall
)

type InvalidRequest

type InvalidRequest struct {
	Err     string `json:"error"`
	Request []byte `json:"request"`
}

func (InvalidRequest) Error

func (e InvalidRequest) Error() string

type InvalidResponse

type InvalidResponse struct {
	Err      string `json:"error"`
	Response []byte `json:"response"`
}

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 Log

type Log struct {
	Address AccountAddress
	Data    LogData
}

type LogData

type LogData struct {
	Topics []U256
	Data   []byte
}

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 Output

type Output struct {
	DeployedAddress [20]byte
	Output          []byte
}

type OutputType

type OutputType uint8

type Result

type Result interface{}

type ResultId

type ResultId uint8
const (
	SuccessId ResultId = iota
	RevertId
	HaltId
	ErrorId
)

type Revert

type Revert struct {
	GasUsed uint64
	Output  []byte
}

Revert variant of ExecutionResult

type Success

type Success struct {
	Reason      string
	GasUsed     uint64
	GasRefunded uint64
	Logs        []Log
	Output      Output
}

Success variant of ExecutionResult

type SuccessReason

type SuccessReason uint
const (
	Stop SuccessReason = iota
	Return
	SelfDestruct
	EofReturnContract
)

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 AccountAddress
	/// The gas limit of the transaction.
	GasLimit uint64
	/// The gas price of the transaction.
	GasPrice U256
	/// The destination of the transaction.
	TransactTo AccountAddress
	/// The value sent to `transact_to`.
	Value U256

	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 U256
}

type U256

type U256 [32]byte

func NewU256

func NewU256(b *big.Int) U256

func (U256) String

func (u U256) String() string

type Unknown

type Unknown struct{}

func (Unknown) Error

func (e Unknown) Error() string

type UnsupportedRequest

type UnsupportedRequest struct {
	Kind string `json:"kind,omitempty"`
}

func (UnsupportedRequest) Error

func (e UnsupportedRequest) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL