@aztec/ethereum 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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/dest/client.d.ts +27 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +63 -8
- package/dest/config.d.ts +17 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +38 -10
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/governance.d.ts +135 -35
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +229 -18
- package/dest/contracts/governance_proposer.d.ts +33 -2
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +54 -6
- package/dest/contracts/gse.d.ts +4 -2
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/gse.js +2 -2
- package/dest/contracts/inbox.d.ts +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +12 -7
- package/dest/contracts/index.d.ts +4 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -2
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -94
- package/dest/contracts/outbox.d.ts +27 -4
- package/dest/contracts/outbox.d.ts.map +1 -1
- package/dest/contracts/outbox.js +34 -7
- package/dest/contracts/registry.d.ts +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +5437 -34
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +448 -104
- package/dest/contracts/slashing_proposer.d.ts +171 -0
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/slashing_proposer.js +753 -0
- package/dest/contracts/watch_event.d.ts +36 -0
- package/dest/contracts/watch_event.d.ts.map +1 -0
- package/dest/contracts/watch_event.js +66 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +5 -9
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +48 -27
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/foundry_binary.d.ts +13 -0
- package/dest/foundry_binary.d.ts.map +1 -0
- package/dest/foundry_binary.js +52 -0
- package/dest/generated/l1-contracts-defaults.d.ts +3 -3
- package/dest/generated/l1-contracts-defaults.js +3 -3
- package/dest/l1_artifacts.d.ts +15524 -15847
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +101 -82
- package/dest/l1_reader.d.ts +5 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +9 -7
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +17 -4
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +156 -79
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +57 -23
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
- package/dest/publisher_manager.d.ts +34 -8
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +119 -8
- package/dest/queries.d.ts +13 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +62 -3
- package/dest/test/blob_kzg_warmup.d.ts +19 -0
- package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
- package/dest/test/blob_kzg_warmup.js +64 -0
- package/dest/test/chain_monitor.d.ts +55 -4
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +104 -3
- package/dest/test/eth_cheat_codes.d.ts +31 -6
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +67 -44
- package/dest/test/index.d.ts +2 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -2
- package/dest/test/recording_rpc_server.d.ts +18 -0
- package/dest/test/recording_rpc_server.d.ts.map +1 -0
- package/dest/test/recording_rpc_server.js +68 -0
- package/dest/test/rollup_cheat_codes.d.ts +60 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +86 -7
- package/dest/test/start_anvil.d.ts +23 -3
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +182 -32
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +9 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +59 -24
- package/package.json +6 -8
- package/src/client.ts +72 -2
- package/src/config.ts +58 -14
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +313 -13
- package/src/contracts/governance_proposer.ts +58 -9
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +3 -2
- package/src/contracts/multicall.ts +243 -105
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +507 -109
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +119 -45
- package/src/contracts/watch_event.ts +110 -0
- package/src/deploy_aztec_l1_contracts.ts +75 -39
- package/src/deploy_l1_contract.ts +3 -3
- package/src/foundry_binary.ts +57 -0
- package/src/generated/l1-contracts-defaults.ts +3 -3
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +17 -10
- package/src/l1_tx_utils/config.ts +23 -3
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +149 -64
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +57 -17
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- package/src/publisher_manager.ts +143 -12
- package/src/queries.ts +70 -4
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +148 -3
- package/src/test/eth_cheat_codes.ts +63 -47
- package/src/test/index.ts +1 -2
- package/src/test/recording_rpc_server.ts +69 -0
- package/src/test/rollup_cheat_codes.ts +115 -6
- package/src/test/start_anvil.ts +212 -32
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +56 -29
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -207
- package/dest/contracts/tally_slashing_proposer.d.ts +0 -140
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/tally_slashing_proposer.js +0 -320
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -259
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A JSON-RPC endpoint that records the method of every request it receives. */
|
|
2
|
+
export type RecordingRpcServer = {
|
|
3
|
+
/** URL the server listens on. */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Methods of the JSON-RPC requests received so far, in arrival order. */
|
|
6
|
+
methods: string[];
|
|
7
|
+
/** Stops the server. */
|
|
8
|
+
close: () => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Starts a JSON-RPC server that records the method of every request it receives, so tests can assert on what a
|
|
12
|
+
* client actually put on the wire. Requests are forwarded to `forwardTo` when given; otherwise the server answers
|
|
13
|
+
* `eth_chainId` with the anvil chain id and rejects anything else.
|
|
14
|
+
*/
|
|
15
|
+
export declare function startRecordingRpcServer(opts?: {
|
|
16
|
+
forwardTo?: string;
|
|
17
|
+
}): Promise<RecordingRpcServer>;
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjb3JkaW5nX3JwY19zZXJ2ZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3JlY29yZGluZ19ycGNfc2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLGdGQUFnRjtBQUNoRixNQUFNLE1BQU0sa0JBQWtCLEdBQUc7SUFDL0IsaUNBQWlDO0lBQ2pDLEdBQUcsRUFBRSxNQUFNLENBQUM7SUFDWiwwRUFBMEU7SUFDMUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ2xCLHdCQUF3QjtJQUN4QixLQUFLLEVBQUUsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7Q0FDNUIsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBc0IsdUJBQXVCLENBQUMsSUFBSSxHQUFFO0lBQUUsU0FBUyxDQUFDLEVBQUUsTUFBTSxDQUFBO0NBQU8sR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FtRDVHIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recording_rpc_server.d.ts","sourceRoot":"","sources":["../../src/test/recording_rpc_server.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,wBAAwB;IACxB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAmD5G"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* Starts a JSON-RPC server that records the method of every request it receives, so tests can assert on what a
|
|
4
|
+
* client actually put on the wire. Requests are forwarded to `forwardTo` when given; otherwise the server answers
|
|
5
|
+
* `eth_chainId` with the anvil chain id and rejects anything else.
|
|
6
|
+
*/ export async function startRecordingRpcServer(opts = {}) {
|
|
7
|
+
const methods = [];
|
|
8
|
+
const server = createServer((req, res)=>{
|
|
9
|
+
const chunks = [];
|
|
10
|
+
req.on('data', (chunk)=>chunks.push(Buffer.from(chunk)));
|
|
11
|
+
req.on('end', ()=>{
|
|
12
|
+
void (async ()=>{
|
|
13
|
+
const body = Buffer.concat(chunks).toString();
|
|
14
|
+
const parsed = body.length > 0 ? JSON.parse(body) : undefined;
|
|
15
|
+
const requests = Array.isArray(parsed) ? parsed : [
|
|
16
|
+
parsed
|
|
17
|
+
];
|
|
18
|
+
for (const request of requests){
|
|
19
|
+
const method = request?.method;
|
|
20
|
+
if (typeof method === 'string') {
|
|
21
|
+
methods.push(method);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (opts.forwardTo) {
|
|
25
|
+
const response = await fetch(opts.forwardTo, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: {
|
|
28
|
+
'content-type': 'application/json'
|
|
29
|
+
},
|
|
30
|
+
body
|
|
31
|
+
});
|
|
32
|
+
res.writeHead(response.status, {
|
|
33
|
+
'content-type': 'application/json'
|
|
34
|
+
});
|
|
35
|
+
res.end(await response.text());
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const id = requests[0]?.id ?? 1;
|
|
39
|
+
const result = methods[methods.length - 1] === 'eth_chainId' ? {
|
|
40
|
+
jsonrpc: '2.0',
|
|
41
|
+
id,
|
|
42
|
+
result: '0x7a69'
|
|
43
|
+
} : {
|
|
44
|
+
jsonrpc: '2.0',
|
|
45
|
+
id,
|
|
46
|
+
error: {
|
|
47
|
+
code: -32601,
|
|
48
|
+
message: 'method not handled by test server'
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
res.writeHead(200, {
|
|
52
|
+
'content-type': 'application/json'
|
|
53
|
+
});
|
|
54
|
+
res.end(JSON.stringify(result));
|
|
55
|
+
})();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
await new Promise((resolve)=>server.listen(0, '127.0.0.1', resolve));
|
|
59
|
+
const address = server.address();
|
|
60
|
+
if (!address || typeof address === 'string') {
|
|
61
|
+
throw new Error('Expected recording RPC server to listen on a TCP port');
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
url: `http://127.0.0.1:${address.port}`,
|
|
65
|
+
methods,
|
|
66
|
+
close: ()=>new Promise((resolve)=>server.close(()=>resolve()))
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -15,6 +15,10 @@ export declare class RollupCheatCodes {
|
|
|
15
15
|
static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>, dateProvider: DateProvider): RollupCheatCodes;
|
|
16
16
|
/** Returns the current slot */
|
|
17
17
|
getSlot(): Promise<SlotNumber>;
|
|
18
|
+
/** Returns the slot number at a given timestamp. */
|
|
19
|
+
getSlotAt(timestamp: bigint): Promise<SlotNumber>;
|
|
20
|
+
/** Returns the timestamp for the start of a given slot. */
|
|
21
|
+
getTimestampForSlot(slot: SlotNumber): Promise<bigint>;
|
|
18
22
|
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */
|
|
19
23
|
getSecondsUntilSlot(slot: SlotNumber): Promise<number>;
|
|
20
24
|
/** Returns the current epoch */
|
|
@@ -49,6 +53,15 @@ export declare class RollupCheatCodes {
|
|
|
49
53
|
advanceToNextEpoch(): Promise<void>;
|
|
50
54
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
51
55
|
advanceToNextSlot(): Promise<(bigint | SlotNumber)[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
|
|
58
|
+
* relative to the current L1 timestamp at call time and therefore races with real-time
|
|
59
|
+
* progression between query and warp, this lands at the slot regardless of latency.
|
|
60
|
+
*
|
|
61
|
+
* Throws if the requested slot is in the past relative to current L1 time (anvil cannot
|
|
62
|
+
* rewind).
|
|
63
|
+
*/
|
|
64
|
+
advanceToSlot(slot: SlotNumber): Promise<bigint>;
|
|
52
65
|
/**
|
|
53
66
|
* Warps time in L1 equivalent to however many slots.
|
|
54
67
|
* @param howMany - The number of slots to advance.
|
|
@@ -59,12 +72,41 @@ export declare class RollupCheatCodes {
|
|
|
59
72
|
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
60
73
|
*/
|
|
61
74
|
markAsProven(maybeCheckpointNumber?: CheckpointNumber): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
|
|
77
|
+
* not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
|
|
78
|
+
*/
|
|
79
|
+
waitForEpoch(epoch: EpochNumber, opts?: {
|
|
80
|
+
timeout?: number;
|
|
81
|
+
interval?: number;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
|
|
85
|
+
* warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
|
|
86
|
+
*/
|
|
87
|
+
waitForSlot(slot: SlotNumber, opts?: {
|
|
88
|
+
timeout?: number;
|
|
89
|
+
interval?: number;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
|
|
93
|
+
* checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
|
|
94
|
+
* rather than a node, since a rollback lands on L1 first.
|
|
95
|
+
*
|
|
96
|
+
* A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
|
|
97
|
+
* replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
|
|
98
|
+
* empty state — hence the non-zero guard.
|
|
99
|
+
*/
|
|
100
|
+
waitForCheckpointBelow(checkpoint: CheckpointNumber, opts?: {
|
|
101
|
+
timeout?: number;
|
|
102
|
+
interval?: number;
|
|
103
|
+
}): Promise<CheckpointNumber>;
|
|
62
104
|
/**
|
|
63
105
|
* Overrides the inProgress field of the Inbox contract state
|
|
64
106
|
* @param howMuch - How many checkpoints to move it forward
|
|
65
107
|
*/
|
|
66
108
|
advanceInboxInProgress(howMuch: number | bigint): Promise<bigint>;
|
|
67
|
-
insertOutbox(epoch: EpochNumber, outHash: bigint): Promise<void>;
|
|
109
|
+
insertOutbox(epoch: EpochNumber, numCheckpointsInEpoch: number, outHash: bigint): Promise<void>;
|
|
68
110
|
/**
|
|
69
111
|
* Executes an action impersonated as the owner of the Rollup contract.
|
|
70
112
|
* @param action - The action to execute
|
|
@@ -82,9 +124,24 @@ export declare class RollupCheatCodes {
|
|
|
82
124
|
*/
|
|
83
125
|
bumpProvingCostPerMana(bumper: (before: bigint) => bigint): Promise<void>;
|
|
84
126
|
/**
|
|
85
|
-
* Directly updates proving cost per mana.
|
|
127
|
+
* Directly updates proving cost per mana. Throws if the on-chain tx reverts
|
|
128
|
+
* (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
|
|
86
129
|
* @param ethValue - The new proving cost per mana in ETH
|
|
87
130
|
*/
|
|
88
131
|
setProvingCostPerMana(ethValue: bigint): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
|
|
134
|
+
* by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
|
|
135
|
+
* successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
|
|
136
|
+
* land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
|
|
137
|
+
*
|
|
138
|
+
* @note This is tightly coupled to the `FeeStore` layout in
|
|
139
|
+
* l1-contracts/src/core/libraries/rollup/FeeLib.sol:
|
|
140
|
+
* slot + 0: CompressedFeeConfig config (uint256)
|
|
141
|
+
* slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
|
|
142
|
+
* slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
|
|
143
|
+
* If the struct layout changes, update the offset below.
|
|
144
|
+
*/
|
|
145
|
+
clearProvingCostCooldown(): Promise<void>;
|
|
89
146
|
}
|
|
90
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
147
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwX2NoZWF0X2NvZGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9yb2xsdXBfY2hlYXRfY29kZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzlELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxXQUFXLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJNUYsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDNUQsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTFELE9BQU8sRUFDTC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Q1UscUJBQXFCLENBQUMsUUFBUSxFQUFFLE1BQU0saUJBaUJsRDtJQUVEOzs7Ozs7Ozs7Ozs7T0FZRztJQUNVLHdCQUF3QixrQkFPcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EAOT,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,8CAA8C;AAC9C,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAA4D;IAE1E,OAAO,CAAC,MAAM,CAAuC;IAErD,YACU,aAAa,EAAE,aAAa,EACpC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,EAWtD;I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AOpC;CACF"}
|
|
@@ -2,8 +2,9 @@ import { OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
|
2
2
|
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
5
6
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
|
-
import { createPublicClient, fallback, getContract, hexToBigInt, http } from 'viem';
|
|
7
|
+
import { createPublicClient, fallback, getContract, hexToBigInt, http, keccak256 } from 'viem';
|
|
7
8
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
8
9
|
/** Cheat codes for the L1 rollup contract. */ export class RollupCheatCodes {
|
|
9
10
|
ethCheatCodes;
|
|
@@ -31,10 +32,18 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
31
32
|
}
|
|
32
33
|
/** Returns the current slot */ async getSlot() {
|
|
33
34
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
35
|
+
return this.getSlotAt(ts);
|
|
36
|
+
}
|
|
37
|
+
/** Returns the slot number at a given timestamp. */ async getSlotAt(timestamp) {
|
|
34
38
|
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
35
|
-
|
|
39
|
+
timestamp
|
|
36
40
|
]));
|
|
37
41
|
}
|
|
42
|
+
/** Returns the timestamp for the start of a given slot. */ async getTimestampForSlot(slot) {
|
|
43
|
+
return await this.rollup.read.getTimestampForSlot([
|
|
44
|
+
BigInt(slot)
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
38
47
|
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */ async getSecondsUntilSlot(slot) {
|
|
39
48
|
const [currentTimestamp, targetTimestamp] = await Promise.all([
|
|
40
49
|
this.client.getBlock().then((b)=>BigInt(b.timestamp)),
|
|
@@ -143,6 +152,26 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
143
152
|
];
|
|
144
153
|
}
|
|
145
154
|
/**
|
|
155
|
+
* Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
|
|
156
|
+
* relative to the current L1 timestamp at call time and therefore races with real-time
|
|
157
|
+
* progression between query and warp, this lands at the slot regardless of latency.
|
|
158
|
+
*
|
|
159
|
+
* Throws if the requested slot is in the past relative to current L1 time (anvil cannot
|
|
160
|
+
* rewind).
|
|
161
|
+
*/ async advanceToSlot(slot) {
|
|
162
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([
|
|
163
|
+
BigInt(slot)
|
|
164
|
+
]);
|
|
165
|
+
await this.ethCheatCodes.warp(Number(timestamp), {
|
|
166
|
+
silent: true,
|
|
167
|
+
resetBlockInterval: true
|
|
168
|
+
});
|
|
169
|
+
this.logger.warn(`Advanced to slot ${slot}`, {
|
|
170
|
+
timestamp
|
|
171
|
+
});
|
|
172
|
+
return timestamp;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
146
175
|
* Warps time in L1 equivalent to however many slots.
|
|
147
176
|
* @param howMany - The number of slots to advance.
|
|
148
177
|
*/ async advanceSlots(howMany) {
|
|
@@ -188,6 +217,32 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
188
217
|
});
|
|
189
218
|
}
|
|
190
219
|
/**
|
|
220
|
+
* Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
|
|
221
|
+
* not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
|
|
222
|
+
*/ async waitForEpoch(epoch, opts = {}) {
|
|
223
|
+
await retryUntil(async ()=>await this.getEpoch() >= epoch || undefined, `rollup epoch >= ${epoch}`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
|
|
227
|
+
* warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
|
|
228
|
+
*/ async waitForSlot(slot, opts = {}) {
|
|
229
|
+
await retryUntil(async ()=>await this.getSlot() >= slot || undefined, `rollup slot >= ${slot}`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
|
|
233
|
+
* checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
|
|
234
|
+
* rather than a node, since a rollback lands on L1 first.
|
|
235
|
+
*
|
|
236
|
+
* A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
|
|
237
|
+
* replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
|
|
238
|
+
* empty state — hence the non-zero guard.
|
|
239
|
+
*/ async waitForCheckpointBelow(checkpoint, opts = {}) {
|
|
240
|
+
return await retryUntil(async ()=>{
|
|
241
|
+
const { pending } = await this.getTips();
|
|
242
|
+
return pending > 0 && pending < checkpoint ? pending : undefined;
|
|
243
|
+
}, `rollup checkpoint in (0, ${checkpoint})`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
191
246
|
* Overrides the inProgress field of the Inbox contract state
|
|
192
247
|
* @param howMuch - How many checkpoints to move it forward
|
|
193
248
|
*/ advanceInboxInProgress(howMuch) {
|
|
@@ -220,12 +275,12 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
220
275
|
return newInProgress;
|
|
221
276
|
});
|
|
222
277
|
}
|
|
223
|
-
insertOutbox(epoch, outHash) {
|
|
278
|
+
insertOutbox(epoch, numCheckpointsInEpoch, outHash) {
|
|
224
279
|
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
225
280
|
const outboxAddress = await this.rollup.read.getOutbox();
|
|
226
|
-
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch);
|
|
281
|
+
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch, numCheckpointsInEpoch);
|
|
227
282
|
await this.ethCheatCodes.store(EthAddress.fromString(outboxAddress), epochRootSlot, outHash);
|
|
228
|
-
this.logger.warn(`Advanced outbox to epoch ${epoch} with out hash ${outHash}`);
|
|
283
|
+
this.logger.warn(`Advanced outbox to epoch ${epoch} numCheckpointsInEpoch ${numCheckpointsInEpoch} with out hash ${outHash}`);
|
|
229
284
|
});
|
|
230
285
|
}
|
|
231
286
|
/**
|
|
@@ -272,7 +327,8 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
272
327
|
await this.setProvingCostPerMana(newCost);
|
|
273
328
|
}
|
|
274
329
|
/**
|
|
275
|
-
* Directly updates proving cost per mana.
|
|
330
|
+
* Directly updates proving cost per mana. Throws if the on-chain tx reverts
|
|
331
|
+
* (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
|
|
276
332
|
* @param ethValue - The new proving cost per mana in ETH
|
|
277
333
|
*/ async setProvingCostPerMana(ethValue) {
|
|
278
334
|
await this.asOwner(async (account, rollup)=>{
|
|
@@ -283,10 +339,33 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
283
339
|
chain: this.client.chain,
|
|
284
340
|
gasLimit: 1000000n
|
|
285
341
|
});
|
|
286
|
-
await this.client.waitForTransactionReceipt({
|
|
342
|
+
const receipt = await this.client.waitForTransactionReceipt({
|
|
287
343
|
hash
|
|
288
344
|
});
|
|
345
|
+
if (receipt.status !== 'success') {
|
|
346
|
+
throw new Error(`setProvingCostPerMana(${ethValue}) reverted on L1 (tx ${hash}). ` + `Likely FeeLib rate-limit (30-day cooldown or 1.5x step cap); ` + `use clearProvingCostCooldown() between successive updates.`);
|
|
347
|
+
}
|
|
289
348
|
this.logger.warn(`Updated proving cost per mana to ${ethValue}`);
|
|
290
349
|
});
|
|
291
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
|
|
353
|
+
* by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
|
|
354
|
+
* successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
|
|
355
|
+
* land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
|
|
356
|
+
*
|
|
357
|
+
* @note This is tightly coupled to the `FeeStore` layout in
|
|
358
|
+
* l1-contracts/src/core/libraries/rollup/FeeLib.sol:
|
|
359
|
+
* slot + 0: CompressedFeeConfig config (uint256)
|
|
360
|
+
* slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
|
|
361
|
+
* slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
|
|
362
|
+
* If the struct layout changes, update the offset below.
|
|
363
|
+
*/ async clearProvingCostCooldown() {
|
|
364
|
+
const feeStoreBaseSlot = hexToBigInt(keccak256(Buffer.from('aztec.fee.storage', 'utf-8')));
|
|
365
|
+
const provingCostLastUpdateSlot = feeStoreBaseSlot + 2n;
|
|
366
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provingCostLastUpdateSlot, 0n, {
|
|
367
|
+
silent: true
|
|
368
|
+
});
|
|
369
|
+
this.logger.warn(`Cleared proving-cost update cooldown`);
|
|
370
|
+
}
|
|
292
371
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
2
|
+
/** Minimal interface matching the @viem/anvil Anvil shape used by callers. */
|
|
3
|
+
export interface Anvil {
|
|
4
|
+
readonly port: number;
|
|
5
|
+
readonly host: string;
|
|
6
|
+
readonly status: 'listening' | 'idle';
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Ensures there's a running Anvil instance and returns the RPC URL.
|
|
4
11
|
*/
|
|
@@ -9,12 +16,25 @@ export declare function startAnvil(opts?: {
|
|
|
9
16
|
captureMethodCalls?: boolean;
|
|
10
17
|
accounts?: number;
|
|
11
18
|
chainId?: number;
|
|
12
|
-
/** The hardfork to use
|
|
19
|
+
/** The hardfork to use (e.g. 'cancun', 'latest'). */
|
|
13
20
|
hardfork?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Number of slots per epoch used by anvil to compute the 'finalized' and 'safe' block tags.
|
|
23
|
+
* Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
|
|
24
|
+
* Defaults to 1 so the finalized block advances immediately, making tests that check
|
|
25
|
+
* L1-finality-based logic work without needing hundreds of mined blocks.
|
|
26
|
+
*/
|
|
27
|
+
slotsInAnEpoch?: number;
|
|
28
|
+
/**
|
|
29
|
+
* If provided, the date provider will be synced to anvil's block time on every mined block.
|
|
30
|
+
* This keeps the dateProvider in lockstep with anvil's chain time, avoiding drift between
|
|
31
|
+
* the wall clock and the L1 chain when computing L1 slot timestamps.
|
|
32
|
+
*/
|
|
33
|
+
dateProvider?: TestDateProvider;
|
|
14
34
|
}): Promise<{
|
|
15
35
|
anvil: Anvil;
|
|
16
36
|
methodCalls?: string[];
|
|
17
37
|
rpcUrl: string;
|
|
18
38
|
stop: () => Promise<void>;
|
|
19
39
|
}>;
|
|
20
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYW52aWwuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3N0YXJ0X2FudmlsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFNaEUsOEVBQThFO0FBQzlFLE1BQU0sV0FBVyxLQUFLO0lBQ3BCLFFBQVEsQ0FBQyxJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLFFBQVEsQ0FBQyxJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ3RCLFFBQVEsQ0FBQyxNQUFNLEVBQUUsV0FBVyxHQUFHLE1BQU0sQ0FBQztJQUN0QyxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0NBQ3ZCO0FBMEJEOztHQUVHO0FBQ0gsd0JBQXNCLFVBQVUsQ0FDOUIsSUFBSSxHQUFFO0lBQ0osSUFBSSxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2QsV0FBVyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ3JCLEdBQUcsQ0FBQyxFQUFFLE9BQU8sQ0FBQztJQUNkLGtCQUFrQixDQUFDLEVBQUUsT0FBTyxDQUFDO0lBQzdCLFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQixPQUFPLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDakIscURBQXFEO0lBQ3JELFFBQVEsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUNsQjs7Ozs7T0FLRztJQUNILGNBQWMsQ0FBQyxFQUFFLE1BQU0sQ0FBQztJQUN4Qjs7OztPQUlHO0lBQ0gsWUFBWSxDQUFDLEVBQUUsZ0JBQWdCLENBQUM7Q0FDNUIsR0FDTCxPQUFPLENBQUM7SUFBRSxLQUFLLEVBQUUsS0FBSyxDQUFDO0lBQUMsV0FBVyxDQUFDLEVBQUUsTUFBTSxFQUFFLENBQUM7SUFBQyxNQUFNLEVBQUUsTUFBTSxDQUFDO0lBQUMsSUFBSSxFQUFFLE1BQU0sT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFBO0NBQUUsQ0FBQyxDQW9JOUYifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,8EAA8E;AAC9E,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IACtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AA0BD;;GAEG;AACH,wBAAsB,UAAU,CAC9B,IAAI,GAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,GACL,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAoI9F"}
|
package/dest/test/start_anvil.js
CHANGED
|
@@ -1,55 +1,205 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { resolveFoundryBinary } from '../foundry_binary.js';
|
|
5
|
+
// Watchdog wrapper: instead of spawning anvil directly, we spawn a small bash supervisor that runs
|
|
6
|
+
// anvil as a background child and polls its own parent (this node process). If the parent dies for
|
|
7
|
+
// ANY reason — including SIGKILL / crash / OOM, where node's own exit handlers never run — the poll
|
|
8
|
+
// loop ends and the EXIT trap reaps anvil. The script is inlined (rather than shipped as a `.sh`) so
|
|
9
|
+
// it works from the published npm tarball too, and the resolved anvil binary is passed via
|
|
10
|
+
// `$ANVIL_BIN` so it works without `anvil` on PATH.
|
|
11
|
+
//
|
|
12
|
+
// `$@` is the anvil argv; `bash -c <script> bash <...args>` puts the args in `$@` and `$0` = 'bash'.
|
|
13
|
+
//
|
|
14
|
+
// The EXIT trap reaps anvil; INT/TERM just `exit` (which fires the EXIT trap) so a signal terminates
|
|
15
|
+
// the supervisor promptly instead of being swallowed — a trapped TERM does NOT terminate the shell,
|
|
16
|
+
// so trapping the kill directly on TERM would leave the poll loop running and the caller's teardown
|
|
17
|
+
// hanging until its SIGKILL escalation. `sleep & wait` makes the poll interruptible, so INT/TERM are
|
|
18
|
+
// handled immediately rather than after the current `sleep` returns.
|
|
19
|
+
const ANVIL_WATCHDOG = `
|
|
20
|
+
set -u
|
|
21
|
+
parent=$PPID
|
|
22
|
+
"$ANVIL_BIN" "$@" &
|
|
23
|
+
anvil_pid=$!
|
|
24
|
+
trap 'kill "$anvil_pid" 2>/dev/null' EXIT
|
|
25
|
+
trap 'exit 0' INT TERM
|
|
26
|
+
while kill -0 "$parent" 2>/dev/null; do sleep 1 & wait $!; done
|
|
27
|
+
`;
|
|
6
28
|
/**
|
|
7
29
|
* Ensures there's a running Anvil instance and returns the RPC URL.
|
|
8
30
|
*/ export async function startAnvil(opts = {}) {
|
|
9
|
-
const anvilBinary =
|
|
31
|
+
const anvilBinary = resolveFoundryBinary('anvil');
|
|
10
32
|
const logger = opts.log ? createLogger('ethereum:anvil') : undefined;
|
|
11
33
|
const methodCalls = opts.captureMethodCalls ? [] : undefined;
|
|
12
|
-
let
|
|
13
|
-
// Start anvil.
|
|
14
|
-
// We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
34
|
+
let detectedPort;
|
|
15
35
|
const anvil = await retry(async ()=>{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
// `--port 0` lets anvil bind an OS-assigned ephemeral port; the actual port is read back from
|
|
37
|
+
// its "Listening on host:port" stdout below, so independent suites can spawn their own anvil
|
|
38
|
+
// in parallel without fighting over a fixed port.
|
|
39
|
+
const port = opts.port ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : 8545);
|
|
40
|
+
const args = [
|
|
41
|
+
'--host',
|
|
42
|
+
'127.0.0.1',
|
|
43
|
+
'--port',
|
|
44
|
+
String(port),
|
|
45
|
+
'--accounts',
|
|
46
|
+
String(opts.accounts ?? 20),
|
|
47
|
+
'--gas-limit',
|
|
48
|
+
String(45_000_000),
|
|
49
|
+
'--chain-id',
|
|
50
|
+
String(opts.chainId ?? 31337)
|
|
51
|
+
];
|
|
52
|
+
if (opts.l1BlockTime !== undefined) {
|
|
53
|
+
args.push('--block-time', String(opts.l1BlockTime));
|
|
54
|
+
}
|
|
55
|
+
if (opts.hardfork !== undefined) {
|
|
56
|
+
args.push('--hardfork', opts.hardfork);
|
|
57
|
+
}
|
|
58
|
+
args.push('--slots-in-an-epoch', String(opts.slotsInAnEpoch ?? 1));
|
|
59
|
+
// Spawn the watchdog (see ANVIL_WATCHDOG). It launches anvil with these args and reaps it if we
|
|
60
|
+
// die; `$0` is 'bash' and `$@` is the anvil argv.
|
|
61
|
+
const child = spawn('bash', [
|
|
62
|
+
'-c',
|
|
63
|
+
ANVIL_WATCHDOG,
|
|
64
|
+
'bash',
|
|
65
|
+
...args
|
|
66
|
+
], {
|
|
67
|
+
stdio: [
|
|
68
|
+
'ignore',
|
|
69
|
+
'pipe',
|
|
70
|
+
'pipe'
|
|
71
|
+
],
|
|
72
|
+
env: {
|
|
73
|
+
...process.env,
|
|
74
|
+
ANVIL_BIN: anvilBinary,
|
|
75
|
+
RAYON_NUM_THREADS: '1'
|
|
32
76
|
}
|
|
33
77
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
78
|
+
// Wait for "Listening on" or an early exit.
|
|
79
|
+
await new Promise((resolve, reject)=>{
|
|
80
|
+
let stderr = '';
|
|
81
|
+
const onStdout = (data)=>{
|
|
82
|
+
const text = data.toString();
|
|
83
|
+
logger?.debug(text.trim());
|
|
84
|
+
methodCalls?.push(...text.match(/eth_[^\s]+/g) || []);
|
|
85
|
+
if (detectedPort === undefined && text.includes('Listening on')) {
|
|
86
|
+
const match = text.match(/Listening on ([^:]+):(\d+)/);
|
|
87
|
+
if (match) {
|
|
88
|
+
detectedPort = parseInt(match[2]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (detectedPort !== undefined) {
|
|
92
|
+
child.stdout?.removeListener('data', onStdout);
|
|
93
|
+
child.stderr?.removeListener('data', onStderr);
|
|
94
|
+
child.removeListener('close', onClose);
|
|
95
|
+
resolve();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const onStderr = (data)=>{
|
|
99
|
+
stderr += data.toString();
|
|
100
|
+
logger?.debug(data.toString().trim());
|
|
101
|
+
};
|
|
102
|
+
const onClose = (code)=>{
|
|
103
|
+
child.stdout?.removeListener('data', onStdout);
|
|
104
|
+
child.stderr?.removeListener('data', onStderr);
|
|
105
|
+
reject(new Error(`Anvil exited with code ${code} before listening. stderr: ${stderr}`));
|
|
106
|
+
};
|
|
107
|
+
child.stdout?.on('data', onStdout);
|
|
108
|
+
child.stderr?.on('data', onStderr);
|
|
109
|
+
child.once('close', onClose);
|
|
110
|
+
});
|
|
111
|
+
// Continue piping for logging, method-call capture, and/or dateProvider sync after startup.
|
|
112
|
+
if (logger || opts.captureMethodCalls || opts.dateProvider) {
|
|
113
|
+
child.stdout?.on('data', (data)=>{
|
|
114
|
+
const text = data.toString();
|
|
115
|
+
logger?.debug(text.trim());
|
|
116
|
+
methodCalls?.push(...text.match(/eth_[^\s]+/g) || []);
|
|
117
|
+
if (opts.dateProvider) {
|
|
118
|
+
syncDateProviderFromAnvilOutput(text, opts.dateProvider);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
child.stderr?.on('data', (data)=>{
|
|
122
|
+
logger?.debug(data.toString().trim());
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
// Consume streams so the child process doesn't block on full pipe buffers.
|
|
126
|
+
child.stdout?.resume();
|
|
127
|
+
child.stderr?.resume();
|
|
37
128
|
}
|
|
38
|
-
return
|
|
129
|
+
return child;
|
|
39
130
|
}, 'Start anvil', makeBackoff([
|
|
40
131
|
5,
|
|
41
132
|
5,
|
|
42
133
|
5
|
|
43
134
|
]));
|
|
44
|
-
if (!
|
|
135
|
+
if (!detectedPort) {
|
|
45
136
|
throw new Error('Failed to start anvil');
|
|
46
137
|
}
|
|
47
|
-
|
|
48
|
-
|
|
138
|
+
const port = detectedPort;
|
|
139
|
+
let status = 'listening';
|
|
140
|
+
anvil.once('close', ()=>{
|
|
141
|
+
status = 'idle';
|
|
142
|
+
});
|
|
143
|
+
const stop = async ()=>{
|
|
144
|
+
if (status === 'idle') {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
await killChild(anvil);
|
|
148
|
+
};
|
|
149
|
+
const anvilObj = {
|
|
150
|
+
port,
|
|
151
|
+
host: '127.0.0.1',
|
|
152
|
+
get status () {
|
|
153
|
+
return status;
|
|
154
|
+
},
|
|
155
|
+
stop
|
|
156
|
+
};
|
|
49
157
|
return {
|
|
50
|
-
anvil,
|
|
158
|
+
anvil: anvilObj,
|
|
51
159
|
methodCalls,
|
|
52
|
-
stop
|
|
160
|
+
stop,
|
|
53
161
|
rpcUrl: `http://127.0.0.1:${port}`
|
|
54
162
|
};
|
|
55
163
|
}
|
|
164
|
+
/** Extracts block time from anvil stdout and syncs the dateProvider. */ function syncDateProviderFromAnvilOutput(text, dateProvider) {
|
|
165
|
+
// Anvil logs mined blocks as:
|
|
166
|
+
// Block Time: "Fri, 20 Mar 2026 02:10:46 +0000"
|
|
167
|
+
const match = text.match(/Block Time:\s*"([^"]+)"/);
|
|
168
|
+
if (match) {
|
|
169
|
+
const blockTimeMs = new Date(match[1]).getTime();
|
|
170
|
+
if (!isNaN(blockTimeMs)) {
|
|
171
|
+
dateProvider.setTime(blockTimeMs);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Send SIGTERM to the watchdog, wait up to 5 s, then SIGKILL. The watchdog's trap forwards the
|
|
177
|
+
* signal to anvil, so terminating it tears down anvil too. All timers are always cleared.
|
|
178
|
+
*/ function killChild(child) {
|
|
179
|
+
return new Promise((resolve)=>{
|
|
180
|
+
if (child.exitCode !== null || child.killed) {
|
|
181
|
+
child.stdout?.destroy();
|
|
182
|
+
child.stderr?.destroy();
|
|
183
|
+
resolve();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
let killTimer;
|
|
187
|
+
const onClose = ()=>{
|
|
188
|
+
if (killTimer !== undefined) {
|
|
189
|
+
clearTimeout(killTimer);
|
|
190
|
+
}
|
|
191
|
+
// Destroy stdio streams so their PipeWrap handles don't keep the event loop alive.
|
|
192
|
+
child.stdout?.destroy();
|
|
193
|
+
child.stderr?.destroy();
|
|
194
|
+
resolve();
|
|
195
|
+
};
|
|
196
|
+
child.once('close', onClose);
|
|
197
|
+
child.kill('SIGTERM');
|
|
198
|
+
killTimer = setTimeout(()=>{
|
|
199
|
+
killTimer = undefined;
|
|
200
|
+
child.kill('SIGKILL');
|
|
201
|
+
}, 5000);
|
|
202
|
+
// Ensure the timer does not prevent Node from exiting.
|
|
203
|
+
killTimer.unref();
|
|
204
|
+
});
|
|
205
|
+
}
|