keeper

package
v1.5.33 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WASMDIR     = "/wasm/"
	AddressSize = 20
)
View Source
const (
	EventAttrValueTypeInt64  = 0
	EventAttrValueTypeString = 1
)
View Source
const (
	InputDataTypeParam          = 0
	InputDataTypeContractResult = 1
)
View Source
const CAN_MIGRATE string = "canMigrate"
View Source
const CAN_MIGRATE_RESULT string = "true"
View Source
const INIT string = "init"
View Source
const INVOKE string = "invoke"
View Source
const (
	InstantiateFuncName = "init"
)
View Source
const UINT_MAX uint64 = ^uint64(0)

Variables

This section is empty.

Functions

func AssertValidKey

func AssertValidKey(key []byte)

Check if the key is valid(key is not nil)

func AssertValidValue

func AssertValidValue(value []byte)

Check if the value is valid(value is not nil)

func EndKey

func EndKey(startKey []byte) (endKey []byte)

func FileExist

func FileExist(path string) bool

func IsValidaWasmFile

func IsValidaWasmFile(code []byte) error

func IsWasm

func IsWasm(input []byte) bool

IsWasm checks if the file contents are of wasm binary

func MakeCodeHash

func MakeCodeHash(code []byte) []byte

func NewHandler

func NewHandler(k *Keeper) sdk.Handler

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

func UnCompress

func UnCompress(src []byte) ([]byte, error)

Types

type Address

type Address [AddressSize]byte

func NewAddress

func NewAddress(raw []byte) (addr Address)

func (*Address) ToString

func (addr *Address) ToString() string

type DatabaseIter

type DatabaseIter struct {
	Prefix string
	MockKV [][2]string
	Index  int
}

type Event

type Event struct {
	Type string                 `json:"type"`
	Attr map[string]interface{} `json:"attr"`
}

func NewEventFromSlice

func NewEventFromSlice(raw []byte) (Event, error)

type Generator

type Generator struct {
	Blooms   [ethtypes.BloomBitLength][]byte `json:"blooms"`   // Rotated blooms for per-bit matching
	Sections uint                            `json:"sections"` // Number of sections to batch together

}

Generator takes a number of bloom filters and generates the rotated bloom bits to be used for batched filtering.

func NewGenerator

func NewGenerator(sections uint) (*Generator, error)

NewGenerator creates a rotated bloom generator that can iteratively fill a batched bloom filter's bits.

func (*Generator) AddBloom

func (b *Generator) AddBloom(index uint, bloom ethtypes.Bloom) error

AddBloom takes a single bloom filter and sets the corresponding bit column in memory accordingly.

func (*Generator) Bitset

func (b *Generator) Bitset(idx uint) ([]byte, error)

Bitset returns the bit vector belonging to the given bit index after all blooms have been added.

type Keeper

type Keeper struct {
	AccountKeeper account.AccountKeeper
	StakingKeeper keeper2.StakingKeeper
	// Ethermint concrete implementation on the EVM StateDB interface
	CommitStateDB *evmtypes.CommitStateDB
	// Transaction counter in a block. Used on StateSB's Prepare function.
	// It is reset to 0 every block on BeginBlock so there's no point in storing the counter
	// on the KVStore or adding it as a field on the EVM genesis state.
	TxCount int
	Bloom   *big.Int
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, homeDir string, wasmConfig types.WasmConfig, paramSpace params.Subspace, accountKeeper account.AccountKeeper, stakingKeeper keeper2.StakingKeeper, cdb dbm.DB) Keeper

func (*Keeper) AddBalance

func (k *Keeper) AddBalance(ctx sdk.Context, addr ethcmn.Address, amount *big.Int)

AddBalance calls CommitStateDB.AddBalance using the passed in context

func (*Keeper) AddLog

func (k *Keeper) AddLog(ctx sdk.Context, log *ethtypes.Log)

AddLog calls CommitStateDB.AddLog using the passed in context

func (*Keeper) AddPreimage

func (k *Keeper) AddPreimage(ctx sdk.Context, hash ethcmn.Hash, preimage []byte)

AddPreimage calls CommitStateDB.AddPreimage using the passed in context

func (*Keeper) AddRefund

func (k *Keeper) AddRefund(ctx sdk.Context, gas uint64)

AddRefund calls CommitStateDB.AddRefund using the passed in context

func (*Keeper) AllLogs

func (k *Keeper) AllLogs(ctx sdk.Context) []*ethtypes.Log

AllLogs calls CommitStateDB.AllLogs using the passed in context

func (*Keeper) BeginBlock

func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock)

BeginBlock sets the block hash -> block height map for the previous block height and resets the Bloom filter and the transaction count to 0.

func (*Keeper) BlockHash

func (k *Keeper) BlockHash(ctx sdk.Context) ethcmn.Hash

BlockHash calls CommitStateDB.BlockHash using the passed in context

func (*Keeper) ClearStateObjects

func (k *Keeper) ClearStateObjects(ctx sdk.Context)

ClearStateObjects calls CommitStateDB.ClearStateObjects using the passed in context

func (*Keeper) Commit

func (k *Keeper) Commit(ctx sdk.Context, deleteEmptyObjects bool) (root ethcmn.Hash, err error)

Commit calls CommitStateDB.Commit using the passed in context

func (*Keeper) Copy

func (k *Keeper) Copy(ctx sdk.Context) ethvm.StateDB

Copy calls CommitStateDB.Copy using the passed in context

func (*Keeper) CreateAccount

func (k *Keeper) CreateAccount(ctx sdk.Context, addr ethcmn.Address)

CreateAccount calls CommitStateDB.CreateAccount using the passed in context

func (*Keeper) Database

func (k *Keeper) Database(ctx sdk.Context) ethstate.Database

Database calls CommitStateDB.Database using the passed in context

func (*Keeper) DeleteLogs

func (k *Keeper) DeleteLogs(ctx sdk.Context, hash ethcmn.Hash)

DeleteLogs calls CommitStateDB.DeleteLogs using the passed in context

func (*Keeper) Empty

func (k *Keeper) Empty(ctx sdk.Context, addr ethcmn.Address) bool

Empty calls CommitStateDB.Empty using the passed in context

func (*Keeper) EndBlock

func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate

EndBlock updates the accounts and commits state objects to the KV Store, while deleting the empty ones. It also sets the bloom filers for the request block to the store. The EVM end block loginc doesn't update the validator set, thus it returns an empty slice.

func (*Keeper) Error

func (k *Keeper) Error(ctx sdk.Context) error

Error calls CommitStateDB.Error using the passed in context

func (*Keeper) Execute

func (k *Keeper) Execute(ctx sdk.Context, contractAddress sdk.AccAddress, invoker sdk.AccAddress, args utils.WasmInput, gasWanted uint64) (sdk.Result, error)

func (*Keeper) Exist

func (k *Keeper) Exist(ctx sdk.Context, addr ethcmn.Address) bool

Exist calls CommitStateDB.Exist using the passed in context

func (*Keeper) Finalise

func (k *Keeper) Finalise(ctx sdk.Context, deleteEmptyObjects bool) error

Finalise calls CommitStateDB.Finalise using the passed in context

func (*Keeper) ForEachStorage

func (k *Keeper) ForEachStorage(ctx sdk.Context, addr ethcmn.Address, cb func(key, value ethcmn.Hash) bool) error

ForEachStorage calls CommitStateDB.ForEachStorage using passed in context

func (*Keeper) GetAccountStorage

func (k *Keeper) GetAccountStorage(ctx sdk.Context, address common.Address) (evmtypes.Storage, error)

GetAccountStorage return state storage associated with an account

func (*Keeper) GetAllTxLogs

func (k *Keeper) GetAllTxLogs(ctx sdk.Context) []evmtypes.TransactionLogs

GetAllTxLogs return all the transaction logs from the store.

func (*Keeper) GetBalance

func (k *Keeper) GetBalance(ctx sdk.Context, addr ethcmn.Address) *big.Int

GetBalance calls CommitStateDB.GetBalance using the passed in context

func (*Keeper) GetBlockBloom

func (k *Keeper) GetBlockBloom(ctx sdk.Context, height int64) (ethtypes.Bloom, bool)

GetBlockBloom gets bloombits from block height

func (*Keeper) GetBlockHash

func (k *Keeper) GetBlockHash(ctx sdk.Context, hash []byte) (int64, bool)

GetBlockHash gets block height from block consensus hash

func (*Keeper) GetChainConfig

func (k *Keeper) GetChainConfig(ctx sdk.Context) (evmtypes.ChainConfig, bool)

GetChainConfig gets block height from block consensus hash

func (*Keeper) GetCode

func (k *Keeper) GetCode(ctx sdk.Context, addr ethcmn.Address) []byte

GetCode calls CommitStateDB.GetCode using the passed in context

func (*Keeper) GetCodeHash

func (k *Keeper) GetCodeHash(ctx sdk.Context, addr ethcmn.Address) ethcmn.Hash

GetCodeHash calls CommitStateDB.GetCodeHash using the passed in context

func (Keeper) GetCodeInfo

func (k Keeper) GetCodeInfo(ctx sdk.Context, codeHash []byte) *types.CodeInfo

func (*Keeper) GetCodeSize

func (k *Keeper) GetCodeSize(ctx sdk.Context, addr ethcmn.Address) int

GetCodeSize calls CommitStateDB.GetCodeSize using the passed in context

func (*Keeper) GetCommittedState

func (k *Keeper) GetCommittedState(ctx sdk.Context, addr ethcmn.Address, hash ethcmn.Hash) ethcmn.Hash

GetCommittedState calls CommitStateDB.GetCommittedState using the passed in context

func (Keeper) GetContractInfo

func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) *types.ContractInfo

func (Keeper) GetCreator

func (k Keeper) GetCreator(ctx sdk.Context, contractAddress sdk.AccAddress) sdk.AccAddress

func (*Keeper) GetLogs

func (k *Keeper) GetLogs(ctx sdk.Context, hash ethcmn.Hash) ([]*ethtypes.Log, error)

GetLogs calls CommitStateDB.GetLogs using the passed in context

func (*Keeper) GetNonce

func (k *Keeper) GetNonce(ctx sdk.Context, addr ethcmn.Address) uint64

GetNonce calls CommitStateDB.GetNonce using the passed in context

func (*Keeper) GetOrNewStateObject

func (k *Keeper) GetOrNewStateObject(ctx sdk.Context, addr ethcmn.Address) evmtypes.StateObject

GetOrNewStateObject calls CommitStateDB.GetOrNetStateObject using the passed in context

func (*Keeper) GetParams

func (k *Keeper) GetParams(ctx sdk.Context) (params evmtypes.Params)

GetParams returns the total set of evm parameters.

func (*Keeper) GetRefund

func (k *Keeper) GetRefund(ctx sdk.Context) uint64

GetRefund calls CommitStateDB.GetRefund using the passed in context

func (*Keeper) GetSectionBloom

func (k *Keeper) GetSectionBloom(ctx sdk.Context, index int64) (*Generator, bool)

func (*Keeper) GetState

func (k *Keeper) GetState(ctx sdk.Context, addr ethcmn.Address, hash ethcmn.Hash) ethcmn.Hash

GetState calls CommitStateDB.GetState using the passed in context

func (Keeper) GetStoreKey added in v1.5.25

func (k Keeper) GetStoreKey() sdk.StoreKey

func (*Keeper) HasSuicided

func (k *Keeper) HasSuicided(ctx sdk.Context, addr ethcmn.Address) bool

HasSuicided calls CommitStateDB.HasSuicided using the passed in context

func (*Keeper) Instantiate

func (k *Keeper) Instantiate(ctx sdk.Context, codeHash []byte, invoker sdk.AccAddress, args utils.WasmInput, name, version, author, email, describe string, genesisContractAddress sdk.AccAddress, gasWanted uint64) (sdk.AccAddress, error)

func (*Keeper) IntermediateRoot

func (k *Keeper) IntermediateRoot(ctx sdk.Context, deleteEmptyObjects bool) error

IntermediateRoot calls CommitStateDB.IntermediateRoot using the passed in context

func (*Keeper) Logger

func (k *Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (*Keeper) Migrate

func (k *Keeper) Migrate(ctx sdk.Context, codeHash []byte, invoker sdk.AccAddress, oldContract sdk.AccAddress, args utils.WasmInput, name, version, author, email, describe string, gasWanted uint64) (sdk.AccAddress, error)

func (*Keeper) Preimages

func (k *Keeper) Preimages(ctx sdk.Context) map[ethcmn.Hash][]byte

Preimages calls CommitStateDB.Preimages using the passed in context

func (*Keeper) Prepare

func (k *Keeper) Prepare(ctx sdk.Context, thash, bhash ethcmn.Hash, txi int)

Prepare calls CommitStateDB.Prepare using the passed in context

func (Keeper) Query

func (k Keeper) Query(ctx sdk.Context, contractAddress, invoker sdk.AccAddress, args utils.WasmInput) (types.ContractState, error)

queryContract

func (*Keeper) RecordSection

func (k *Keeper) RecordSection(ctx sdk.Context, height int64, bloom ethtypes.Bloom)

func (*Keeper) Reset

func (k *Keeper) Reset(ctx sdk.Context, root ethcmn.Hash) error

Reset calls CommitStateDB.Reset using the passed in context

func (*Keeper) RevertToSnapshot

func (k *Keeper) RevertToSnapshot(ctx sdk.Context, revID int)

RevertToSnapshot calls CommitStateDB.RevertToSnapshot using the passed in context

func (*Keeper) SetBalance

func (k *Keeper) SetBalance(ctx sdk.Context, addr ethcmn.Address, amount *big.Int)

SetBalance calls CommitStateDB.SetBalance using the passed in context

func (*Keeper) SetBlockBloom

func (k *Keeper) SetBlockBloom(ctx sdk.Context, height int64, bloom ethtypes.Bloom)

SetBlockBloom sets the mapping from block height to bloom bits

func (*Keeper) SetBlockHash

func (k *Keeper) SetBlockHash(ctx sdk.Context, hash []byte, height int64)

SetBlockHash sets the mapping from block consensus hash to block height

func (*Keeper) SetChainConfig

func (k *Keeper) SetChainConfig(ctx sdk.Context, config evmtypes.ChainConfig)

SetChainConfig sets the mapping from block consensus hash to block height

func (*Keeper) SetCode

func (k *Keeper) SetCode(ctx sdk.Context, addr ethcmn.Address, code []byte)

SetCode calls CommitStateDB.SetCode using the passed in context

func (Keeper) SetContractInfo

func (k Keeper) SetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress, contract types.ContractInfo)

func (*Keeper) SetLogs

func (k *Keeper) SetLogs(ctx sdk.Context, hash ethcmn.Hash, logs []*ethtypes.Log) error

SetLogs calls CommitStateDB.SetLogs using the passed in context

func (*Keeper) SetNonce

func (k *Keeper) SetNonce(ctx sdk.Context, addr ethcmn.Address, nonce uint64)

SetNonce calls CommitStateDB.SetNonce using the passed in context

func (*Keeper) SetParams

func (k *Keeper) SetParams(ctx sdk.Context, params evmtypes.Params)

SetParams sets the evm parameters to the param space.

func (*Keeper) SetSectionBloom

func (k *Keeper) SetSectionBloom(ctx sdk.Context, index int64, gen *Generator)

func (*Keeper) SetState

func (k *Keeper) SetState(ctx sdk.Context, addr ethcmn.Address, key, value ethcmn.Hash)

SetState calls CommitStateDB.SetState using the passed in context

func (*Keeper) Snapshot

func (k *Keeper) Snapshot(ctx sdk.Context) int

Snapshot calls CommitStateDB.Snapshot using the passed in context

func (*Keeper) StorageTrie

func (k *Keeper) StorageTrie(ctx sdk.Context, addr ethcmn.Address) ethstate.Trie

StorageTrie calls CommitStateDB.StorageTrie using the passed in context

func (*Keeper) SubBalance

func (k *Keeper) SubBalance(ctx sdk.Context, addr ethcmn.Address, amount *big.Int)

SubBalance calls CommitStateDB.SubBalance using the passed in context

func (*Keeper) SubRefund

func (k *Keeper) SubRefund(ctx sdk.Context, gas uint64)

SubRefund calls CommitStateDB.SubRefund using the passed in context

func (*Keeper) Suicide

func (k *Keeper) Suicide(ctx sdk.Context, addr ethcmn.Address) bool

Suicide calls CommitStateDB.Suicide using the passed in context

func (*Keeper) TxIndex

func (k *Keeper) TxIndex(ctx sdk.Context) int

TxIndex calls CommitStateDB.TxIndex using the passed in context

func (*Keeper) UpdateAccounts

func (k *Keeper) UpdateAccounts(ctx sdk.Context)

UpdateAccounts calls CommitStateDB.UpdateAccounts using the passed in context

func (*Keeper) Upload

func (k *Keeper) Upload(ctx sdk.Context, wasmCode []byte, creator sdk.AccAddress) (codeHash []byte, err error)

type QueryETHLogs

type QueryETHLogs struct {
	Logs []*ethtypes.Log `json:"logs"`
}

QueryETHLogs is response type for tx logs query

type QueryResBlockNumber

type QueryResBlockNumber struct {
	Number int64 `json:"blockNumber"`
}

QueryResBlockNumber is response type for block number query

type Sink

type Sink struct {
	// contains filtered or unexported fields
}

func NewSink

func NewSink(raw []byte) Sink

func (Sink) Bytes

func (sink Sink) Bytes() []byte

func (Sink) ReadBool

func (sink Sink) ReadBool() (bool, error)

func (Sink) ReadByte

func (sink Sink) ReadByte() (byte, error)

func (Sink) ReadBytes

func (sink Sink) ReadBytes() ([]byte, int, error)

func (Sink) ReadI64

func (sink Sink) ReadI64() (result int64, err error)

func (Sink) ReadString

func (sink Sink) ReadString() (string, error)

func (Sink) ReadU32

func (sink Sink) ReadU32() (result uint32, err error)

func (Sink) WriteAddress

func (sink Sink) WriteAddress(addr Address)

func (Sink) WriteBytes

func (sink Sink) WriteBytes(b []byte)

func (Sink) WriteI32

func (sink Sink) WriteI32(i int32)

func (Sink) WriteI64

func (sink Sink) WriteI64(i int64)

func (Sink) WriteString

func (sink Sink) WriteString(s string)

func (Sink) WriteU128

func (sink Sink) WriteU128(u *types.RustU128)

func (Sink) WriteU32

func (sink Sink) WriteU32(i uint32)

func (Sink) WriteU64

func (sink Sink) WriteU64(i uint64)

type SortMap

type SortMap struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type SortMaps

type SortMaps []SortMap

A slice of Pairs that implements sort.Interface to sort by Value.

func (SortMaps) Len

func (s SortMaps) Len() int

func (SortMaps) Less

func (s SortMaps) Less(i, j int) bool

func (SortMaps) Swap

func (s SortMaps) Swap(i, j int)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(parent types.KVStore, prefix []byte) Store

func (Store) Delete

func (s Store) Delete(key []byte)

Implements KVStore

func (Store) Get

func (s Store) Get(key []byte) []byte

Implements KVStore

func (Store) Has

func (s Store) Has(key []byte) bool

Implements KVStore

func (Store) Set

func (s Store) Set(key, value []byte)

Implements KVStore

type VMRes

type VMRes struct {
	// contains filtered or unexported fields
}

type Wasmer

type Wasmer struct {
	FilePathMap map[string]string `json:"file_path_map"`
	SortMaps    SortMaps          `json:"sort_maps"`
	LastFileID  int               `json:"last_file_id"`
}

func NewWasmer

func NewWasmer(homeDir string, _ types.WasmConfig) (*Wasmer, error)

func (*Wasmer) Create

func (w *Wasmer) Create(homeDir, codeHash string) (Wasmer, error)

func (*Wasmer) DeleteCode

func (w *Wasmer) DeleteCode(homeDir string, hash []byte) error

func (*Wasmer) GetWasmCode

func (w *Wasmer) GetWasmCode(homeDir string, hash []byte) ([]byte, error)

type WasmerContext

type WasmerContext struct {
	*wasmer.Instance
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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