Documentation
Overview ¶
Package trie implements Merkle Patricia Tries.
Visualisation of Merkle Patricia Tries.
Index ¶
- Constants
- Variables
- func AddrHashFromCodeKey(codeKey []byte) []byte
- func CodeHexFromHex(hex []byte) []byte
- func CodeKeyFromAddrHash(addrHash []byte) []byte
- func CompressNibbles(nibbles []byte, out *[]byte)
- func DecompressNibbles(in []byte, out *[]byte)
- func EncodeAsValue(data []byte) ([]byte, error)
- func FullKeys(t *Trie) []string
- func FullNode1()
- func FullNode2()
- func FullNode3()
- func FullNode4()
- func GenStructStep(retain func(prefix []byte) bool, curr, succ []byte, e structInfoReceiver, ...) ([]uint16, error)
- func Hash1()
- func Hash2()
- func Hash3()
- func Hash4()
- func Hash5()
- func Hash6()
- func Hash7()
- func HashWithModifications(t *Trie, aKeys common.Hashes, aValues []*accounts.Account, aCodes [][]byte, ...) (common.Hash, error)
- func IsPointingToCode(key []byte) bool
- func KeyToQuad(key []byte) []byte
- func NewShortNode(key []byte, value node) *shortNode
- func ShortNode1()
- func ShortNode2()
- func StarkStats(witness *Witness, w io.Writer, trace bool) error
- func StreamHash(it *StreamMergeIterator, storagePrefixLen int, hb *HashBuilder, trace bool) (common.Hash, error)
- func Visual(t *Trie, w io.Writer, opts *VisualOpts)
- type AccountEvicter
- type BinaryTrie
- type BlockWitnessStats
- func (s *BlockWitnessStats) BlockWitnessSize() uint64
- func (s *BlockWitnessStats) CodesSize() uint64
- func (s *BlockWitnessStats) HashesSize() uint64
- func (s *BlockWitnessStats) LeafKeysSize() uint64
- func (s *BlockWitnessStats) LeafValuesSize() uint64
- func (s *BlockWitnessStats) StructureSize() uint64
- type ByteArrayWriter
- type Database
- func (db *Database) Cap(limit common.StorageSize) error
- func (db *Database) Commit(node common.Hash, report bool) error
- func (db *Database) Dereference(root common.Hash)
- func (db *Database) DiskDB() ethdb.Database
- func (db *Database) InsertBlob(hash common.Hash, blob []byte)
- func (db *Database) Nodes() []common.Hash
- func (db *Database) Reference(child common.Hash, parent common.Hash)
- func (db *Database) SaveCache(dir string) error
- func (db *Database) SaveCachePeriodically(dir string, interval time.Duration, stopCh <-chan struct{})
- func (db *Database) Size() (common.StorageSize, common.StorageSize)
- type DatabaseReader
- type DefaultReceiver
- type Eviction
- func (tp *Eviction) BlockNumber() uint64
- func (tp *Eviction) BranchNodeCreated(hex []byte)
- func (tp *Eviction) BranchNodeDeleted(hex []byte)
- func (tp *Eviction) BranchNodeTouched(hex []byte)
- func (tp *Eviction) CodeNodeCreated(hex []byte, size uint)
- func (tp *Eviction) CodeNodeDeleted(hex []byte)
- func (tp *Eviction) CodeNodeSizeChanged(hex []byte, newSize uint)
- func (tp *Eviction) CodeNodeTouched(hex []byte)
- func (tp *Eviction) DebugDump() string
- func (tp *Eviction) EvictToFitSize(evicter AccountEvicter, threshold uint64) bool
- func (tp *Eviction) NumberOf() uint64
- func (tp *Eviction) SetBlockNumber(blockNumber uint64)
- func (tp *Eviction) TotalSize() uint64
- type FilterCursor
- type FlatDBTrieLoader
- type FlatDbSubTrieLoader
- func (fstl *FlatDbSubTrieLoader) AttachRequestedCode(db ethdb.Getter, requests []*LoadRequestForCode) error
- func (fstl *FlatDbSubTrieLoader) LoadSubTries() (SubTries, error)
- func (fstl *FlatDbSubTrieLoader) Reset(db ethdb.Database, rl RetainDecider, receiverDecider RetainDecider, ...) error
- func (fstl *FlatDbSubTrieLoader) SetStreamReceiver(receiver StreamReceiver)
- type GenStructStepAccountData
- type GenStructStepData
- type GenStructStepHashData
- type GenStructStepLeafData
- type HashBuilder
- type HashCollector
- type HashNodeFunc
- type HexStdOutWriter
- type IHCursor
- type Iterator
- type Keybytes
- type LoadFunc
- type LoadRequestForCode
- type MerklePathLimiter
- type MissingNodeError
- type NoopObserver
- func (*NoopObserver) BranchNodeCreated(_ []byte)
- func (*NoopObserver) BranchNodeDeleted(_ []byte)
- func (*NoopObserver) BranchNodeLoaded(_ []byte, _ uint64)
- func (*NoopObserver) BranchNodeTouched(_ []byte)
- func (*NoopObserver) CodeNodeCreated(_ []byte, _ uint)
- func (*NoopObserver) CodeNodeDeleted(_ []byte)
- func (*NoopObserver) CodeNodeSizeChanged(_ []byte, _ uint)
- func (*NoopObserver) CodeNodeTouched(_ []byte)
- func (*NoopObserver) WillUnloadBranchNode(_ []byte, _ common.Hash, _ uint64)
- func (*NoopObserver) WillUnloadNode(_ []byte, _ common.Hash)
- type Observer
- type ObserverMux
- func (mux *ObserverMux) AddChild(child Observer)
- func (mux *ObserverMux) BranchNodeCreated(hex []byte)
- func (mux *ObserverMux) BranchNodeDeleted(hex []byte)
- func (mux *ObserverMux) BranchNodeLoaded(prefixAsNibbles []byte, incarnation uint64)
- func (mux *ObserverMux) BranchNodeTouched(hex []byte)
- func (mux *ObserverMux) CodeNodeCreated(hex []byte, size uint)
- func (mux *ObserverMux) CodeNodeDeleted(hex []byte)
- func (mux *ObserverMux) CodeNodeSizeChanged(hex []byte, newSize uint)
- func (mux *ObserverMux) CodeNodeTouched(hex []byte)
- func (mux *ObserverMux) WillUnloadBranchNode(key []byte, nodeHash common.Hash, incarnation uint64)
- func (mux *ObserverMux) WillUnloadNode(key []byte, nodeHash common.Hash)
- type OperatorBranch
- type OperatorCode
- type OperatorEmptyRoot
- type OperatorExtension
- type OperatorHash
- type OperatorKindCode
- type OperatorLeafAccount
- type OperatorLeafValue
- type OperatorMarshaller
- func (w *OperatorMarshaller) GetStats() *BlockWitnessStats
- func (w *OperatorMarshaller) WithColumn(column StatsColumn) *OperatorMarshaller
- func (w *OperatorMarshaller) Write(p []byte) (int, error)
- func (w *OperatorMarshaller) WriteByteArrayValue(value []byte) error
- func (w *OperatorMarshaller) WriteByteValue(value byte) error
- func (w *OperatorMarshaller) WriteCode(value []byte) error
- func (w *OperatorMarshaller) WriteHash(hash common.Hash) error
- func (w *OperatorMarshaller) WriteKey(keyNibbles []byte) error
- func (w *OperatorMarshaller) WriteOpCode(opcode OperatorKindCode) error
- func (w *OperatorMarshaller) WriteUint64Value(value uint64) error
- type OperatorUnmarshaller
- func (l *OperatorUnmarshaller) ReadByte() (byte, error)
- func (l *OperatorUnmarshaller) ReadByteArray() ([]byte, error)
- func (l *OperatorUnmarshaller) ReadHash() (common.Hash, error)
- func (l *OperatorUnmarshaller) ReadKey() ([]byte, error)
- func (l *OperatorUnmarshaller) ReadUInt64() (uint64, error)
- func (l *OperatorUnmarshaller) ReadUint32() (uint32, error)
- type RetainAll
- type RetainDecider
- type RetainLevels
- type RetainList
- func (rl *RetainList) AddCodeTouch(codeHash common.Hash)
- func (rl *RetainList) AddHex(hex []byte)
- func (rl *RetainList) AddKey(key []byte)
- func (rl *RetainList) IsCodeTouched(codeHash common.Hash) bool
- func (rl *RetainList) Retain(prefix []byte) bool
- func (rl *RetainList) Rewind()
- func (rl *RetainList) String() string
- type RetainListBuilder
- func (rlb *RetainListBuilder) AddStorageTouch(touch []byte)
- func (rlb *RetainListBuilder) AddTouch(touch []byte)
- func (rlb *RetainListBuilder) Build(isBinary bool) *RetainList
- func (rlb *RetainListBuilder) CreateCode(codeHash common.Hash)
- func (rlb *RetainListBuilder) ExtractTouches() ([][]byte, [][]byte)
- func (rlb *RetainListBuilder) ReadCode(codeHash common.Hash)
- type RetainRange
- type RootHashAggregator
- func (r *RootHashAggregator) Receive(itemType StreamItem, accountKey []byte, storageKey []byte, ...) error
- func (r *RootHashAggregator) Reset(hc HashCollector, trace bool)
- func (r *RootHashAggregator) Result() SubTries
- func (r *RootHashAggregator) RetainNothing(prefix []byte) bool
- func (r *RootHashAggregator) Root() common.Hash
- type StarkStatsBuilder
- type StatsColumn
- type Stream
- type StreamItem
- type StreamIterator
- type StreamMergeIterator
- type StreamReceiver
- type SubTrieLoader
- func (stl *SubTrieLoader) AddCodeRequest(req *LoadRequestForCode)
- func (stl *SubTrieLoader) LoadFromFlatDB(db ethdb.Database, rl RetainDecider, hc HashCollector, dbPrefixes [][]byte, ...) (SubTries, error)
- func (stl *SubTrieLoader) LoadFromWitnessDb(db WitnessStorage, blockNr uint64, trieLimit uint32, startPos int64, count int) (SubTries, int64, error)
- func (stl *SubTrieLoader) LoadSubTries(db ethdb.Database, blockNr uint64, rl RetainDecider, hc HashCollector, ...) (SubTries, error)
- func (stl *SubTrieLoader) Reset(blockNr uint64)
- type SubTries
- type Trie
- func (t *Trie) AddObserver(observer Observer)
- func (t *Trie) DeepHash(keyPrefix []byte) (bool, common.Hash)
- func (t *Trie) Delete(key []byte)
- func (t *Trie) DeleteSubtree(keyPrefix []byte)
- func (t *Trie) EvictNode(hex []byte)
- func (t *Trie) ExtractWitness(trace bool, rl RetainDecider) (*Witness, error)
- func (t *Trie) ExtractWitnessForPrefix(prefix []byte, trace bool, rl RetainDecider) (*Witness, error)
- func (t *Trie) FindSubTriesToLoad(rl RetainDecider) (prefixes [][]byte, fixedbits []int, hooks [][]byte)
- func (t *Trie) Fold(keys [][]byte)
- func (t *Trie) Get(key []byte) (value []byte, gotValue bool)
- func (t *Trie) GetAccount(key []byte) (value *accounts.Account, gotValue bool)
- func (t *Trie) GetAccountCode(key []byte) (value []byte, gotValue bool)
- func (t *Trie) GetAccountCodeSize(key []byte) (value int, gotValue bool)
- func (t *Trie) GetNodeByHash(hash common.Hash) []byte
- func (t *Trie) Hash() common.Hash
- func (t *Trie) HashMapSize() int
- func (t *Trie) HashOfHexKey(hexKey []byte) (common.Hash, error)
- func (t *Trie) HookSubTries(subTries SubTries, hooks [][]byte) error
- func (t *Trie) NeedLoadCode(addrHash common.Hash, codeHash common.Hash, bytecode bool) (bool, *LoadRequestForCode)
- func (t *Trie) NewLoadRequestForCode(addrHash common.Hash, codeHash common.Hash, bytecode bool) *LoadRequestForCode
- func (t *Trie) NumberOfAccounts() int
- func (t *Trie) Print(w io.Writer)
- func (t *Trie) PrintDiff(t2 *Trie, w io.Writer)
- func (t *Trie) PrintTrie()
- func (t *Trie) Prove(key []byte, fromLevel int, storage bool) ([][]byte, error)
- func (t *Trie) Reset()
- func (t *Trie) Root() []byte
- func (t *Trie) TrieSize() int
- func (t *Trie) Update(key, value []byte)
- func (t *Trie) UpdateAccount(key []byte, acc *accounts.Account)
- func (t *Trie) UpdateAccountCode(key []byte, code codeNode) error
- func (t *Trie) UpdateAccountCodeSize(key []byte, codeSize int) error
- type VisualOpts
- type Witness
- type WitnessBuilder
- type WitnessDbSubTrieLoader
- type WitnessHeader
- type WitnessOperator
- type WitnessStorage
Constants ¶
const ( AccountFieldNonceOnly uint32 = 0x01 AccountFieldBalanceOnly uint32 = 0x02 AccountFieldStorageOnly uint32 = 0x04 AccountFieldCodeOnly uint32 = 0x08 AccountFieldSSizeOnly uint32 = 0x10 AccountFieldSetNotAccount uint32 = 0x00 )
Various values of the account field set
const ( ColumnStructure = StatsColumn("structure") ColumnHashes = StatsColumn("hashes") ColumnCodes = StatsColumn("codes") ColumnLeafKeys = StatsColumn("leaf_keys") ColumnLeafValues = StatsColumn("leaf_values") ColumnTotal = StatsColumn("total_witness_size") )
const WitnessVersion = uint8(1)
WitnessVersion represents the current version of the block witness in case of incompatible changes it should be updated and the code to migrate the old witness format should be present
Variables ¶
var EmptyCodeHash = crypto.Keccak256Hash(nil)
var ( // EmptyRoot is the known root hash of an empty trie. // DESCRIBED: docs/programmers_guide/guide.md#root EmptyRoot = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") )
Functions ¶
func AddrHashFromCodeKey ¶
func CodeHexFromHex ¶
func CodeKeyFromAddrHash ¶
func CompressNibbles ¶
CompressNibbles - supports only even number of nibbles This method supports only arrays of even nibbles
HI_NIBBLE(b) = (b >> 4) & 0x0F LO_NIBBLE(b) = b & 0x0F
func DecompressNibbles ¶
DecompressNibbles - supports only even number of nibbles
HI_NIBBLE(b) = (b >> 4) & 0x0F LO_NIBBLE(b) = b & 0x0F
func EncodeAsValue ¶
func FullKeys ¶
FullKeys construct the list of full keys (i.e. keys that can be accessed without resolution via DB) that are present in the given trie
func GenStructStep ¶
func GenStructStep( retain func(prefix []byte) bool, curr, succ []byte, e structInfoReceiver, h HashCollector, data GenStructStepData, groups []uint16, trace bool, ) ([]uint16, error)
GenStructStep is one step of the algorithm that generates the structural information based on the sequence of keys. `retain` parameter is the function that, called for a certain prefix, determines whether the trie node for that prefix needs to be compressed into just hash (if `false` is returned), or constructed (if `true` is returned). Usually the `retain` function is implemented in such a way to guarantee that certain keys are always accessible in the resulting trie (see RetainList.Retain function). `buildExtensions` is set to true if the algorithm's step is invoked recursively, i.e. not after a freshly provided leaf or hash `curr`, `succ` are two full keys or prefixes that are currently visible to the algorithm. By comparing these, the algorithm makes decisions about the local structure, i.e. the presense of the prefix groups. `e` parameter is the trie builder, which uses the structure information to assemble trie on the stack and compute its hash. `h` parameter is the hash collector, which is notified whenever branch node is constructed. `data` parameter specified if a hash or a binary string or an account should be emitted. `groups` parameter is the map of the stack. each element of the `groups` slice is a bitmask, one bit per element currently on the stack. Whenever a `BRANCH` or `BRANCHHASH` opcode is emitted, the set of digits is taken from the corresponding `groups` item, which is then removed from the slice. This signifies the usage of the number of the stack items by the `BRANCH` or `BRANCHHASH` opcode. DESCRIBED: docs/programmers_guide/guide.md#separation-of-keys-and-the-structure
func HashWithModifications ¶
func HashWithModifications( t *Trie, aKeys common.Hashes, aValues []*accounts.Account, aCodes [][]byte, sKeys common.StorageKeys, sValues [][]byte, storagePrefixLen int, newStream *Stream, hb *HashBuilder, trace bool, ) (common.Hash, error)
HashWithModifications computes the hash of the would-be modified trie, but without any modifications
func IsPointingToCode ¶
func KeyToQuad ¶
KeyToQuad converts a key in KEY encoding to QUAD encoding (similar to HEX encoding, but uses digits 0..3 instead of digits 0..15)
func NewShortNode ¶
func NewShortNode(key []byte, value node) *shortNode
func ShortNode1 ¶
func ShortNode1()
func ShortNode2 ¶
func ShortNode2()
func StarkStats ¶
StarkStats collects Keccak256 stats from the witness and write them into the file
func StreamHash ¶
func StreamHash(it *StreamMergeIterator, storagePrefixLen int, hb *HashBuilder, trace bool) (common.Hash, error)
StreamHash computes the hash of a stream, as if it was a trie
Types ¶
type AccountEvicter ¶
type AccountEvicter interface {
EvictNode([]byte)
}
type BinaryTrie ¶
type BinaryTrie Trie
BinaryTrie is a binary trie represnentation. Extracted to simplify type checks, etc
func HexToBin ¶
func HexToBin(hexTrie *Trie) *BinaryTrie
HexToBin transforms a hexary trie into binary representation (where the keys can only contain symbols [0,1])
func (*BinaryTrie) Trie ¶
func (b *BinaryTrie) Trie() *Trie
type BlockWitnessStats ¶
type BlockWitnessStats struct {
// contains filtered or unexported fields
}
func (*BlockWitnessStats) BlockWitnessSize ¶
func (s *BlockWitnessStats) BlockWitnessSize() uint64
func (*BlockWitnessStats) CodesSize ¶
func (s *BlockWitnessStats) CodesSize() uint64
func (*BlockWitnessStats) HashesSize ¶
func (s *BlockWitnessStats) HashesSize() uint64
func (*BlockWitnessStats) LeafKeysSize ¶
func (s *BlockWitnessStats) LeafKeysSize() uint64
func (*BlockWitnessStats) LeafValuesSize ¶
func (s *BlockWitnessStats) LeafValuesSize() uint64
func (*BlockWitnessStats) StructureSize ¶
func (s *BlockWitnessStats) StructureSize() uint64
type ByteArrayWriter ¶
type ByteArrayWriter struct {
// contains filtered or unexported fields
}
func (*ByteArrayWriter) Setup ¶
func (w *ByteArrayWriter) Setup(dest []byte, pos int)
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is an intermediate write layer between the trie data structures and the disk database. The aim is to accumulate trie writes in-memory and only periodically flush a couple tries to disk, garbage collecting the remainder.
Note, the trie Database is **not** thread safe in its mutations, but it **is** thread safe in providing individual, independent node access. The rationale behind this split design is to provide read access to RPC handlers and sync servers even while the trie is executing expensive garbage collection.
func NewDatabase ¶
NewDatabase creates a new trie database to store ephemeral trie content before its written out to disk or garbage collected. No read cache is created, so all data retrievals will hit the underlying disk database.
func NewDatabaseWithCache ¶
NewDatabaseWithCache creates a new trie database to store ephemeral trie content before its written out to disk or garbage collected. It also acts as a read cache for nodes loaded from disk.
func (*Database) Cap ¶
func (db *Database) Cap(limit common.StorageSize) error
Cap iteratively flushes old but still referenced trie nodes until the total memory usage goes below the given threshold.
Note, this method is a non-synchronized mutator. It is unsafe to call this concurrently with other mutators.
func (*Database) Commit ¶
Commit iterates over all the children of a particular node, writes them out to disk, forcefully tearing down all references in both directions. As a side effect, all pre-images accumulated up to this point are also written.
Note, this method is a non-synchronized mutator. It is unsafe to call this concurrently with other mutators.
func (*Database) Dereference ¶
Dereference removes an existing reference from a root node.
func (*Database) DiskDB ¶
DiskDB retrieves the persistent storage backing the trie database. FIXME: maybe a more restrictive interface?
func (*Database) InsertBlob ¶
InsertBlob writes a new reference tracked blob to the memory database if it's yet unknown. This method should only be used for non-trie nodes that require reference counting, since trie nodes are garbage collected directly through their embedded children.
func (*Database) Nodes ¶
Nodes retrieves the hashes of all the nodes cached within the memory database. This method is extremely expensive and should only be used to validate internal states in test code.
func (*Database) SaveCache ¶
SaveCache atomically saves fast cache data to the given dir using all available CPU cores.
func (*Database) SaveCachePeriodically ¶
func (db *Database) SaveCachePeriodically(dir string, interval time.Duration, stopCh <-chan struct{})
SaveCachePeriodically atomically saves fast cache data to the given dir with the specified interval. All dump operation will only use a single CPU core.
func (*Database) Size ¶
func (db *Database) Size() (common.StorageSize, common.StorageSize)
Size returns the current storage size of the memory cache in front of the persistent database layer.
type DatabaseReader ¶
type DatabaseReader interface { // Get retrieves the value associated with key from the database. Get(bucket, key []byte) (value []byte, err error) GetAsOf(bucket, hBucket, key []byte, timestamp uint64) ([]byte, error) // Has retrieves whether a key is present in the database. Has(bucket, key []byte) (bool, error) Walk(bucket, key []byte, keybits uint, walker func([]byte, []byte) (bool, error)) error }
DatabaseReader wraps the Get method of a backing store for the trie.
type DefaultReceiver ¶
type DefaultReceiver struct {
// contains filtered or unexported fields
}
func NewDefaultReceiver ¶
func NewDefaultReceiver() *DefaultReceiver
func (*DefaultReceiver) Receive ¶
func (dr *DefaultReceiver) Receive(itemType StreamItem, accountKey []byte, storageKey []byte, accountValue *accounts.Account, storageValue []byte, hash []byte, cutoff int, ) error
func (*DefaultReceiver) Reset ¶
func (dr *DefaultReceiver) Reset(rl RetainDecider, hc HashCollector, trace bool)
func (*DefaultReceiver) Result ¶
func (dr *DefaultReceiver) Result() SubTries
func (*DefaultReceiver) Root ¶
func (dr *DefaultReceiver) Root() common.Hash
type Eviction ¶
type Eviction struct { NoopObserver // make sure that we don't need to implement unnecessary observer methods // contains filtered or unexported fields }
func NewEviction ¶
func NewEviction() *Eviction
func (*Eviction) BlockNumber ¶
func (*Eviction) BranchNodeCreated ¶
func (*Eviction) BranchNodeDeleted ¶
func (*Eviction) BranchNodeTouched ¶
func (*Eviction) CodeNodeCreated ¶
func (*Eviction) CodeNodeDeleted ¶
func (*Eviction) CodeNodeSizeChanged ¶
func (*Eviction) CodeNodeTouched ¶
func (*Eviction) EvictToFitSize ¶
func (tp *Eviction) EvictToFitSize( evicter AccountEvicter, threshold uint64, ) bool
EvictToFitSize evicts mininum number of generations necessary so that the total size of accounts left is fits into the provided threshold
func (*Eviction) SetBlockNumber ¶
type FilterCursor ¶
type FilterCursor struct {
// contains filtered or unexported fields
}
FilterCursor - call .filter() and if it returns false - skip element
type FlatDBTrieLoader ¶
type FlatDBTrieLoader struct {
// contains filtered or unexported fields
}
FlatDBTrieLoader reads state and intermediate trie hashes in order equal to "Preorder trie traversal" (Preorder - visit Root, visit Left, visit Right)
It produces stream of values and send this stream to `defaultReceiver` It skips storage with incorrect incarnations
Each intermediate hash key firstly pass to RetainDecider, only if it returns "false" - such IH can be used.
func NewFlatDBTrieLoader ¶
func NewFlatDBTrieLoader(stateBucket, intermediateHashesBucket string) *FlatDBTrieLoader
func (*FlatDBTrieLoader) CalcTrieRoot ¶
CalcTrieRoot - spawn 2 cursors (IntermediateHashes and HashedState) Wrap IntermediateHashes cursor to IH class - this class will return only keys which passed RetainDecider check If RetainDecider check not passed, then such key must be deleted - HashCollector receiving nil for such key.
func (*FlatDBTrieLoader) Reset ¶
func (l *FlatDBTrieLoader) Reset(rd RetainDecider, hc HashCollector, trace bool) error
Reset prepares the loader for reuse
func (*FlatDBTrieLoader) SetStreamReceiver ¶
func (l *FlatDBTrieLoader) SetStreamReceiver(receiver StreamReceiver)
type FlatDbSubTrieLoader ¶
type FlatDbSubTrieLoader struct {
// contains filtered or unexported fields
}
func NewFlatDbSubTrieLoader ¶
func NewFlatDbSubTrieLoader() *FlatDbSubTrieLoader
func (*FlatDbSubTrieLoader) AttachRequestedCode ¶
func (fstl *FlatDbSubTrieLoader) AttachRequestedCode(db ethdb.Getter, requests []*LoadRequestForCode) error
func (*FlatDbSubTrieLoader) LoadSubTries ¶
func (fstl *FlatDbSubTrieLoader) LoadSubTries() (SubTries, error)
func (*FlatDbSubTrieLoader) Reset ¶
func (fstl *FlatDbSubTrieLoader) Reset(db ethdb.Database, rl RetainDecider, receiverDecider RetainDecider, hc HashCollector, dbPrefixes [][]byte, fixedbits []int, trace bool) error
Reset prepares the loader for reuse
func (*FlatDbSubTrieLoader) SetStreamReceiver ¶
func (fstl *FlatDbSubTrieLoader) SetStreamReceiver(receiver StreamReceiver)
type GenStructStepAccountData ¶
type GenStructStepAccountData struct { FieldSet uint32 Balance uint256.Int Nonce uint64 Incarnation uint64 }
func (GenStructStepAccountData) GenStructStepData ¶
func (GenStructStepAccountData) GenStructStepData()
type GenStructStepData ¶
type GenStructStepData interface {
GenStructStepData()
}
type GenStructStepHashData ¶
func (GenStructStepHashData) GenStructStepData ¶
func (GenStructStepHashData) GenStructStepData()
type GenStructStepLeafData ¶
type GenStructStepLeafData struct {
Value rlphacks.RlpSerializable
}
func (GenStructStepLeafData) GenStructStepData ¶
func (GenStructStepLeafData) GenStructStepData()
type HashBuilder ¶
type HashBuilder struct {
// contains filtered or unexported fields
}
HashBuilder implements the interface `structInfoReceiver` and opcodes that the structural information of the trie is comprised of DESCRIBED: docs/programmers_guide/guide.md#separation-of-keys-and-the-structure
func NewHashBuilder ¶
func NewHashBuilder(trace bool) *HashBuilder
NewHashBuilder creates a new HashBuilder
func (*HashBuilder) Reset ¶
func (hb *HashBuilder) Reset()
Reset makes the HashBuilder suitable for reuse
type HashCollector ¶
hashCollector gets called whenever there might be a need to create intermediate hash record
type HexStdOutWriter ¶
type HexStdOutWriter struct{}
type IHCursor ¶
type IHCursor struct {
// contains filtered or unexported fields
}
IHCursor - holds logic related to iteration over IH bucket
func IH ¶
func IH(c *FilterCursor) *IHCursor
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator helps iterate over a trie according to a given resolve set
func NewIterator ¶
func NewIterator(t *Trie, rl *RetainList, trace bool) *Iterator
NewIterator creates a new iterator from scratch from a given trie and resolve set
type Keybytes ¶
Keybytes represent a packed encoding of hex sequences where 2 nibbles per byte are stored in Data + an additional flag for terminating nodes.
func CompactToKeybytes ¶
CompactToKeybytes translates from COMPACT to KEYBYTES encoding.
func (*Keybytes) DecodeRLP ¶
DecodeRLP implements rlp.Decoder and decodes Keybytes from the COMPACT encoding.
func (*Keybytes) EncodeRLP ¶
EncodeRLP implements rlp.Encoder and encodes Keybytes in the COMPACT encoding.
type LoadFunc ¶
type LoadFunc func(*SubTrieLoader, *RetainList, [][]byte, []int) (SubTries, error)
type LoadRequestForCode ¶
type LoadRequestForCode struct {
// contains filtered or unexported fields
}
LoadRequestForCode Code expresses the need to fetch code from the DB (by its hash) and attach to a specific account leaf in the trie.
func (*LoadRequestForCode) String ¶
func (lrc *LoadRequestForCode) String() string
type MerklePathLimiter ¶
type MerklePathLimiter struct { RetainDecider RetainDecider HashFunc HashNodeFunc }
type MissingNodeError ¶
type MissingNodeError struct { NodeHash common.Hash // hash of the missing node Path []byte // hex-encoded path to the missing node }
MissingNodeError is returned by the trie functions (TryGet, TryUpdate, TryDelete) in the case where a trie node is not present in the local database. It contains information necessary for retrieving the missing node.
func (*MissingNodeError) Error ¶
func (err *MissingNodeError) Error() string
type NoopObserver ¶
type NoopObserver struct{}
NoopTrieObserver might be used to emulate optional methods in observers
func (*NoopObserver) BranchNodeCreated ¶
func (*NoopObserver) BranchNodeCreated(_ []byte)
func (*NoopObserver) BranchNodeDeleted ¶
func (*NoopObserver) BranchNodeDeleted(_ []byte)
func (*NoopObserver) BranchNodeLoaded ¶
func (*NoopObserver) BranchNodeLoaded(_ []byte, _ uint64)
func (*NoopObserver) BranchNodeTouched ¶
func (*NoopObserver) BranchNodeTouched(_ []byte)
func (*NoopObserver) CodeNodeCreated ¶
func (*NoopObserver) CodeNodeCreated(_ []byte, _ uint)
func (*NoopObserver) CodeNodeDeleted ¶
func (*NoopObserver) CodeNodeDeleted(_ []byte)
func (*NoopObserver) CodeNodeSizeChanged ¶
func (*NoopObserver) CodeNodeSizeChanged(_ []byte, _ uint)
func (*NoopObserver) CodeNodeTouched ¶
func (*NoopObserver) CodeNodeTouched(_ []byte)
func (*NoopObserver) WillUnloadBranchNode ¶
func (*NoopObserver) WillUnloadBranchNode(_ []byte, _ common.Hash, _ uint64)
func (*NoopObserver) WillUnloadNode ¶
func (*NoopObserver) WillUnloadNode(_ []byte, _ common.Hash)
type Observer ¶
type Observer interface { BranchNodeCreated(hex []byte) BranchNodeDeleted(hex []byte) BranchNodeTouched(hex []byte) CodeNodeCreated(hex []byte, size uint) CodeNodeDeleted(hex []byte) CodeNodeTouched(hex []byte) CodeNodeSizeChanged(hex []byte, newSize uint) WillUnloadBranchNode(key []byte, nodeHash common.Hash, incarnation uint64) WillUnloadNode(key []byte, nodeHash common.Hash) BranchNodeLoaded(prefixAsNibbles []byte, incarnation uint64) }
type ObserverMux ¶
type ObserverMux struct {
// contains filtered or unexported fields
}
TrieObserverMux multiplies the callback methods and sends them to all it's children.
func NewTrieObserverMux ¶
func NewTrieObserverMux() *ObserverMux
func (*ObserverMux) AddChild ¶
func (mux *ObserverMux) AddChild(child Observer)
func (*ObserverMux) BranchNodeCreated ¶
func (mux *ObserverMux) BranchNodeCreated(hex []byte)
func (*ObserverMux) BranchNodeDeleted ¶
func (mux *ObserverMux) BranchNodeDeleted(hex []byte)
func (*ObserverMux) BranchNodeLoaded ¶
func (mux *ObserverMux) BranchNodeLoaded(prefixAsNibbles []byte, incarnation uint64)
func (*ObserverMux) BranchNodeTouched ¶
func (mux *ObserverMux) BranchNodeTouched(hex []byte)
func (*ObserverMux) CodeNodeCreated ¶
func (mux *ObserverMux) CodeNodeCreated(hex []byte, size uint)
func (*ObserverMux) CodeNodeDeleted ¶
func (mux *ObserverMux) CodeNodeDeleted(hex []byte)
func (*ObserverMux) CodeNodeSizeChanged ¶
func (mux *ObserverMux) CodeNodeSizeChanged(hex []byte, newSize uint)
func (*ObserverMux) CodeNodeTouched ¶
func (mux *ObserverMux) CodeNodeTouched(hex []byte)
func (*ObserverMux) WillUnloadBranchNode ¶
func (mux *ObserverMux) WillUnloadBranchNode(key []byte, nodeHash common.Hash, incarnation uint64)
func (*ObserverMux) WillUnloadNode ¶
func (mux *ObserverMux) WillUnloadNode(key []byte, nodeHash common.Hash)
type OperatorBranch ¶
type OperatorBranch struct {
Mask uint32
}
func (*OperatorBranch) LoadFrom ¶
func (o *OperatorBranch) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorBranch) WriteTo ¶
func (o *OperatorBranch) WriteTo(output *OperatorMarshaller) error
type OperatorCode ¶
type OperatorCode struct {
Code []byte
}
func (*OperatorCode) LoadFrom ¶
func (o *OperatorCode) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorCode) WriteTo ¶
func (o *OperatorCode) WriteTo(output *OperatorMarshaller) error
type OperatorEmptyRoot ¶
type OperatorEmptyRoot struct{}
func (*OperatorEmptyRoot) LoadFrom ¶
func (o *OperatorEmptyRoot) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorEmptyRoot) WriteTo ¶
func (o *OperatorEmptyRoot) WriteTo(output *OperatorMarshaller) error
type OperatorExtension ¶
type OperatorExtension struct {
Key []byte
}
func (*OperatorExtension) LoadFrom ¶
func (o *OperatorExtension) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorExtension) WriteTo ¶
func (o *OperatorExtension) WriteTo(output *OperatorMarshaller) error
type OperatorHash ¶
func (*OperatorHash) LoadFrom ¶
func (o *OperatorHash) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorHash) WriteTo ¶
func (o *OperatorHash) WriteTo(output *OperatorMarshaller) error
type OperatorKindCode ¶
type OperatorKindCode uint8
OperatorKindCode is "enum" type for defining the opcodes of the stack machine that reconstructs the structure of tries from Structure tape
const ( // OpLeaf creates leaf node and pushes it onto the node stack, its hash onto the hash stack OpLeaf OperatorKindCode = iota // OpExtension pops a node from the node stack, constructs extension node from it and its operand's key, and pushes this extension node onto // the node stack, its hash onto the hash stack OpExtension // OpBranch has operand, which is a bitset representing digits in the branch node. Pops the children nodes from the node stack (the number of // children is equal to the number of bits in the bitset), constructs branch node and pushes it onto the node stack, its hash onto the hash stack OpBranch // OpHash and pushes the hash them onto the stack. OpHash // OpCode constructs code node and pushes it onto the node stack, its hash onto the hash stack. OpCode // OpAccountLeaf constructs an account node (without any storage and code) and pushes it onto the node stack, its hash onto the hash stack. OpAccountLeaf // OpEmptyRoot places nil onto the node stack, and empty root hash onto the hash stack. OpEmptyRoot // OpNewTrie stops the processing, because another trie is encoded into the witness. OpNewTrie = OperatorKindCode(0xBB) )
type OperatorLeafAccount ¶
type OperatorLeafAccount struct { Key []byte Nonce uint64 Balance *big.Int HasCode bool HasStorage bool CodeSize uint64 }
func (*OperatorLeafAccount) LoadFrom ¶
func (o *OperatorLeafAccount) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorLeafAccount) WriteTo ¶
func (o *OperatorLeafAccount) WriteTo(output *OperatorMarshaller) error
type OperatorLeafValue ¶
func (*OperatorLeafValue) LoadFrom ¶
func (o *OperatorLeafValue) LoadFrom(loader *OperatorUnmarshaller) error
func (*OperatorLeafValue) WriteTo ¶
func (o *OperatorLeafValue) WriteTo(output *OperatorMarshaller) error
type OperatorMarshaller ¶
type OperatorMarshaller struct {
// contains filtered or unexported fields
}
OperatorMarshaller is responsible for encoding operators to a stream and collecting stats IMPORTANT: not thread-safe! use from a single thread only
func NewOperatorMarshaller ¶
func NewOperatorMarshaller(w io.Writer) *OperatorMarshaller
func (*OperatorMarshaller) GetStats ¶
func (w *OperatorMarshaller) GetStats() *BlockWitnessStats
func (*OperatorMarshaller) WithColumn ¶
func (w *OperatorMarshaller) WithColumn(column StatsColumn) *OperatorMarshaller
func (*OperatorMarshaller) WriteByteArrayValue ¶
func (w *OperatorMarshaller) WriteByteArrayValue(value []byte) error
func (*OperatorMarshaller) WriteByteValue ¶
func (w *OperatorMarshaller) WriteByteValue(value byte) error
func (*OperatorMarshaller) WriteCode ¶
func (w *OperatorMarshaller) WriteCode(value []byte) error
func (*OperatorMarshaller) WriteHash ¶
func (w *OperatorMarshaller) WriteHash(hash common.Hash) error
func (*OperatorMarshaller) WriteKey ¶
func (w *OperatorMarshaller) WriteKey(keyNibbles []byte) error
func (*OperatorMarshaller) WriteOpCode ¶
func (w *OperatorMarshaller) WriteOpCode(opcode OperatorKindCode) error
func (*OperatorMarshaller) WriteUint64Value ¶
func (w *OperatorMarshaller) WriteUint64Value(value uint64) error
type OperatorUnmarshaller ¶
type OperatorUnmarshaller struct {
// contains filtered or unexported fields
}
OperatorMarshaller provides all needed primitives to read witness operators from a serialized form.
func NewOperatorUnmarshaller ¶
func NewOperatorUnmarshaller(r io.Reader) *OperatorUnmarshaller
func (*OperatorUnmarshaller) ReadByte ¶
func (l *OperatorUnmarshaller) ReadByte() (byte, error)
func (*OperatorUnmarshaller) ReadByteArray ¶
func (l *OperatorUnmarshaller) ReadByteArray() ([]byte, error)
func (*OperatorUnmarshaller) ReadHash ¶
func (l *OperatorUnmarshaller) ReadHash() (common.Hash, error)
func (*OperatorUnmarshaller) ReadKey ¶
func (l *OperatorUnmarshaller) ReadKey() ([]byte, error)
func (*OperatorUnmarshaller) ReadUInt64 ¶
func (l *OperatorUnmarshaller) ReadUInt64() (uint64, error)
func (*OperatorUnmarshaller) ReadUint32 ¶
func (l *OperatorUnmarshaller) ReadUint32() (uint32, error)
type RetainAll ¶
type RetainAll struct {
// contains filtered or unexported fields
}
RetainAll - returns true to any prefix
func NewRetainAll ¶
func NewRetainAll(decider RetainDecider) *RetainAll
NewRetainAll creates new NewRetainRange to=nil - means no upper bound
func (*RetainAll) AddCodeTouch ¶
AddCodeTouch adds a new code touch into the resolve set
type RetainDecider ¶
type RetainLevels ¶
type RetainLevels struct {
// contains filtered or unexported fields
}
RetainLevels - returns true to any prefix shorter than `levels`
func NewRetainLevels ¶
func NewRetainLevels(decider RetainDecider, levels int) *RetainLevels
NewRetainLevels creates new NewRetainRange to=nil - means no upper bound
func (*RetainLevels) AddCodeTouch ¶
func (rr *RetainLevels) AddCodeTouch(codeHash common.Hash)
AddCodeTouch adds a new code touch into the resolve set
func (*RetainLevels) IsCodeTouched ¶
func (rr *RetainLevels) IsCodeTouched(codeHash common.Hash) bool
func (*RetainLevels) Retain ¶
func (rr *RetainLevels) Retain(prefix []byte) (retain bool)
func (*RetainLevels) String ¶
func (rr *RetainLevels) String() string
type RetainList ¶
type RetainList struct {
// contains filtered or unexported fields
}
RetainList encapsulates the list of keys that are required to be fully available, or loaded (by using `BRANCH` opcode instead of `HASHER`) after processing of the sequence of key-value pairs DESCRIBED: docs/programmers_guide/guide.md#converting-sequence-of-keys-and-value-into-a-multiproof
func NewBinaryRetainList ¶
func NewBinaryRetainList(minLength int) *RetainList
func NewRetainList ¶
func NewRetainList(minLength int) *RetainList
NewRetainList creates new RetainList
func (*RetainList) AddCodeTouch ¶
func (rl *RetainList) AddCodeTouch(codeHash common.Hash)
AddCodeTouch adds a new code touch into the resolve set
func (*RetainList) AddHex ¶
func (rl *RetainList) AddHex(hex []byte)
AddHex adds a new key (in HEX encoding) to the list
func (*RetainList) AddKey ¶
func (rl *RetainList) AddKey(key []byte)
AddKey adds a new key (in KEY encoding) to the list
func (*RetainList) IsCodeTouched ¶
func (rl *RetainList) IsCodeTouched(codeHash common.Hash) bool
func (*RetainList) Retain ¶
func (rl *RetainList) Retain(prefix []byte) bool
Retain decides whether to emit `HASHER` or `BRANCH` for a given prefix, by checking if this is prefix of any of the keys added to the set Since keys in the set are sorted, and we expect that the prefixes will come in monotonically ascending order, we optimise for this, though the function would still work if the order is different
func (*RetainList) Rewind ¶
func (rl *RetainList) Rewind()
Rewind lets us reuse this list from the beginning
func (*RetainList) String ¶
func (rl *RetainList) String() string
type RetainListBuilder ¶
type RetainListBuilder struct {
// contains filtered or unexported fields
}
RetainListBuilder is the structure that accumulates the list of keys that were read or changes (touched) during the execution of a block. It also tracks the contract codes that were created and used during the execution of a block
func NewRetainListBuilder ¶
func NewRetainListBuilder() *RetainListBuilder
NewRetainListBuilder creates new ProofGenerator and initialised its maps
func (*RetainListBuilder) AddStorageTouch ¶
func (rlb *RetainListBuilder) AddStorageTouch(touch []byte)
AddStorageTouch adds a key (in KEY encoding) into the read/change set of storage keys
func (*RetainListBuilder) AddTouch ¶
func (rlb *RetainListBuilder) AddTouch(touch []byte)
AddTouch adds a key (in KEY encoding) into the read/change set of account keys
func (*RetainListBuilder) Build ¶
func (rlb *RetainListBuilder) Build(isBinary bool) *RetainList
func (*RetainListBuilder) CreateCode ¶
func (rlb *RetainListBuilder) CreateCode(codeHash common.Hash)
CreateCode registers that given contract code has been created (deployed) during current block's execution
func (*RetainListBuilder) ExtractTouches ¶
func (rlb *RetainListBuilder) ExtractTouches() ([][]byte, [][]byte)
ExtractTouches returns accumulated read/change sets and clears them for the next block's execution
func (*RetainListBuilder) ReadCode ¶
func (rlb *RetainListBuilder) ReadCode(codeHash common.Hash)
ReadCode registers that given contract code has been accessed during current block's execution
type RetainRange ¶
type RetainRange struct {
// contains filtered or unexported fields
}
RetainRange encapsulates the range of keys that are required to be fully available, or loaded (by using `BRANCH` opcode instead of `HASHER`) after processing of the sequence of key-value pairs DESCRIBED: docs/programmers_guide/guide.md#converting-sequence-of-keys-and-value-into-a-multiproof
func NewRetainRange ¶
func NewRetainRange(from, to []byte) *RetainRange
NewRetainRange creates new NewRetainRange to=nil - means no upper bound
func (*RetainRange) AddCodeTouch ¶
func (rr *RetainRange) AddCodeTouch(codeHash common.Hash)
AddCodeTouch adds a new code touch into the resolve set
func (*RetainRange) IsCodeTouched ¶
func (rr *RetainRange) IsCodeTouched(codeHash common.Hash) bool
func (*RetainRange) Retain ¶
func (rr *RetainRange) Retain(prefix []byte) (retain bool)
Retain decides whether to emit `HASHER` or `BRANCH` for a given prefix, by checking if this is prefix of any of the keys added to the set it returns True:
- for keys between from and to - for keys which are prefixes of from and to - for keys which are contains from and to as a prefix
func (*RetainRange) String ¶
func (rr *RetainRange) String() string
type RootHashAggregator ¶
type RootHashAggregator struct {
// contains filtered or unexported fields
}
RootHashAggregator - calculates Merkle trie root hash from incoming data stream
func NewRootHashAggregator ¶
func NewRootHashAggregator() *RootHashAggregator
func (*RootHashAggregator) Receive ¶
func (r *RootHashAggregator) Receive(itemType StreamItem, accountKey []byte, storageKey []byte, accountValue *accounts.Account, storageValue []byte, hash []byte, cutoff int, ) error
func (*RootHashAggregator) Reset ¶
func (r *RootHashAggregator) Reset(hc HashCollector, trace bool)
func (*RootHashAggregator) Result ¶
func (r *RootHashAggregator) Result() SubTries
func (*RootHashAggregator) RetainNothing ¶
func (r *RootHashAggregator) RetainNothing(prefix []byte) bool
func (*RootHashAggregator) Root ¶
func (r *RootHashAggregator) Root() common.Hash
type StarkStatsBuilder ¶
type StarkStatsBuilder struct {
// contains filtered or unexported fields
}
func NewStarkStatsBuilder ¶
func NewStarkStatsBuilder() *StarkStatsBuilder
type StatsColumn ¶
type StatsColumn string
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream represents the collection of key-value pairs, sorted by keys, where values may belong to three different types - accounts, strage item leaves, and intermediate hashes
type StreamItem ¶
type StreamItem uint8
StreamItem is an enum type for values that help distinguish different types of key-value pairs in the stream of values produce by function `ToStream`
const ( // NoItem is used to signal the end of iterator NoItem StreamItem = iota // AccountStreamItem used for marking a key-value pair in the stream as belonging to an account AccountStreamItem // StorageStreamItem used for marking a key-value pair in the stream as belonging to a storage item leaf StorageStreamItem // AHashStreamItem used for marking a key-value pair in the stream as belonging to an intermediate hash // within the accounts (main state trie) AHashStreamItem // SHashStreamItem used for marking a key-value pair in the stream as belonging to an intermediate hash // within the storage items (storage tries) SHashStreamItem // CutoffStremItem used for marking the end of the subtrie CutoffStreamItem )
type StreamIterator ¶
type StreamMergeIterator ¶
type StreamMergeIterator struct {
// contains filtered or unexported fields
}
StreamMergeIterator merges an Iterator and a Stream
func NewStreamMergeIterator ¶
func NewStreamMergeIterator(it *Iterator, s *Stream, trace bool) *StreamMergeIterator
NewStreamMergeIterator create a brand new StreamMergeIterator
func (*StreamMergeIterator) Next ¶
func (smi *StreamMergeIterator) Next() (itemType1 StreamItem, hex1 []byte, aValue *accounts.Account, aCode []byte, hash []byte, value []byte)
Next returns the next item in the merged iterator
type StreamReceiver ¶
type SubTrieLoader ¶
type SubTrieLoader struct {
// contains filtered or unexported fields
}
Resolver looks up (resolves) some keys and corresponding values from a database. One resolver per trie (prefix). See also ResolveRequest in trie.go
func NewSubTrieLoader ¶
func NewSubTrieLoader(blockNr uint64) *SubTrieLoader
func (*SubTrieLoader) AddCodeRequest ¶
func (stl *SubTrieLoader) AddCodeRequest(req *LoadRequestForCode)
AddCodeRequest add a request for code loading
func (*SubTrieLoader) LoadFromFlatDB ¶
func (stl *SubTrieLoader) LoadFromFlatDB(db ethdb.Database, rl RetainDecider, hc HashCollector, dbPrefixes [][]byte, fixedbits []int, trace bool) (SubTries, error)
func (*SubTrieLoader) LoadFromWitnessDb ¶
func (stl *SubTrieLoader) LoadFromWitnessDb(db WitnessStorage, blockNr uint64, trieLimit uint32, startPos int64, count int) (SubTries, int64, error)
LoadFromWitnessDb loads subtries from a witnesses database instead of a state DB.
func (*SubTrieLoader) LoadSubTries ¶
func (stl *SubTrieLoader) LoadSubTries(db ethdb.Database, blockNr uint64, rl RetainDecider, hc HashCollector, dbPrefixes [][]byte, fixedbits []int, trace bool) (SubTries, error)
LoadFromDb loads subtries from a state database.
func (*SubTrieLoader) Reset ¶
func (stl *SubTrieLoader) Reset(blockNr uint64)
type SubTries ¶
type SubTries struct { Hashes []common.Hash // Root hashes of the sub-tries // contains filtered or unexported fields }
SubTrie is a result of loading sub-trie from either flat db or witness db. It encapsulates sub-trie root (which is of the un-exported type `node`) If the loading is done for verification and testing purposes, then usually only sub-tree root hash would be queried
type Trie ¶
type Trie struct { Version uint8 // contains filtered or unexported fields }
Trie is a Merkle Patricia Trie. The zero value is an empty trie with no database. Use New to create a trie that sits on top of a database.
Trie is not safe for concurrent use.
func BuildTrieFromWitness ¶
func New ¶
New creates a trie with an existing root node from db.
If root is the zero hash or the sha3 hash of an empty string, the trie is initially empty and does not require a database. Otherwise, New will panic if db is nil and returns a MissingNodeError if root does not exist in the database. Accessing the trie loads nodes from db on demand.
func NewTestRLPTrie ¶
NewTestRLPTrie treats all the data provided to `Update` function as rlp-encoded. it is usually used for testing purposes.
func (*Trie) AddObserver ¶
func (*Trie) DeepHash ¶
DeepHash returns internal hash of a node reachable by the specified key prefix. Note that if the prefix points into the middle of a key for a leaf node or of an extention node, it will return the hash of a modified leaf node or extension node, where the key prefix is removed from the key. First returned value is `true` if the node with the specified prefix is found.
func (*Trie) Delete ¶
Delete removes any existing value for key from the trie. DESCRIBED: docs/programmers_guide/guide.md#root
func (*Trie) DeleteSubtree ¶
DeleteSubtree removes any existing value for key from the trie. The only difference between Delete and DeleteSubtree is that Delete would delete accountNode too, wherewas DeleteSubtree will keep the accountNode, but will make the storage sub-trie empty
func (*Trie) ExtractWitness ¶
func (t *Trie) ExtractWitness(trace bool, rl RetainDecider) (*Witness, error)
func (*Trie) ExtractWitnessForPrefix ¶
func (*Trie) FindSubTriesToLoad ¶
func (t *Trie) FindSubTriesToLoad(rl RetainDecider) (prefixes [][]byte, fixedbits []int, hooks [][]byte)
FindSubTriesToLoad walks over the trie and creates the list of DB prefixes and corresponding list of valid bits in the prefix (for the cases when prefix contains an odd number of nibbles) that would allow loading the missing information from the database It also create list of `hooks`, the paths in the trie (in nibbles) where the loaded sub-tries need to be inserted.
func (*Trie) Fold ¶
Fold modifies the trie by folding the given set of keys, making sure that they are inaccessible without resolution via DB
func (*Trie) GetAccount ¶
func (*Trie) GetAccountCode ¶
func (*Trie) GetAccountCodeSize ¶
func (*Trie) GetNodeByHash ¶
GetNodeByHash gets node's RLP by hash.
func (*Trie) Hash ¶
Hash returns the root hash of the trie. It does not write to the database and can be used even if the trie doesn't have one. DESCRIBED: docs/programmers_guide/guide.md#root
func (*Trie) HashMapSize ¶
HashMapSize returns the number of entries in trie's hash map.
func (*Trie) NeedLoadCode ¶
func (*Trie) NewLoadRequestForCode ¶
func (*Trie) NumberOfAccounts ¶
func (*Trie) Prove ¶
Prove constructs a merkle proof for key. The result contains all encoded nodes on the path to the value at key. The value itself is also included in the last node and can be retrieved by verifying the proof.
If the trie does not contain a value for key, the returned proof contains all nodes of the longest existing prefix of the key (at least the root node), ending with the node that proves the absence of the key.
func (*Trie) Update ¶
Update associates key with value in the trie. Subsequent calls to Get will return value. If value has length zero, any existing value is deleted from the trie and calls to Get will return nil.
The value bytes must not be modified by the caller while they are stored in the trie. DESCRIBED: docs/programmers_guide/guide.md#root
func (*Trie) UpdateAccountCode ¶
UpdateAccountCode attaches the code node to an account at specified key
type VisualOpts ¶
type VisualOpts struct { Highlights [][]byte // Collection of keys, in the HEX encoding, that need to be highlighted with digits IndexColors []string // Array of colors for representing digits as colored boxes FontColors []string // Array of colors, the same length as indexColors, for the textual digits inside the coloured boxes CutTerminals int // Specifies how many digits to cut from the terminal short node keys for a more convinient display Values bool // Whether to display value nodes (as box with rounded corners) CodeCompressed bool // Whether to turn the code from a large rectange to a small square for a more convinient display ValCompressed bool // Whether long values (over 10 characters) are shortened using ... in the middle ValHex bool // Whether values should be displayed as hex numbers (otherwise they are displayed as just strings) SameLevel bool // Whether the leaves (and hashes) need to be on the same horizontal level }
VisualOpts contains various configuration options fo the Visual function It has been introduced as a replacement for too many arguments with options
type Witness ¶
type Witness struct { Header WitnessHeader Operators []WitnessOperator }
func ExtractWitnesses ¶
func ExtractWitnesses(subTries SubTries, trace bool, retainDec RetainDecider) ([]*Witness, error)
ExtractWitnesses extracts witnesses for subtries starting from the specified root if retainDec param is nil it will make a witness for the full subtrie, if retainDec param is set to a RetainList instance, it will make a witness for only the accounts/storages that were actually touched; other paths will be hashed.
func NewWitness ¶
func NewWitness(operands []WitnessOperator) *Witness
func NewWitnessFromReader ¶
type WitnessBuilder ¶
type WitnessBuilder struct {
// contains filtered or unexported fields
}
func NewWitnessBuilder ¶
func NewWitnessBuilder(root node, trace bool) *WitnessBuilder
func (*WitnessBuilder) Build ¶
func (b *WitnessBuilder) Build(limiter *MerklePathLimiter) (*Witness, error)
type WitnessDbSubTrieLoader ¶
type WitnessDbSubTrieLoader struct { }
func NewWitnessDbSubTrieLoader ¶
func NewWitnessDbSubTrieLoader() *WitnessDbSubTrieLoader
func (*WitnessDbSubTrieLoader) LoadSubTries ¶
func (wstl *WitnessDbSubTrieLoader) LoadSubTries(db WitnessStorage, blockNr uint64, trieLimit uint32, startPos int64, count int) (SubTries, int64, error)
type WitnessHeader ¶
type WitnessHeader struct {
Version uint8
}
WitnessHeader contains version information and maybe some future format bits the version is always the 1st bit.
func (*WitnessHeader) WriteTo ¶
func (h *WitnessHeader) WriteTo(out *OperatorMarshaller) error
type WitnessOperator ¶
type WitnessOperator interface { WriteTo(*OperatorMarshaller) error // LoadFrom always assumes that the opcode value was already read LoadFrom(*OperatorUnmarshaller) error }
WitnessOperator is a single operand in the block witness. It knows how to serialize/deserialize itself.
Source Files
- database.go
- debug.go
- encoding.go
- errors.go
- flatdb_sub_trie_loader.go
- gen_struct_step.go
- hack.go
- hashbuilder.go
- hasher.go
- intermediate_hash_receiver.go
- intermediate_trie_hashes.go
- node.go
- proof.go
- retain_list.go
- retain_list_builder.go
- stark_stats.go
- stream.go
- sub_trie_loader.go
- sync_bloom.go
- trie.go
- trie_binary.go
- trie_eviction.go
- trie_from_witness.go
- trie_observers.go
- trie_root.go
- trie_transform.go
- trie_witness.go
- utils.go
- visual.go
- witness.go
- witness_builder.go
- witness_marshalling.go
- witness_operators.go
- witness_stats.go
- witnessdb_sub_trie_loader.go
Directories
Path | Synopsis |
---|---|
rlphacks |