ethereumjs-monorepo

@ethereumjs/trie

@ethereumjs/trie

Table of contents

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

Checkpoint

Ƭ Checkpoint: Object

Type declaration

Name Type
keyValueMap Map<string, Uint8Array | undefined>
root Uint8Array

Defined in

packages/trie/src/types.ts:135


EmbeddedNode

Ƭ EmbeddedNode: Uint8Array | Uint8Array[]

Defined in

packages/trie/src/types.ts:13


FoundNodeFunction

Ƭ FoundNodeFunction: (nodeRef: Uint8Array, node: TrieNode | null, key: Nibbles, walkController: WalkController) => void

Type declaration

▸ (nodeRef, node, key, walkController): void

Parameters
Name Type
nodeRef Uint8Array
node TrieNode | null
key Nibbles
walkController WalkController
Returns

void

Defined in

packages/trie/src/types.ts:29


HashKeysFunction

Ƭ HashKeysFunction: (msg: Uint8Array) => Uint8Array

Type declaration

▸ (msg): Uint8Array

Parameters
Name Type
msg Uint8Array
Returns

Uint8Array

Defined in

packages/trie/src/types.ts:36


Nibbles

Ƭ Nibbles: number[]

Defined in

packages/trie/src/types.ts:9


Proof

Ƭ Proof: Uint8Array[]

Defined in

packages/trie/src/types.ts:15


TrieNode

Ƭ TrieNode: BranchNode | ExtensionNode | LeafNode

Defined in

packages/trie/src/types.ts:7


TrieOptsWithDefaults

Ƭ TrieOptsWithDefaults: TrieOpts & { cacheSize: number ; useKeyHashing: boolean ; useKeyHashingFunction: HashKeysFunction ; useNodePruning: boolean ; useRootPersistence: boolean }

Defined in

packages/trie/src/types.ts:105

Variables

ROOT_DB_KEY

Const ROOT_DB_KEY: Uint8Array

Defined in

packages/trie/src/types.ts:142

Functions

byteTypeToNibbleType

byteTypeToNibbleType(key): Nibbles

Turns each byte into a single nibble, only extracting the lower nibble of each byte

Parameters

Name Type Description
key Uint8Array Uint8Array typed byte array

Returns

Nibbles

Nibble typed nibble array

Defined in

packages/trie/src/util/encoding.ts:144


bytesToNibbles

bytesToNibbles(str): Uint8Array

Parameters

Name Type
str Uint8Array

Returns

Uint8Array

Defined in

packages/trie/src/util/encoding.ts:77


compactBytesToNibbles

compactBytesToNibbles(compact): Uint8Array

Parameters

Name Type
compact Uint8Array

Returns

Uint8Array

Defined in

packages/trie/src/util/encoding.ts:91


decodeNode

decodeNode(node): BranchNode | ExtensionNode | LeafNode

Parameters

Name Type
node Uint8Array

Returns

BranchNode | ExtensionNode | LeafNode

Defined in

packages/trie/src/node/util.ts:30


decodeRawNode

decodeRawNode(raw): BranchNode | ExtensionNode | LeafNode

Parameters

Name Type
raw Uint8Array[]

Returns

BranchNode | ExtensionNode | LeafNode

Defined in

packages/trie/src/node/util.ts:12


genesisStateRoot

genesisStateRoot(genesisState): Promise<Uint8Array>

Derives the stateRoot of the genesis block based on genesis allocations

Parameters

Name Type
genesisState GenesisState

Returns

Promise<Uint8Array>

Defined in

packages/trie/src/util/genesisState.ts:12


hasTerminator

hasTerminator(nibbles): boolean

Parameters

Name Type
nibbles Uint8Array

Returns

boolean

boolean indicating if input hex nibble sequence has terminator indicating leaf-node terminator is represented with 16 because a nibble ranges from 0 - 15(f)

Defined in

packages/trie/src/util/encoding.ts:31


hexToKeybytes

hexToKeybytes(hex): Uint8Array

Parameters

Name Type
hex Uint8Array

Returns

Uint8Array

Defined in

packages/trie/src/util/encoding.ts:41


isRawNode

isRawNode(n): n is Uint8Array[]

Parameters

Name Type
n Uint8Array | NestedUint8Array

Returns

n is Uint8Array[]

Defined in

packages/trie/src/node/util.ts:26


mergeAndFormatKeyPaths

mergeAndFormatKeyPaths(pathStrings): Uint8Array[][]

Parameters

Name Type
pathStrings string[]

Returns

Uint8Array[][]

Defined in

packages/trie/src/util/encoding.ts:175


nibbleTypeToByteType

nibbleTypeToByteType(arr): Uint8Array

Converts each nibble into a single byte

Parameters

Name Type Description
arr Nibbles Nibble typed nibble array

Returns

Uint8Array

Uint8Array typed byte array

Defined in

packages/trie/src/util/encoding.ts:128


nibbleTypeToPackedBytes

nibbleTypeToPackedBytes(arr): Uint8Array

Packs every two nibbles into a single byte

Parameters

Name Type Description
arr Nibbles Nibble typed nibble array

Returns

Uint8Array

Uint8Array typed byte array

Defined in

packages/trie/src/util/encoding.ts:112


nibblesToBytes

nibblesToBytes(nibbles, bytes): void

Parameters

Name Type
nibbles Uint8Array
bytes Uint8Array

Returns

void

Defined in

packages/trie/src/util/encoding.ts:35


nibblesToCompactBytes

nibblesToCompactBytes(nibbles): Uint8Array

Parameters

Name Type
nibbles Uint8Array

Returns

Uint8Array

Defined in

packages/trie/src/util/encoding.ts:55


pathToHexKey

pathToHexKey(path, extension, retType): Uint8Array

Takes a string path and extends it by the given extension nibbles

Parameters

Name Type Description
path string String node path
extension Nibbles nibbles to extend by
retType string string indicating whether to return the key in “keybyte” or “hex” encoding

Returns

Uint8Array

hex-encoded key

Defined in

packages/trie/src/util/encoding.ts:164


verifyRangeProof

verifyRangeProof(rootHash, firstKey, lastKey, keys, values, proof, useKeyHashingFunction): Promise<boolean>

verifyRangeProof checks whether the given leaf nodes and edge proof can prove the given trie leaves range is matched with the specific root.

There are four situations:

NOTE: Currently only supports verification when the length of firstKey and lastKey are the same.

Parameters

Name Type Description
rootHash Uint8Array root hash of state trie this proof is being verified against.
firstKey null | Nibbles first key of range being proven.
lastKey null | Nibbles last key of range being proven.
keys Nibbles[] key list of leaf data being proven.
values Uint8Array[] value list of leaf data being proven, one-to-one correspondence with keys.
proof null | Uint8Array[] proof node list, if all-elements-proof where no proof is needed, proof should be null, and both firstKey and lastKey must be null as well
useKeyHashingFunction HashKeysFunction -

Returns

Promise<boolean>

a flag to indicate whether there exists more trie node in the trie

Defined in

packages/trie/src/proof/range.ts:411