types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeEthereumTx = types.TypeMsgEthereumTx
	EventTypeBlockBloom = "block_bloom"
	EventTypeTxLog      = "tx_log"

	AttributeKeyContractAddress = "contract"
	AttributeKeyRecipient       = "recipient"
	AttributeKeyTxHash          = "txHash"
	AttributeKeyEthereumTxHash  = "ethereumTxHash"
	AttributeKeyTxIndex         = "txIndex"
	AttributeKeyTxGasUsed       = "txGasUsed"
	AttributeKeyTxType          = "txType"
	AttributeKeyTxLog           = "txLog"
	// tx failed in eth vm execution
	AttributeKeyEthereumTxFailed = "ethereumTxFailed"
	AttributeValueCategory       = ModuleName
	AttributeKeyEthereumBloom    = "bloom"

	MetricKeyTransitionDB = "transition_db"
	MetricKeyStaticCall   = "static_call"
)

Evm module events

View Source
const (
	// ModuleName string name of module
	ModuleName = "evm"

	// StoreKey key for ethereum storage data, account code (StateDB) or block
	// related data for Web3.
	// The EVM module should use a prefix store.
	StoreKey = ModuleName

	// TransientKey is the key to access the EVM transient store, that is reset
	// during the Commit phase.
	TransientKey = "transient_" + ModuleName

	// RouterKey uses module name for routing
	RouterKey = ModuleName
)
View Source
const (
	TracerAccessList = "access_list"
	TracerJSON       = "json"
	TracerStruct     = "struct"
	TracerMarkdown   = "markdown"
)

Variables

View Source
var (
	KeyPrefixCode    = []byte{prefixCode}
	KeyPrefixStorage = []byte{prefixStorage}
)

KVStore key prefixes

View Source
var (
	KeyPrefixTransientBloom   = []byte{prefixTransientBloom}
	KeyPrefixTransientTxIndex = []byte{prefixTransientTxIndex}
	KeyPrefixTransientLogSize = []byte{prefixTransientLogSize}
	KeyPrefixTransientGasUsed = []byte{prefixTransientGasUsed}
)

Transient Store key prefixes

View Source
var (
	// DefaultEVMDenom defines the default EVM denomination on Ethermint
	DefaultEVMDenom = maratypes.AttoMara
	// DefaultMinGasMultiplier is 0.5 or 50%
	DefaultMinGasMultiplier = sdk.NewDecWithPrec(50, 2)
	// DefaultAllowUnprotectedTxs rejects all unprotected txs (i.e false)
	DefaultAllowUnprotectedTxs = false
)
View Source
var (
	ParamStoreKeyEVMDenom            = []byte("EVMDenom")
	ParamStoreKeyEnableCreate        = []byte("EnableCreate")
	ParamStoreKeyEnableCall          = []byte("EnableCall")
	ParamStoreKeyExtraEIPs           = []byte("EnableExtraEIPs")
	ParamStoreKeyChainConfig         = []byte("ChainConfig")
	ParamStoreKeyAllowUnprotectedTxs = []byte("AllowUnprotectedTxs")

	// AvailableExtraEIPs define the list of all EIPs that can be enabled by the
	// EVM interpreter. These EIPs are applied in order and can override the
	// instruction sets from the latest hard fork enabled by the ChainConfig. For
	// more info check:
	// https://github.com/ethereum/go-ethereum/blob/master/core/vm/interpreter.go#L97
	AvailableExtraEIPs = []int64{1344, 1884, 2200, 2929, 3198, 3529}
)

Parameter keys

View Source
var EmptyCodeHash = crypto.Keccak256(nil)

Functions

func AddressStoragePrefix

func AddressStoragePrefix(address common.Address) []byte

AddressStoragePrefix returns a prefix to iterate over a given account storage.

func BinSearch

func BinSearch(lo, hi uint64, executable func(uint64) (bool, *types.MsgEthereumTxResponse, error)) (uint64, error)

BinSearch execute the binary search and hone in on an executable gas limit

func DecodeTransactionLogs

func DecodeTransactionLogs(data []byte) (types.TransactionLogs, error)

DecodeTxResponse decodes an protobuf-encoded byte slice into TransactionLogs

func DecodeTxResponse

func DecodeTxResponse(in []byte) (*types.MsgEthereumTxResponse, error)

DecodeTxResponse decodes an protobuf-encoded byte slice into TxResponse

func DefaultGenesisState

func DefaultGenesisState() *types.GenesisState

DefaultGenesisState sets default evm genesis state with empty accounts and default params and chain config values.

func DefaultParams

func DefaultParams() types.Params

DefaultParams returns default evm parameters ExtraEIPs is empty to prevent overriding the latest hard fork instruction set

func EncodeTransactionLogs

func EncodeTransactionLogs(res *types.TransactionLogs) ([]byte, error)

EncodeTransactionLogs encodes TransactionLogs slice into a protobuf-encoded byte slice.

func IsLondon

func IsLondon(ethConfig *params.ChainConfig, height int64) bool

IsLondon returns if london hardfork is enabled.

func NewParams

func NewParams(evmDenom string, enableCreate, enableCall bool, config types.ChainConfig, extraEIPs ...int64) types.Params

NewParams creates a new types.Params instance

func NewTracer

func NewTracer(tracer string, msg core.Message, cfg *params.ChainConfig, height int64) vm.EVMLogger

NewTracer creates a new Logger tracer to collect execution traces from an EVM transaction.

func ParamKeyTable

func ParamKeyTable() paramtypes.KeyTable

ParamKeyTable returns the parameter key table.

func StateKey

func StateKey(address common.Address, key []byte) []byte

StateKey defines the full key under which an account state is stored.

func UnwrapEthereumMsg

func UnwrapEthereumMsg(tx *sdk.Tx, ethHash common.Hash) (*types.MsgEthereumTx, error)

UnwrapEthereumMsg extract MsgEthereumTx from wrapping sdk.Tx

Types

type AccountKeeper

type AccountKeeper interface {
	NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
	GetModuleAddress(moduleName string) sdk.AccAddress
	GetAllAccounts(ctx sdk.Context) (accounts []authtypes.AccountI)
	IterateAccounts(ctx sdk.Context, cb func(account authtypes.AccountI) bool)
	GetSequence(sdk.Context, sdk.AccAddress) (uint64, error)
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
	SetAccount(ctx sdk.Context, account authtypes.AccountI)
	RemoveAccount(ctx sdk.Context, account authtypes.AccountI)
	GetParams(ctx sdk.Context) (params authtypes.Params)
}

AccountKeeper defines the expected account keeper interface

type BankKeeper

type BankKeeper interface {
	GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	// SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
	BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
}

BankKeeper defines the expected interface needed to retrieve account balances.

type CompiledContract

type CompiledContract struct {
	ABI abi.ABI
	Bin HexString
}

CompiledContract contains compiled bytecode and abi

var (

	// ERC20Contract is the compiled test erc20 contract
	ERC20Contract CompiledContract

	// SimpleStorageContract is the compiled test simple storage contract
	SimpleStorageContract CompiledContract

	// TestMessageCall is the compiled message call benchmark contract
	TestMessageCall CompiledContract
)

func (CompiledContract) MarshalJSON

func (s CompiledContract) MarshalJSON() ([]byte, error)

MarshalJSON serializes ByteArray to hex

func (*CompiledContract) UnmarshalJSON

func (s *CompiledContract) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes ByteArray to hex

type EVMConfig

type EVMConfig struct {
	Params      types.Params
	ChainConfig *params.ChainConfig
	CoinBase    common.Address
	BaseFee     *big.Int
}

EVMConfig encapsulates common parameters needed to create an EVM to execute a message It's mainly to reduce the number of method parameters

type EvmHooks

type EvmHooks interface {
	// Must be called after tx is processed successfully, if return an error, the whole transaction is reverted.
	PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error
}

EvmHooks event hooks for evm tx processing

type FeeMarketKeeper

type FeeMarketKeeper interface {
	GetBaseFee(ctx sdk.Context) *big.Int
	GetParams(ctx sdk.Context) feemarkettypes.Params
	AddTransientGasWanted(ctx sdk.Context, gasWanted uint64) (uint64, error)
}

FeeMarketKeeper

type HexString

type HexString []byte

HexString is a byte array that serializes to hex

func (HexString) MarshalJSON

func (s HexString) MarshalJSON() ([]byte, error)

MarshalJSON serializes ByteArray to hex

func (*HexString) UnmarshalJSON

func (s *HexString) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes ByteArray to hex

type NoOpTracer

type NoOpTracer struct{}

NoOpTracer is an empty implementation of vm.Tracer interface

func NewNoOpTracer

func NewNoOpTracer() *NoOpTracer

NewNoOpTracer creates a no-op vm.Tracer

func (NoOpTracer) CaptureEnd

func (dt NoOpTracer) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error)

CaptureEnd implements vm.Tracer interface

func (NoOpTracer) CaptureEnter

func (dt NoOpTracer) CaptureEnter(typ vm.OpCode, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int)

CaptureEnter implements vm.Tracer interface

func (NoOpTracer) CaptureExit

func (dt NoOpTracer) CaptureExit(output []byte, gasUsed uint64, err error)

CaptureExit implements vm.Tracer interface

func (NoOpTracer) CaptureFault

func (dt NoOpTracer) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error)

CaptureFault implements vm.Tracer interface

func (NoOpTracer) CaptureStart

func (dt NoOpTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int)

CaptureStart implements vm.Tracer interface

func (NoOpTracer) CaptureState

func (dt NoOpTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error)

CaptureState implements vm.Tracer interface

func (NoOpTracer) CaptureTxEnd

func (dt NoOpTracer) CaptureTxEnd(restGas uint64)

CaptureTxEnd implements vm.Tracer interface

func (NoOpTracer) CaptureTxStart

func (dt NoOpTracer) CaptureTxStart(gasLimit uint64)

CaptureTxStart implements vm.Tracer interface

type StakingKeeper

type StakingKeeper interface {
	GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
	GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool)
}

StakingKeeper returns the historical headers kept in store.

type TransactionArgs

type TransactionArgs struct {
	From                 *common.Address `json:"from"`
	To                   *common.Address `json:"to"`
	Gas                  *hexutil.Uint64 `json:"gas"`
	GasPrice             *hexutil.Big    `json:"gasPrice"`
	MaxFeePerGas         *hexutil.Big    `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big    `json:"maxPriorityFeePerGas"`
	Value                *hexutil.Big    `json:"value"`
	Nonce                *hexutil.Uint64 `json:"nonce"`

	// We accept "data" and "input" for backwards-compatibility reasons.
	// "input" is the newer name and should be preferred by clients.
	// Issue detail: https://github.com/ethereum/go-ethereum/issues/15628
	Data  *hexutil.Bytes `json:"data"`
	Input *hexutil.Bytes `json:"input"`

	// Introduced by AccessListTxType transaction.
	AccessList *ethtypes.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big         `json:"chainId,omitempty"`
}

TransactionArgs represents the arguments to construct a new transaction or a message call using JSON-RPC. Duplicate struct definition since geth struct is in internal package Ref: https://github.com/ethereum/go-ethereum/blob/release/1.10.4/internal/ethapi/transaction_args.go#L36

func (*TransactionArgs) GetData

func (args *TransactionArgs) GetData() []byte

GetData retrieves the transaction calldata. Input field is preferred.

func (*TransactionArgs) GetFrom

func (args *TransactionArgs) GetFrom() common.Address

GetFrom retrieves the transaction sender address.

func (*TransactionArgs) String

func (args *TransactionArgs) String() string

String return the struct in a string format

func (*TransactionArgs) ToMessage

func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (ethtypes.Message, error)

ToMessage converts the arguments to the Message type used by the core evm. This assumes that setTxDefaults has been called.

type TxTraceResult

type TxTraceResult struct {
	Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
	Error  string      `json:"error,omitempty"`  // Trace failure produced by the tracer
}

TxTraceResult is the result of a single transaction trace during a block trace.

Jump to

Keyboard shortcuts

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