Documentation ¶
Index ¶
- Variables
- func CompactedKeyToHex(compact []byte) []byte
- type BinPatriciaHashed
- func (bph *BinPatriciaHashed) EncodeCurrentState(buf []byte) ([]byte, error)
- func (bph *BinPatriciaHashed) ProcessUpdates(plainKeys, hashedKeys [][]byte, updates []Update) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
- func (bph *BinPatriciaHashed) Reset()
- func (bph *BinPatriciaHashed) ResetFns(branchFn func(prefix []byte) ([]byte, error), ...)
- func (bph *BinPatriciaHashed) ReviewKeys(plainKeys, hashedKeys [][]byte) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
- func (bph *BinPatriciaHashed) RootHash() ([]byte, error)
- func (bph *BinPatriciaHashed) SetState(buf []byte) error
- func (bph *BinPatriciaHashed) SetTrace(trace bool)
- func (bph *BinPatriciaHashed) Variant() TrieVariant
- type BinaryCell
- type BranchData
- func (branchData BranchData) DecodeCells() (touchMap, afterMap uint16, row [16]*Cell, err error)
- func (branchData BranchData) ExtractPlainKeys() (accountPlainKeys [][]byte, storagePlainKeys [][]byte, err error)
- func (branchData BranchData) IsComplete() bool
- func (branchData BranchData) MergeHexBranches(branchData2 BranchData, newData []byte) (BranchData, error)
- func (branchData BranchData) ReplacePlainKeys(accountPlainKeys [][]byte, storagePlainKeys [][]byte, newData []byte) (BranchData, error)
- func (branchData BranchData) String() string
- type BranchMerger
- type Cell
- type HexPatriciaHashed
- func (hph *HexPatriciaHashed) EncodeCurrentState(buf []byte) ([]byte, error)
- func (hph *HexPatriciaHashed) ProcessUpdates(plainKeys, hashedKeys [][]byte, updates []Update) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
- func (hph *HexPatriciaHashed) Reset()
- func (hph *HexPatriciaHashed) ResetFns(branchFn func(prefix []byte) ([]byte, error), ...)
- func (hph *HexPatriciaHashed) ReviewKeys(plainKeys, hashedKeys [][]byte) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
- func (hph *HexPatriciaHashed) RootHash() ([]byte, error)
- func (hph *HexPatriciaHashed) SetState(buf []byte) error
- func (hph *HexPatriciaHashed) SetTrace(trace bool)
- func (hph *HexPatriciaHashed) Variant() TrieVariant
- type PartFlags
- type Trie
- type TrieVariant
- type Update
- type UpdateFlags
Constants ¶
This section is empty.
Variables ¶
var (
EmptyBinRootHash, _ = hex.DecodeString("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
EmptyBinCodeHash, _ = hex.DecodeString("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
)
var (
EmptyRootHash, _ = hex.DecodeString("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
EmptyCodeHash, _ = hex.DecodeString("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")
)
Functions ¶
func CompactedKeyToHex ¶
Types ¶
type BinPatriciaHashed ¶
type BinPatriciaHashed struct {
// contains filtered or unexported fields
}
BinHashed implements commitment based on patricia merkle tree with radix 16, with keys pre-hashed by keccak256
func NewBinPatriciaHashed ¶
func (*BinPatriciaHashed) EncodeCurrentState ¶
func (bph *BinPatriciaHashed) EncodeCurrentState(buf []byte) ([]byte, error)
Encode current state of hph into bytes
func (*BinPatriciaHashed) ProcessUpdates ¶
func (bph *BinPatriciaHashed) ProcessUpdates(plainKeys, hashedKeys [][]byte, updates []Update) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
func (*BinPatriciaHashed) Reset ¶
func (bph *BinPatriciaHashed) Reset()
Reset allows BinPatriciaHashed instance to be reused for the new commitment calculation
func (*BinPatriciaHashed) ReviewKeys ¶
func (bph *BinPatriciaHashed) ReviewKeys(plainKeys, hashedKeys [][]byte) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
func (*BinPatriciaHashed) RootHash ¶
func (bph *BinPatriciaHashed) RootHash() ([]byte, error)
func (*BinPatriciaHashed) SetState ¶
func (bph *BinPatriciaHashed) SetState(buf []byte) error
buf expected to be encoded hph state. Decode state and set up hph to that state.
func (*BinPatriciaHashed) SetTrace ¶
func (bph *BinPatriciaHashed) SetTrace(trace bool)
func (*BinPatriciaHashed) Variant ¶
func (bph *BinPatriciaHashed) Variant() TrieVariant
type BinaryCell ¶
type BranchData ¶
type BranchData []byte
func EncodeBranch ¶
func (BranchData) DecodeCells ¶
func (branchData BranchData) DecodeCells() (touchMap, afterMap uint16, row [16]*Cell, err error)
func (BranchData) ExtractPlainKeys ¶
func (branchData BranchData) ExtractPlainKeys() (accountPlainKeys [][]byte, storagePlainKeys [][]byte, err error)
ExtractPlainKeys parses branchData and extract the plain keys for accounts and storage in the same order they appear witjin the branchData
func (BranchData) IsComplete ¶
func (branchData BranchData) IsComplete() bool
IsComplete determines whether given branch data is complete, meaning that all information about all the children is present Each of 16 children of a branch node have two attributes touch - whether this child has been modified or deleted in this branchData (corresponding bit in touchMap is set) after - whether after this branchData application, the child is present in the tree or not (corresponding bit in afterMap is set)
func (BranchData) MergeHexBranches ¶
func (branchData BranchData) MergeHexBranches(branchData2 BranchData, newData []byte) (BranchData, error)
MergeHexBranches combines two branchData, number 2 coming after (and potentially shadowing) number 1
func (BranchData) ReplacePlainKeys ¶
func (branchData BranchData) ReplacePlainKeys(accountPlainKeys [][]byte, storagePlainKeys [][]byte, newData []byte) (BranchData, error)
func (BranchData) String ¶
func (branchData BranchData) String() string
type BranchMerger ¶
type BranchMerger struct {
// contains filtered or unexported fields
}
func NewHexBranchMerger ¶
func NewHexBranchMerger(capacity uint64) *BranchMerger
func (*BranchMerger) Merge ¶
func (m *BranchMerger) Merge(branch1 BranchData, branch2 BranchData) (BranchData, error)
MergeHexBranches combines two branchData, number 2 coming after (and potentially shadowing) number 1
type HexPatriciaHashed ¶
type HexPatriciaHashed struct {
// contains filtered or unexported fields
}
HexPatriciaHashed implements commitment based on patricia merkle tree with radix 16, with keys pre-hashed by keccak256
func NewHexPatriciaHashed ¶
func (*HexPatriciaHashed) EncodeCurrentState ¶
func (hph *HexPatriciaHashed) EncodeCurrentState(buf []byte) ([]byte, error)
Encode current state of hph into bytes
func (*HexPatriciaHashed) ProcessUpdates ¶
func (hph *HexPatriciaHashed) ProcessUpdates(plainKeys, hashedKeys [][]byte, updates []Update) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
func (*HexPatriciaHashed) Reset ¶
func (hph *HexPatriciaHashed) Reset()
Reset allows HexPatriciaHashed instance to be reused for the new commitment calculation
func (*HexPatriciaHashed) ReviewKeys ¶
func (hph *HexPatriciaHashed) ReviewKeys(plainKeys, hashedKeys [][]byte) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error)
func (*HexPatriciaHashed) RootHash ¶
func (hph *HexPatriciaHashed) RootHash() ([]byte, error)
func (*HexPatriciaHashed) SetState ¶
func (hph *HexPatriciaHashed) SetState(buf []byte) error
buf expected to be encoded hph state. Decode state and set up hph to that state.
func (*HexPatriciaHashed) SetTrace ¶
func (hph *HexPatriciaHashed) SetTrace(trace bool)
func (*HexPatriciaHashed) Variant ¶
func (hph *HexPatriciaHashed) Variant() TrieVariant
type Trie ¶
type Trie interface { // RootHash produces root hash of the trie RootHash() (hash []byte, err error) // Variant returns commitment trie variant Variant() TrieVariant // Reset Drops everything from the trie Reset() ReviewKeys(pk, hk [][]byte) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error) ProcessUpdates(pk, hk [][]byte, updates []Update) (rootHash []byte, branchNodeUpdates map[string]BranchData, err error) ResetFns( branchFn func(prefix []byte) ([]byte, error), accountFn func(plainKey []byte, cell *Cell) error, storageFn func(plainKey []byte, cell *Cell) error, ) // Makes trie more verbose SetTrace(bool) }
Trie represents commitment variant.
func InitializeTrie ¶
func InitializeTrie(tv TrieVariant) Trie
type TrieVariant ¶
type TrieVariant string
const ( // VariantHexPatriciaTrie used as default commitment approach VariantHexPatriciaTrie TrieVariant = "hex-patricia-hashed" // VariantBinPatriciaTrie - Experimental mode with binary key representation VariantBinPatriciaTrie TrieVariant = "bin-patricia-hashed" )
func ParseTrieVariant ¶
func ParseTrieVariant(s string) TrieVariant
type Update ¶
type Update struct { Flags UpdateFlags Balance uint256.Int Nonce uint64 CodeHashOrStorage [length.Hash]byte ValLength int }
func (*Update) DecodeForStorage ¶
type UpdateFlags ¶
type UpdateFlags uint8
const ( CodeUpdate UpdateFlags = 1 DeleteUpdate UpdateFlags = 2 BalanceUpdate UpdateFlags = 4 NonceUpdate UpdateFlags = 8 StorageUpdate UpdateFlags = 16 )
func (UpdateFlags) String ¶
func (uf UpdateFlags) String() string