@feelyourprotocol/binarytree 8141.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +46 -0
- package/dist/cjs/binaryTree.d.ts +167 -0
- package/dist/cjs/binaryTree.d.ts.map +1 -0
- package/dist/cjs/binaryTree.js +606 -0
- package/dist/cjs/binaryTree.js.map +1 -0
- package/dist/cjs/constructors.d.ts +4 -0
- package/dist/cjs/constructors.d.ts.map +1 -0
- package/dist/cjs/constructors.js +44 -0
- package/dist/cjs/constructors.js.map +1 -0
- package/dist/cjs/db/checkpoint.d.ts +87 -0
- package/dist/cjs/db/checkpoint.d.ts.map +1 -0
- package/dist/cjs/db/checkpoint.js +257 -0
- package/dist/cjs/db/checkpoint.js.map +1 -0
- package/dist/cjs/db/index.d.ts +2 -0
- package/dist/cjs/db/index.d.ts.map +1 -0
- package/dist/cjs/db/index.js +18 -0
- package/dist/cjs/db/index.js.map +1 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/node/index.d.ts +4 -0
- package/dist/cjs/node/index.d.ts.map +1 -0
- package/dist/cjs/node/index.js +20 -0
- package/dist/cjs/node/index.js.map +1 -0
- package/dist/cjs/node/internalNode.d.ts +37 -0
- package/dist/cjs/node/internalNode.d.ts.map +1 -0
- package/dist/cjs/node/internalNode.js +92 -0
- package/dist/cjs/node/internalNode.js.map +1 -0
- package/dist/cjs/node/stemNode.d.ts +34 -0
- package/dist/cjs/node/stemNode.d.ts.map +1 -0
- package/dist/cjs/node/stemNode.js +75 -0
- package/dist/cjs/node/stemNode.js.map +1 -0
- package/dist/cjs/node/types.d.ts +35 -0
- package/dist/cjs/node/types.d.ts.map +1 -0
- package/dist/cjs/node/types.js +9 -0
- package/dist/cjs/node/types.js.map +1 -0
- package/dist/cjs/node/util.d.ts +9 -0
- package/dist/cjs/node/util.d.ts.map +1 -0
- package/dist/cjs/node/util.js +40 -0
- package/dist/cjs/node/util.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/proof.d.ts +16 -0
- package/dist/cjs/proof.d.ts.map +1 -0
- package/dist/cjs/proof.js +49 -0
- package/dist/cjs/proof.js.map +1 -0
- package/dist/cjs/types.d.ts +45 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +6 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/util.d.ts +17 -0
- package/dist/cjs/util.d.ts.map +1 -0
- package/dist/cjs/util.js +71 -0
- package/dist/cjs/util.js.map +1 -0
- package/dist/esm/binaryTree.d.ts +167 -0
- package/dist/esm/binaryTree.d.ts.map +1 -0
- package/dist/esm/binaryTree.js +602 -0
- package/dist/esm/binaryTree.js.map +1 -0
- package/dist/esm/constructors.d.ts +4 -0
- package/dist/esm/constructors.d.ts.map +1 -0
- package/dist/esm/constructors.js +41 -0
- package/dist/esm/constructors.js.map +1 -0
- package/dist/esm/db/checkpoint.d.ts +87 -0
- package/dist/esm/db/checkpoint.d.ts.map +1 -0
- package/dist/esm/db/checkpoint.js +253 -0
- package/dist/esm/db/checkpoint.js.map +1 -0
- package/dist/esm/db/index.d.ts +2 -0
- package/dist/esm/db/index.d.ts.map +1 -0
- package/dist/esm/db/index.js +2 -0
- package/dist/esm/db/index.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/node/index.d.ts +4 -0
- package/dist/esm/node/index.d.ts.map +1 -0
- package/dist/esm/node/index.js +4 -0
- package/dist/esm/node/index.js.map +1 -0
- package/dist/esm/node/internalNode.d.ts +37 -0
- package/dist/esm/node/internalNode.d.ts.map +1 -0
- package/dist/esm/node/internalNode.js +88 -0
- package/dist/esm/node/internalNode.js.map +1 -0
- package/dist/esm/node/stemNode.d.ts +34 -0
- package/dist/esm/node/stemNode.d.ts.map +1 -0
- package/dist/esm/node/stemNode.js +71 -0
- package/dist/esm/node/stemNode.js.map +1 -0
- package/dist/esm/node/types.d.ts +35 -0
- package/dist/esm/node/types.d.ts.map +1 -0
- package/dist/esm/node/types.js +6 -0
- package/dist/esm/node/types.js.map +1 -0
- package/dist/esm/node/util.d.ts +9 -0
- package/dist/esm/node/util.d.ts.map +1 -0
- package/dist/esm/node/util.js +33 -0
- package/dist/esm/node/util.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/proof.d.ts +16 -0
- package/dist/esm/proof.d.ts.map +1 -0
- package/dist/esm/proof.js +45 -0
- package/dist/esm/proof.js.map +1 -0
- package/dist/esm/types.d.ts +45 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/util.d.ts +17 -0
- package/dist/esm/util.d.ts.map +1 -0
- package/dist/esm/util.js +66 -0
- package/dist/esm/util.js.map +1 -0
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
- package/package.json +77 -0
- package/src/binaryTree.ts +742 -0
- package/src/constructors.ts +50 -0
- package/src/db/checkpoint.ts +297 -0
- package/src/db/index.ts +1 -0
- package/src/index.ts +6 -0
- package/src/node/index.ts +3 -0
- package/src/node/internalNode.ts +112 -0
- package/src/node/stemNode.ts +87 -0
- package/src/node/types.ts +41 -0
- package/src/node/util.ts +38 -0
- package/src/proof.ts +54 -0
- package/src/types.ts +58 -0
- package/src/util.ts +80 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BinaryTree = void 0;
|
|
4
|
+
const util_1 = require("@feelyourprotocol/util");
|
|
5
|
+
const debug_1 = require("debug");
|
|
6
|
+
const index_ts_1 = require("./db/index.js");
|
|
7
|
+
const internalNode_ts_1 = require("./node/internalNode.js");
|
|
8
|
+
const stemNode_ts_1 = require("./node/stemNode.js");
|
|
9
|
+
const util_ts_1 = require("./node/util.js");
|
|
10
|
+
const types_ts_1 = require("./types.js");
|
|
11
|
+
/**
|
|
12
|
+
* The basic binary tree interface, use with `import { BinaryTree } from '@feelyourprotocol/binarytree'`.
|
|
13
|
+
*
|
|
14
|
+
* A BinaryTree object can be created with the constructor method:
|
|
15
|
+
*
|
|
16
|
+
* - {@link createBinaryTree}
|
|
17
|
+
*/
|
|
18
|
+
class BinaryTree {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new binary tree.
|
|
21
|
+
* @param opts Options for instantiating the binary tree
|
|
22
|
+
*
|
|
23
|
+
* Note: in most cases, the static {@link createBinaryTree} constructor should be used. It uses the same API but provides sensible defaults
|
|
24
|
+
*/
|
|
25
|
+
constructor(opts) {
|
|
26
|
+
this._lock = new util_1.Lock();
|
|
27
|
+
this._debug = (0, debug_1.default)('binarytree:#');
|
|
28
|
+
this._opts = opts;
|
|
29
|
+
if (opts.db instanceof index_ts_1.CheckpointDB) {
|
|
30
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('Cannot pass in an instance of CheckpointDB');
|
|
31
|
+
}
|
|
32
|
+
this._db = new index_ts_1.CheckpointDB({ db: opts.db, cacheSize: opts.cacheSize });
|
|
33
|
+
this.EMPTY_TREE_ROOT = new Uint8Array(32);
|
|
34
|
+
this._hashLen = 32;
|
|
35
|
+
this._root = this.EMPTY_TREE_ROOT;
|
|
36
|
+
if (opts?.root) {
|
|
37
|
+
this.root(opts.root);
|
|
38
|
+
}
|
|
39
|
+
this.DEBUG = (0, util_1.isDebugEnabled)('ethjs');
|
|
40
|
+
this.debug = this.DEBUG
|
|
41
|
+
? (message, namespaces = []) => {
|
|
42
|
+
let log = this._debug;
|
|
43
|
+
for (const name of namespaces) {
|
|
44
|
+
log = log.extend(name);
|
|
45
|
+
}
|
|
46
|
+
log(message);
|
|
47
|
+
}
|
|
48
|
+
: (..._) => { };
|
|
49
|
+
this.DEBUG &&
|
|
50
|
+
this.debug(`Trie created:
|
|
51
|
+
|| Root: ${(0, util_1.bytesToHex)(this._root)}
|
|
52
|
+
|| Persistent: ${this._opts.useRootPersistence}
|
|
53
|
+
|| CacheSize: ${this._opts.cacheSize}
|
|
54
|
+
|| ----------------`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets and/or Sets the current root of the `tree`
|
|
58
|
+
*/
|
|
59
|
+
root(value) {
|
|
60
|
+
if (value !== undefined) {
|
|
61
|
+
if (value === null) {
|
|
62
|
+
value = this.EMPTY_TREE_ROOT;
|
|
63
|
+
}
|
|
64
|
+
if (value.length !== this._hashLen) {
|
|
65
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`Invalid root length. Roots are ${this._hashLen} bytes`);
|
|
66
|
+
}
|
|
67
|
+
this._root = value;
|
|
68
|
+
}
|
|
69
|
+
return this._root;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Checks if a given root exists.
|
|
73
|
+
*/
|
|
74
|
+
async checkRoot(root) {
|
|
75
|
+
try {
|
|
76
|
+
const value = await this._db.get(root);
|
|
77
|
+
return value !== undefined;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error.message === 'Missing node in DB') {
|
|
81
|
+
return (0, util_1.equalsBytes)(root, this.EMPTY_TREE_ROOT);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Gets values at a given binary tree `stem` and set of suffixes
|
|
90
|
+
* @param stem - the stem of the stem node where we're seeking values
|
|
91
|
+
* @param suffixes - an array of suffixes corresponding to the values desired
|
|
92
|
+
* @returns A Promise that resolves to an array of `Uint8Array`s or `null` depending on if values were found.
|
|
93
|
+
* If the stem is not found, will return an empty array.
|
|
94
|
+
*/
|
|
95
|
+
async get(stem, suffixes) {
|
|
96
|
+
if (stem.length !== 31)
|
|
97
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`expected stem with length 31; got ${stem.length}`);
|
|
98
|
+
this.DEBUG && this.debug(`Stem: ${(0, util_1.bytesToHex)(stem)}; Suffix: ${suffixes}`, ['get']);
|
|
99
|
+
const stemPath = await this.findPath(stem);
|
|
100
|
+
if (stemPath.node instanceof stemNode_ts_1.StemBinaryNode) {
|
|
101
|
+
// The retrieved stem node contains an array of 256 possible values.
|
|
102
|
+
// We read all the suffixes to get the desired values
|
|
103
|
+
const values = [];
|
|
104
|
+
for (const suffix of suffixes) {
|
|
105
|
+
const value = stemPath.node.getValue(suffix);
|
|
106
|
+
this.DEBUG &&
|
|
107
|
+
this.debug(`Suffix: ${suffix}; Value: ${value === null ? 'null' : (0, util_1.bytesToHex)(value)}`, [
|
|
108
|
+
'get',
|
|
109
|
+
]);
|
|
110
|
+
values.push(value);
|
|
111
|
+
}
|
|
112
|
+
return values;
|
|
113
|
+
}
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Stores a given `value` at the given `key` or performs a deletion if `value` is null.
|
|
118
|
+
* @param stem - the stem (must be 31 bytes) to store the value at.
|
|
119
|
+
* @param suffixes - array of suffixes at which to store individual values.
|
|
120
|
+
* @param values - the value(s) to store (or null for deletion).
|
|
121
|
+
* @returns A Promise that resolves once the value is stored.
|
|
122
|
+
*/
|
|
123
|
+
async put(stem, suffixes, values) {
|
|
124
|
+
if (stem.length !== 31)
|
|
125
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`expected stem with length 31, got ${stem.length}`);
|
|
126
|
+
if (values.length > 0 && values.length !== suffixes.length)
|
|
127
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`expected number of values (${values.length}) to equal number of suffixes (${suffixes.length})`);
|
|
128
|
+
this.DEBUG && this.debug(`Stem: ${(0, util_1.bytesToHex)(stem)}`, ['put']);
|
|
129
|
+
const putStack = []; // A stack of updated nodes starting with the stem node being updated/created to be saved to the DB
|
|
130
|
+
// If the tree is empty, initialize it.
|
|
131
|
+
if ((0, util_1.equalsBytes)(this.root(), this.EMPTY_TREE_ROOT)) {
|
|
132
|
+
await this._createInitialNode(stem, suffixes, values);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Find the path to the node (or the nearest node) for the given stem.
|
|
136
|
+
const foundPath = await this.findPath(stem);
|
|
137
|
+
// We should always at least get the root node back
|
|
138
|
+
if (foundPath.stack.length === 0)
|
|
139
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`Root node not found in trie`);
|
|
140
|
+
// Step 1) Create or update the stem node
|
|
141
|
+
let stemNode;
|
|
142
|
+
// If we found a stem node with the same stem, we'll update it.
|
|
143
|
+
if (foundPath.node &&
|
|
144
|
+
(0, util_ts_1.isStemBinaryNode)(foundPath.node) &&
|
|
145
|
+
(0, util_1.equalsBytes)(foundPath.node.stem, stem)) {
|
|
146
|
+
stemNode = foundPath.node;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Otherwise, we'll create a new stem node.
|
|
150
|
+
stemNode = stemNode_ts_1.StemBinaryNode.create(stem);
|
|
151
|
+
this.DEBUG && this.debug(`Creating new stem node for stem: ${(0, util_1.bytesToHex)(stem)}`, ['put']);
|
|
152
|
+
}
|
|
153
|
+
// Update the values in the stem node
|
|
154
|
+
for (let i = 0; i < suffixes.length; i++) {
|
|
155
|
+
const suffix = suffixes[i];
|
|
156
|
+
const value = values[i];
|
|
157
|
+
stemNode.setValue(suffix, value);
|
|
158
|
+
this.DEBUG &&
|
|
159
|
+
this.debug(`Setting value for suffix: ${suffix} to value: ${value instanceof Uint8Array ? (0, util_1.bytesToHex)(value) : value} at stem node with stem: ${(0, util_1.bytesToHex)(stem)}`, ['put']);
|
|
160
|
+
}
|
|
161
|
+
// If all values are null then we treat this as a deletion.
|
|
162
|
+
if (stemNode.values.every((val) => val === null)) {
|
|
163
|
+
if (foundPath.node !== null) {
|
|
164
|
+
this.DEBUG && this.debug(`Deleting stem node for stem: ${(0, util_1.bytesToHex)(stem)}`, ['put']);
|
|
165
|
+
putStack.push([this.merkelize(stemNode), null]);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return; // nothing to delete
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// Otherwise, we add the new or updated stemNode to the putStack
|
|
173
|
+
putStack.push([this.merkelize(stemNode), stemNode]);
|
|
174
|
+
}
|
|
175
|
+
// Get the bit representation of the stem.
|
|
176
|
+
const stemBits = (0, util_1.bytesToBits)(stemNode.stem);
|
|
177
|
+
// We keep a reference to the current "parent" node path as we update up the tree.
|
|
178
|
+
let lastUpdatedParentPath = [];
|
|
179
|
+
// Step 2: Add any needed new internal nodes if inserting a new stem.
|
|
180
|
+
// If updating an existing stem, just update the parent internal node reference
|
|
181
|
+
if (foundPath.stack.length > 1) {
|
|
182
|
+
// Pop the nearest node on the path.
|
|
183
|
+
const [nearestNode, nearestNodePath] = foundPath.stack.pop();
|
|
184
|
+
const parentPath = foundPath.stack[foundPath.stack.length - 1]?.[1] ?? [];
|
|
185
|
+
this.DEBUG && this.debug(`Adding necessary internal nodes.`, ['put']);
|
|
186
|
+
// Update the parent branch if necessary.
|
|
187
|
+
// If an update was necessary, updateBranch returns a stack of internal nodes
|
|
188
|
+
// that connect the new stem node to the previous parent inner node
|
|
189
|
+
const updated = this.updateBranch(stemNode, nearestNode, nearestNodePath, parentPath);
|
|
190
|
+
if (updated !== undefined) {
|
|
191
|
+
for (const update of updated) {
|
|
192
|
+
putStack.push([this.merkelize(update.node), update.node]);
|
|
193
|
+
lastUpdatedParentPath = update.parentPath;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Step 3: Update remaining parent node hashes
|
|
198
|
+
while (foundPath.stack.length > 1) {
|
|
199
|
+
const [node, path] = foundPath.stack.pop();
|
|
200
|
+
if ((0, util_ts_1.isInternalBinaryNode)(node)) {
|
|
201
|
+
// Set child pointer to the last internal node in the putStack (last updated internal node)
|
|
202
|
+
node.setChild(lastUpdatedParentPath[lastUpdatedParentPath.length - 1], {
|
|
203
|
+
hash: putStack[putStack.length - 1][0], // Reuse hash already computed above
|
|
204
|
+
path: lastUpdatedParentPath,
|
|
205
|
+
});
|
|
206
|
+
putStack.push([this.merkelize(node), node]); // Update node hash and add to putStack
|
|
207
|
+
lastUpdatedParentPath = path;
|
|
208
|
+
this.DEBUG &&
|
|
209
|
+
this.debug(`Updated parent internal node hash for path ${path.join(',')}`, ['put']);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`Expected internal node at path ${path.join(',')}, got ${node}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Step 4: Update the root node.
|
|
216
|
+
let rootNode = foundPath.stack.pop()[0]; // The root node.
|
|
217
|
+
const childReference = putStack[putStack.length - 1][1];
|
|
218
|
+
if ((0, util_ts_1.isStemBinaryNode)(rootNode)) {
|
|
219
|
+
// If the root is a stem node but its stem differs from the one we're updating,
|
|
220
|
+
// then we need to split the root. Per the spec, when two stems share a common prefix,
|
|
221
|
+
// we create one internal node per bit in that common prefix, and then at the first
|
|
222
|
+
// divergence, an internal node that points to both stem nodes.
|
|
223
|
+
if (!(0, util_1.equalsBytes)(rootNode.stem, stem)) {
|
|
224
|
+
this.DEBUG && this.debug(`Root stem differs from new stem. Splitting root.`, ['put']);
|
|
225
|
+
const rootBits = (0, util_1.bytesToBits)(rootNode.stem);
|
|
226
|
+
const commonPrefixLength = (0, util_1.matchingBitsLength)(rootBits, stemBits);
|
|
227
|
+
// Create the split node at the divergence bit.
|
|
228
|
+
const splitNode = internalNode_ts_1.InternalBinaryNode.create();
|
|
229
|
+
const branchForNew = stemBits[commonPrefixLength];
|
|
230
|
+
const branchForExisting = rootBits[commonPrefixLength];
|
|
231
|
+
splitNode.setChild(branchForNew, {
|
|
232
|
+
hash: this.merkelize(stemNode),
|
|
233
|
+
path: stemBits,
|
|
234
|
+
});
|
|
235
|
+
splitNode.setChild(branchForExisting, {
|
|
236
|
+
hash: this.merkelize(rootNode),
|
|
237
|
+
path: rootBits,
|
|
238
|
+
});
|
|
239
|
+
let newRoot = splitNode;
|
|
240
|
+
// If there is a common prefix (i.e. commonPrefixLength > 0), we build a chain
|
|
241
|
+
// of internal nodes representing that prefix.
|
|
242
|
+
for (let depth = commonPrefixLength - 1; depth >= 0; depth--) {
|
|
243
|
+
this.DEBUG && this.debug(`Creating internal node at depth ${depth}`, ['put']);
|
|
244
|
+
putStack.push([this.merkelize(newRoot), newRoot]);
|
|
245
|
+
const parent = internalNode_ts_1.InternalBinaryNode.create();
|
|
246
|
+
// At each level, the branch is determined by the bit of the new stem at position i.
|
|
247
|
+
parent.setChild(stemBits[depth], {
|
|
248
|
+
hash: this.merkelize(newRoot),
|
|
249
|
+
path: stemBits.slice(0, depth + 1),
|
|
250
|
+
});
|
|
251
|
+
newRoot = parent;
|
|
252
|
+
}
|
|
253
|
+
// Now newRoot is an internal node chain that represents the entire common prefix,
|
|
254
|
+
// ending in a split node that distinguishes the two different stems.
|
|
255
|
+
rootNode = newRoot;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// For an internal root node, we assign the last update child reference to the root.
|
|
260
|
+
if (childReference !== null) {
|
|
261
|
+
rootNode.setChild(stemBits[0], childReference !== null
|
|
262
|
+
? {
|
|
263
|
+
hash: this.merkelize(childReference),
|
|
264
|
+
path: (0, util_ts_1.isStemBinaryNode)(childReference) ? stemBits : lastUpdatedParentPath,
|
|
265
|
+
}
|
|
266
|
+
: null);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
this.root(this.merkelize(rootNode));
|
|
270
|
+
putStack.push([this._root, rootNode]);
|
|
271
|
+
this.DEBUG && this.debug(`Updated root hash to ${(0, util_1.bytesToHex)(this._root)}`, ['put']);
|
|
272
|
+
await this.saveStack(putStack);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Helper method for updating or creating the parent internal node for a given stem node.
|
|
276
|
+
* If the nearest node is a stem node with a different stem, a new internal node is created
|
|
277
|
+
* to branch at the first differing bit.
|
|
278
|
+
* If the nearest node is an internal node, its child reference is updated.
|
|
279
|
+
*
|
|
280
|
+
* @param stemNode - The child stem node that will be referenced by the new/updated internal node.
|
|
281
|
+
* @param nearestNode - The nearest node to the new stem node.
|
|
282
|
+
* @param pathToNode - The path (in bits) to `nearestNode` as known from the trie.
|
|
283
|
+
* @returns An array of nodes and their partial paths from the new stem node to the branch parent node
|
|
284
|
+
* or `undefined` if no changes were made.
|
|
285
|
+
*/
|
|
286
|
+
updateBranch(stemNode, nearestNode, pathToNode, pathToParent) {
|
|
287
|
+
const stemBits = (0, util_1.bytesToBits)(stemNode.stem);
|
|
288
|
+
if ((0, util_ts_1.isStemBinaryNode)(nearestNode)) {
|
|
289
|
+
// For two different stems, find the first differing bit.
|
|
290
|
+
const nearestNodeStemBits = (0, util_1.bytesToBits)(nearestNode.stem);
|
|
291
|
+
const diffIndex = (0, util_1.matchingBitsLength)(stemBits, nearestNodeStemBits);
|
|
292
|
+
const parentDiffIndex = (0, util_1.matchingBitsLength)(pathToNode, pathToParent);
|
|
293
|
+
const newInternal = internalNode_ts_1.InternalBinaryNode.create();
|
|
294
|
+
// Set the child pointer for the new stem node using the bit at diffIndex.
|
|
295
|
+
newInternal.setChild(stemBits[diffIndex], {
|
|
296
|
+
hash: this.merkelize(stemNode),
|
|
297
|
+
path: stemBits,
|
|
298
|
+
});
|
|
299
|
+
// Set the child pointer for the existing stem node.
|
|
300
|
+
newInternal.setChild(nearestNodeStemBits[diffIndex], {
|
|
301
|
+
hash: this.merkelize(nearestNode),
|
|
302
|
+
path: nearestNodeStemBits,
|
|
303
|
+
});
|
|
304
|
+
const putStack = [{ node: newInternal, parentPath: stemBits.slice(0, diffIndex) }];
|
|
305
|
+
let parent = newInternal;
|
|
306
|
+
for (let depth = diffIndex - 1; depth > parentDiffIndex; depth--) {
|
|
307
|
+
this.DEBUG && this.debug(`Creating internal node at depth ${depth}`, ['put']);
|
|
308
|
+
const newParent = internalNode_ts_1.InternalBinaryNode.create();
|
|
309
|
+
// At each level, the branch is determined by the bit of the new stem at position i.
|
|
310
|
+
newParent.setChild(stemBits[depth], {
|
|
311
|
+
hash: this.merkelize(parent),
|
|
312
|
+
path: stemBits.slice(0, depth + 1),
|
|
313
|
+
});
|
|
314
|
+
putStack.push({ node: newParent, parentPath: stemBits.slice(0, depth) });
|
|
315
|
+
parent = newParent;
|
|
316
|
+
}
|
|
317
|
+
// Return the stack of new internal nodes that connect the new stem node to the previous parent inner node
|
|
318
|
+
return putStack;
|
|
319
|
+
}
|
|
320
|
+
else if ((0, util_ts_1.isInternalBinaryNode)(nearestNode)) {
|
|
321
|
+
// For an internal node, determine the branch index using the parent's known path length.
|
|
322
|
+
const branchIndex = stemBits[pathToNode.length];
|
|
323
|
+
nearestNode.setChild(branchIndex, {
|
|
324
|
+
hash: this.merkelize(stemNode),
|
|
325
|
+
path: stemBits,
|
|
326
|
+
});
|
|
327
|
+
return [{ node: nearestNode, parentPath: pathToNode }];
|
|
328
|
+
}
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Tries to find a path to the node for the given key.
|
|
333
|
+
* It returns a `Path` object containing:
|
|
334
|
+
* - `node`: the found node (if any),
|
|
335
|
+
* - `stack`: an array of tuples [node, path] representing the nodes encountered,
|
|
336
|
+
* - `remaining`: the bits of the key that were not matched.
|
|
337
|
+
*
|
|
338
|
+
* @param keyInBytes - the search key as a byte array.
|
|
339
|
+
* @returns A Promise that resolves to a Path object.
|
|
340
|
+
*/
|
|
341
|
+
async findPath(keyInBytes) {
|
|
342
|
+
const keyInBits = (0, util_1.bytesToBits)(keyInBytes);
|
|
343
|
+
this.DEBUG && this.debug(`Searching for key: ${(0, util_1.bytesToHex)(keyInBytes)}`, ['find_path']);
|
|
344
|
+
const result = {
|
|
345
|
+
node: null,
|
|
346
|
+
stack: [],
|
|
347
|
+
remaining: keyInBits,
|
|
348
|
+
};
|
|
349
|
+
// If tree is empty, return empty path.
|
|
350
|
+
if ((0, util_1.equalsBytes)(this.root(), this.EMPTY_TREE_ROOT))
|
|
351
|
+
return result;
|
|
352
|
+
// Get the root node.
|
|
353
|
+
let rawNode = await this._db.get(this.root());
|
|
354
|
+
if (rawNode === undefined)
|
|
355
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('root node should exist');
|
|
356
|
+
const rootNode = (0, util_ts_1.decodeBinaryNode)(rawNode);
|
|
357
|
+
this.DEBUG && this.debug(`Starting with Root Node: [${(0, util_1.bytesToHex)(this.root())}]`, ['find_path']);
|
|
358
|
+
// Treat the root as being at an empty path.
|
|
359
|
+
result.stack.push([rootNode, []]);
|
|
360
|
+
// If the root node is a stem node, we're done.
|
|
361
|
+
if ((0, util_ts_1.isStemBinaryNode)(rootNode)) {
|
|
362
|
+
this.DEBUG && this.debug(`Found stem node at root.`, ['find_path']);
|
|
363
|
+
if ((0, util_1.equalsBytes)(keyInBytes, rootNode.stem)) {
|
|
364
|
+
result.node = rootNode;
|
|
365
|
+
result.remaining = [];
|
|
366
|
+
}
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
// The root is an internal node. Determine the branch to follow using the first bit of the key
|
|
370
|
+
let childNode = rootNode.getChild(keyInBits[0]);
|
|
371
|
+
let finished = false;
|
|
372
|
+
while (!finished) {
|
|
373
|
+
if (childNode === null)
|
|
374
|
+
break;
|
|
375
|
+
// Look up child node by its node hash.
|
|
376
|
+
rawNode = await this._db.get(childNode.hash);
|
|
377
|
+
if (rawNode === undefined)
|
|
378
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`missing node at ${childNode.path}`);
|
|
379
|
+
const decodedNode = (0, util_ts_1.decodeBinaryNode)(rawNode);
|
|
380
|
+
// Determine how many bits match between keyInBits and the stored path in childNode.
|
|
381
|
+
const matchingKeyLength = (0, util_1.matchingBitsLength)(keyInBits, childNode.path);
|
|
382
|
+
// If we have an exact match (i.e. the stored path equals a prefix of the key)
|
|
383
|
+
// and either the key is fully consumed or we have reached a stem node, we stop.
|
|
384
|
+
if (matchingKeyLength === childNode.path.length &&
|
|
385
|
+
(matchingKeyLength === keyInBits.length || (0, util_ts_1.isStemBinaryNode)(decodedNode))) {
|
|
386
|
+
finished = true;
|
|
387
|
+
if (matchingKeyLength === keyInBits.length &&
|
|
388
|
+
(0, util_1.equalsBits)(keyInBits, childNode.path) === true) {
|
|
389
|
+
// We found the sought node
|
|
390
|
+
this.DEBUG &&
|
|
391
|
+
this.debug(`Path ${(0, util_1.bytesToHex)(keyInBytes)} - found full path to node ${(0, util_1.bytesToHex)(this.merkelize(decodedNode))}.`, ['find_path']);
|
|
392
|
+
result.node = decodedNode;
|
|
393
|
+
result.remaining = [];
|
|
394
|
+
return result;
|
|
395
|
+
}
|
|
396
|
+
// We didn't find the sought node so record the unmatched tail of the key.
|
|
397
|
+
result.remaining = keyInBits.slice(matchingKeyLength);
|
|
398
|
+
result.stack.push([decodedNode, childNode.path]);
|
|
399
|
+
return result;
|
|
400
|
+
}
|
|
401
|
+
// Otherwise, push this internal node and continue.
|
|
402
|
+
result.stack.push([decodedNode, keyInBits.slice(0, matchingKeyLength)]);
|
|
403
|
+
this.DEBUG &&
|
|
404
|
+
this.debug(`Partial Path ${keyInBits.slice(0, matchingKeyLength)} - found next node in path ${(0, util_1.bytesToHex)(this.merkelize(decodedNode))}.`, ['find_path']);
|
|
405
|
+
// If the decoded node is not internal, then we cannot traverse further.
|
|
406
|
+
if (!(0, util_ts_1.isInternalBinaryNode)(decodedNode)) {
|
|
407
|
+
result.remaining = keyInBits.slice(matchingKeyLength);
|
|
408
|
+
finished = true;
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
// The next branch is determined by the next bit after the matched prefix.
|
|
412
|
+
const childIndex = keyInBits[matchingKeyLength];
|
|
413
|
+
childNode = decodedNode.getChild(childIndex);
|
|
414
|
+
if (childNode === null) {
|
|
415
|
+
result.remaining = keyInBits.slice(matchingKeyLength);
|
|
416
|
+
finished = true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
this.DEBUG &&
|
|
420
|
+
this.debug(`Found partial path ${(0, util_1.bytesToHex)((0, util_1.bitsToBytes)(keyInBits.slice(256 - result.remaining.length)))} but sought node is not present in trie.`, ['find_path']);
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Deletes a given `key` from the tree.
|
|
425
|
+
* @param stem - the stem of the stem node to delete from
|
|
426
|
+
* @param suffixes - the suffixes to delete
|
|
427
|
+
* @returns A Promise that resolves once the key is deleted.
|
|
428
|
+
*/
|
|
429
|
+
async del(stem, suffixes) {
|
|
430
|
+
this.DEBUG && this.debug(`Stem: ${(0, util_1.bytesToHex)(stem)}; Suffix(es): ${suffixes}`, ['del']);
|
|
431
|
+
await this.put(stem, suffixes, new Array(suffixes.length).fill(null));
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Create empty root node for initializing an empty tree.
|
|
435
|
+
*/
|
|
436
|
+
async createRootNode() {
|
|
437
|
+
const rootNode = null;
|
|
438
|
+
this.DEBUG && this.debug(`No root node. Creating new root node`, ['initialize']);
|
|
439
|
+
this.root(this.merkelize(rootNode));
|
|
440
|
+
await this.saveStack([[this.root(), rootNode]]);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Creates the initial node from an empty tree.
|
|
445
|
+
* @private
|
|
446
|
+
*/
|
|
447
|
+
async _createInitialNode(stem, indexes, values) {
|
|
448
|
+
const initialNode = stemNode_ts_1.StemBinaryNode.create(stem);
|
|
449
|
+
for (let i = 0; i < indexes.length; i++) {
|
|
450
|
+
initialNode.setValue(indexes[i], values[i]);
|
|
451
|
+
}
|
|
452
|
+
this.root(this.merkelize(initialNode));
|
|
453
|
+
await this._db.put(this.root(), initialNode.serialize());
|
|
454
|
+
await this.persistRoot();
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Saves a stack of nodes to the database.
|
|
458
|
+
*
|
|
459
|
+
* @param putStack - an array of tuples of keys (the partial path of the node in the trie) and nodes (BinaryNodes)
|
|
460
|
+
*/
|
|
461
|
+
async saveStack(putStack) {
|
|
462
|
+
const opStack = putStack.map(([key, node]) => {
|
|
463
|
+
return {
|
|
464
|
+
type: node !== null ? 'put' : 'del',
|
|
465
|
+
key,
|
|
466
|
+
value: node !== null ? node.serialize() : null,
|
|
467
|
+
};
|
|
468
|
+
});
|
|
469
|
+
await this._db.batch(opStack);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Creates a proof from a tree and key that can be verified using {@link BinaryTree.verifyBinaryProof}.
|
|
473
|
+
* @param key a 32 byte binary tree key (31 byte stem + 1 byte suffix)
|
|
474
|
+
*/
|
|
475
|
+
async createBinaryProof(key) {
|
|
476
|
+
this.DEBUG && this.debug(`creating proof for ${(0, util_1.bytesToHex)(key)}`, ['create_proof']);
|
|
477
|
+
// We only use the stem (i.e. the first 31 bytes) to find the path to the node
|
|
478
|
+
const { node, stack } = await this.findPath(key.slice(0, 31));
|
|
479
|
+
const proof = stack.map(([node, _]) => node.serialize());
|
|
480
|
+
if (node !== null) {
|
|
481
|
+
// If node is found, add node to proof
|
|
482
|
+
proof.push(node.serialize());
|
|
483
|
+
}
|
|
484
|
+
return proof;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* The `data` event is given an `Object` that has two properties; the `key` and the `value`. Both should be Uint8Arrays.
|
|
488
|
+
* @return Returns a [stream](https://nodejs.org/dist/latest-v12.x/docs/api/stream.html#stream_class_stream_readable) of the contents of the `tree`
|
|
489
|
+
*/
|
|
490
|
+
createReadStream() {
|
|
491
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('Not implemented');
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Returns a copy of the underlying tree.
|
|
495
|
+
*
|
|
496
|
+
* Note on db: the copy will create a reference to the
|
|
497
|
+
* same underlying database.
|
|
498
|
+
*
|
|
499
|
+
* Note on cache: for memory reasons a copy will not
|
|
500
|
+
* recreate a new LRU cache but initialize with cache
|
|
501
|
+
* being deactivated.
|
|
502
|
+
*
|
|
503
|
+
* @param includeCheckpoints - If true and during a checkpoint, the copy will contain the checkpointing metadata and will use the same scratch as underlying db.
|
|
504
|
+
*/
|
|
505
|
+
shallowCopy(includeCheckpoints = true) {
|
|
506
|
+
const tree = new BinaryTree({
|
|
507
|
+
...this._opts,
|
|
508
|
+
db: this._db.db.shallowCopy(),
|
|
509
|
+
root: this.root(),
|
|
510
|
+
cacheSize: 0,
|
|
511
|
+
});
|
|
512
|
+
if (includeCheckpoints && this.hasCheckpoints()) {
|
|
513
|
+
tree._db.setCheckpoints(this._db.checkpoints);
|
|
514
|
+
}
|
|
515
|
+
return tree;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Persists the root hash in the underlying database
|
|
519
|
+
*/
|
|
520
|
+
async persistRoot() {
|
|
521
|
+
if (this._opts.useRootPersistence === true) {
|
|
522
|
+
await this._db.put(types_ts_1.ROOT_DB_KEY, this.root());
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Is the tree during a checkpoint phase?
|
|
527
|
+
*/
|
|
528
|
+
hasCheckpoints() {
|
|
529
|
+
return this._db.hasCheckpoints();
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Creates a checkpoint that can later be reverted to or committed.
|
|
533
|
+
* After this is called, all changes can be reverted until `commit` is called.
|
|
534
|
+
*/
|
|
535
|
+
checkpoint() {
|
|
536
|
+
this._db.checkpoint(this.root());
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Commits a checkpoint to disk, if current checkpoint is not nested.
|
|
540
|
+
* If nested, only sets the parent checkpoint as current checkpoint.
|
|
541
|
+
* @throws If not during a checkpoint phase
|
|
542
|
+
*/
|
|
543
|
+
async commit() {
|
|
544
|
+
if (!this.hasCheckpoints()) {
|
|
545
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('trying to commit when not checkpointed');
|
|
546
|
+
}
|
|
547
|
+
await this._lock.acquire();
|
|
548
|
+
await this._db.commit();
|
|
549
|
+
await this.persistRoot();
|
|
550
|
+
this._lock.release();
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Reverts the tree to the state it was at when `checkpoint` was first called.
|
|
554
|
+
* If during a nested checkpoint, sets root to most recent checkpoint, and sets
|
|
555
|
+
* parent checkpoint as current.
|
|
556
|
+
*/
|
|
557
|
+
async revert() {
|
|
558
|
+
if (!this.hasCheckpoints()) {
|
|
559
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('trying to revert when not checkpointed');
|
|
560
|
+
}
|
|
561
|
+
await this._lock.acquire();
|
|
562
|
+
this.root(await this._db.revert());
|
|
563
|
+
await this.persistRoot();
|
|
564
|
+
this._lock.release();
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Flushes all checkpoints, restoring the initial checkpoint state.
|
|
568
|
+
*/
|
|
569
|
+
flushCheckpoints() {
|
|
570
|
+
this._db.checkpoints = [];
|
|
571
|
+
}
|
|
572
|
+
hash(msg) {
|
|
573
|
+
// As per spec, if value is null or a 64-byte array of 0s, hash(msg) is a 32-byte array of 0s
|
|
574
|
+
if (msg === null || (msg.length === 64 && msg.every((byte) => byte === 0))) {
|
|
575
|
+
return new Uint8Array(32);
|
|
576
|
+
}
|
|
577
|
+
if (msg.length !== 32 && msg.length !== 64) {
|
|
578
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('Data must be 32 or 64 bytes');
|
|
579
|
+
}
|
|
580
|
+
return Uint8Array.from(this._opts.hashFunction.call(undefined, msg));
|
|
581
|
+
}
|
|
582
|
+
merkelize(node) {
|
|
583
|
+
if (node === null) {
|
|
584
|
+
return new Uint8Array(32);
|
|
585
|
+
}
|
|
586
|
+
if ((0, util_ts_1.isInternalBinaryNode)(node)) {
|
|
587
|
+
const [leftChild, rightChild] = node.children;
|
|
588
|
+
return this.hash((0, util_1.concatBytes)(leftChild === null ? this.hash(null) : leftChild.hash, rightChild === null ? this.hash(null) : rightChild.hash));
|
|
589
|
+
}
|
|
590
|
+
// Otherwise, it's a stem node.
|
|
591
|
+
// Map each value in node.values through the hash function.
|
|
592
|
+
let currentLayerHashes = node.values.map((value) => this.hash(value));
|
|
593
|
+
// While there is more than one hash at the current layer, combine them pairwise.
|
|
594
|
+
while (currentLayerHashes.length > 1) {
|
|
595
|
+
const newLayerHashes = [];
|
|
596
|
+
for (let i = 0; i < currentLayerHashes.length; i += 2) {
|
|
597
|
+
newLayerHashes.push(this.hash((0, util_1.concatBytes)(currentLayerHashes[i], currentLayerHashes[i + 1])));
|
|
598
|
+
}
|
|
599
|
+
currentLayerHashes = newLayerHashes;
|
|
600
|
+
}
|
|
601
|
+
// Return the hash of the concatenation of node.stem appended with 00 and the final level hash.
|
|
602
|
+
return this.hash((0, util_1.concatBytes)((0, util_1.setLengthRight)(node.stem, 32), currentLayerHashes[0]));
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
exports.BinaryTree = BinaryTree;
|
|
606
|
+
//# sourceMappingURL=binaryTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binaryTree.js","sourceRoot":"","sources":["../../src/binaryTree.ts"],"names":[],"mappings":";;;AAAA,2CAYyB;AACzB,iCAAyB;AAEzB,4CAA4C;AAC5C,4DAA2D;AAC3D,oDAAmD;AACnD,4CAAyF;AACzF,yCAA6D;AAY7D;;;;;;GAMG;AACH,MAAa,UAAU;IAerB;;;;;OAKG;IACH,YAAY,IAAoB;QAZtB,UAAK,GAAG,IAAI,WAAI,EAAE,CAAA;QAIlB,WAAM,GAAa,IAAA,eAAK,EAAC,cAAc,CAAC,CAAA;QAShD,IAAI,CAAC,KAAK,GAA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