@ethereumjs/verkle / VerkleTree
Defined in: verkleTree.ts:31
The basic verkle tree interface, use with import { VerkleTree } from '@ethereumjs/verkle'
.
new VerkleTree(
opts
):VerkleTree
Defined in: verkleTree.ts:55
Creates a new verkle tree.
Options for instantiating the verkle tree
Note: in most cases, the static createVerkleTree constructor should be used. It uses the same API but provides sensible defaults
VerkleTree
_opts:
VerkleTreeOpts
Defined in: verkleTree.ts:32
EMPTY_TREE_ROOT:
Uint8Array
Defined in: verkleTree.ts:35
The root for an empty tree
checkpoint():
void
Defined in: verkleTree.ts:639
Creates a checkpoint that can later be reverted to or committed.
After this is called, all changes can be reverted until commit
is called.
void
checkRoot(
root
):Promise
<boolean
>
Defined in: verkleTree.ts:115
Checks if a given root exists.
Uint8Array
Promise
<boolean
>
commit():
Promise
<void
>
Defined in: verkleTree.ts:648
Commits a checkpoint to disk, if current checkpoint is not nested. If nested, only sets the parent checkpoint as current checkpoint.
Promise
<void
>
If not during a checkpoint phase
createReadStream():
any
Defined in: verkleTree.ts:589
The data
event is given an Object
that has two properties; the key
and the value
. Both should be Uint8Arrays.
any
Returns a stream of the contents of the tree
createRootNode():
Promise
<void
>
Defined in: verkleTree.ts:523
Create empty root node for initializing an empty tree.
Promise
<void
>
createVerkleProof(
_key
):Promise
<Proof
>
Defined in: verkleTree.ts:565
Creates a proof from a tree and key that can be verified using VerkleTree.verifyVerkleProof.
Uint8Array
Promise
<Proof
>
del(
stem
,suffixes
):Promise
<void
>
Defined in: verkleTree.ts:329
Uint8Array
number
[]
Promise
<void
>
findPath(
key
):Promise
<Path
>
Defined in: verkleTree.ts:424
Tries to find a path to the node for the given key.
It returns a stack
of nodes to the closest node.
Uint8Array
the search key
Promise
<Path
>
flushCheckpoints():
void
Defined in: verkleTree.ts:678
Flushes all checkpoints, restoring the initial checkpoint state.
void
fromProof(
_proof
):Promise
<void
>
Defined in: verkleTree.ts:557
Saves the nodes from a proof into the tree.
Promise
<void
>
get(
stem
,suffixes
):Promise
<(undefined
|Uint8Array
<ArrayBufferLike
>)[]>
Defined in: verkleTree.ts:135
Gets values at a given verkle stem
and set of suffixes
Uint8Array
the stem of the leaf node where we’re seeking values
number
[]
an array of suffixes corresponding to the values desired
Promise
<(undefined
| Uint8Array
<ArrayBufferLike
>)[]>
A Promise that resolves to an array of Uint8Array
s if a value
was found or undefined
if no value was found at a given suffixes.
hasCheckpoints():
boolean
Defined in: verkleTree.ts:631
Is the tree during a checkpoint phase?
boolean
persistRoot():
Promise
<void
>
Defined in: verkleTree.ts:622
Persists the root hash in the underlying database
Promise
<void
>
put(
stem
,suffixes
,values
):Promise
<void
>
Defined in: verkleTree.ts:166
Stores given values
at the given stem
and suffixes
or do a delete if value
is empty Uint8Array
Uint8Array
number
[]
array of suffixes at which to store individual values
(0
| Uint8Array
<ArrayBufferLike
>)[] = []
Promise
<void
>
A Promise that resolves once value(s) are stored.
revert():
Promise
<void
>
Defined in: verkleTree.ts:664
Reverts the tree to the state it was at when checkpoint
was first called.
If during a nested checkpoint, sets root to most recent checkpoint, and sets
parent checkpoint as current.
Promise
<void
>
root(
value?
):Uint8Array
Defined in: verkleTree.ts:96
Gets and/or Sets the current root of the tree
null |
Uint8Array <ArrayBufferLike > |
Uint8Array
saveStack(
putStack
):Promise
<void
>
Defined in: verkleTree.ts:542
Saves a stack of nodes to the database.
[Uint8Array
<ArrayBufferLike
>, null
| VerkleNode
][]
an array of tuples of keys (the partial path of the node in the trie) and nodes (VerkleNodes)
Promise
<void
>
shallowCopy(
includeCheckpoints
):VerkleTree
Defined in: verkleTree.ts:605
Returns a copy of the underlying tree.
Note on db: the copy will create a reference to the same underlying database.
Note on cache: for memory reasons a copy will not recreate a new LRU cache but initialize with cache being deactivated.
boolean
= true
If true and during a checkpoint, the copy will contain the checkpointing metadata and will use the same scratch as underlying db.
VerkleTree
updateParent(
leafNode
,nearestNode
,pathToNode
):Promise
<undefined
| {lastPath
:Uint8Array
;node
:VerkleNode
; }>
Defined in: verkleTree.ts:341
Helper method for updating or creating the parent internal node for a given leaf node
the child leaf node that will be referenced by the new/updated internal node returned by this method
the nearest node to the new leaf node
Uint8Array
the path to nearestNode
Promise
<undefined
| { lastPath
: Uint8Array
; node
: VerkleNode
; }>
a tuple of the updated parent node and the path to that parent (i.e. the partial stem of the leaf node that leads to the parent)
verifyVerkleProof(
_rootHash
,_key
,_proof
):Promise
<null
|Uint8Array
<ArrayBufferLike
>>
Defined in: verkleTree.ts:577
Verifies a proof.
Uint8Array
Uint8Array
Promise
<null
| Uint8Array
<ArrayBufferLike
>>
The value from the key, or null if valid proof of non-existence.
If proof is found to be invalid.