@aztec/ethereum 0.0.1-commit.27d773e65 → 0.0.1-commit.2b2662070
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 +10 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +13 -7
- package/dest/config.d.ts +8 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -9
- package/dest/contracts/chain_state_override.d.ts +38 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +100 -0
- package/dest/contracts/inbox.d.ts +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +5 -6
- package/dest/contracts/index.d.ts +3 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -2
- package/dest/contracts/multicall.d.ts +51 -2
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +85 -0
- 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 +83 -20
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +288 -58
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +13 -15
- package/dest/deploy_aztec_l1_contracts.d.ts +3 -6
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +2 -4
- package/dest/generated/l1-contracts-defaults.d.ts +1 -1
- package/dest/generated/l1-contracts-defaults.js +1 -1
- package/dest/l1_artifacts.d.ts +8644 -15983
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +1 -5
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +0 -6
- package/dest/l1_reader.d.ts +3 -1
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +6 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +5 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +40 -21
- 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 +8 -4
- package/dest/publisher_manager.d.ts +21 -7
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +81 -7
- package/dest/queries.js +3 -3
- package/dest/test/chain_monitor.d.ts +22 -3
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +33 -2
- package/dest/test/eth_cheat_codes.d.ts +6 -4
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +6 -4
- package/dest/test/rollup_cheat_codes.d.ts +5 -1
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +9 -1
- 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 +143 -29
- package/dest/utils.d.ts +1 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +16 -12
- package/package.json +5 -7
- package/src/client.ts +10 -2
- package/src/config.ts +21 -13
- package/src/contracts/chain_state_override.ts +147 -0
- package/src/contracts/inbox.ts +4 -4
- package/src/contracts/index.ts +2 -2
- package/src/contracts/multicall.ts +65 -1
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +315 -61
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
- package/src/deploy_aztec_l1_contracts.ts +1 -5
- package/src/generated/l1-contracts-defaults.ts +1 -1
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +0 -7
- package/src/l1_reader.ts +13 -1
- package/src/l1_tx_utils/l1_tx_utils.ts +31 -8
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +8 -4
- package/src/publisher_manager.ts +105 -10
- package/src/queries.ts +3 -3
- package/src/test/chain_monitor.ts +60 -3
- package/src/test/eth_cheat_codes.ts +6 -4
- package/src/test/rollup_cheat_codes.ts +11 -1
- package/src/test/start_anvil.ts +177 -29
- package/src/utils.ts +17 -14
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -69
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -216
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -265
|
@@ -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;AAG5F,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,EAMT,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;IAEr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OAGG;IACI,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCvE;IAEM,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAOtD;IAED;;;OAGG;IACU,OAAO,CAClB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,iBAMzG;IAED;;OAEG;IACU,UAAU,kBAOtB;IAED,4CAA4C;IAC/B,oBAAoB,kBAMhC;IAED;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,iBAIrE;IAED;;;OAGG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM,iBAUlD;CACF"}
|
|
@@ -31,10 +31,18 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
31
31
|
}
|
|
32
32
|
/** Returns the current slot */ async getSlot() {
|
|
33
33
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
34
|
+
return this.getSlotAt(ts);
|
|
35
|
+
}
|
|
36
|
+
/** Returns the slot number at a given timestamp. */ async getSlotAt(timestamp) {
|
|
34
37
|
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
35
|
-
|
|
38
|
+
timestamp
|
|
36
39
|
]));
|
|
37
40
|
}
|
|
41
|
+
/** Returns the timestamp for the start of a given slot. */ async getTimestampForSlot(slot) {
|
|
42
|
+
return await this.rollup.read.getTimestampForSlot([
|
|
43
|
+
BigInt(slot)
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
38
46
|
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */ async getSecondsUntilSlot(slot) {
|
|
39
47
|
const [currentTimestamp, targetTimestamp] = await Promise.all([
|
|
40
48
|
this.client.getBlock().then((b)=>BigInt(b.timestamp)),
|
|
@@ -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,eyJ2Z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FBQyxXQUFXLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUFDLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFBQyxJQUFJLEVBQUUsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7Q0FBRSxDQUFDLENBK0g5RiJ9
|
|
@@ -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;AAED;;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,CA+H9F"}
|
package/dest/test/start_anvil.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
3
3
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
4
|
-
import {
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
5
|
import { dirname, resolve } from 'path';
|
|
6
6
|
/**
|
|
7
7
|
* Ensures there's a running Anvil instance and returns the RPC URL.
|
|
@@ -9,47 +9,161 @@ import { dirname, resolve } from 'path';
|
|
|
9
9
|
const anvilBinary = resolve(dirname(fileURLToPath(import.meta.url)), '../../', 'scripts/anvil_kill_wrapper.sh');
|
|
10
10
|
const logger = opts.log ? createLogger('ethereum:anvil') : undefined;
|
|
11
11
|
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.
|
|
12
|
+
let detectedPort;
|
|
15
13
|
const anvil = await retry(async ()=>{
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
host
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
accounts
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
const port = opts.port ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : 8545);
|
|
15
|
+
const args = [
|
|
16
|
+
'--host',
|
|
17
|
+
'127.0.0.1',
|
|
18
|
+
'--port',
|
|
19
|
+
String(port),
|
|
20
|
+
'--accounts',
|
|
21
|
+
String(opts.accounts ?? 20),
|
|
22
|
+
'--gas-limit',
|
|
23
|
+
String(45_000_000),
|
|
24
|
+
'--chain-id',
|
|
25
|
+
String(opts.chainId ?? 31337)
|
|
26
|
+
];
|
|
27
|
+
if (opts.l1BlockTime !== undefined) {
|
|
28
|
+
args.push('--block-time', String(opts.l1BlockTime));
|
|
29
|
+
}
|
|
30
|
+
if (opts.hardfork !== undefined) {
|
|
31
|
+
args.push('--hardfork', opts.hardfork);
|
|
32
|
+
}
|
|
33
|
+
args.push('--slots-in-an-epoch', String(opts.slotsInAnEpoch ?? 1));
|
|
34
|
+
const child = spawn(anvilBinary, args, {
|
|
35
|
+
stdio: [
|
|
36
|
+
'ignore',
|
|
37
|
+
'pipe',
|
|
38
|
+
'pipe'
|
|
39
|
+
],
|
|
40
|
+
env: {
|
|
41
|
+
...process.env,
|
|
42
|
+
RAYON_NUM_THREADS: '1'
|
|
32
43
|
}
|
|
33
44
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
// Wait for "Listening on" or an early exit.
|
|
46
|
+
await new Promise((resolve, reject)=>{
|
|
47
|
+
let stderr = '';
|
|
48
|
+
const onStdout = (data)=>{
|
|
49
|
+
const text = data.toString();
|
|
50
|
+
logger?.debug(text.trim());
|
|
51
|
+
methodCalls?.push(...text.match(/eth_[^\s]+/g) || []);
|
|
52
|
+
if (detectedPort === undefined && text.includes('Listening on')) {
|
|
53
|
+
const match = text.match(/Listening on ([^:]+):(\d+)/);
|
|
54
|
+
if (match) {
|
|
55
|
+
detectedPort = parseInt(match[2]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (detectedPort !== undefined) {
|
|
59
|
+
child.stdout?.removeListener('data', onStdout);
|
|
60
|
+
child.stderr?.removeListener('data', onStderr);
|
|
61
|
+
child.removeListener('close', onClose);
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const onStderr = (data)=>{
|
|
66
|
+
stderr += data.toString();
|
|
67
|
+
logger?.debug(data.toString().trim());
|
|
68
|
+
};
|
|
69
|
+
const onClose = (code)=>{
|
|
70
|
+
child.stdout?.removeListener('data', onStdout);
|
|
71
|
+
child.stderr?.removeListener('data', onStderr);
|
|
72
|
+
reject(new Error(`Anvil exited with code ${code} before listening. stderr: ${stderr}`));
|
|
73
|
+
};
|
|
74
|
+
child.stdout?.on('data', onStdout);
|
|
75
|
+
child.stderr?.on('data', onStderr);
|
|
76
|
+
child.once('close', onClose);
|
|
77
|
+
});
|
|
78
|
+
// Continue piping for logging, method-call capture, and/or dateProvider sync after startup.
|
|
79
|
+
if (logger || opts.captureMethodCalls || opts.dateProvider) {
|
|
80
|
+
child.stdout?.on('data', (data)=>{
|
|
81
|
+
const text = data.toString();
|
|
82
|
+
logger?.debug(text.trim());
|
|
83
|
+
methodCalls?.push(...text.match(/eth_[^\s]+/g) || []);
|
|
84
|
+
if (opts.dateProvider) {
|
|
85
|
+
syncDateProviderFromAnvilOutput(text, opts.dateProvider);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
child.stderr?.on('data', (data)=>{
|
|
89
|
+
logger?.debug(data.toString().trim());
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
// Consume streams so the child process doesn't block on full pipe buffers.
|
|
93
|
+
child.stdout?.resume();
|
|
94
|
+
child.stderr?.resume();
|
|
37
95
|
}
|
|
38
|
-
return
|
|
96
|
+
return child;
|
|
39
97
|
}, 'Start anvil', makeBackoff([
|
|
40
98
|
5,
|
|
41
99
|
5,
|
|
42
100
|
5
|
|
43
101
|
]));
|
|
44
|
-
if (!
|
|
102
|
+
if (!detectedPort) {
|
|
45
103
|
throw new Error('Failed to start anvil');
|
|
46
104
|
}
|
|
47
|
-
|
|
48
|
-
|
|
105
|
+
const port = detectedPort;
|
|
106
|
+
let status = 'listening';
|
|
107
|
+
anvil.once('close', ()=>{
|
|
108
|
+
status = 'idle';
|
|
109
|
+
});
|
|
110
|
+
const stop = async ()=>{
|
|
111
|
+
if (status === 'idle') {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
await killChild(anvil);
|
|
115
|
+
};
|
|
116
|
+
const anvilObj = {
|
|
117
|
+
port,
|
|
118
|
+
host: '127.0.0.1',
|
|
119
|
+
get status () {
|
|
120
|
+
return status;
|
|
121
|
+
},
|
|
122
|
+
stop
|
|
123
|
+
};
|
|
49
124
|
return {
|
|
50
|
-
anvil,
|
|
125
|
+
anvil: anvilObj,
|
|
51
126
|
methodCalls,
|
|
52
|
-
stop
|
|
127
|
+
stop,
|
|
53
128
|
rpcUrl: `http://127.0.0.1:${port}`
|
|
54
129
|
};
|
|
55
130
|
}
|
|
131
|
+
/** Extracts block time from anvil stdout and syncs the dateProvider. */ function syncDateProviderFromAnvilOutput(text, dateProvider) {
|
|
132
|
+
// Anvil logs mined blocks as:
|
|
133
|
+
// Block Time: "Fri, 20 Mar 2026 02:10:46 +0000"
|
|
134
|
+
const match = text.match(/Block Time:\s*"([^"]+)"/);
|
|
135
|
+
if (match) {
|
|
136
|
+
const blockTimeMs = new Date(match[1]).getTime();
|
|
137
|
+
if (!isNaN(blockTimeMs)) {
|
|
138
|
+
dateProvider.setTime(blockTimeMs);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** Send SIGTERM, wait up to 5 s, then SIGKILL. All timers are always cleared. */ function killChild(child) {
|
|
143
|
+
return new Promise((resolve)=>{
|
|
144
|
+
if (child.exitCode !== null || child.killed) {
|
|
145
|
+
child.stdout?.destroy();
|
|
146
|
+
child.stderr?.destroy();
|
|
147
|
+
resolve();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let killTimer;
|
|
151
|
+
const onClose = ()=>{
|
|
152
|
+
if (killTimer !== undefined) {
|
|
153
|
+
clearTimeout(killTimer);
|
|
154
|
+
}
|
|
155
|
+
// Destroy stdio streams so their PipeWrap handles don't keep the event loop alive.
|
|
156
|
+
child.stdout?.destroy();
|
|
157
|
+
child.stderr?.destroy();
|
|
158
|
+
resolve();
|
|
159
|
+
};
|
|
160
|
+
child.once('close', onClose);
|
|
161
|
+
child.kill('SIGTERM');
|
|
162
|
+
killTimer = setTimeout(()=>{
|
|
163
|
+
killTimer = undefined;
|
|
164
|
+
child.kill('SIGKILL');
|
|
165
|
+
}, 5000);
|
|
166
|
+
// Ensure the timer does not prevent Node from exiting.
|
|
167
|
+
killTimer.unref();
|
|
168
|
+
});
|
|
169
|
+
}
|
package/dest/utils.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ export declare function isBlobTransaction(tx: FormattedTransaction): tx is Forma
|
|
|
35
35
|
* Calculates a percentile from an array of bigints
|
|
36
36
|
*/
|
|
37
37
|
export declare function calculatePercentile(values: bigint[], percentile: number): bigint;
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUdwRCxPQUFPLEVBQ0wsS0FBSyxHQUFHLEVBR1IsS0FBSyxpQkFBaUIsRUFFdEIsS0FBSyx3QkFBd0IsRUFDN0IsS0FBSyxvQkFBb0IsRUFDekIsS0FBSyxHQUFHLEVBQ1IsS0FBSyxHQUFHLEVBR1QsTUFBTSxNQUFNLENBQUM7QUFHZCxNQUFNLFdBQVcsT0FBTztJQUN0QixXQUFXLEVBQUUsRUFBRSxDQUFDO0lBQ2hCLFdBQVcsRUFBRSxFQUFFLENBQUM7SUFDaEIsV0FBVyxFQUFFLEdBQUcsQ0FBQztJQUNqQixnQkFBZ0IsRUFBRSxNQUFNLENBQUM7Q0FDMUI7QUFFRCxxQkFBYSxrQkFBbUIsU0FBU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B,eAAe,CAC7B,KAAK,CAAC,IAAI,SAAS,GAAG,GAAG,SAAS,OAAO,EAAE,EAC3C,UAAU,SAAS,iBAAiB,CAAC,IAAI,CAAC,EAC1C,UAAU,GAAG,wBAAwB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,EAE/E,IAAI,EAAE,GAAG,EAAE,EACX,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,UAAU,EACrB,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,EACrC,MAAM,CAAC,EAAE,MAAM,GACd,UAAU,GAAG,SAAS,CAgBxB;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,OAW7C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAe1C;AA2ED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAE,GAAe,GAAG,kBAAkB,CA4DpF;AAyBD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,sBAa7C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,oBAAoB,GAAG,EAAE,IAAI,oBAAoB,GAAG;IACxF,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,SAAS,GAAG,EAAE,CAAC;CACrC,CAOA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAOhF"}
|
package/dest/utils.js
CHANGED
|
@@ -112,6 +112,19 @@ function getNestedErrorData(error) {
|
|
|
112
112
|
// Not found
|
|
113
113
|
return undefined;
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Truncates an error message to a safe length for log renderers.
|
|
117
|
+
* LogExplorer can only render up to 2500 characters in its summary view.
|
|
118
|
+
* We cap at 2000 to leave room for decorating context added by callers.
|
|
119
|
+
*/ function truncateErrorMessage(message) {
|
|
120
|
+
const MAX = 2000;
|
|
121
|
+
const CHUNK = 950;
|
|
122
|
+
if (message.length <= MAX) {
|
|
123
|
+
return message;
|
|
124
|
+
}
|
|
125
|
+
const truncated = message.length - 2 * CHUNK;
|
|
126
|
+
return message.slice(0, CHUNK) + `...${truncated} characters truncated...` + message.slice(-CHUNK);
|
|
127
|
+
}
|
|
115
128
|
/**
|
|
116
129
|
* Formats a Viem error into a FormattedViemError instance.
|
|
117
130
|
* @param error - The error to format.
|
|
@@ -162,18 +175,9 @@ function getNestedErrorData(error) {
|
|
|
162
175
|
}
|
|
163
176
|
// If it's a regular Error instance, return it with its message
|
|
164
177
|
if (error instanceof Error) {
|
|
165
|
-
return new FormattedViemError(error.message, error?.metaMessages);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const length = body.length;
|
|
169
|
-
// LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
|
|
170
|
-
// Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
|
|
171
|
-
if (length > 2000) {
|
|
172
|
-
const chunk = 950;
|
|
173
|
-
const truncated = length - 2 * chunk;
|
|
174
|
-
return new FormattedViemError(body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk));
|
|
175
|
-
}
|
|
176
|
-
return new FormattedViemError(body);
|
|
178
|
+
return new FormattedViemError(truncateErrorMessage(error.message), error?.metaMessages);
|
|
179
|
+
}
|
|
180
|
+
return new FormattedViemError(truncateErrorMessage(String(error)));
|
|
177
181
|
}
|
|
178
182
|
function stripAbis(obj) {
|
|
179
183
|
if (!obj || typeof obj !== 'object') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.2b2662070",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -50,11 +50,10 @@
|
|
|
50
50
|
"../package.common.json"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
54
|
-
"@aztec/constants": "0.0.1-commit.
|
|
55
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
56
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
57
|
-
"@viem/anvil": "^0.0.10",
|
|
53
|
+
"@aztec/blob-lib": "0.0.1-commit.2b2662070",
|
|
54
|
+
"@aztec/constants": "0.0.1-commit.2b2662070",
|
|
55
|
+
"@aztec/foundation": "0.0.1-commit.2b2662070",
|
|
56
|
+
"@aztec/l1-artifacts": "0.0.1-commit.2b2662070",
|
|
58
57
|
"dotenv": "^16.0.3",
|
|
59
58
|
"lodash.chunk": "^4.2.0",
|
|
60
59
|
"lodash.pickby": "^4.5.0",
|
|
@@ -69,7 +68,6 @@
|
|
|
69
68
|
"@types/lodash.pickby": "^4",
|
|
70
69
|
"@types/node": "^22.15.17",
|
|
71
70
|
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
72
|
-
"@viem/anvil": "^0.0.10",
|
|
73
71
|
"get-port": "^7.1.0",
|
|
74
72
|
"jest": "^30.0.0",
|
|
75
73
|
"jest-mock-extended": "^4.0.0",
|
package/src/client.ts
CHANGED
|
@@ -25,10 +25,17 @@ type Config = {
|
|
|
25
25
|
l1ChainId: number;
|
|
26
26
|
/** The polling interval viem uses in ms */
|
|
27
27
|
viemPollingIntervalMS?: number;
|
|
28
|
+
/** Timeout for HTTP requests to the L1 RPC node in ms. */
|
|
29
|
+
l1HttpTimeoutMS?: number;
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
export type { Config as EthereumClientConfig };
|
|
31
33
|
|
|
34
|
+
/** Creates a viem fallback HTTP transport for the given L1 RPC URLs. */
|
|
35
|
+
export function makeL1HttpTransport(rpcUrls: string[], opts?: { timeout?: number }) {
|
|
36
|
+
return fallback(rpcUrls.map(url => http(url, { batch: false, timeout: opts?.timeout })));
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
// TODO: Use these methods to abstract the creation of viem clients.
|
|
33
40
|
|
|
34
41
|
/** Returns a viem public client given the L1 config. */
|
|
@@ -36,7 +43,7 @@ export function getPublicClient(config: Config): ViemPublicClient {
|
|
|
36
43
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
37
44
|
return createPublicClient({
|
|
38
45
|
chain: chain.chainInfo,
|
|
39
|
-
transport:
|
|
46
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
40
47
|
pollingInterval: config.viemPollingIntervalMS,
|
|
41
48
|
});
|
|
42
49
|
}
|
|
@@ -77,6 +84,7 @@ export function createExtendedL1Client(
|
|
|
77
84
|
chain: Chain = foundry,
|
|
78
85
|
pollingIntervalMS?: number,
|
|
79
86
|
addressIndex?: number,
|
|
87
|
+
opts?: { httpTimeoutMS?: number },
|
|
80
88
|
): ExtendedViemWalletClient {
|
|
81
89
|
const hdAccount =
|
|
82
90
|
typeof mnemonicOrPrivateKeyOrHdAccount === 'string'
|
|
@@ -88,7 +96,7 @@ export function createExtendedL1Client(
|
|
|
88
96
|
const extendedClient = createWalletClient({
|
|
89
97
|
account: hdAccount,
|
|
90
98
|
chain,
|
|
91
|
-
transport:
|
|
99
|
+
transport: makeL1HttpTransport(rpcUrls, { timeout: opts?.httpTimeoutMS }),
|
|
92
100
|
pollingInterval: pollingIntervalMS,
|
|
93
101
|
}).extend(publicActions);
|
|
94
102
|
|
package/src/config.ts
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
bigintConfigHelper,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
-
enumConfigHelper,
|
|
6
5
|
getConfigFromMappings,
|
|
7
6
|
getDefaultConfig,
|
|
8
7
|
numberConfigHelper,
|
|
@@ -19,6 +18,8 @@ export type GenesisStateConfig = {
|
|
|
19
18
|
testAccounts: boolean;
|
|
20
19
|
/** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
|
|
21
20
|
sponsoredFPC: boolean;
|
|
21
|
+
/** Additional addresses to prefund with fee juice at genesis */
|
|
22
|
+
prefundAddresses: string[];
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export type L1ContractsConfig = {
|
|
@@ -58,13 +59,13 @@ export type L1ContractsConfig = {
|
|
|
58
59
|
slashingOffsetInRounds: number;
|
|
59
60
|
/** How long slashing can be disabled for in seconds when vetoer disables it */
|
|
60
61
|
slashingDisableDuration: number;
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
/** Minimum amount that can be slashed
|
|
62
|
+
/** Whether to deploy a slasher proposer */
|
|
63
|
+
slasherEnabled: boolean;
|
|
64
|
+
/** Minimum amount that can be slashed */
|
|
64
65
|
slashAmountSmall: bigint;
|
|
65
|
-
/** Medium amount to slash
|
|
66
|
+
/** Medium amount to slash */
|
|
66
67
|
slashAmountMedium: bigint;
|
|
67
|
-
/** Largest amount that can be slashed per round
|
|
68
|
+
/** Largest amount that can be slashed per round */
|
|
68
69
|
slashAmountLarge: bigint;
|
|
69
70
|
/** Governance proposing quorum (defaults to roundSize/2 + 1) */
|
|
70
71
|
governanceProposerQuorum?: number;
|
|
@@ -150,13 +151,10 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
150
151
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
151
152
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
152
153
|
},
|
|
153
|
-
|
|
154
|
-
env: '
|
|
155
|
-
description: '
|
|
156
|
-
...
|
|
157
|
-
['empire', 'tally', 'none'] as const,
|
|
158
|
-
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
159
|
-
),
|
|
154
|
+
slasherEnabled: {
|
|
155
|
+
env: 'AZTEC_SLASHER_ENABLED',
|
|
156
|
+
description: 'Whether to deploy a slasher proposer',
|
|
157
|
+
...booleanConfigHelper(true),
|
|
160
158
|
},
|
|
161
159
|
slashAmountSmall: {
|
|
162
160
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
@@ -259,6 +257,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
|
|
|
259
257
|
description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
|
|
260
258
|
...booleanConfigHelper(false),
|
|
261
259
|
},
|
|
260
|
+
prefundAddresses: {
|
|
261
|
+
env: 'PREFUND_ADDRESSES',
|
|
262
|
+
description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
|
|
263
|
+
parseEnv: (val: string) =>
|
|
264
|
+
val
|
|
265
|
+
.split(',')
|
|
266
|
+
.map(a => a.trim())
|
|
267
|
+
.filter(a => a.length > 0),
|
|
268
|
+
defaultValue: [],
|
|
269
|
+
},
|
|
262
270
|
};
|
|
263
271
|
|
|
264
272
|
export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
|
|
5
|
+
import type { StateOverride } from 'viem';
|
|
6
|
+
|
|
7
|
+
import { type FeeHeader, RollupContract } from './rollup.js';
|
|
8
|
+
|
|
9
|
+
export type PendingCheckpointOverrideState = {
|
|
10
|
+
archive?: Fr;
|
|
11
|
+
feeHeader?: FeeHeader;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Describes the simulated L1 rollup state that downstream calls should observe. */
|
|
15
|
+
export type SimulationOverridesPlan = {
|
|
16
|
+
pendingCheckpointNumber?: CheckpointNumber;
|
|
17
|
+
pendingCheckpointState?: PendingCheckpointOverrideState;
|
|
18
|
+
disableBlobCheck?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Builds a single-checkpoint simulation plan before it is translated into a viem state override. */
|
|
22
|
+
export class SimulationOverridesBuilder {
|
|
23
|
+
private pendingCheckpointNumber?: CheckpointNumber;
|
|
24
|
+
private pendingCheckpointState?: PendingCheckpointOverrideState;
|
|
25
|
+
private disableBlobCheck = false;
|
|
26
|
+
|
|
27
|
+
/** Starts from an existing plan so callers can extend or specialize it. */
|
|
28
|
+
public static from(plan: SimulationOverridesPlan | undefined): SimulationOverridesBuilder {
|
|
29
|
+
return new SimulationOverridesBuilder().merge(plan);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Merges another plan into this builder. Later values win. */
|
|
33
|
+
public merge(plan: SimulationOverridesPlan | undefined): this {
|
|
34
|
+
if (!plan) {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
this.pendingCheckpointNumber = plan.pendingCheckpointNumber;
|
|
39
|
+
this.pendingCheckpointState = plan.pendingCheckpointState
|
|
40
|
+
? { ...(this.pendingCheckpointState ?? {}), ...plan.pendingCheckpointState }
|
|
41
|
+
: this.pendingCheckpointState;
|
|
42
|
+
this.disableBlobCheck = this.disableBlobCheck || (plan.disableBlobCheck ?? false);
|
|
43
|
+
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Sets the checkpoint number that archive and fee header overrides should attach to. */
|
|
48
|
+
public forPendingCheckpoint(pendingCheckpointNumber: CheckpointNumber | undefined): this {
|
|
49
|
+
this.pendingCheckpointNumber = pendingCheckpointNumber;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Overrides the archive root for the configured pending checkpoint. */
|
|
54
|
+
public withPendingArchive(archive: Fr): this {
|
|
55
|
+
this.assertPendingCheckpointNumber();
|
|
56
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), archive };
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Overrides the fee header for the configured pending checkpoint. */
|
|
61
|
+
public withPendingFeeHeader(feeHeader: FeeHeader): this {
|
|
62
|
+
this.assertPendingCheckpointNumber();
|
|
63
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), feeHeader };
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Disables blob checking for simulations that cannot provide DA inputs. */
|
|
68
|
+
public withoutBlobCheck(): this {
|
|
69
|
+
this.disableBlobCheck = true;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Builds the final plan, or `undefined` when no overrides were configured. */
|
|
74
|
+
public build(): SimulationOverridesPlan | undefined {
|
|
75
|
+
if (!this.pendingCheckpointState && this.pendingCheckpointNumber === undefined && !this.disableBlobCheck) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
pendingCheckpointNumber: this.pendingCheckpointNumber,
|
|
81
|
+
pendingCheckpointState: this.pendingCheckpointState,
|
|
82
|
+
disableBlobCheck: this.disableBlobCheck || undefined,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private assertPendingCheckpointNumber(): void {
|
|
87
|
+
if (this.pendingCheckpointNumber === undefined) {
|
|
88
|
+
throw new Error('pendingCheckpointNumber must be set before attaching archive or fee header overrides');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Translates a simulation plan into the viem state override shape expected by rollup calls. */
|
|
94
|
+
export async function buildSimulationOverridesStateOverride(
|
|
95
|
+
rollup: RollupContract,
|
|
96
|
+
plan: SimulationOverridesPlan | undefined,
|
|
97
|
+
): Promise<StateOverride> {
|
|
98
|
+
if (!plan) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const rollupStateDiff: NonNullable<StateOverride[number]['stateDiff']> = [];
|
|
103
|
+
|
|
104
|
+
if (plan.pendingCheckpointNumber !== undefined) {
|
|
105
|
+
rollupStateDiff.push(
|
|
106
|
+
...extractRollupStateDiff(await rollup.makePendingCheckpointNumberOverride(plan.pendingCheckpointNumber)),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (plan.pendingCheckpointState && plan.pendingCheckpointNumber === undefined) {
|
|
111
|
+
throw new Error('pendingCheckpointState requires pendingCheckpointNumber to be set');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (plan.pendingCheckpointState?.archive) {
|
|
115
|
+
rollupStateDiff.push(
|
|
116
|
+
...extractRollupStateDiff(
|
|
117
|
+
rollup.makeArchiveOverride(plan.pendingCheckpointNumber!, plan.pendingCheckpointState.archive),
|
|
118
|
+
),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (plan.pendingCheckpointState?.feeHeader) {
|
|
123
|
+
rollupStateDiff.push(
|
|
124
|
+
...extractRollupStateDiff(
|
|
125
|
+
await rollup.makeFeeHeaderOverride(plan.pendingCheckpointNumber!, plan.pendingCheckpointState.feeHeader),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (plan.disableBlobCheck) {
|
|
131
|
+
rollupStateDiff.push({
|
|
132
|
+
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
133
|
+
value: toPaddedHex(0n, true),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (rollupStateDiff.length === 0) {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return [{ address: rollup.address, stateDiff: rollupStateDiff }];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function extractRollupStateDiff(override: StateOverride | StateOverride[number] | undefined) {
|
|
145
|
+
const entries = Array.isArray(override) ? override : override ? [override] : [];
|
|
146
|
+
return entries.flatMap(entry => entry.stateDiff ?? []);
|
|
147
|
+
}
|