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.
Files changed (56) hide show
  1. package/README.md +148 -63
  2. package/dist/derived-trie.d.ts +38 -0
  3. package/dist/derived-trie.d.ts.map +1 -0
  4. package/dist/derived-trie.js +187 -0
  5. package/dist/derived-trie.js.map +1 -0
  6. package/dist/engine.d.ts +1 -2
  7. package/dist/engine.d.ts.map +1 -1
  8. package/dist/engine.js +2 -3
  9. package/dist/engine.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/node.d.ts +45 -0
  14. package/dist/node.d.ts.map +1 -1
  15. package/dist/node.js +1125 -141
  16. package/dist/node.js.map +1 -1
  17. package/dist/revm-state-store.d.ts +5 -0
  18. package/dist/revm-state-store.d.ts.map +1 -1
  19. package/dist/revm-state-store.js +42 -13
  20. package/dist/revm-state-store.js.map +1 -1
  21. package/dist/revm.d.ts.map +1 -1
  22. package/dist/revm.js +5 -19
  23. package/dist/revm.js.map +1 -1
  24. package/dist/state-manager.d.ts +256 -18
  25. package/dist/state-manager.d.ts.map +1 -1
  26. package/dist/state-manager.js +429 -20
  27. package/dist/state-manager.js.map +1 -1
  28. package/dist/storage-keys.d.ts +8 -0
  29. package/dist/storage-keys.d.ts.map +1 -1
  30. package/dist/storage-keys.js +18 -2
  31. package/dist/storage-keys.js.map +1 -1
  32. package/dist/types.d.ts +180 -34
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/worker-client.d.ts.map +1 -1
  35. package/dist/worker-client.js +37 -11
  36. package/dist/worker-client.js.map +1 -1
  37. package/dist/worker-host.d.ts.map +1 -1
  38. package/dist/worker-host.js +21 -8
  39. package/dist/worker-host.js.map +1 -1
  40. package/dist/worker-rpc-error.d.ts +21 -0
  41. package/dist/worker-rpc-error.d.ts.map +1 -0
  42. package/dist/worker-rpc-error.js +121 -0
  43. package/dist/worker-rpc-error.js.map +1 -0
  44. package/package.json +4 -1
  45. package/src/derived-trie.ts +214 -0
  46. package/src/engine.ts +2 -3
  47. package/src/index.ts +3 -1
  48. package/src/node.ts +1335 -138
  49. package/src/revm-state-store.ts +47 -13
  50. package/src/revm.ts +11 -25
  51. package/src/state-manager.ts +515 -21
  52. package/src/storage-keys.ts +21 -2
  53. package/src/types.ts +183 -35
  54. package/src/worker-client.ts +42 -11
  55. package/src/worker-host.ts +21 -8
  56. package/src/worker-rpc-error.ts +139 -0
package/README.md CHANGED
@@ -48,6 +48,8 @@ npm install comlink
48
48
  installed automatically; `comlink` is an optional peer used only by the Worker
49
49
  entry/client.)
50
50
 
51
+ (`@eip-1193/over-port` is a direct dependency too: about 6 kB, with no runtime dependency of its own, and it is what `node.serveOn(port)` speaks. A consumer on the other end of that port installs it as well, for `providerOverPort`.)
52
+
51
53
  ## Usage (main thread)
52
54
 
53
55
  ```ts
@@ -91,6 +93,8 @@ const node = await createWorkerNode({worker, chainId: 31337, miningConfig: {type
91
93
  // with the SAME viem client code as the main-thread node.
92
94
  ```
93
95
 
96
+ **Errors cross whole.** A worker-hosted node rejects with the same `RpcError` a main-thread node does: same `code`, `message` and `data`, and `instanceof RpcError` on the main thread. So a revert's `data` reaches viem, which decodes it into your contract's custom error exactly as it would on the main thread. (comlink alone carries only an error's message; the worker host sends an `RpcError` across as a plain `{code, message, data}` object and the client rebuilds it, without touching comlink's global transfer handlers.) Any other error arrives as comlink delivers it: an `Error` with its message.
97
+
94
98
  ### A Worker that builds its own engine
95
99
 
96
100
  `worker-entry` exposes the node the moment it is imported, which is what makes
@@ -134,6 +138,37 @@ is synchronous at module scope: the factory defers the await into `createNode()`
134
138
  which is one of the reasons `createEngine` is a function. If you must await
135
139
  something, do it INSIDE `createEngine`.
136
140
 
141
+ ### Serving the node to another worker (worker to worker)
142
+
143
+ A consumer that runs in ANOTHER worker (an indexer, say) can use a worker-hosted node as its EIP-1193 provider directly, without the page relaying its requests. The page makes a `MessageChannel`, hands one end to the node with `node.serveOn(port)` (the client TRANSFERS it into the node's worker), and hands the other end to the consumer, which turns it back into a provider with [`@eip-1193/over-port`](https://www.npmjs.com/package/@eip-1193/over-port)'s `providerOverPort`:
144
+
145
+ ```ts
146
+ // page
147
+ import {createWorkerNode} from 'webevm/worker-client';
148
+
149
+ const node = await createWorkerNode({worker: nodeWorker, chainId: 31337});
150
+ const {port1, port2} = new MessageChannel();
151
+ const served = await node.serveOn(port1);
152
+ indexerWorker.postMessage({provider: port2}, [port2]);
153
+ // later, to stop answering on that port: await served.close();
154
+
155
+ // indexer worker
156
+ import {providerOverPort} from '@eip-1193/over-port';
157
+
158
+ self.addEventListener('message', (event) => {
159
+ if (event.data?.provider) {
160
+ const provider = providerOverPort(event.data.provider);
161
+ // provider.request({method: 'eth_blockNumber'}) goes straight to the node's worker
162
+ }
163
+ });
164
+ ```
165
+
166
+ Only `request` crosses; `onNewHead`, `mine` and the other controls stay with whoever holds `node`. An error the node raises arrives with its `code`, `message` and `data` (an unsupported method is still `-32601`). Call `serveOn` once per consumer: each call serves one port, each returns its own `close()`, and `node.dispose()` stops them all. Every request served this way queues on the node's one-request-at-a-time serialisation point like any other.
167
+
168
+ **It is the same call on a main-thread node.** `createNode()`'s node has `serveOn(port)` too and serves the port in place, so the two kinds of node stay interchangeable. (A main-thread node needs nothing from this package for it anyway: `serveProvider(node, port)` from `@eip-1193/over-port` works on it directly, since a node is an object with a `request`.)
169
+
170
+ **No page code relays the requests, but on Safari the page's thread still carries them.** WebKit routes `MessagePort` traffic between two workers through the main thread inside the engine, so a page that holds its thread busy stalls the consumer's requests until it yields (measured: zero answers during a one-second busy loop, all of them the moment it ends). Chromium carries them without the page's thread. Either way nothing in your page's JavaScript touches them.
171
+
137
172
  ## RPC surface (the contract)
138
173
 
139
174
  This is a **curated, execution-only** method set — NOT a full EIP-1193 provider.
@@ -146,19 +181,19 @@ method-not-found (`-32601`) — it never fakes a result.
146
181
  |---|---|
147
182
  | `eth_chainId`, `net_version` | from `chainId` option |
148
183
  | `eth_blockNumber` | latest mined block number |
149
- | `eth_getBlockByNumber`, `eth_getBlockByHash` | header + (optional) full txs; roots are zero in `'none'` mode. `miner`, `mixHash` and `logsBloom` are **real**: the first two are the block's [`blockEnv`](#genesis-pre-state--block-env) coinbase/prevRandao (the same values `COINBASE`/`PREVRANDAO` return to a contract), the third is the OR of the block's receipt blooms, so the standard pre-filter finds the logs that are there. `sha3Uncles`/`transactionsRoot`/`receiptsRoot`/`difficulty`/`totalDifficulty`/`size`/`nonce` are placeholders, and the header's `gasUsed` is **always `0x0`** (read the receipts' `gasUsed`) |
150
- | `eth_call` | **runs on the [engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)**; pure (never mutates); reverts throw `RpcError(3, 'execution reverted')` |
151
- | `eth_estimateGas` | **runs on the [engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)**; the **smallest gas LIMIT at which the request succeeds**, found by re-executing it, with intrinsic gas (incl. EIP-3860) **+ the request's EIP-2930 `accessList`** (2,400/address + 1,900/key, as geth charges it) as the floor. A request that succeeds at what it consumes — a transfer, a plain deployment — gets exactly that, in one extra execution. A request that reverts at any limit gets `RpcError(3, 'execution reverted')` naming the decoded reason and carrying the callee's bytes; one that is simply too big for the allowance gets `-32000 gas required exceeds allowance` (geth's vocabulary) — never a number. `gas` on the request is the **cap on the search**, capped in turn by the block gas limit |
152
- | `eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount` | state reads at a block tag |
184
+ | `eth_getBlockByNumber`, `eth_getBlockByHash` | header + (optional) full txs; roots are zero unless the node was created with [`computeStateRoot: true`](#state-root-computestateroot-off-by-default-opt-in). `miner`, `mixHash` and `logsBloom` are **real**: the first two are the block's [`blockEnv`](#genesis-pre-state--block-env) coinbase/prevRandao (the same values `COINBASE`/`PREVRANDAO` return to a contract), the third is the OR of the block's receipt blooms, so the standard pre-filter finds the logs that are there. `sha3Uncles`/`transactionsRoot`/`receiptsRoot`/`difficulty`/`totalDifficulty`/`size`/`nonce` are placeholders, and the header's `gasUsed` is **always `0x0`** (read the receipts' `gasUsed`) |
185
+ | `eth_call` | **runs on the [engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)**; pure (never mutates); reverts throw `RpcError(3, 'execution reverted')`; **at the head by default, and at any block in the window with `stateHistory`**, executing against that block's state and block environment (a block below what the node holds is refused, see [State reads at past blocks](#state-reads-at-past-blocks-statehistory)). geth-style **state overrides** (3rd parameter: `balance`, `nonce`, `code`, `state`, `stateDiff`) are applied for that call only, and a malformed or oversized value is `-32602`; any other override field, and **block overrides** (4th parameter), are refused with `-32602` rather than ignored |
186
+ | `eth_estimateGas` | **runs on the [engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)**; the **smallest gas LIMIT at which the request succeeds**, found by re-executing it, with intrinsic gas (incl. EIP-3860) **+ the request's EIP-2930 `accessList`** (2,400/address + 1,900/key, as geth charges it) as the floor. A request that succeeds at what it consumes (a transfer, a plain deployment) gets exactly that, in one extra execution. A request that reverts at any limit gets `RpcError(3, 'execution reverted')` naming the decoded reason and carrying the callee's bytes; one that is simply too big for the allowance gets `-32000 gas required exceeds allowance` (geth's vocabulary), never a number. `gas` on the request is the **cap on the search**, capped in turn by the block gas limit. **At the head by default, and at any block in the window with [`stateHistory`](#state-reads-at-past-blocks-statehistory)**, and takes the same state overrides, like `eth_call` |
187
+ | `eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount` | state reads **at the head by default, and at any block in the window with `stateHistory`** (the values at the end of that block); see [State reads at past blocks](#state-reads-at-past-blocks-statehistory) |
153
188
  | `eth_gasPrice`, `eth_maxPriorityFeePerGas` | **constant** (faked fee market — local chain) |
154
- | `eth_feeHistory` | correct response **shape**, but **constant/faked values** — not for real fee prediction |
189
+ | `eth_feeHistory` | honours `newestBlock` (a block above the head is `-32000`); the window is clamped at genesis and at 1024 blocks, as geth clamps it, so a chain shorter than `blockCount` returns fewer entries; `baseFeePerGas` is each block's own and `gasUsedRatio` is summed from the block's receipts. `reward` is the **constant** `maxPriorityFeePerGas` (flat fee model), so this is not for real fee prediction |
155
190
  | `eth_fillTransaction` | fills missing nonce/gas/fees of a tx request and returns `{tx, raw}` (the `raw` is **unsigned** — sign client-side); viem's `prepareTransactionRequest` uses it. Its gas estimate **runs on the [engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)** |
156
191
  | **`eth_sendRawTransaction`** | accepts a **signed** raw tx; mines per `miningConfig`. **Executes and commits on the [engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)**, through its transaction operation |
157
192
  | **`eth_sendRawTransactionSync`** | the fast path: send + mine + return receipt in one call |
158
193
  | `eth_getTransactionReceipt`, `eth_getTransactionByHash` | from the in-memory store |
159
- | `eth_getLogs` | address + topic filtering over mined logs. **Perf note:** a full linear scan over all logs per call (O(total_logs), no index/cache) — fine for a local chain |
194
+ | `eth_getLogs` | address + topic filtering over mined logs, by `fromBlock`/`toBlock` or by `blockHash` (EIP-234; an unknown hash is `-32000`, a hash together with a range is `-32602`). An omitted `fromBlock` means block **0** here, where geth means `latest`. **Perf note:** a full linear scan over all logs per call (O(total_logs), no index/cache) — fine for a local chain |
160
195
  | `eth_subscribe`/`eth_unsubscribe` | **`newHeads` only**; prefer `onNewHead()` over comlink |
161
- | `evm_setBalance` / `evm_setNonce` / `evm_setCode` / `evm_setStorageAt` / `evm_setAccount` | anvil/hardhat-style runtime state cheats (mutate live state with no tx); commit into the trie in `'trie'` mode |
196
+ | `evm_setBalance` / `evm_setNonce` / `evm_setCode` / `evm_setStorageAt` / `evm_setAccount` | anvil/hardhat-style runtime state cheats (mutate live state with no tx); with `computeStateRoot: true`, `getStateRoot()` reflects them straight away, and the next block's root includes them |
162
197
  | `evm_sendRawTransactionAs` / `evm_sendRawTransactionSyncAs` | `[raw, from]` — execute as `from`, **skipping ecrecover**. Only exist when `senderMode: 'trusted'`; otherwise a loud `-32601`. See [Sender mode](#sender-mode-recover-authenticated-default-vs-trusted-no-ecrecover) |
163
198
 
164
199
  ### Intentionally NOT supported (loud `-32601`)
@@ -230,52 +265,97 @@ method-not-found (`-32601`) — it never fakes a result.
230
265
  client uses an estimate as its gas limit. Mined transactions are unaffected;
231
266
  they are charged and warmed by whichever engine executed them.
232
267
 
233
- ## State mode: `'none'` (fast, default) vs `'trie'` (real state root, opt-in)
268
+ ## State reads at past blocks (`stateHistory`)
269
+
270
+ Every method that reads state at a block (`eth_call`, `eth_estimateGas`, `eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount`) is served at the head. **By default that is all:** the node keeps one state, the one at its head, and a block below it is refused. **With `stateHistory: {blocks: N}` it also serves the last N blocks below the head**, answering exactly as a node holding that block's state would, on both [engines](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in):
234
271
 
235
272
  ```ts
236
- const fast = await createNode({stateMode: 'none'}); // default — SimpleStateManager
237
- const conformant = await createNode({stateMode: 'trie'}); // MerkleStateManager
273
+ const node = await createNode({chainId: 31337, stateHistory: {blocks: 64}});
274
+ // With block 100 the head, blocks 36 to 100 are readable:
275
+ await node.request({method: 'eth_getStorageAt', params: [contract, slot, '0x40']});
276
+ await node.request({method: 'eth_call', params: [{to: contract, data}, '0x40']});
238
277
  ```
239
278
 
240
- - **`'none'`** (default): `SimpleStateManager`, no trie, no state root. The fast
241
- path; measured only **~1.4× faster per signed call / ~1.35× on deploy** than trie
242
- for typical workloads (so the cost of turning the root on is small). Block
279
+ This is what a client needs whose head moves between reading a block number and issuing the reads it pins to it (interval mining, a second tab, a transaction of its own): `eth_getLogs` up to block K and `eth_call` at block K then describe the same moment.
280
+
281
+ - **Served, always:** `latest`, `pending`, `safe`, `finalized`, an omitted block, and a number, a hash or an EIP-1898 `{blockNumber}` / `{blockHash}` object that names the **head** block. Pinning to the block you just read is the common case, and that block is usually the head. `pending` is the head because queued transactions (`manual`/`interval` mining) have not executed yet, with one exception: `eth_getTransactionCount(addr, 'pending')` (and the nonce `eth_fillTransaction` fills) counts the sender's queued transactions, so two sends before a mine get two nonces.
282
+ - **Served with `stateHistory: {blocks: N}`:** any block K from `head - N` to the head, named by number, hash, `{blockNumber}` / `{blockHash}`, or `earliest` while block 0 is in the window. The four point reads return the values at the end of block K. `eth_call` and `eth_estimateGas` **execute** at K: against K's state AND K's block environment (`NUMBER`, `TIMESTAMP`, `COINBASE`, `PREVRANDAO`, `BASEFEE`, `GASLIMIT`), with `BLOCKHASH` answering for the blocks below K and zero from K up, and with state overrides applied on top of K's state. (`eth_estimateGas` at K still caps its search at the head's block gas limit, since the number is for a transaction you would send now.) An `evm_set*` cheat shows at the head it was applied on top of (as `latest` always has) and, once the next block is mined, from that block on, never at an older block; a call, an estimate or a reverted transaction never changes what the past was.
283
+ - **Refused, `-32000 historical state not available`:** a block below what the node holds: without `stateHistory`, every block below the head; with it, every block below `head - N` (and, after loading a dump that held less history, below where its history starts). The message names the oldest block the node can serve and the option that widens the window. geth answers pruned state with `-32000 missing trie node`, so a client handles both the same way.
284
+ - **Refused, `-32000 header not found`:** a block above the head, or a hash no block has (geth's wording).
285
+ - **Refused, `-32602`:** a block parameter that is not a block reference.
286
+
287
+ Blocks, receipts and logs are **not** affected by any of this: `eth_getBlockByNumber` and `eth_getLogs` work at any height. Up to and including 0.7.0 the six state methods ignored the block parameter and answered from the head, which was silently wrong: a client that pinned `eth_getLogs` and `eth_call` to the same block got logs as of that block and storage as of a later one.
288
+
289
+ **Opt-in, with no default window.** A node created without the option records nothing, pays nothing and refuses below the head. `N` must be a positive safe integer; anything else throws at construction. It works with and without `computeStateRoot`: every node runs on the same flat state the history records. The history **is persisted**: `dumpState` carries it and `loadState` restores it, so an [IndexedDB](#persistence-indexeddb) reload serves the same window. A dump written without history (or before this option existed) still loads, with history starting at its head; a dump holding more blocks than the loading node's N is cut to N, one holding fewer serves what it has. The option passes through `createWorkerNode` / `exposeNode` like every other, and historical reads work the same over a port handed to `node.serveOn(port)` as through `node.request`.
290
+
291
+ **How it works:** an undo log over the node's one state, not copies of it. While block j is built, the node records, for each account, code entry and storage slot the block changes, the value it had at the end of block j - 1; the records of the last N blocks are kept and older ones evicted as each block is mined. A point read at K takes the first record for its key after K, or the live value. A historical `eth_call` applies every key changed since K as a state override inside the call's own reverted checkpoint. The reasoning, and the alternatives rejected (per-block snapshots, retained tries, diffing), is [ADR 0013](docs/adr/0013-bounded-state-history-is-an-undo-log-over-the-flat-state.md); the gate every state method goes through is `historicalBlock` in `src/node.ts`.
292
+
293
+ ### What it costs
294
+
295
+ Measured, not estimated: [`docs/spikes/bounded-state-history-cost/results.md`](docs/spikes/bounded-state-history-cost/results.md) (the script that produced it is beside it). V8 under Node on a desktop CPU, so read the orders of magnitude.
296
+
297
+ - **Memory: about 300 bytes per changed key per retained block**, for a key that held a value before the block; about 50 bytes for a key the block created; plus well under 1 KB per retained block. The keys a block changes are every storage slot written, every account touched (a simple call touches 3: sender, callee, coinbase) and every contract deployed. Clearing an account's storage (creation over existing storage, `SELFDESTRUCT`) records every slot it held, once. Memory is linear in keys: 10 times the slots per block is 10 times the memory.
298
+ - **Per block: nothing measurable.** The record is taken at the write, where the key is already in hand.
299
+ - **A historical `eth_call` / `eth_estimateGas` costs in proportion to the keys changed since K:** about 0.8 µs per distinct key changed in blocks K+1 to the head (each is applied before the call runs), plus about 0.03 µs per further record of a key already applied. At the head it is an ordinary call.
300
+ - **A historical point read is microseconds:** it looks its one key up in the records after K and stops at the first that names it.
301
+ - **In `dumpState` (what IndexedDB stores): about 80 to 200 bytes per recorded key.**
302
+
303
+ **Sizing it for a game.** A game that mines one block per move, where a move rewrites M = 100 storage slots, with a window of N = 256 blocks: 256 x 103 keys x 300 bytes is about **7.9 MB** (measured: 7.92 MB), and a call at the oldest block in the window applies the 103 distinct keys over 26,368 records in about **0.5 ms**. If instead every block wrote 100 slots nobody wrote before, the memory drops to about 1.4 MB (the records hold "absent") but a call at the oldest block applies 25,600 distinct keys: about **20 ms**. So: memory is about N x (keys per block) x 300 bytes, and the call at K is about 0.8 µs per distinct key changed since K. A window a few blocks deeper than your client's worst-case lag (how far the head can move between reading a block number and pinning reads to it) is usually all a game needs; `N = 16` at M = 100 is about 0.5 MB.
304
+
305
+ ## State root: `computeStateRoot` (off by default, opt-in)
306
+
307
+ ```ts
308
+ const fast = await createNode(); // default: no state root
309
+ const conformant = await createNode({computeStateRoot: true}); // + a real state root
310
+ ```
311
+
312
+ **Every node runs on ONE state**: our `SimpleStateManager` subclass, plain Maps
313
+ with no trie. `computeStateRoot: true` does not change that state or how anything executes; it
314
+ ADDITIONALLY keeps a Merkle-Patricia trie **derived** from it, updated at the end
315
+ of each block from the keys that block changed, and reports the trie's root
316
+ ([ADR 0014](docs/adr/0014-the-trie-is-derived-from-the-flat-state-not-a-state-manager.md)).
317
+
318
+ - **Without it** (default): no trie and no trie work at all. Block
243
319
  `stateRoot`/`receiptsRoot`/`transactionsRoot` are zero placeholders and
244
- `node.getStateRoot()` throws (there is no root). **Full-storage
245
- persistence is a `'none'`-mode feature.**
246
- - **`'trie'`** (opt-in): `MerkleStateManager` — a real Merkle-Patricia trie.
247
- `node.getStateRoot()` returns the **real** root and block headers carry it. This
248
- is what lets the node be **conformance-tested against `ethereum/tests`
249
- GeneralStateTests** (they verify exactly that post-state root). Bundle cost ~0
250
- (the trie code is already pulled in transitively by `@ethereumjs/vm`).
251
- Caveat: trie-mode `dumpState` carries accounts + code but **not** contract
252
- storage — use `'none'` for IndexedDB persistence, `'trie'` for the state root /
253
- conformance.
254
-
255
- One behaviour genuinely differs between the modes, when a contract is created at
256
- an address that **already holds storage** (reachable via `evm_setStorageAt`, a
257
- `loadState`, or a re-deploy after `SELFDESTRUCT`):
258
-
259
- - **`'none'`** clears that storage and the creation **succeeds**, so the new
260
- contract starts empty. This is the pre-EIP-7610 behaviour, and it is what the
261
- EVM itself asks for on every create.
262
- - **`'trie'`** has a real `storageRoot`, so the EIP-7610 collision check fires and
263
- the creation **fails** with a revert. This is the spec-current behaviour.
264
-
265
- A DELETED account, by contrast, behaves the SAME in both modes: a `SELFDESTRUCT`
266
- (or an EIP-161 empty-account clearing) takes the account's storage with it, so a
267
- destroyed contract's slots read `0` and `dumpState` stops carrying them. That is
268
- free in `'trie'` (the account's storage trie goes with the account) and is our
269
- override in `'none'`, where upstream `SimpleStateManager.deleteAccount` leaves
270
- storage where it was — the same gap as the `clearStorage` no-op below, and
271
- recorded in the same ADR.
272
-
273
- Neither mode lets the new contract *inherit* the old storage, which is the part
274
- that would silently corrupt results. `'none'` cannot detect the collision at all,
275
- because detecting it means reading a `storageRoot` that mode does not have. Note
276
- that `@ethereumjs/statemanager@10.1.2` does not clear it either — its
277
- `SimpleStateManager.clearStorage` is an empty no-op, so we override it and a fresh
278
- contract does read `0`
320
+ `node.getStateRoot()` throws (there is no root).
321
+ - **`computeStateRoot: true`** (opt-in): `node.getStateRoot()` returns the **real** root (including
322
+ `evm_set*` cheats made since the last block) and every block header carries the
323
+ root of its post-state. This is what lets the node be **conformance-tested
324
+ against `ethereum/tests` GeneralStateTests** (they verify exactly that post-state
325
+ root). Execution never touches the trie, so what it costs is a root update per
326
+ block proportional to what the block changed, and it works with **both
327
+ engines**, the [revm engine](#engine-ethereumjsevm-default-vs-revm-wasm-opt-in)
328
+ included. Everything else is the same as without it: `dumpState` carries the full
329
+ state, storage included (the trie is not serialised; `loadState` rebuilds it, so
330
+ a reloaded chain reports the same roots), and
331
+ [`stateHistory`](#state-reads-at-past-blocks-statehistory) works in it.
332
+
333
+ **What it costs, measured.** Execution costs exactly what it costs without the option: reads, `eth_call` and MGas/s do not move on either engine, and gas is identical (the benchmark suite's gas gate covers both `computeStateRoot` rows). What it adds is the root update at the end of each block, and that is **linear in the storage slots the block changed, at about 0.1 ms per slot** (80-130 µs across two runs, the same on both engines and in Chromium and WebKit, because the update runs in JS after execution whichever engine ran it). A one-slot block (a small transaction) gains about 0.25 ms; 100 slots about 9-10 ms; **300 slots about 25-39 ms**; 1,000 slots about 100-125 ms. So for a game that rewrites a few hundred slots per block, the root update, not execution, is the block's cost: on the revm engine a 300-slot block goes from under 1 ms to 26-39 ms. Leave the option off unless you need the root. Source: the `computeStateRoot` rows and the root-update measurement in [`packages/benchmarks`](packages/benchmarks), figures and conditions in [`docs/spikes/computestateroot-cost-benchmark/measurements.md`](docs/spikes/computestateroot-cost-benchmark/measurements.md) (the per-slot cost is tracked in [`work/notes/observations/2026-09-28-computestateroot-root-update-dominates-a-game-block.md`](work/notes/observations/2026-09-28-computestateroot-root-update-dominates-a-game-block.md)).
334
+
335
+ **Turning it on cannot change what a contract does.** One case is worth
336
+ spelling out, because Ethereum itself changed its answer: a contract CREATED at an
337
+ address that has no nonce and no code but **already holds storage** (reachable via
338
+ `evm_setStorageAt`, `evm_setAccount`, `initialState` or a `loadState`). Every node,
339
+ with or without `computeStateRoot` and on both engines, follows the reference spec (EIP-684 plus the
340
+ Yellow Paper, as execution-specs now specifies it): that is **not** a collision,
341
+ so the creation **succeeds** and the old storage is **wiped**, and the new contract
342
+ starts empty. A nonce or code at the target is still a collision, refused
343
+ everywhere. EIP-7610 (a collision on storage too) is not what this node does: it
344
+ never became final, the reference spec went the other way, and the storage-only
345
+ shape is being retired on mainnet by bumping those accounts' nonces instead. The
346
+ evidence is in
347
+ [`work/notes/findings/storage-only-creation-collisions-are-not-refused-by-the-reference-spec.md`](work/notes/findings/storage-only-creation-collisions-are-not-refused-by-the-reference-spec.md).
348
+ (A root-computing node, then called `'trie'` mode, used to refuse that creation,
349
+ because it ran on `MerkleStateManager`, whose real `storageRoot` fed the EIP-7610
350
+ check; that asymmetry is gone.)
351
+
352
+ A DELETED account likewise behaves the same everywhere: a `SELFDESTRUCT` (or an
353
+ EIP-161 empty-account clearing) takes the account's storage with it, so a
354
+ destroyed contract's slots read `0` and `dumpState` stops carrying them. Neither
355
+ case lets a new contract *inherit* old storage, which is the part that would
356
+ silently corrupt results. Note that `@ethereumjs/statemanager@10.1.2` clears
357
+ nothing on either path: its `SimpleStateManager.clearStorage` is an empty no-op
358
+ and its `deleteAccount` leaves storage where it was, so we override both
279
359
  ([ADR 0007](docs/adr/0007-we-override-simplestatemanagers-no-op-clearstorage.md)).
280
360
 
281
361
  ## Sender mode: `'recover'` (authenticated, default) vs `'trusted'` (no ecrecover)
@@ -481,12 +561,15 @@ geth (`ErrInsufficientBalance`). A read never invents funds it can then report.
481
561
 
482
562
  Caveats, all of them real:
483
563
 
484
- - **`stateMode:'none'` only.** revm reads the node's state SYNCHRONOUSLY (an
564
+ - **With and without `computeStateRoot`.** revm reads the node's state SYNCHRONOUSLY (an
485
565
  interpreter has no suspension point mid-opcode) through `SimpleStateManager`'s
486
- checkpoint stacks, and `MerkleStateManager` has no synchronous view at any
487
- depth ([ADR 0005](docs/adr/0005-revm-reads-the-nodes-state-through-simplestatemanagers-stacks.md)).
488
- `createNode({stateMode:'trie', engine: revm})` **throws at construction**,
489
- naming the reason.
566
+ checkpoint stacks
567
+ ([ADR 0005](docs/adr/0005-revm-reads-the-nodes-state-through-simplestatemanagers-stacks.md)),
568
+ and every node runs on that state: with `computeStateRoot: true` the trie is derived
569
+ from it after each block and never read during execution
570
+ ([ADR 0014](docs/adr/0014-the-trie-is-derived-from-the-flat-state-not-a-state-manager.md)),
571
+ so `createNode({computeStateRoot: true, engine: revm})` gives the fast engine and a
572
+ real state root together. (It used to throw at construction.)
490
573
  - **Only the hardforks it can COST.** The engine serves `berlin`, `london`,
491
574
  `paris`, `shanghai` and `cancun` (the node runs Cancun) and refuses `prague`
492
575
  and `osaka` at construction, naming the EIP: revm enforces EIP-7623's calldata
@@ -589,12 +672,14 @@ where execution runs OUT of gas.
589
672
  fields apply to the **genesis** block as well, describing the environment the
590
673
  chain runs under; `number`, `timestamp` and `gasLimit` are mined-block-only
591
674
  (block 0 is block 0).
675
+ - **`genesisTimestamp`**: block 0's timestamp, a `bigint` in seconds since the epoch (the unit of `blockEnv.timestamp`). Absent means the wall clock at `createNode()`, so two nodes created in different seconds hash every block differently; set it (with `blockEnv.timestamp` pinning the mined blocks) and the same chain gives the same hashes and a byte-identical `dumpState`. It moves only block 0: mined blocks keep the wall clock (or `blockEnv.timestamp`) even when it is in the future. A `loadState` (or an IndexedDB restore) brings its own block 0, which wins. Anything but a non-negative `bigint` throws at construction.
592
676
 
593
677
  ## Persistence (IndexedDB)
594
678
 
595
679
  `createIndexedDBPersistence()` writes the dumped state as a single IndexedDB record
596
680
  and rehydrates on `createNode()`. No trie, no RLP state-root walk — live-set-sized.
597
- Verified to round-trip across a real page reload, including `eth_getLogs`.
681
+ Verified to round-trip across a real page reload, including `eth_getLogs`, and
682
+ including the [`stateHistory`](#state-reads-at-past-blocks-statehistory) window.
598
683
 
599
684
  ## Mining
600
685
 
@@ -605,14 +690,15 @@ Verified to round-trip across a real page reload, including `eth_getLogs`.
605
690
 
606
691
  `GeneralStateTests` / `execution-spec-tests` verify a tx by comparing the
607
692
  post-state **Merkle-Patricia trie root** (`hash`) + a `keccak(RLP(logs))` hash. The
608
- default `stateMode:'none'` has no trie/root by design, so it can't consume those
609
- fixtures — but the opt-in `stateMode:'trie'` **can**, and the test suite does
610
- exactly that (see `test/statetest.spec.ts`, 5/5 vendored cases pass). `VMTests`
693
+ default node has no trie/root by design, so it can't consume those
694
+ fixtures, but the opt-in `computeStateRoot: true` **can**, and the test suite does
695
+ exactly that (see `test/statetest.spec.ts`, 5/5 vendored cases pass, and
696
+ `test/revm-statetest.spec.ts`, the same cases with the revm engine executing). `VMTests`
611
697
  (the one trie-free format) is frozen at Homestead and useless for a Cancun node.
612
698
  Beyond that, the test suite also runs a **differential** conformance check
613
699
  (`test/conformance.spec.ts`): a battery of signed txs through BOTH the node and a
614
700
  hand-wired trie-backed `@ethereumjs/vm` `runTx` reference, asserting field-by-field
615
- equality of receipts/logs/return-data/gas/post-state in both state modes. That
701
+ equality of receipts/logs/return-data/gas/post-state with and without `computeStateRoot`. That
616
702
  reference is the oracle for the receipt and post-state steps but deliberately not
617
703
  for all of them: the block-environment and value-bearing steps are diffed instead
618
704
  against the node's OWN block plus the `blockEnv` it was configured with, and
@@ -643,11 +729,10 @@ Listing an entry a transaction touches is **100 gas cheaper** (charged 2,400 or
643
729
  **+6,200 exactly**, and a dropped list is 0.
644
730
 
645
731
  That same battery runs once more with the optional revm engine installed
646
- (`test/revm-conformance.spec.ts`), in the one state mode that engine serves
647
- (`'none'` — it refuses `'trie'` at construction), so the alternative EVM faces
648
- the repo's strongest correctness bar rather than a softer one of its own. Nothing
649
- is relaxed for it: `test/conformance.spec.ts` still runs both modes on the
650
- default engine, unchanged.
732
+ (`test/revm-conformance.spec.ts`), with and without `computeStateRoot`, so the alternative EVM
733
+ faces the repo's strongest correctness bar rather than a softer one of its own.
734
+ Nothing is relaxed for it: `test/conformance.spec.ts` still runs both configurations on
735
+ the default engine, unchanged.
651
736
 
652
737
  The node's own state-owning features are held to that same bar rather than
653
738
  assumed to survive: `dumpState`, `loadState`, IndexedDB persistence and the
@@ -0,0 +1,38 @@
1
+ import type { Common } from '@ethereumjs/common';
2
+ import type { ChangeSet, OverlayStorageStateManager } from './state-manager.js';
3
+ /** See {@link created}. Not exported from `src/index.ts`. */
4
+ export declare function derivedTriesCreatedForTests(): number;
5
+ export declare class DerivedStateTrie {
6
+ private readonly flat;
7
+ private readonly common;
8
+ private readonly accounts;
9
+ /** Only accounts whose storage is non-empty have an entry. */
10
+ private readonly storage;
11
+ private constructor();
12
+ /**
13
+ * Build the trie from the WHOLE flat state. O(state), paid once per
14
+ * construction or load, never per block.
15
+ */
16
+ static build(flat: OverlayStorageStateManager, common: Common): Promise<DerivedStateTrie>;
17
+ /**
18
+ * Bring the trie up to date with every key `changes` names, reading each
19
+ * key's CURRENT value from the flat state. Idempotent. O(keys named).
20
+ */
21
+ apply(changes: ChangeSet): Promise<void>;
22
+ /** The state root: the account trie's root. */
23
+ root(): Uint8Array;
24
+ /**
25
+ * Write one account into the account trie as the flat state holds it now,
26
+ * with its `storageRoot` from its storage trie, or delete it when the flat
27
+ * state has none.
28
+ */
29
+ private writeAccount;
30
+ private newTrie;
31
+ /**
32
+ * The trie reads the BOTTOM of the flat state's stacks, which is committed
33
+ * state only while no checkpoint is open. Anything else would put a
34
+ * mid-execution state into the root, so it is refused rather than guessed at.
35
+ */
36
+ private requireNoCheckpoint;
37
+ }
38
+ //# sourceMappingURL=derived-trie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derived-trie.d.ts","sourceRoot":"","sources":["../src/derived-trie.ts"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EACX,SAAS,EACT,0BAA0B,EAE1B,MAAM,oBAAoB,CAAC;AAe5B,6DAA6D;AAC7D,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED,qBAAa,gBAAgB;IAM3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,8DAA8D;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmD;IAE3E,OAAO;IAQP;;;OAGG;WACU,KAAK,CACjB,IAAI,EAAE,0BAA0B,EAChC,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,gBAAgB,CAAC;IAiB5B;;;OAGG;IACG,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB9C,+CAA+C;IAC/C,IAAI,IAAI,UAAU;IAIlB;;;;OAIG;YACW,YAAY;IAiB1B,OAAO,CAAC,OAAO;IAQf;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAU3B"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * derived-trie.ts: the Merkle-Patricia trie a `computeStateRoot: true` node DERIVES
3
+ * from its flat state, and nothing else.
4
+ *
5
+ * Every node runs on ONE state representation: the flat
6
+ * `OverlayStorageStateManager` (./state-manager.ts). A node with `computeStateRoot: true`
7
+ * ADDITIONALLY keeps this object, which mirrors that state as a real Ethereum
8
+ * state trie so the node can report a real state root. The decision and what it
9
+ * replaced (`MerkleStateManager` as the node's state manager) are in
10
+ * `docs/adr/0014-the-trie-is-derived-from-the-flat-state-not-a-state-manager.md`.
11
+ *
12
+ * ## The shape, which is Ethereum's
13
+ *
14
+ * - ONE account trie, keyed by `keccak(address)` (the trie hashes the key
15
+ * itself: `useKeyHashing`), whose value is `RLP([nonce, balance, storageRoot,
16
+ * codeHash])`.
17
+ * - ONE storage trie per account, keyed by `keccak(slot)`, whose value is
18
+ * `RLP(value)` with the value in shortest form; a zero value is ABSENT.
19
+ * - An account's `storageRoot` is taken from ITS storage trie at the moment the
20
+ * account is written into the account trie. The flat state's own `Account`
21
+ * objects never carry a real `storageRoot` (`SimpleStateManager` has no trie),
22
+ * and that is deliberate: the collision rule every engine applies reads it, and
23
+ * every node follows the reference spec there (see the ADR).
24
+ *
25
+ * ## The flat state is the source, the change set is the index
26
+ *
27
+ * {@link DerivedStateTrie.build} reads the WHOLE flat state once (at
28
+ * construction, after the genesis baselines, and at the end of `loadState`).
29
+ * From then on {@link DerivedStateTrie.apply} takes a change set (the open record
30
+ * of ./state-manager.ts) and uses it ONLY AS A LIST OF KEYS: every value is read
31
+ * from the flat state as it stands now, never from the record, whose values are
32
+ * the PRIOR ones. That makes `apply` idempotent, which is what lets the node
33
+ * apply the open record for a `getStateRoot()` between blocks and again, as part
34
+ * of the block's record, when the next block is mined.
35
+ *
36
+ * A storage CLEAR (`storageCleared`) replaces the account's storage trie with an
37
+ * empty one before its named slots are re-read: the clear recorded every slot
38
+ * the account held and every later write records its own slot, so the slots the
39
+ * record names are a superset of what can be live afterwards.
40
+ *
41
+ * ## It never runs during execution
42
+ *
43
+ * Both entry points require NO checkpoint to be open (they read the bottom of
44
+ * the flat state's stacks) and the node calls them only at the end of a mined
45
+ * block and inside `getStateRoot()`, both inside the serialisation point. The
46
+ * trie is async (`@ethereumjs/mpt`), and that costs no opcode anything because
47
+ * no engine ever reads it: this is why revm can run on a root-computing node.
48
+ *
49
+ * ## Old nodes are pruned
50
+ *
51
+ * Each trie has its OWN in-memory database and runs with `useNodePruning`, so a
52
+ * node replaced by a write is deleted rather than retained. The node reports the
53
+ * root of its head and nothing older (history is `stateHistory`'s undo log, not
54
+ * old tries), so a retained node could never be read again; keeping them would
55
+ * make a long-lived in-browser node's memory grow with every block. A dropped
56
+ * storage trie (account deleted, storage cleared) is simply released.
57
+ */
58
+ import { MerklePatriciaTrie } from '@ethereumjs/mpt';
59
+ import { RLP } from '@ethereumjs/rlp';
60
+ import { Account, equalsBytes, hexToBytes, unpadBytes } from '@ethereumjs/util';
61
+ import { packAddressKey, packedKeyBytes, unpackAddressKey, } from './storage-keys.js';
62
+ /**
63
+ * How many {@link DerivedStateTrie} objects this module has ever created. TEST
64
+ * ONLY: it is how a node without `computeStateRoot` is PROVEN to do no trie work (not one is created
65
+ * by a node that does not compute roots), which a flag on the node could only
66
+ * claim.
67
+ */
68
+ let created = 0;
69
+ /** See {@link created}. Not exported from `src/index.ts`. */
70
+ export function derivedTriesCreatedForTests() {
71
+ return created;
72
+ }
73
+ export class DerivedStateTrie {
74
+ flat;
75
+ common;
76
+ accounts;
77
+ /** Only accounts whose storage is non-empty have an entry. */
78
+ storage = new Map();
79
+ constructor(flat, common) {
80
+ this.flat = flat;
81
+ this.common = common;
82
+ created++;
83
+ this.accounts = this.newTrie();
84
+ }
85
+ /**
86
+ * Build the trie from the WHOLE flat state. O(state), paid once per
87
+ * construction or load, never per block.
88
+ */
89
+ static async build(flat, common) {
90
+ const trie = new DerivedStateTrie(flat, common);
91
+ trie.requireNoCheckpoint('build');
92
+ // Storage first, so every account is written with its final storageRoot.
93
+ // The bottom overlay IS committed storage and holds no tombstones
94
+ // (./state-manager.ts), so its `written` map is the whole of it.
95
+ for (const [addressKey, slots] of flat.storageOverlays[0].written) {
96
+ const st = trie.newTrie();
97
+ for (const [slotKey, value] of slots)
98
+ await putSlot(st, packedKeyBytes(slotKey), value);
99
+ if (!isEmptyTrie(st))
100
+ trie.storage.set(addressKey, st);
101
+ }
102
+ for (const [addressHex, account] of flat.accountStack[0])
103
+ if (account !== undefined)
104
+ await trie.writeAccount(addressHex);
105
+ return trie;
106
+ }
107
+ /**
108
+ * Bring the trie up to date with every key `changes` names, reading each
109
+ * key's CURRENT value from the flat state. Idempotent. O(keys named).
110
+ */
111
+ async apply(changes) {
112
+ this.requireNoCheckpoint('apply');
113
+ const dirty = new Set();
114
+ for (const addressHex of changes.accounts.keys())
115
+ dirty.add(addressHex);
116
+ for (const addressHex of changes.code.keys())
117
+ dirty.add(addressHex);
118
+ for (const addressKey of changes.storageCleared) {
119
+ this.storage.delete(addressKey);
120
+ dirty.add(unpackAddressKey(addressKey));
121
+ }
122
+ for (const [addressKey, slots] of changes.storage) {
123
+ const st = this.storage.get(addressKey) ?? this.newTrie();
124
+ for (const slotKey of slots.keys()) {
125
+ const value = this.flat.storageAt(addressKey, slotKey);
126
+ await putSlot(st, packedKeyBytes(slotKey), value);
127
+ }
128
+ if (isEmptyTrie(st))
129
+ this.storage.delete(addressKey);
130
+ else
131
+ this.storage.set(addressKey, st);
132
+ dirty.add(unpackAddressKey(addressKey));
133
+ }
134
+ for (const addressHex of dirty)
135
+ await this.writeAccount(addressHex);
136
+ }
137
+ /** The state root: the account trie's root. */
138
+ root() {
139
+ return this.accounts.root();
140
+ }
141
+ /**
142
+ * Write one account into the account trie as the flat state holds it now,
143
+ * with its `storageRoot` from its storage trie, or delete it when the flat
144
+ * state has none.
145
+ */
146
+ async writeAccount(addressHex) {
147
+ const key = hexToBytes(addressHex);
148
+ const account = this.flat.accountStack[0].get(addressHex);
149
+ if (account === undefined) {
150
+ await this.accounts.del(key);
151
+ return;
152
+ }
153
+ const st = this.storage.get(packAddressKey(key));
154
+ const derived = new Account(account.nonce, account.balance, st === undefined ? undefined : st.root(), account.codeHash);
155
+ await this.accounts.put(key, derived.serialize());
156
+ }
157
+ newTrie() {
158
+ return new MerklePatriciaTrie({
159
+ useKeyHashing: true,
160
+ useNodePruning: true,
161
+ common: this.common,
162
+ });
163
+ }
164
+ /**
165
+ * The trie reads the BOTTOM of the flat state's stacks, which is committed
166
+ * state only while no checkpoint is open. Anything else would put a
167
+ * mid-execution state into the root, so it is refused rather than guessed at.
168
+ */
169
+ requireNoCheckpoint(what) {
170
+ if (this.flat.accountStack.length !== 1 ||
171
+ this.flat.storageOverlays.length !== 1)
172
+ throw new Error(`webevm: the derived state trie was asked to ${what} with a checkpoint ` +
173
+ 'open; a state root is computed only between executions.');
174
+ }
175
+ }
176
+ /** One slot into a storage trie: shortest form, RLP-encoded; zero deletes. */
177
+ async function putSlot(trie, slot, value) {
178
+ const short = value === undefined ? undefined : unpadBytes(value);
179
+ if (short === undefined || short.length === 0)
180
+ await trie.del(slot);
181
+ else
182
+ await trie.put(slot, RLP.encode(short));
183
+ }
184
+ function isEmptyTrie(trie) {
185
+ return equalsBytes(trie.root(), trie.EMPTY_TRIE_ROOT);
186
+ }
187
+ //# sourceMappingURL=derived-trie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derived-trie.js","sourceRoot":"","sources":["../src/derived-trie.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEpC,OAAO,EAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAM9E,OAAO,EACN,cAAc,EACd,cAAc,EACd,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,IAAI,OAAO,GAAG,CAAC,CAAC;AAEhB,6DAA6D;AAC7D,MAAM,UAAU,2BAA2B;IAC1C,OAAO,OAAO,CAAC;AAChB,CAAC;AAED,MAAM,OAAO,gB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I,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC;YAEtC,MAAM,IAAI,KAAK,CACd,+CAA+C,IAAI,qBAAqB;gBACvE,yDAAyD,CAC1D,CAAC;IACJ,CAAC;CACD;AAED,8EAA8E;AAC9E,KAAK,UAAU,OAAO,CACrB,IAAwB,EACxB,IAAgB,EAChB,KAA6B;IAE7B,MAAM,KAAK,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAClE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;;QAC/D,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,WAAW,CAAC,IAAwB;IAC5C,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;AACvD,CAAC"}
package/dist/engine.d.ts CHANGED
@@ -58,8 +58,7 @@ export declare function createEthereumjsEngine(deps: {
58
58
  * engine to mine on, so this is a missing capability the node cannot supply;
59
59
  * 3. its `connect(context)` throws, either because it cannot initialise (no
60
60
  * wasm, no memory) or because it refuses this node's configuration (the
61
- * revm engine refuses `stateMode:'trie'`, having no synchronous view of a
62
- * `MerkleStateManager` to read through).
61
+ * revm engine refuses a hardfork it cannot cost, ADR 0008).
63
62
  *
64
63
  * The engine's own message is preserved verbatim inside the thrown error's
65
64
  * message (not only as `cause`), because the engine is the only party that
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAQ,KAAK,EAAE,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAG9D,OAAO,KAAK,EACX,MAAM,EACN,aAAa,EAKb,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC5C,EAAE,EAAE,EAAE,CAAC;IACP,YAAY,EAAE,qBAAqB,CAAC;CACpC,GAAG,MAAM,CA6GT;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,aAAa,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAoCf"}
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAQ,KAAK,EAAE,EAAC,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAG9D,OAAO,KAAK,EACX,MAAM,EACN,aAAa,EAKb,MAAM,YAAY,CAAC;AAEpB,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC5C,EAAE,EAAE,EAAE,CAAC;IACP,YAAY,EAAE,qBAAqB,CAAC;CACpC,GAAG,MAAM,CA6GT;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,aAAa,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAoCf"}
package/dist/engine.js CHANGED
@@ -214,8 +214,7 @@ function effectiveGasPrice(tx, blockBaseFee) {
214
214
  * engine to mine on, so this is a missing capability the node cannot supply;
215
215
  * 3. its `connect(context)` throws, either because it cannot initialise (no
216
216
  * wasm, no memory) or because it refuses this node's configuration (the
217
- * revm engine refuses `stateMode:'trie'`, having no synchronous view of a
218
- * `MerkleStateManager` to read through).
217
+ * revm engine refuses a hardfork it cannot cost, ADR 0008).
219
218
  *
220
219
  * The engine's own message is preserved verbatim inside the thrown error's
221
220
  * message (not only as `cause`), because the engine is the only party that
@@ -249,7 +248,7 @@ export async function connectEngine(engine, context) {
249
248
  catch (err) {
250
249
  throw new Error(`webevm: the engine '${engine.id}' could not be connected, so the node was NOT created. ` +
251
250
  `It is deliberately NOT replaced by the default @ethereumjs/evm engine: that node would work, return correct results, and run at a completely different speed from the one you asked for, silently. ` +
252
- `Fix the configuration (this node is stateMode:'${context.stateMode}') or pass a different engine. Cause: ${message(err)}`, { cause: err });
251
+ `Fix the engine's configuration or pass a different engine. Cause: ${message(err)}`, { cause: err });
253
252
  }
254
253
  }
255
254
  /** A short, safe rendering of whatever was passed as an engine. */