mpt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0, Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StoreTypeMPT = types.StoreTypeMPT

	// StoreKey is string representation of the store key for mpt
	StoreKey = "mpt"
)
View Source
const (
	FlagTrieDirtyDisabled = "trie.dirty-disabled"
	FlagTrieCacheSize     = "trie.cache-size"
	FlagTrieNodesLimit    = "trie.nodes-limit"
	FlagTrieImgsLimit     = "trie.imgs-limit"
	FlagTrieInMemory      = "trie.in-memory"

	FlagTrieAsyncDB               = "trie.asyncdb"
	FlagTrieAsyncDBInitCap        = "trie.asyncdb.init-cap"
	FlagTrieAsyncDBAutoPruningOff = "trie.asyncdb.auto-pruning-off"
	FlagTrieAsyncDBSyncPruning    = "trie.asyncdb.sync-pruning"

	FlagTrieEnableSnapshotJournal = "trie.enable-snapshot-journal"
)
View Source
const (
	FlagTrieAccStoreCache = "trie.account-store-cache"

	StorageRootLen = len(ethcmn.Hash{})
)
View Source
const ProofOpMptAbsence = "mpt:a"
View Source
const ProofOpMptValue = "mpt:v"

Variables

View Source
var (
	TrieDirtyDisabled       = false
	TrieCacheSize     uint  = 2048 // MB
	TrieCommitGap     int64 = 100
	TriesInMemory     uint  = 100

	TrieAsyncDB               = true
	TrieAsyncDBInitCap        = 200_0000
	TrieAsyncDBAutoPruningOff = false
	TrieAsyncDBSyncPruning    = false

	EnableAsyncCommit = false
)
View Source
var (
	KeyPrefixAccRootMptHash        = []byte{0x11}
	KeyPrefixAccLatestStoredHeight = []byte{0x12}

	GAccToPrefetchChannel    = make(chan [][]byte, 2000)
	GAccTryUpdateTrieChannel = make(chan struct{})
	GAccTrieUpdatedChannel   = make(chan struct{})
)
View Source
var (
	NilHash = ethcmn.Hash{}

	// EmptyCodeHash is the known hash of an empty code.
	EmptyCodeHash      = crypto.Keccak256Hash(nil)
	EmptyCodeHashBytes = crypto.Keccak256(nil)
)
View Source
var (
	PrefixSizeInMpt = prefixSizeInMpt
)

Functions

func AddressStoragePrefixMpt

func AddressStoragePrefixMpt(address ethcmn.Address, stateRoot ethcmn.Hash) []byte

func AddressStoreKey

func AddressStoreKey(addr []byte) []byte

func DisableSnapshot

func DisableSnapshot()

func GetAddressFromStoragePrefix

func GetAddressFromStoragePrefix(prefix []byte) ethcmn.Address

func GetEthDB

func GetEthDB() ethdb.Database

func GetRawDBDeltaInstance

func GetRawDBDeltaInstance() *rawdbDelta

func HasVersionByDiskDB

func HasVersionByDiskDB(height int64) bool

func InstanceOfMptStore

func InstanceOfMptStore() ethstate.Database

func IsStorageKey

func IsStorageKey(key []byte) bool

IsStorageKey used for wasm contract storage key.

func IsStoragePrefix

func IsStoragePrefix(prefix []byte) bool

func NewStatKeyValueStore

func NewStatKeyValueStore(db ethdb.KeyValueStore, stat *RuntimeState) ethdb.KeyValueStore

func PutStoreKey

func PutStoreKey(key []byte) []byte

func SetApplyDelta

func SetApplyDelta(val bool)

func SetProduceDelta

func SetProduceDelta(val bool)

func SetSnapshotJournal

func SetSnapshotJournal(enable bool)

func SetSnapshotRebuild

func SetSnapshotRebuild(rebuild bool)

func UpdateCommitGapHeight

func UpdateCommitGapHeight(gap int64)

Types

type AsyncKeyValueStore

type AsyncKeyValueStore struct {
	ethdb.KeyValueStore
	// contains filtered or unexported fields
}

func NewAsyncKeyValueStore

func NewAsyncKeyValueStore(db ethdb.KeyValueStore) *AsyncKeyValueStore

func NewAsyncKeyValueStoreWithOptions

func NewAsyncKeyValueStoreWithOptions(db ethdb.KeyValueStore, options AsyncKeyValueStoreOptions) *AsyncKeyValueStore

func (*AsyncKeyValueStore) ActionAfterWriteDone

func (store *AsyncKeyValueStore) ActionAfterWriteDone(act func(), once bool)

func (*AsyncKeyValueStore) Close

func (store *AsyncKeyValueStore) Close() error

func (*AsyncKeyValueStore) Compact

func (store *AsyncKeyValueStore) Compact(start []byte, limit []byte) error

func (*AsyncKeyValueStore) Delete

func (store *AsyncKeyValueStore) Delete(key []byte) error

func (*AsyncKeyValueStore) Get

func (store *AsyncKeyValueStore) Get(key []byte) ([]byte, error)

func (*AsyncKeyValueStore) Has

func (store *AsyncKeyValueStore) Has(key []byte) (bool, error)

func (*AsyncKeyValueStore) LogInfoAfterWriteDone

func (store *AsyncKeyValueStore) LogInfoAfterWriteDone(msg string, args ...interface{})

func (*AsyncKeyValueStore) LogStats

func (store *AsyncKeyValueStore) LogStats()

func (*AsyncKeyValueStore) NewBatch

func (store *AsyncKeyValueStore) NewBatch() ethdb.Batch

func (*AsyncKeyValueStore) NewIterator

func (store *AsyncKeyValueStore) NewIterator(prefix []byte, start []byte) ethdb.Iterator

func (*AsyncKeyValueStore) Prune

func (store *AsyncKeyValueStore) Prune()

func (*AsyncKeyValueStore) Put

func (store *AsyncKeyValueStore) Put(key []byte, value []byte) error

func (*AsyncKeyValueStore) SetLogger

func (store *AsyncKeyValueStore) SetLogger(logger log.Logger)

func (*AsyncKeyValueStore) Stat

func (store *AsyncKeyValueStore) Stat(property string) (string, error)

func (*AsyncKeyValueStore) WaitCurrentWriteDone

func (store *AsyncKeyValueStore) WaitCurrentWriteDone()

type AsyncKeyValueStoreOptions

type AsyncKeyValueStoreOptions struct {
	DisableAutoPrune bool
	SyncPrune        bool
	InitCap          int
}

type Batch

type Batch struct {
	ethdb.Batch
	// contains filtered or unexported fields
}

func (*Batch) Delete

func (s *Batch) Delete(key []byte) error

func (*Batch) Put

func (s *Batch) Put(key []byte, value []byte) error

type EmptyStateRootRetriever

type EmptyStateRootRetriever struct{}

func (EmptyStateRootRetriever) GetAccStateRoot

func (e EmptyStateRootRetriever) GetAccStateRoot(rootBytes []byte) ethcmn.Hash

func (EmptyStateRootRetriever) GetStateRootAndCodeHash

func (e EmptyStateRootRetriever) GetStateRootAndCodeHash(rootBytes []byte) (ethcmn.Hash, []byte)

func (EmptyStateRootRetriever) ModifyAccStateRoot

func (e EmptyStateRootRetriever) ModifyAccStateRoot(before []byte, rootHash ethcmn.Hash) []byte

func (EmptyStateRootRetriever) RetrieveStateRoot

func (e EmptyStateRootRetriever) RetrieveStateRoot([]byte) ethcmn.Hash

type ImmutableMptStore

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

func NewImmutableMptStore

func NewImmutableMptStore(db ethstate.Database, root ethcmn.Hash, brcRpcStateCache map[string][]byte) (*ImmutableMptStore, error)

func NewImmutableMptStoreFromTrie

func NewImmutableMptStoreFromTrie(db ethstate.Database, trie ethstate.Trie) *ImmutableMptStore

func (*ImmutableMptStore) CacheWrap

func (ms *ImmutableMptStore) CacheWrap() types.CacheWrap

func (*ImmutableMptStore) CacheWrapWithTrace

func (ms *ImmutableMptStore) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap

func (*ImmutableMptStore) CleanBrcRpcState

func (ms *ImmutableMptStore) CleanBrcRpcState()

func (*ImmutableMptStore) Delete

func (ms *ImmutableMptStore) Delete(key []byte)

func (*ImmutableMptStore) Get

func (ms *ImmutableMptStore) Get(key []byte) []byte

func (*ImmutableMptStore) GetBrcRpcState

func (ms *ImmutableMptStore) GetBrcRpcState(key []byte) []byte

func (*ImmutableMptStore) GetStoreName

func (ms *ImmutableMptStore) GetStoreName() string

func (*ImmutableMptStore) GetStoreType

func (ms *ImmutableMptStore) GetStoreType() types.StoreType

func (*ImmutableMptStore) Has

func (ms *ImmutableMptStore) Has(key []byte) bool

func (*ImmutableMptStore) Iterator

func (ms *ImmutableMptStore) Iterator(start, end []byte) types.Iterator

func (*ImmutableMptStore) ReverseIterator

func (ms *ImmutableMptStore) ReverseIterator(start, end []byte) types.Iterator

func (*ImmutableMptStore) Set

func (ms *ImmutableMptStore) Set(key []byte, value []byte)

type MptStore

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

MptStore Implements types.KVStore and CommitKVStore. Its main purpose is to own the same interface as iavl store in libs/cosmos-sdk/store/iavl/iavl_store.go

func NewMptStore

func NewMptStore(logger tmlog.Logger, id types.CommitID) (*MptStore, error)

func (*MptStore) CacheWrap

func (ms *MptStore) CacheWrap() types.CacheWrap

func (*MptStore) CacheWrapWithTrace

func (ms *MptStore) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.CacheWrap

func (*MptStore) CleanBrcRpcState

func (ms *MptStore) CleanBrcRpcState()

func (*MptStore) CommitterCommit

func (ms *MptStore) CommitterCommit(inputDelta interface{}) (rootHash types.CommitID, outputDelta interface{})

func (*MptStore) CommitterCommitMap

func (ms *MptStore) CommitterCommitMap(deltaMap iavl.TreeDeltaMap) (_ types.CommitID, _ iavl.TreeDeltaMap)

func (*MptStore) CurrentVersion

func (ms *MptStore) CurrentVersion() int64

func (*MptStore) Delete

func (ms *MptStore) Delete(key []byte)

func (*MptStore) EndTiming

func (ms *MptStore) EndTiming(tag string)

func (*MptStore) Get

func (ms *MptStore) Get(key []byte) []byte

func (*MptStore) GetBrcRpcState

func (ms *MptStore) GetBrcRpcState(key []byte) []byte

func (*MptStore) GetCacheReadCount

func (ms *MptStore) GetCacheReadCount() int

func (*MptStore) GetDBReadCount

func (ms *MptStore) GetDBReadCount() int

func (*MptStore) GetDBReadTime

func (ms *MptStore) GetDBReadTime() int

func (*MptStore) GetDBWriteCount

func (ms *MptStore) GetDBWriteCount() int

func (*MptStore) GetFlatKVReadCount

func (ms *MptStore) GetFlatKVReadCount() int

func (*MptStore) GetFlatKVReadTime

func (ms *MptStore) GetFlatKVReadTime() int

func (*MptStore) GetFlatKVWriteCount

func (ms *MptStore) GetFlatKVWriteCount() int

func (*MptStore) GetFlatKVWriteTime

func (ms *MptStore) GetFlatKVWriteTime() int

func (*MptStore) GetImmutable

func (ms *MptStore) GetImmutable(height int64) (*ImmutableMptStore, error)

func (*MptStore) GetLatestStoredBlockHeight

func (ms *MptStore) GetLatestStoredBlockHeight() uint64

GetLatestStoredBlockHeight get latest mpt storage height

func (*MptStore) GetMptRootHash

func (ms *MptStore) GetMptRootHash(height uint64) ethcmn.Hash

GetMptRootHash gets root mpt hash from block height

func (*MptStore) GetNodeReadCount

func (ms *MptStore) GetNodeReadCount() int

func (*MptStore) GetStoreName

func (ms *MptStore) GetStoreName() string

func (*MptStore) GetStoreType

func (ms *MptStore) GetStoreType() types.StoreType

* implement KVStore

func (*MptStore) Has

func (ms *MptStore) Has(key []byte) bool

func (*MptStore) HasVersion

func (ms *MptStore) HasVersion(height int64) bool

func (*MptStore) Iterator

func (ms *MptStore) Iterator(start, end []byte) types.Iterator

func (*MptStore) LastCommitID

func (ms *MptStore) LastCommitID() types.CommitID

func (*MptStore) LastCommitVersion

func (ms *MptStore) LastCommitVersion() int64

func (*MptStore) OnStop

func (ms *MptStore) OnStop() error

func (*MptStore) PushData2Database

func (ms *MptStore) PushData2Database(curHeight int64)

PushData2Database writes all associated state in cache to the database

func (*MptStore) Query

func (ms *MptStore) Query(req abci.RequestQuery) (res abci.ResponseQuery)

* implement Queryable

func (*MptStore) ResetCount

func (ms *MptStore) ResetCount()

func (*MptStore) ReverseIterator

func (ms *MptStore) ReverseIterator(start, end []byte) types.Iterator

func (*MptStore) Set

func (ms *MptStore) Set(key, value []byte)

func (*MptStore) SetLatestStoredBlockHeight

func (ms *MptStore) SetLatestStoredBlockHeight(height uint64)

SetLatestStoredBlockHeight sets the latest stored storage height

func (*MptStore) SetMptRootHash

func (ms *MptStore) SetMptRootHash(height uint64, hash ethcmn.Hash)

SetMptRootHash sets the mapping from block height to root mpt hash

func (*MptStore) SetPruning

func (ms *MptStore) SetPruning(options types.PruningOptions)

func (*MptStore) SetUpgradeVersion

func (ms *MptStore) SetUpgradeVersion(i int64)

func (*MptStore) SnapshotAccountIterator

func (ms *MptStore) SnapshotAccountIterator(root, seek ethcmn.Hash) (SnapshotAccountIterator, error)

func (*MptStore) SnapshotStorageIterator

func (ms *MptStore) SnapshotStorageIterator(root, account, seek ethcmn.Hash) (SnapshotStorageIterator, error)

func (*MptStore) StartPrefetcher

func (ms *MptStore) StartPrefetcher(namespace string)

func (*MptStore) StartTiming

func (ms *MptStore) StartTiming()

func (*MptStore) StopPrefetcher

func (ms *MptStore) StopPrefetcher()

StopPrefetcher terminates a running prefetcher and reports any leftover stats from the gathered metrics.

func (*MptStore) StopWithVersion

func (ms *MptStore) StopWithVersion(targetVersion int64) error

Stop stops the blockchain service. If any imports are currently in progress it will abort them using the procInterrupt.

type ProofList

type ProofList [][]byte

func (*ProofList) Delete

func (n *ProofList) Delete(key []byte) error

func (*ProofList) Put

func (n *ProofList) Put(key []byte, value []byte) error

type RuntimeState

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

func NewRuntimeState

func NewRuntimeState() *RuntimeState

type SnapshotAccountIterator

type SnapshotAccountIterator interface {
	snapshot.AccountIterator
}

type SnapshotStorageIterator

type SnapshotStorageIterator interface {
	snapshot.StorageIterator
}

type StatKeyValueStore

type StatKeyValueStore struct {
	ethdb.KeyValueStore
	// contains filtered or unexported fields
}

func (*StatKeyValueStore) Delete

func (s *StatKeyValueStore) Delete(key []byte) error

func (*StatKeyValueStore) Get

func (s *StatKeyValueStore) Get(key []byte) ([]byte, error)

func (*StatKeyValueStore) NewBatch

func (s *StatKeyValueStore) NewBatch() ethdb.Batch

func (*StatKeyValueStore) Put

func (s *StatKeyValueStore) Put(key []byte, value []byte) error

type StateRootRetriever

type StateRootRetriever interface {
	RetrieveStateRoot([]byte) ethcmn.Hash
	ModifyAccStateRoot(before []byte, rootHash ethcmn.Hash) []byte
	GetAccStateRoot(rootBytes []byte) ethcmn.Hash
	GetStateRootAndCodeHash([]byte) (ethcmn.Hash, []byte)
}
var (
	AccountStateRootRetriever StateRootRetriever = EmptyStateRootRetriever{}
)

type TriePrefetcher

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

TriePrefetcher is an active prefetcher, which receives accounts or storage items and does trie-loading of them. The goal is to get as much useful content into the caches as possible.

Note, the prefetcher's API is not thread safe.

func NewTriePrefetcher

func NewTriePrefetcher(db ethstate.Database, root common.Hash, namespace string) *TriePrefetcher

NewTriePrefetcher

func (*TriePrefetcher) Close

func (p *TriePrefetcher) Close()

Close iterates over all the subfetchers, aborts any that were left spinning and reports the stats to the metrics subsystem.

func (*TriePrefetcher) Copy

func (p *TriePrefetcher) Copy() *TriePrefetcher

copy creates a deep-but-inactive copy of the trie prefetcher. Any trie data already loaded will be copied over, but no goroutines will be started. This is mostly used in the miner which creates a copy of it's actively mutated state to be sealed while it may further mutate the state.

func (*TriePrefetcher) Prefetch

func (p *TriePrefetcher) Prefetch(root common.Hash, keys [][]byte)

prefetch schedules a batch of trie items to prefetch.

func (*TriePrefetcher) Trie

func (p *TriePrefetcher) Trie(root common.Hash) ethstate.Trie

trie returns the trie matching the root hash, or nil if the prefetcher doesn't have it.

func (*TriePrefetcher) Used

func (p *TriePrefetcher) Used(root common.Hash, used [][]byte)

used marks a batch of state items used to allow creating statistics as to how useful or wasteful the prefetcher is.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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