@aztec/ethereum 0.0.1-commit.3e3d0c9cd → 0.0.1-commit.3f296a7d2
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/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/rollup.d.ts +3 -3
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +4 -5
- package/dest/l1_artifacts.d.ts +69 -69
- 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/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/start_anvil.d.ts +8 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -2
- package/package.json +5 -5
- package/src/contracts/multicall.ts +65 -1
- package/src/contracts/rollup.ts +5 -7
- package/src/publisher_manager.ts +105 -10
- package/src/test/eth_cheat_codes.ts +6 -4
- package/src/test/start_anvil.ts +25 -2
package/src/test/start_anvil.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
3
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
3
4
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
4
5
|
|
|
5
6
|
import { type ChildProcess, spawn } from 'child_process';
|
|
@@ -33,6 +34,12 @@ export async function startAnvil(
|
|
|
33
34
|
* L1-finality-based logic work without needing hundreds of mined blocks.
|
|
34
35
|
*/
|
|
35
36
|
slotsInAnEpoch?: number;
|
|
37
|
+
/**
|
|
38
|
+
* If provided, the date provider will be synced to anvil's block time on every mined block.
|
|
39
|
+
* This keeps the dateProvider in lockstep with anvil's chain time, avoiding drift between
|
|
40
|
+
* the wall clock and the L1 chain when computing L1 slot timestamps.
|
|
41
|
+
*/
|
|
42
|
+
dateProvider?: TestDateProvider;
|
|
36
43
|
} = {},
|
|
37
44
|
): Promise<{ anvil: Anvil; methodCalls?: string[]; rpcUrl: string; stop: () => Promise<void> }> {
|
|
38
45
|
const anvilBinary = resolve(dirname(fileURLToPath(import.meta.url)), '../../', 'scripts/anvil_kill_wrapper.sh');
|
|
@@ -108,12 +115,15 @@ export async function startAnvil(
|
|
|
108
115
|
child.once('close', onClose);
|
|
109
116
|
});
|
|
110
117
|
|
|
111
|
-
// Continue piping for logging
|
|
112
|
-
if (logger || opts.captureMethodCalls) {
|
|
118
|
+
// Continue piping for logging, method-call capture, and/or dateProvider sync after startup.
|
|
119
|
+
if (logger || opts.captureMethodCalls || opts.dateProvider) {
|
|
113
120
|
child.stdout?.on('data', (data: Buffer) => {
|
|
114
121
|
const text = data.toString();
|
|
115
122
|
logger?.debug(text.trim());
|
|
116
123
|
methodCalls?.push(...(text.match(/eth_[^\s]+/g) || []));
|
|
124
|
+
if (opts.dateProvider) {
|
|
125
|
+
syncDateProviderFromAnvilOutput(text, opts.dateProvider);
|
|
126
|
+
}
|
|
117
127
|
});
|
|
118
128
|
child.stderr?.on('data', (data: Buffer) => {
|
|
119
129
|
logger?.debug(data.toString().trim());
|
|
@@ -160,6 +170,19 @@ export async function startAnvil(
|
|
|
160
170
|
return { anvil: anvilObj, methodCalls, stop, rpcUrl: `http://127.0.0.1:${port}` };
|
|
161
171
|
}
|
|
162
172
|
|
|
173
|
+
/** Extracts block time from anvil stdout and syncs the dateProvider. */
|
|
174
|
+
function syncDateProviderFromAnvilOutput(text: string, dateProvider: TestDateProvider): void {
|
|
175
|
+
// Anvil logs mined blocks as:
|
|
176
|
+
// Block Time: "Fri, 20 Mar 2026 02:10:46 +0000"
|
|
177
|
+
const match = text.match(/Block Time:\s*"([^"]+)"/);
|
|
178
|
+
if (match) {
|
|
179
|
+
const blockTimeMs = new Date(match[1]).getTime();
|
|
180
|
+
if (!isNaN(blockTimeMs)) {
|
|
181
|
+
dateProvider.setTime(blockTimeMs);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
163
186
|
/** Send SIGTERM, wait up to 5 s, then SIGKILL. All timers are always cleared. */
|
|
164
187
|
function killChild(child: ChildProcess): Promise<void> {
|
|
165
188
|
return new Promise<void>(resolve => {
|