webevm 0.6.0 → 0.8.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/README.md +148 -63
- package/dist/derived-trie.d.ts +38 -0
- package/dist/derived-trie.d.ts.map +1 -0
- package/dist/derived-trie.js +187 -0
- package/dist/derived-trie.js.map +1 -0
- package/dist/engine.d.ts +1 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +2 -3
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +45 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +1125 -141
- package/dist/node.js.map +1 -1
- package/dist/revm-state-store.d.ts +5 -0
- package/dist/revm-state-store.d.ts.map +1 -1
- package/dist/revm-state-store.js +42 -13
- package/dist/revm-state-store.js.map +1 -1
- package/dist/revm.d.ts.map +1 -1
- package/dist/revm.js +5 -19
- package/dist/revm.js.map +1 -1
- package/dist/state-manager.d.ts +256 -18
- package/dist/state-manager.d.ts.map +1 -1
- package/dist/state-manager.js +429 -20
- package/dist/state-manager.js.map +1 -1
- package/dist/storage-keys.d.ts +8 -0
- package/dist/storage-keys.d.ts.map +1 -1
- package/dist/storage-keys.js +18 -2
- package/dist/storage-keys.js.map +1 -1
- package/dist/types.d.ts +180 -34
- package/dist/types.d.ts.map +1 -1
- package/dist/worker-client.d.ts.map +1 -1
- package/dist/worker-client.js +37 -11
- package/dist/worker-client.js.map +1 -1
- package/dist/worker-host.d.ts.map +1 -1
- package/dist/worker-host.js +21 -8
- package/dist/worker-host.js.map +1 -1
- package/dist/worker-rpc-error.d.ts +21 -0
- package/dist/worker-rpc-error.d.ts.map +1 -0
- package/dist/worker-rpc-error.js +121 -0
- package/dist/worker-rpc-error.js.map +1 -0
- package/package.json +4 -1
- package/src/derived-trie.ts +214 -0
- package/src/engine.ts +2 -3
- package/src/index.ts +3 -1
- package/src/node.ts +1335 -138
- package/src/revm-state-store.ts +47 -13
- package/src/revm.ts +11 -25
- package/src/state-manager.ts +515 -21
- package/src/storage-keys.ts +21 -2
- package/src/types.ts +183 -35
- package/src/worker-client.ts +42 -11
- package/src/worker-host.ts +21 -8
- package/src/worker-rpc-error.ts +139 -0
package/dist/state-manager.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* state-manager.ts
|
|
2
|
+
* state-manager.ts: the node's state manager, on EVERY node: a
|
|
3
|
+
* `computeStateRoot: true` node runs on it too and derives its trie from it
|
|
4
|
+
* (./derived-trie.ts, ADR 0014).
|
|
3
5
|
*
|
|
4
6
|
* `@ethereumjs/statemanager@10.1.2`'s `SimpleStateManager` keeps storage in ONE
|
|
5
7
|
* FLAT `Map` keyed `` `${address}_${slot}` ``, and `checkpointSync()` pushes a
|
|
@@ -98,24 +100,133 @@
|
|
|
98
100
|
* has to live in code we publish. That argument is even stronger for the layout,
|
|
99
101
|
* which is a representation our own `dumpState` and revm store read directly.
|
|
100
102
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* has non-empty storage
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
103
|
+
* WHICH COLLISION RULE EVERY NODE FOLLOWS, and why this class is where it is
|
|
104
|
+
* decided. `@ethereumjs/evm` also carries an EIP-7610 guard, just above that
|
|
105
|
+
* call, that refuses a creation when the target has non-empty storage; it reads
|
|
106
|
+
* `account.storageRoot`, which this class never sets (`SimpleStateManager` has no
|
|
107
|
+
* trie), so the guard never fires. That is the INTENDED rule, not a gap: a
|
|
108
|
+
* creation over a zero-nonce, code-less account that holds storage SUCCEEDS and
|
|
109
|
+
* the storage is WIPED by the `clearStorage` above, which is what the reference
|
|
110
|
+
* spec specifies (EIP-684 plus the Yellow Paper, execution-specs PR #3508) and
|
|
111
|
+
* what revm does through this same state. A nonce or code at the target is still
|
|
112
|
+
* a collision on both engines. Every node follows it, with or without
|
|
113
|
+
* `computeStateRoot`, because every node runs on this class: a root-computing
|
|
114
|
+
* node derives its trie from this state rather than running on
|
|
115
|
+
* `MerkleStateManager` (whose real `storageRoot` used to make trie mode, as it
|
|
116
|
+
* was then called, refuse the creation, EIP-7610, the one
|
|
117
|
+
* behaviour that differed by mode). Decided with the user 2026-09-28; the
|
|
118
|
+
* evidence is
|
|
119
|
+
* `work/notes/findings/storage-only-creation-collisions-are-not-refused-by-the-reference-spec.md`
|
|
120
|
+
* and the record is
|
|
121
|
+
* `docs/adr/0014-the-trie-is-derived-from-the-flat-state-not-a-state-manager.md`.
|
|
122
|
+
* So a real `storageRoot` must never be written into this class's accounts: it
|
|
123
|
+
* would silently switch the EIP-7610 guard back on for that account.
|
|
124
|
+
*
|
|
125
|
+
* ## The per-block CHANGE SET (the open record), and why it lives HERE
|
|
126
|
+
*
|
|
127
|
+
* When switched on ({@link OverlayStorageStateManager.enableChangeSets}, an
|
|
128
|
+
* INTERNAL switch the node flips; no option exposes it yet), this class keeps
|
|
129
|
+
* the OPEN RECORD: every account, code entry and storage slot changed since the
|
|
130
|
+
* record was last taken, with the value each had when it was (FIRST WRITE WINS),
|
|
131
|
+
* plus a per-account "storage was cleared" marker. The node takes it at the end
|
|
132
|
+
* of each mined block, so it names what that block (and any `evm_set*` cheat
|
|
133
|
+
* issued before it) changed, and the value at the end of the previous block. It
|
|
134
|
+
* is the seam bounded state history (an undo log) and trie-from-flat-state (the
|
|
135
|
+
* keys to rehash) both stand on: `work/specs/tasked/bounded-state-history.md`.
|
|
136
|
+
*
|
|
137
|
+
* IT IS HERE, IN ONE PLACE, because every write reaches this class: the default
|
|
138
|
+
* engine's through the async `StateManagerInterface` methods overridden below,
|
|
139
|
+
* revm's through the SYNCHRONOUS by-key methods ({@link setAccountAt},
|
|
140
|
+
* {@link setCodeAt}, {@link removeAccountAt}, {@link setStorageAt},
|
|
141
|
+
* {@link clearStorageAt}) that `src/revm-state-store.ts` is required to call
|
|
142
|
+
* instead of writing the maps itself. The async writers are thin wrappers over
|
|
143
|
+
* the same by-key methods, so there is ONE recording path per key kind.
|
|
144
|
+
*
|
|
145
|
+
* CHECKPOINT-AWARE, the same way the storage overlays are. A record is kept PER
|
|
146
|
+
* CHECKPOINT LEVEL (lazily: a level with no write allocates nothing), holding the
|
|
147
|
+
* value each key had at the START of that level, which is its value in the level
|
|
148
|
+
* BELOW (frozen while this one is open, so reading it at first-write time is the
|
|
149
|
+
* same as reading it at checkpoint time). `commit()` merges the top record into
|
|
150
|
+
* the one below with the BELOW entry winning (it is older), `revert()` drops it.
|
|
151
|
+
* So a write inside a reverted frame, a reverted transaction's inner writes, and
|
|
152
|
+
* every `eth_call` / `eth_estimateGas` / state override leave no trace, by
|
|
153
|
+
* construction rather than by bookkeeping. Pure reads additionally SUSPEND
|
|
154
|
+
* recording ({@link withChangeSetsSuspended}) because their levels are always
|
|
155
|
+
* reverted: a cost rule, not a correctness one.
|
|
156
|
+
*
|
|
157
|
+
* THE PRIOR IS READ FROM THE LEVEL BELOW, NOT FROM THE LEVEL BEING WRITTEN, and
|
|
158
|
+
* that is what makes it immune to an in-place mutation inside a checkpoint
|
|
159
|
+
* (`@ethereumjs/vm` mutates the `Account` object it got and then `putAccount`s
|
|
160
|
+
* it). At the BOTTOM level there is no level below, so the prior is the map's
|
|
161
|
+
* current value, and {@link getAccount} hands out a COPY there so that no caller
|
|
162
|
+
* can mutate it before the write arrives. See {@link getAccount} for the
|
|
163
|
+
* decision and its measured cost.
|
|
111
164
|
*/
|
|
112
165
|
import { SimpleStateManager } from '@ethereumjs/statemanager';
|
|
166
|
+
import { Account } from '@ethereumjs/util';
|
|
167
|
+
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
113
168
|
import { packAddressKey, packSlotKey, unpackAddressKey, unpackSlotKey, } from './storage-keys.js';
|
|
114
169
|
function emptyOverlay() {
|
|
115
170
|
return { written: new Map(), cleared: new Set() };
|
|
116
171
|
}
|
|
172
|
+
function emptyChangeSet() {
|
|
173
|
+
return {
|
|
174
|
+
accounts: new Map(),
|
|
175
|
+
code: new Map(),
|
|
176
|
+
storage: new Map(),
|
|
177
|
+
storageCleared: new Set(),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** `true` when the change set records nothing. */
|
|
181
|
+
export function isEmptyChangeSet(cs) {
|
|
182
|
+
return (cs.accounts.size === 0 &&
|
|
183
|
+
cs.code.size === 0 &&
|
|
184
|
+
cs.storage.size === 0 &&
|
|
185
|
+
cs.storageCleared.size === 0);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Merge `newer` INTO `older`, the OLDER entry winning for a key both name: it
|
|
189
|
+
* holds the value from before the first of the two changes, which is what a
|
|
190
|
+
* change set means. `newer` is consumed (its inner storage maps may be handed to
|
|
191
|
+
* `older` whole), so the caller must not use it afterwards.
|
|
192
|
+
*
|
|
193
|
+
* Two callers, one rule: {@link OverlayStorageStateManager.commit} merging a
|
|
194
|
+
* checkpoint level's record down, and the node sealing a block under the number
|
|
195
|
+
* of the block it replaces (`sealBlock` in ./node.ts).
|
|
196
|
+
*/
|
|
197
|
+
export function mergeChangeSetOlderWins(older, newer) {
|
|
198
|
+
for (const [key, value] of newer.accounts)
|
|
199
|
+
if (!older.accounts.has(key))
|
|
200
|
+
older.accounts.set(key, value);
|
|
201
|
+
for (const [key, value] of newer.code)
|
|
202
|
+
if (!older.code.has(key))
|
|
203
|
+
older.code.set(key, value);
|
|
204
|
+
for (const [addressKey, slots] of newer.storage) {
|
|
205
|
+
const target = older.storage.get(addressKey);
|
|
206
|
+
if (target === undefined) {
|
|
207
|
+
older.storage.set(addressKey, slots);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
for (const [slotKey, value] of slots)
|
|
211
|
+
if (!target.has(slotKey))
|
|
212
|
+
target.set(slotKey, value);
|
|
213
|
+
}
|
|
214
|
+
for (const addressKey of newer.storageCleared)
|
|
215
|
+
older.storageCleared.add(addressKey);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* A copy of an `Account` that shares no mutable state with it: the same trick
|
|
219
|
+
* `checkpointSync()` uses (upstream's, kept byte for byte), which copies the
|
|
220
|
+
* instance's own fields onto a fresh object of the same prototype. The fields are
|
|
221
|
+
* bigints and `Uint8Array`s that are REPLACED rather than mutated, so a shallow
|
|
222
|
+
* copy is independent. Exported for the node, which hands a sealed record's
|
|
223
|
+
* account to the engine for a historical call (`historicalEntries`).
|
|
224
|
+
*/
|
|
225
|
+
export function copyAccount(account) {
|
|
226
|
+
return Object.assign(Object.create(Object.getPrototypeOf(account)), account);
|
|
227
|
+
}
|
|
117
228
|
const STORAGE_STACK_IS_GONE = "webevm: SimpleStateManager's flat `storageStack` is not maintained " +
|
|
118
|
-
|
|
229
|
+
'by this node. Its storage is per-account with per-checkpoint ' +
|
|
119
230
|
'OVERLAYS — read it through `storageAt(addressKey, slotKey)` (one slot, ' +
|
|
120
231
|
'synchronously), `liveStorage()` (every live slot, grouped by account) or the ' +
|
|
121
232
|
'async `getStorage(address, key)`. This throws on purpose: an empty ' +
|
|
@@ -155,6 +266,9 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
155
266
|
}
|
|
156
267
|
this.accountStack.push(newTopA);
|
|
157
268
|
this.codeStack.push(new Map(this.topCodeStack()));
|
|
269
|
+
// A new level records nothing until it writes (lazy), so a frame that only
|
|
270
|
+
// reads allocates nothing here.
|
|
271
|
+
this.changeLevels?.push(undefined);
|
|
158
272
|
// First call comes from the BASE constructor, before any subclass field
|
|
159
273
|
// could have run. `as ... | undefined` because the declared type says it is
|
|
160
274
|
// always there, and at this one instant it is not.
|
|
@@ -187,6 +301,8 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
187
301
|
* {@link clearStorageAt}, with no checkpoint open), rather than swept later.
|
|
188
302
|
*/
|
|
189
303
|
async commit() {
|
|
304
|
+
// Refused BEFORE anything moves, so a refusal leaves the stacks as they were.
|
|
305
|
+
this.refuseCommitIntoBottomWhileSuspended();
|
|
190
306
|
this.accountStack.splice(-2, 1);
|
|
191
307
|
this.codeStack.splice(-2, 1);
|
|
192
308
|
const overlays = this.storageOverlays;
|
|
@@ -199,6 +315,7 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
199
315
|
// After the `pop()` below, `below` is the bottom overlay exactly when the
|
|
200
316
|
// stack is two deep now.
|
|
201
317
|
const belowIsBottom = overlays.length === 2;
|
|
318
|
+
this.mergeChangeLevelDown();
|
|
202
319
|
for (const address of top.cleared) {
|
|
203
320
|
below.written.delete(address);
|
|
204
321
|
if (!belowIsBottom)
|
|
@@ -223,6 +340,289 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
223
340
|
this.accountStack.pop();
|
|
224
341
|
this.codeStack.pop();
|
|
225
342
|
this.storageOverlays.pop();
|
|
343
|
+
// ...and the change set it recorded goes with it: a reverted write was never
|
|
344
|
+
// a change.
|
|
345
|
+
this.changeLevels?.pop();
|
|
346
|
+
}
|
|
347
|
+
// --- the change set (the open record) -------------------------------------
|
|
348
|
+
/**
|
|
349
|
+
* Switch change-set recording ON. INTERNAL: called by the node when a feature
|
|
350
|
+
* that consumes change sets is on (bounded state history, trie-from-flat-state);
|
|
351
|
+
* no option exposes it directly. Only with no checkpoint open, so the level
|
|
352
|
+
* array starts parallel to the stacks.
|
|
353
|
+
*/
|
|
354
|
+
enableChangeSets() {
|
|
355
|
+
if (this.accountStack.length !== 1)
|
|
356
|
+
throw new Error('webevm: change sets can only be switched on with no checkpoint open.');
|
|
357
|
+
this.changeLevels ??= [emptyChangeSet()];
|
|
358
|
+
}
|
|
359
|
+
/** Whether {@link enableChangeSets} was called. */
|
|
360
|
+
get recordsChangeSets() {
|
|
361
|
+
return this.changeLevels !== undefined;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The OPEN RECORD as it stands, without taking it. `undefined` when recording
|
|
365
|
+
* is off. Read-only by contract: the node's test-only probe and the next
|
|
366
|
+
* consumers read it; nothing may mutate it.
|
|
367
|
+
*/
|
|
368
|
+
peekChangeSet() {
|
|
369
|
+
return this.changeLevels?.[0];
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* TAKE the open record and open a fresh one: the node calls this at the end of
|
|
373
|
+
* each mined block. `undefined` when recording is off. Refused with a
|
|
374
|
+
* checkpoint open, because the writes of an open level are not in the open
|
|
375
|
+
* record yet and would be attributed to the wrong block.
|
|
376
|
+
*/
|
|
377
|
+
takeChangeSet() {
|
|
378
|
+
const levels = this.changeLevels;
|
|
379
|
+
if (levels === undefined)
|
|
380
|
+
return undefined;
|
|
381
|
+
if (levels.length !== 1)
|
|
382
|
+
throw new Error('webevm: the change set was taken with a checkpoint open; its writes ' +
|
|
383
|
+
'would be attributed to the wrong block.');
|
|
384
|
+
const taken = levels[0] ?? emptyChangeSet();
|
|
385
|
+
levels[0] = emptyChangeSet();
|
|
386
|
+
return taken;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Run a PURE READ (`eth_call`, `eth_estimateGas`, a state override) with
|
|
390
|
+
* recording suspended. Its levels are always reverted, so recording there is
|
|
391
|
+
* wasted work that the revert would throw away: a COST rule. Correctness does
|
|
392
|
+
* not depend on it, and it is guarded anyway: a write at the bottom level (no
|
|
393
|
+
* checkpoint open) is still recorded, and a commit INTO the bottom level while
|
|
394
|
+
* suspended throws, since that would be a suspended write becoming state.
|
|
395
|
+
*/
|
|
396
|
+
async withChangeSetsSuspended(read) {
|
|
397
|
+
if (this.changeLevels === undefined)
|
|
398
|
+
return read();
|
|
399
|
+
this.changeSetsSuspended = (this.changeSetsSuspended ?? 0) + 1;
|
|
400
|
+
try {
|
|
401
|
+
return await read();
|
|
402
|
+
}
|
|
403
|
+
finally {
|
|
404
|
+
this.changeSetsSuspended = (this.changeSetsSuspended ?? 1) - 1;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* The record of the CURRENT (top) level, created on first use, or `undefined`
|
|
409
|
+
* when nothing should be recorded: recording off, or a suspended pure read above
|
|
410
|
+
* the bottom level.
|
|
411
|
+
*/
|
|
412
|
+
recordingLevel() {
|
|
413
|
+
const levels = this.changeLevels;
|
|
414
|
+
if (levels === undefined)
|
|
415
|
+
return undefined;
|
|
416
|
+
const depth = levels.length - 1;
|
|
417
|
+
if (depth > 0 && (this.changeSetsSuspended ?? 0) > 0)
|
|
418
|
+
return undefined;
|
|
419
|
+
let record = levels[depth];
|
|
420
|
+
if (record === undefined) {
|
|
421
|
+
record = emptyChangeSet();
|
|
422
|
+
levels[depth] = record;
|
|
423
|
+
}
|
|
424
|
+
return record;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* The stack index the PRIOR of a write is read from: the level below the top
|
|
428
|
+
* (frozen while the top is open), or the bottom itself when no checkpoint is
|
|
429
|
+
* open (read before the write lands).
|
|
430
|
+
*/
|
|
431
|
+
priorIndex() {
|
|
432
|
+
return Math.max(this.accountStack.length - 2, 0);
|
|
433
|
+
}
|
|
434
|
+
recordAccountPrior(key) {
|
|
435
|
+
const record = this.recordingLevel();
|
|
436
|
+
if (record === undefined || record.accounts.has(key))
|
|
437
|
+
return;
|
|
438
|
+
const prior = this.accountStack[this.priorIndex()].get(key);
|
|
439
|
+
// A COPY: the object may be handed to (and mutated by) somebody later, and
|
|
440
|
+
// the record must keep saying what it was.
|
|
441
|
+
record.accounts.set(key, prior && copyAccount(prior));
|
|
442
|
+
}
|
|
443
|
+
recordCodePrior(key) {
|
|
444
|
+
const record = this.recordingLevel();
|
|
445
|
+
if (record === undefined || record.code.has(key))
|
|
446
|
+
return;
|
|
447
|
+
record.code.set(key, this.codeStack[this.priorIndex()].get(key));
|
|
448
|
+
}
|
|
449
|
+
recordSlotPrior(addressKey, slotKey) {
|
|
450
|
+
const record = this.recordingLevel();
|
|
451
|
+
if (record === undefined)
|
|
452
|
+
return;
|
|
453
|
+
let inner = record.storage.get(addressKey);
|
|
454
|
+
if (inner?.has(slotKey))
|
|
455
|
+
return;
|
|
456
|
+
if (inner === undefined) {
|
|
457
|
+
inner = new Map();
|
|
458
|
+
record.storage.set(addressKey, inner);
|
|
459
|
+
}
|
|
460
|
+
inner.set(slotKey, this.storageAtDepth(addressKey, slotKey, this.priorIndex()));
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* A storage CLEAR: record every slot the account held (as seen from the level
|
|
464
|
+
* below) that is not already recorded, plus the cleared marker. O(slots of
|
|
465
|
+
* that account), paid only on a clear and only with recording on.
|
|
466
|
+
*/
|
|
467
|
+
recordClearPrior(addressKey) {
|
|
468
|
+
const record = this.recordingLevel();
|
|
469
|
+
if (record === undefined)
|
|
470
|
+
return;
|
|
471
|
+
record.storageCleared.add(addressKey);
|
|
472
|
+
let inner = record.storage.get(addressKey);
|
|
473
|
+
const overlays = this.storageOverlays;
|
|
474
|
+
// Walk downwards exactly as `storageAt` does: a higher overlay shadows a
|
|
475
|
+
// lower one (the `has` check keeps the first, i.e. highest, value seen), and
|
|
476
|
+
// an overlay that cleared the account hides everything below it.
|
|
477
|
+
for (let i = this.priorIndex(); i >= 0; i--) {
|
|
478
|
+
const overlay = overlays[i];
|
|
479
|
+
const written = overlay.written.get(addressKey);
|
|
480
|
+
if (written !== undefined) {
|
|
481
|
+
for (const [slotKey, value] of written) {
|
|
482
|
+
if (inner === undefined) {
|
|
483
|
+
inner = new Map();
|
|
484
|
+
record.storage.set(addressKey, inner);
|
|
485
|
+
}
|
|
486
|
+
if (!inner.has(slotKey))
|
|
487
|
+
inner.set(slotKey, value);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (overlay.cleared.has(addressKey))
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* A commit INTO the bottom level while recording is suspended would turn a
|
|
496
|
+
* pure read's unrecorded writes into committed state behind the record, so it
|
|
497
|
+
* is refused. No pure read does it (each reverts the level it opened); this is
|
|
498
|
+
* the guard that makes the suspension a cost rule and never a correctness one.
|
|
499
|
+
*/
|
|
500
|
+
refuseCommitIntoBottomWhileSuspended() {
|
|
501
|
+
if (this.changeLevels !== undefined &&
|
|
502
|
+
(this.changeSetsSuspended ?? 0) > 0 &&
|
|
503
|
+
this.accountStack.length === 2)
|
|
504
|
+
throw new Error('webevm: a checkpoint was committed into committed state while change ' +
|
|
505
|
+
'sets were suspended for a pure read. A pure read must revert its ' +
|
|
506
|
+
'levels; its writes were not recorded.');
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* `commit()`'s half for the change set: merge the top level's record into the
|
|
510
|
+
* one below, the BELOW entry winning (it holds the older value: the key was
|
|
511
|
+
* written there before the checkpoint).
|
|
512
|
+
*/
|
|
513
|
+
mergeChangeLevelDown() {
|
|
514
|
+
const levels = this.changeLevels;
|
|
515
|
+
if (levels === undefined)
|
|
516
|
+
return;
|
|
517
|
+
const top = levels.pop();
|
|
518
|
+
if (top === undefined)
|
|
519
|
+
return;
|
|
520
|
+
const belowIndex = levels.length - 1;
|
|
521
|
+
const below = levels[belowIndex];
|
|
522
|
+
// The top level is gone after this, so nobody else holds its maps: hand them
|
|
523
|
+
// down whole when the level below has recorded nothing.
|
|
524
|
+
if (below === undefined) {
|
|
525
|
+
levels[belowIndex] = top;
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
mergeChangeSetOlderWins(below, top);
|
|
529
|
+
}
|
|
530
|
+
// --- accounts and code ------------------------------------------------------
|
|
531
|
+
// Every write to the account and code maps goes through the three by-key
|
|
532
|
+
// methods below, which record the prior first. The async `StateManagerInterface`
|
|
533
|
+
// writers are wrappers over them; `src/revm-state-store.ts` calls them directly
|
|
534
|
+
// (it cannot await). Upstream's writers, enumerated from
|
|
535
|
+
// `@ethereumjs/statemanager@10.1.2`'s `SimpleStateManager`: `putAccount`,
|
|
536
|
+
// `deleteAccount`, `modifyAccountFields` and `putCode` (which writes the code
|
|
537
|
+
// map and then the account's `codeHash`). All four are overridden.
|
|
538
|
+
/**
|
|
539
|
+
* Write one account SYNCHRONOUSLY, by key, into the TOP level: the account
|
|
540
|
+
* twin of {@link setStorageAt}, for revm's synchronous commit callback. The key
|
|
541
|
+
* is `address.toString()` (`0x`, lowercase), the upstream stack's key.
|
|
542
|
+
* `undefined` tombstones the account, as upstream's `putAccount` does.
|
|
543
|
+
*/
|
|
544
|
+
setAccountAt(addressKey, account) {
|
|
545
|
+
this.recordAccountPrior(addressKey);
|
|
546
|
+
this.topAccountStack().set(addressKey, account);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Tombstone one account SYNCHRONOUSLY, by key. The ACCOUNT only: the storage
|
|
550
|
+
* half is {@link clearStorageAt}, which revm's binding sends immediately
|
|
551
|
+
* before (see `removeAccount` in `src/revm-state-store.ts`), and the async
|
|
552
|
+
* {@link deleteAccount} does both. Code is left in place, as upstream leaves it.
|
|
553
|
+
*/
|
|
554
|
+
removeAccountAt(addressKey) {
|
|
555
|
+
this.setAccountAt(addressKey, undefined);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Write one account's CODE SYNCHRONOUSLY, by key, into the TOP level. The code
|
|
559
|
+
* map only: the account's `codeHash` is the caller's to write (revm's
|
|
560
|
+
* `setAccount` carries it; the async {@link putCode} writes it itself).
|
|
561
|
+
*/
|
|
562
|
+
setCodeAt(addressKey, code) {
|
|
563
|
+
this.recordCodePrior(addressKey);
|
|
564
|
+
this.topCodeStack().set(addressKey, code);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Read one account, handing out a COPY WHEN NO CHECKPOINT IS OPEN.
|
|
568
|
+
*
|
|
569
|
+
* THE HAZARD: upstream returns the object stored IN the top account map.
|
|
570
|
+
* Inside a checkpoint that is harmless, because a level holds copies and the
|
|
571
|
+
* change set reads a write's prior from the level below. At the BOTTOM level
|
|
572
|
+
* (where the `evm_set*` cheats, `refuseIfSenderCannotSend` and every RPC read
|
|
573
|
+
* run) there is no level below: a caller that edits the object and then calls
|
|
574
|
+
* `putAccount` (the node's `mutateAccount`, upstream `modifyAccountFields`,
|
|
575
|
+
* reached from `putCode`) has overwritten the prior before any write hook
|
|
576
|
+
* runs, and the record would hold the NEW value as the old one.
|
|
577
|
+
*
|
|
578
|
+
* DECISION (state-change-set-capture, 2026-09-28): close it at the seam, by
|
|
579
|
+
* copying at the bottom level only, and regardless of whether change sets are
|
|
580
|
+
* on, so aliasing semantics do not depend on an internal flag. Rejected: fixing
|
|
581
|
+
* `mutateAccount` alone (upstream `modifyAccountFields` does the same);
|
|
582
|
+
* recording the prior on the first bottom-level READ (it would put every
|
|
583
|
+
* `eth_getBalance`'d key in the record, a superset the history would then
|
|
584
|
+
* store per block); copying at every level (the default engine's hot path runs
|
|
585
|
+
* inside checkpoints and needs no copy). MEASURED COST: one object allocation
|
|
586
|
+
* per bottom-level read, which is only RPC reads and cheats, never the
|
|
587
|
+
* interpreter; see
|
|
588
|
+
* `docs/spikes/state-change-set-capture/measurements.md`.
|
|
589
|
+
*/
|
|
590
|
+
async getAccount(address) {
|
|
591
|
+
const account = this.topAccountStack().get(address.toString());
|
|
592
|
+
if (account === undefined || this.accountStack.length > 1)
|
|
593
|
+
return account;
|
|
594
|
+
return copyAccount(account);
|
|
595
|
+
}
|
|
596
|
+
async putAccount(address, account) {
|
|
597
|
+
this.setAccountAt(address.toString(), account);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Read-modify-write of named fields. Overridden rather than inherited so the
|
|
601
|
+
* write provably goes through {@link putAccount} and the read through
|
|
602
|
+
* {@link getAccount}'s bottom-level copy, instead of depending on upstream's
|
|
603
|
+
* `modifyAccountFields` helper keeping that shape.
|
|
604
|
+
*/
|
|
605
|
+
async modifyAccountFields(address, accountFields) {
|
|
606
|
+
const account = (await this.getAccount(address)) ?? new Account();
|
|
607
|
+
account.nonce = accountFields.nonce ?? account.nonce;
|
|
608
|
+
account.balance = accountFields.balance ?? account.balance;
|
|
609
|
+
account.storageRoot = accountFields.storageRoot ?? account.storageRoot;
|
|
610
|
+
account.codeHash = accountFields.codeHash ?? account.codeHash;
|
|
611
|
+
account.codeSize = accountFields.codeSize ?? account.codeSize;
|
|
612
|
+
await this.putAccount(address, account);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Upstream's `putCode`, restated so the code-map write goes through
|
|
616
|
+
* {@link setCodeAt}: the code, then an empty account if there was none, then
|
|
617
|
+
* the account's `codeHash`.
|
|
618
|
+
*/
|
|
619
|
+
async putCode(address, value) {
|
|
620
|
+
this.setCodeAt(address.toString(), value);
|
|
621
|
+
if ((await this.getAccount(address)) === undefined)
|
|
622
|
+
await this.putAccount(address, new Account());
|
|
623
|
+
await this.modifyAccountFields(address, {
|
|
624
|
+
codeHash: (this.common?.customCrypto.keccak256 ?? keccak_256)(value),
|
|
625
|
+
});
|
|
226
626
|
}
|
|
227
627
|
// --- storage -------------------------------------------------------------
|
|
228
628
|
topOverlay() {
|
|
@@ -253,8 +653,12 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
253
653
|
* distinguishable from the flat map's single lookup; see the spike.
|
|
254
654
|
*/
|
|
255
655
|
storageAt(addressKey, slotKey) {
|
|
656
|
+
return this.storageAtDepth(addressKey, slotKey, this.storageOverlays.length - 1);
|
|
657
|
+
}
|
|
658
|
+
/** {@link storageAt} as seen from overlay `from` downwards. */
|
|
659
|
+
storageAtDepth(addressKey, slotKey, from) {
|
|
256
660
|
const overlays = this.storageOverlays;
|
|
257
|
-
for (let i =
|
|
661
|
+
for (let i = from; i >= 0; i--) {
|
|
258
662
|
const overlay = overlays[i];
|
|
259
663
|
const hit = overlay.written.get(addressKey)?.get(slotKey);
|
|
260
664
|
if (hit !== undefined)
|
|
@@ -281,6 +685,7 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
281
685
|
*/
|
|
282
686
|
setStorageAt(addressKey, slotKey, value) {
|
|
283
687
|
const top = this.topOverlay();
|
|
688
|
+
this.recordSlotPrior(addressKey, slotKey);
|
|
284
689
|
let inner = top.written.get(addressKey);
|
|
285
690
|
if (inner === undefined) {
|
|
286
691
|
inner = new Map();
|
|
@@ -312,6 +717,7 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
312
717
|
*/
|
|
313
718
|
clearStorageAt(addressKey) {
|
|
314
719
|
const top = this.topOverlay();
|
|
720
|
+
this.recordClearPrior(addressKey);
|
|
315
721
|
top.written.delete(addressKey);
|
|
316
722
|
if (this.storageOverlays.length > 1)
|
|
317
723
|
top.cleared.add(addressKey);
|
|
@@ -355,15 +761,15 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
355
761
|
* clearing) left every slot of the dead account READABLE at its address, and
|
|
356
762
|
* `dumpState` kept serialising them. Measured through the node's own surface:
|
|
357
763
|
* after a contract that writes slot 0 and selfdestructs in the same
|
|
358
|
-
* transaction, `eth_getStorageAt` answered `0x2a`
|
|
359
|
-
* `0x0`
|
|
764
|
+
* transaction, `eth_getStorageAt` answered `0x2a` on a node computing no root and
|
|
765
|
+
* `0x0` on one computing a root (which then ran on `MerkleStateManager`)
|
|
360
766
|
* (`docs/spikes/revm-write-callbacks-reproduce-the-post-state/measurements.md`).
|
|
361
767
|
*
|
|
362
768
|
* A DELETED ACCOUNT HAS NO STORAGE, in a trie by construction: the account is
|
|
363
|
-
* removed and its storage trie goes with it, which
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
769
|
+
* removed and its storage trie goes with it. This makes the flat state, which
|
|
770
|
+
* every node now runs on, say the same thing (the derived trie of
|
|
771
|
+
* a `computeStateRoot` node sees this clear as a storage-cleared change), and it is
|
|
772
|
+
* the reason the revm
|
|
367
773
|
* engine — whose host is handed `clearStorage` then `removeAccount` for exactly
|
|
368
774
|
* these two cases, with revm's commit semantics already applied — now leaves
|
|
369
775
|
* post-state a diff cannot tell apart from `@ethereumjs/vm`'s. See
|
|
@@ -376,7 +782,7 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
376
782
|
* frame is reverted.
|
|
377
783
|
*/
|
|
378
784
|
async deleteAccount(address) {
|
|
379
|
-
|
|
785
|
+
this.removeAccountAt(address.toString());
|
|
380
786
|
this.clearStorageAt(packAddressKey(address.bytes));
|
|
381
787
|
}
|
|
382
788
|
/**
|
|
@@ -422,6 +828,9 @@ export class OverlayStorageStateManager extends SimpleStateManager {
|
|
|
422
828
|
* overlay's outer map and each inner map), because the copy's overlays are not
|
|
423
829
|
* this object's: sharing an inner map would let a write on the copy land in
|
|
424
830
|
* this manager's committed state.
|
|
831
|
+
*
|
|
832
|
+
* CHANGE-SET RECORDING IS NOT COPIED: the copy starts with it off. A copy's
|
|
833
|
+
* writes are not this node's blocks.
|
|
425
834
|
*/
|
|
426
835
|
shallowCopy() {
|
|
427
836
|
const copy = new OverlayStorageStateManager({ common: this.common });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-manager.js","sourceRoot":"","sources":["../src/state-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GG;AACH,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EACN,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,aAAa,GAIb,MAAM,mBAAmB,CAAC;AAgC3B,SAAS,YAAY;IACpB,OAAO,EAAC,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAC,CAAC;AACjD,CAAC;AAED,MAAM,qBAAqB,GAC1B,qEAAqE;IACrE,8EAA8E;IAC9E,yEAAyE;IACzE,+EAA+E;IAC/E,qEAAqE;IACrE,2EAA2E;IAC3E,0EAA0E;IAC1E,2EAA2E;IAC3E,oDAAoD,CAAC;AAEtD,MAAM,OAA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,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
package/dist/storage-keys.d.ts
CHANGED
|
@@ -18,4 +18,12 @@ export declare function packSlotKey(slot: Uint8Array): PackedSlotKey;
|
|
|
18
18
|
export declare function unpackAddressKey(key: PackedAddressKey): HexKey;
|
|
19
19
|
/** `0x` + 64 hex digits, i.e. exactly what `bytesToHex(slot32)` would give. */
|
|
20
20
|
export declare function unpackSlotKey(key: PackedSlotKey): HexKey;
|
|
21
|
+
/**
|
|
22
|
+
* The RAW BYTES a packed key encodes (20 for an account, 32 for a slot): the
|
|
23
|
+
* inverse of {@link packAddressKey} / {@link packSlotKey} without the hex
|
|
24
|
+
* detour. For the derived trie (`src/derived-trie.ts`), which keys its tries by
|
|
25
|
+
* the raw address and slot and reaches them from the change set's packed keys.
|
|
26
|
+
* Allocates, so it is a per-changed-key cost, never a read path.
|
|
27
|
+
*/
|
|
28
|
+
export declare function packedKeyBytes(key: PackedAddressKey | PackedSlotKey): Uint8Array;
|
|
21
29
|
//# sourceMappingURL=storage-keys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-keys.d.ts","sourceRoot":"","sources":["../src/storage-keys.ts"],"names":[],"mappings":"AA0EA,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,+EAA+E;AAC/E,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAcpE;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa,CAoB3D;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAE9D;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAExD"}
|
|
1
|
+
{"version":3,"file":"storage-keys.d.ts","sourceRoot":"","sources":["../src/storage-keys.ts"],"names":[],"mappings":"AA0EA,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,+EAA+E;AAC/E,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAcpE;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa,CAoB3D;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAE9D;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,gBAAgB,GAAG,aAAa,GACnC,UAAU,CAQZ"}
|
package/dist/storage-keys.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* storage-keys.ts
|
|
2
|
+
* storage-keys.ts: the node's STORAGE KEY encoding (on every node), and the
|
|
3
3
|
* ONE place either side of it is allowed to build a key.
|
|
4
4
|
*
|
|
5
5
|
* A storage key here is **PACKED**: two bytes per UTF-16 code unit, so an
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* to that width rather than encoding it ambiguously. Normalising is safe and
|
|
46
46
|
* unreachable in practice: `@ethereumjs/evm` always hands over a 32-byte slot
|
|
47
47
|
* key, every caller in `src/node.ts` pads to 32 first, and `MerkleStateManager`
|
|
48
|
-
* (
|
|
48
|
+
* (which trie mode, as it was then called, ran on) REFUSES a key that is not 32 bytes at all, so a short
|
|
49
49
|
* key names the slot it obviously means instead of an unreadable one.
|
|
50
50
|
*
|
|
51
51
|
* ## What this is NOT the key format for
|
|
@@ -97,6 +97,22 @@ export function unpackAddressKey(key) {
|
|
|
97
97
|
export function unpackSlotKey(key) {
|
|
98
98
|
return unpack(key);
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The RAW BYTES a packed key encodes (20 for an account, 32 for a slot): the
|
|
102
|
+
* inverse of {@link packAddressKey} / {@link packSlotKey} without the hex
|
|
103
|
+
* detour. For the derived trie (`src/derived-trie.ts`), which keys its tries by
|
|
104
|
+
* the raw address and slot and reaches them from the change set's packed keys.
|
|
105
|
+
* Allocates, so it is a per-changed-key cost, never a read path.
|
|
106
|
+
*/
|
|
107
|
+
export function packedKeyBytes(key) {
|
|
108
|
+
const out = new Uint8Array(key.length * 2);
|
|
109
|
+
for (let i = 0; i < key.length; i++) {
|
|
110
|
+
const c = key.charCodeAt(i);
|
|
111
|
+
out[2 * i] = c >>> 8;
|
|
112
|
+
out[2 * i + 1] = c & 0xff;
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
100
116
|
/**
|
|
101
117
|
* The inverse of the two encoders, for the dump path ONLY — it allocates a
|
|
102
118
|
* string per key and is O(live slots) over a whole dump. Read one slot with
|