@aztec/aztec 0.0.1-commit.2f68f620 → 0.0.1-commit.3100065
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/bin/index.js +2 -0
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +6 -27
- package/dest/cli/aztec_start_options.js +1 -1
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +25 -17
- package/dest/cli/cmds/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +28 -2
- package/dest/cli/cmds/standby.d.ts.map +1 -1
- package/dest/cli/cmds/standby.js +45 -2
- package/dest/cli/cmds/start_bot.d.ts +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +5 -1
- package/dest/cli/cmds/start_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +13 -22
- package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
- package/dest/cli/util.d.ts +10 -5
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +20 -49
- package/dest/examples/token.js +3 -3
- package/dest/local-network/local-network.d.ts +4 -5
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +32 -75
- package/dest/testing/cheat_codes.d.ts +16 -23
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +20 -82
- package/dest/testing/epoch_test_settler.d.ts +2 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +5 -26
- package/dest/testing/index.d.ts +1 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +0 -1
- package/dest/testing/token_allowed_setup.d.ts +9 -4
- package/dest/testing/token_allowed_setup.d.ts.map +1 -1
- package/dest/testing/token_allowed_setup.js +12 -8
- package/package.json +34 -34
- package/scripts/templates/counter/contract/src/main.nr +4 -4
- package/src/bin/index.ts +2 -0
- package/src/cli/aztec_start_action.ts +3 -14
- package/src/cli/aztec_start_options.ts +1 -1
- package/src/cli/cmds/compile.ts +29 -16
- package/src/cli/cmds/prover.ts +42 -0
- package/src/cli/cmds/standby.ts +55 -3
- package/src/cli/cmds/start_bot.ts +6 -1
- package/src/cli/cmds/start_node.ts +16 -22
- package/src/cli/cmds/utils/artifacts.ts +5 -0
- package/src/cli/util.ts +21 -62
- package/src/examples/token.ts +11 -3
- package/src/local-network/local-network.ts +34 -87
- package/src/testing/cheat_codes.ts +19 -103
- package/src/testing/epoch_test_settler.ts +8 -30
- package/src/testing/index.ts +0 -1
- package/src/testing/token_allowed_setup.ts +15 -8
- package/dest/testing/anvil_test_watcher.d.ts +0 -54
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -235
- package/src/testing/anvil_test_watcher.ts +0 -273
package/dest/cli/util.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { getNetworkConfig } from '@aztec/cli/config';
|
|
2
|
-
import { RegistryContract } from '@aztec/ethereum/contracts';
|
|
3
1
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
6
2
|
import chalk from 'chalk';
|
|
7
3
|
import { aztecStartOptions } from './aztec_start_options.js';
|
|
8
4
|
export var ExitCode = /*#__PURE__*/ function(ExitCode) {
|
|
@@ -38,6 +34,25 @@ export function shutdown(logFn, exitCode, cb) {
|
|
|
38
34
|
export function isShuttingDown() {
|
|
39
35
|
return shutdownPromise !== undefined;
|
|
40
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Stops the node's subsystems (via the registered signal handlers) without exiting the process, leaving
|
|
39
|
+
* the HTTP health server listening so K8s liveness/readiness probes keep passing. Unlike {@link shutdown}
|
|
40
|
+
* this deliberately does not latch `shutdownPromise` or call `process.exit`; instead it re-arms
|
|
41
|
+
* SIGTERM/SIGINT so a later K8s pod deletion still terminates the wound-down pod with a clean exit.
|
|
42
|
+
*/ export async function softShutdown(logFn, signalHandlers) {
|
|
43
|
+
logFn('Canonical rollup upgrade detected: stopping subsystems, health server stays up.', {
|
|
44
|
+
exitCode: 78
|
|
45
|
+
});
|
|
46
|
+
await Promise.allSettled(signalHandlers.map((fn)=>fn()));
|
|
47
|
+
for (const sig of [
|
|
48
|
+
'SIGTERM',
|
|
49
|
+
'SIGINT'
|
|
50
|
+
]){
|
|
51
|
+
process.removeAllListeners(sig);
|
|
52
|
+
process.once(sig, ()=>process.exit(78));
|
|
53
|
+
}
|
|
54
|
+
logFn('Subsystems stopped due to rollup upgrade. Health server remains active.');
|
|
55
|
+
}
|
|
41
56
|
export const installSignalHandlers = (logFn, cb)=>{
|
|
42
57
|
const signals = [
|
|
43
58
|
[
|
|
@@ -79,7 +94,7 @@ export const installSignalHandlers = (logFn, cb)=>{
|
|
|
79
94
|
if (registeredAccounts.find((a)=>a.item.equals(completeAddress.address))) {
|
|
80
95
|
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
81
96
|
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
82
|
-
accountLogStrings.push(` Secret Key: ${
|
|
97
|
+
accountLogStrings.push(` Secret Key: ${accountManager.getSecretKey().toString()}\n`);
|
|
83
98
|
accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
|
|
84
99
|
accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
|
|
85
100
|
accountLogStrings.push(` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`);
|
|
@@ -241,50 +256,6 @@ export const printAztecStartHelpText = ()=>{
|
|
|
241
256
|
]);
|
|
242
257
|
}
|
|
243
258
|
}
|
|
244
|
-
export async function setupVersionChecker(network, followsCanonicalRollup, publicClient, signalHandlers, cacheDir) {
|
|
245
|
-
const networkConfig = await getNetworkConfig(network, cacheDir);
|
|
246
|
-
if (!networkConfig) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const { VersionChecker } = await import('@aztec/stdlib/update-checker');
|
|
250
|
-
const logger = createLogger('version_check');
|
|
251
|
-
const registry = new RegistryContract(publicClient, networkConfig.registryAddress);
|
|
252
|
-
const checks = [];
|
|
253
|
-
checks.push({
|
|
254
|
-
name: 'node',
|
|
255
|
-
currentVersion: getPackageVersion(),
|
|
256
|
-
getLatestVersion: async ()=>{
|
|
257
|
-
const cfg = await getNetworkConfig(network, cacheDir);
|
|
258
|
-
return cfg?.nodeVersion;
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
if (followsCanonicalRollup) {
|
|
262
|
-
const getLatestVersion = async ()=>{
|
|
263
|
-
const version = (await registry.getRollupVersions()).at(-1);
|
|
264
|
-
return version !== undefined ? String(version) : undefined;
|
|
265
|
-
};
|
|
266
|
-
const currentVersion = await getLatestVersion();
|
|
267
|
-
if (currentVersion !== undefined) {
|
|
268
|
-
checks.push({
|
|
269
|
-
name: 'rollup',
|
|
270
|
-
currentVersion,
|
|
271
|
-
getLatestVersion
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const checker = new VersionChecker(checks, 600_000, logger);
|
|
276
|
-
checker.on('newVersion', ({ name, latestVersion, currentVersion })=>{
|
|
277
|
-
if (isShuttingDown()) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
logger.warn(`New ${name} version available`, {
|
|
281
|
-
latestVersion,
|
|
282
|
-
currentVersion
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
checker.start();
|
|
286
|
-
signalHandlers.push(()=>checker.stop());
|
|
287
|
-
}
|
|
288
259
|
export function stringifyConfig(config) {
|
|
289
260
|
return Object.entries(config).map(([key, value])=>`${key}=${jsonStringify(value)}`).join(' ');
|
|
290
261
|
}
|
package/dest/examples/token.js
CHANGED
|
@@ -13,10 +13,10 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
13
13
|
*/ async function main() {
|
|
14
14
|
logger.info('Running token contract test on HTTP interface.');
|
|
15
15
|
const wallet = await EmbeddedWallet.create(node);
|
|
16
|
-
// During local network setup we
|
|
16
|
+
// During local network setup we create a few initializerless accounts. Below we add them to our wallet.
|
|
17
17
|
const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
|
|
18
|
-
await wallet.
|
|
19
|
-
await wallet.
|
|
18
|
+
await wallet.createSchnorrInitializerlessAccount(aliceInitialAccountData.secret, aliceInitialAccountData.salt, aliceInitialAccountData.signingKey);
|
|
19
|
+
await wallet.createSchnorrInitializerlessAccount(bobInitialAccountData.secret, bobInitialAccountData.salt, bobInitialAccountData.signingKey);
|
|
20
20
|
const alice = aliceInitialAccountData.address;
|
|
21
21
|
const bob = bobInitialAccountData.address;
|
|
22
22
|
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import { AztecNodeService } from '@aztec/aztec-node';
|
|
3
2
|
import { type AztecNodeConfig } from '@aztec/aztec-node/config';
|
|
4
3
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
4
|
import { type BlobClientInterface } from '@aztec/blob-client/client';
|
|
@@ -9,7 +8,7 @@ import { DateProvider } from '@aztec/foundation/timer';
|
|
|
9
8
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
10
9
|
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
11
10
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
12
|
-
import {
|
|
11
|
+
import type { Hex } from 'viem';
|
|
13
12
|
/**
|
|
14
13
|
* Function to deploy our L1 contracts to the local network L1
|
|
15
14
|
* @param aztecNodeConfig - The Aztec Node Config
|
|
@@ -32,7 +31,7 @@ export type LocalNetworkConfig = AztecNodeConfig & {
|
|
|
32
31
|
* @param config - Optional local network settings.
|
|
33
32
|
*/
|
|
34
33
|
export declare function createLocalNetwork(config: Partial<LocalNetworkConfig> | undefined, userLog: LogFn): Promise<{
|
|
35
|
-
node: AztecNodeService;
|
|
34
|
+
node: import("@aztec/aztec-node").AztecNodeService;
|
|
36
35
|
stop: () => Promise<void>;
|
|
37
36
|
}>;
|
|
38
37
|
/**
|
|
@@ -46,5 +45,5 @@ export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?
|
|
|
46
45
|
proverBroker?: ProvingJobBroker;
|
|
47
46
|
}, options?: {
|
|
48
47
|
genesis?: GenesisData;
|
|
49
|
-
}): Promise<AztecNodeService>;
|
|
50
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
48
|
+
}): Promise<import("@aztec/aztec-node").AztecNodeService>;
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbmV0d29yay5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvY2FsLW5ldHdvcmsvbG9jYWwtbmV0d29yay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBR0EsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFvQixNQUFNLDBCQUEwQixDQUFDO0FBQ2xGLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUU1QyxPQUFPLEVBQUUsS0FBSyxtQkFBbUIsRUFBb0IsTUFBTSwyQkFBMkIsQ0FBQztBQU12RixPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBR2pGLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sRUFBRSxZQUFZLEVBQW9CLE1BQU0seUJBQXlCLENBQUM7QUFJekUsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUV4RSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUM3RCxPQUFPLEVBQ0wsS0FBSyxlQUFlLEVBR3JCLE1BQU0seUJBQXlCLENBQUM7QUFLakMsT0FBTyxLQUFLLEVBQUUsR0FBRyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBbUJoQzs7OztHQUlHO0FBQ0gsd0JBQXNCLG1CQUFtQixDQUN2QyxlQUFlLEVBQUUsZUFBZSxFQUNoQyxVQUFVLEVBQUUsR0FBRyxFQUNmLElBQUksR0FBRTtJQUNKLGtCQUFrQixDQUFDLEVBQUUsRUFBRSxDQUFDO0lBQ3hCLDRCQUE0QixDQUFDLEVBQUUsTUFBTSxDQUFDO0NBQ2xDLEdBQ0wsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBbUI5QjtBQUVELDhCQUE4QjtBQUM5QixNQUFNLE1BQU0sa0JBQWtCLEdBQUcsZUFBZSxHQUFHO0lBQ2pELDBEQUEwRDtJQUMxRCxVQUFVLEVBQUUsTUFBTSxDQUFDO0lBQ25CLDZEQUE2RDtJQUM3RCxZQUFZLEVBQUUsT0FBTyxDQUFDO0NBQ3ZCLENBQUM7QUFFRjs7OztHQUlHO0FBQ0gsd0JBQXNCLGtCQUFrQixDQUFDLE1BQU0seUNBQWtDLEVBQUUsT0FBTyxFQUFFLEtBQUs7OztHQTRIaEc7QUFFRDs7O0dBR0c7QUFDSCx3QkFBc0IsZUFBZSxDQUNuQyxNQUFNLEdBQUUsT0FBTyxDQUFDLGVBQWUsQ0FBTSxFQUNyQyxJQUFJLEdBQUU7SUFDSixTQUFTLENBQUMsRUFBRSxlQUFlLENBQUM7SUFDNUIsVUFBVSxDQUFDLEVBQUUsbUJBQW1CLENBQUM7SUFDakMsWUFBWSxDQUFDLEVBQUUsWUFBWSxDQUFDO0lBQzVCLFlBQVksQ0FBQyxFQUFFLGdCQUFnQixDQUFDO0NBQzVCLEVBQ04sT0FBTyxHQUFFO0lBQUUsT0FBTyxDQUFDLEVBQUUsV0FBVyxDQUFBO0NBQU8seURBY3hDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-network.d.ts","sourceRoot":"","sources":["../../src/local-network/local-network.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"local-network.d.ts","sourceRoot":"","sources":["../../src/local-network/local-network.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAE5C,OAAO,EAAE,KAAK,mBAAmB,EAAoB,MAAM,2BAA2B,CAAC;AAMvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;AAIzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAmBhC;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,GAAG,EACf,IAAI,GAAE;IACJ,kBAAkB,CAAC,EAAE,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAClC,GACL,OAAO,CAAC,mBAAmB,CAAC,CAmB9B;AAED,8BAA8B;AAC9B,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,yCAAkC,EAAE,OAAO,EAAE,KAAK;;;GA4HhG;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IACJ,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,EACN,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,yDAcxC"}
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
2
|
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
|
-
import {
|
|
3
|
+
import { createAztecNodeService } from '@aztec/aztec-node';
|
|
4
4
|
import { getConfigEnvVars } from '@aztec/aztec-node/config';
|
|
5
5
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
6
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
7
7
|
import { createBlobClient } from '@aztec/blob-client/client';
|
|
8
8
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
-
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
9
|
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
11
10
|
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
11
|
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
13
12
|
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
14
|
-
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
15
13
|
import { SecretValue } from '@aztec/foundation/config';
|
|
16
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
15
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
18
16
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
17
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
|
-
import { SequencerState } from '@aztec/sequencer-client';
|
|
21
18
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
19
|
import { TxStatus } from '@aztec/stdlib/tx';
|
|
23
20
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
24
21
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
25
|
-
import {
|
|
22
|
+
import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
|
|
26
23
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
27
|
-
import { createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
28
24
|
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
29
25
|
import { foundry } from 'viem/chains';
|
|
30
26
|
import { createAccountLogs } from '../cli/util.js';
|
|
31
27
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
32
|
-
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
33
|
-
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
34
28
|
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
35
29
|
import { publishStandardAuthRegistry } from './auth_registry.js';
|
|
36
30
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
@@ -43,7 +37,6 @@ const logger = createLogger('local-network');
|
|
|
43
37
|
const setupWaitOpts = {
|
|
44
38
|
waitForStatus: TxStatus.CHECKPOINTED
|
|
45
39
|
};
|
|
46
|
-
const localAnvil = foundry;
|
|
47
40
|
/**
|
|
48
41
|
* Function to deploy our L1 contracts to the local network L1
|
|
49
42
|
* @param aztecNodeConfig - The Aztec Node Config
|
|
@@ -81,13 +74,36 @@ const localAnvil = foundry;
|
|
|
81
74
|
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
82
75
|
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
83
76
|
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
77
|
+
const envConfig = getConfigEnvVars();
|
|
84
78
|
const aztecNodeConfig = {
|
|
85
|
-
...
|
|
79
|
+
...envConfig,
|
|
86
80
|
...config,
|
|
81
|
+
skipOrphanProposedBlockPruning: true,
|
|
82
|
+
// The local network builds node config from env without a DATA_DIRECTORY, so the validator's
|
|
83
|
+
// local signing protection runs against an ephemeral store. That is acceptable for this dev
|
|
84
|
+
// network; production validators must persist it and fail-fast when the data directory is unset.
|
|
85
|
+
allowEphemeralSigningProtection: config.allowEphemeralSigningProtection ?? true,
|
|
87
86
|
txPublicSetupAllowListExtend: [
|
|
88
87
|
...tokenAllowList,
|
|
89
88
|
...config.txPublicSetupAllowListExtend ?? []
|
|
90
|
-
]
|
|
89
|
+
],
|
|
90
|
+
// The local network runs against anvil with no committee, so it defaults to the deterministic
|
|
91
|
+
// AutomineSequencer, which owns L1 time control (warps the dateProvider and L1 timestamps to slot
|
|
92
|
+
// boundaries as it builds), replacing the deleted AnvilTestWatcher. This remains true when p2p is
|
|
93
|
+
// enabled for local peer testing; local-network is not a mode for connecting to an existing network.
|
|
94
|
+
useAutomineSequencer: config.useAutomineSequencer ?? true,
|
|
95
|
+
// The AutomineSequencer owns epoch proving in the local network — it writes epoch out hashes to
|
|
96
|
+
// the L1 Outbox and advances the proven tip as checkpoints land, through the same serial queue as
|
|
97
|
+
// its builds — replacing the standalone EpochTestSettler that used to race the build loop.
|
|
98
|
+
automineEnableProveEpoch: config.automineEnableProveEpoch ?? true,
|
|
99
|
+
// Defaults for the local network / sandbox; callers (e.g. the CLI) may override. No real proving
|
|
100
|
+
// happens here — the AutomineSequencer synthetically settles epochs. Short epochs let it write out
|
|
101
|
+
// hashes quickly (so users can consume L2-to-L1 messages without a long wait), with a wider
|
|
102
|
+
// proof-submission window so the synthetic settler has headroom before the rollup would prune an
|
|
103
|
+
// unproven checkpoint.
|
|
104
|
+
realProofs: config.realProofs ?? false,
|
|
105
|
+
aztecEpochDuration: config.aztecEpochDuration ?? 4,
|
|
106
|
+
aztecProofSubmissionEpochs: config.aztecProofSubmissionEpochs ?? 2
|
|
91
107
|
};
|
|
92
108
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
93
109
|
if (aztecNodeConfig.sequencerPublisherPrivateKeys == undefined || !aztecNodeConfig.sequencerPublisherPrivateKeys.length || aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY) {
|
|
@@ -106,7 +122,7 @@ const localAnvil = foundry;
|
|
|
106
122
|
const initialAccounts = await (async ()=>{
|
|
107
123
|
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
108
124
|
if (aztecNodeConfig.p2pEnabled) {
|
|
109
|
-
userLog(`Not setting up test accounts
|
|
125
|
+
userLog(`Not setting up test accounts when p2p is enabled`);
|
|
110
126
|
} else {
|
|
111
127
|
userLog(`Setting up test accounts`);
|
|
112
128
|
return await getInitialTestAccountsData();
|
|
@@ -116,7 +132,7 @@ const localAnvil = foundry;
|
|
|
116
132
|
})();
|
|
117
133
|
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
118
134
|
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
119
|
-
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map((a)=>AztecAddress.
|
|
135
|
+
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map((a)=>AztecAddress.fromStringUnsafe(a));
|
|
120
136
|
const fundedAddresses = [
|
|
121
137
|
...initialAccounts.map((a)=>a.address),
|
|
122
138
|
...initialAccounts.length ? [
|
|
@@ -127,32 +143,11 @@ const localAnvil = foundry;
|
|
|
127
143
|
];
|
|
128
144
|
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
129
145
|
const dateProvider = new TestDateProvider();
|
|
130
|
-
let cheatcodes;
|
|
131
|
-
let rollupAddress;
|
|
132
|
-
let watcher;
|
|
133
146
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
134
|
-
|
|
147
|
+
await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
|
|
135
148
|
genesisArchiveRoot,
|
|
136
149
|
feeJuicePortalInitialBalance: fundingNeeded
|
|
137
|
-
}));
|
|
138
|
-
const chain = aztecNodeConfig.l1RpcUrls.length > 0 ? createEthereumChain([
|
|
139
|
-
l1RpcUrl
|
|
140
|
-
], aztecNodeConfig.l1ChainId) : {
|
|
141
|
-
chainInfo: localAnvil
|
|
142
|
-
};
|
|
143
|
-
const publicClient = createPublicClient({
|
|
144
|
-
chain: chain.chainInfo,
|
|
145
|
-
transport: fallback([
|
|
146
|
-
httpViemTransport(l1RpcUrl)
|
|
147
|
-
])
|
|
148
150
|
});
|
|
149
|
-
cheatcodes = new EthCheatCodes([
|
|
150
|
-
l1RpcUrl
|
|
151
|
-
], dateProvider);
|
|
152
|
-
watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
|
|
153
|
-
watcher.setisLocalNetwork(true);
|
|
154
|
-
watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
|
|
155
|
-
await watcher.start();
|
|
156
151
|
}
|
|
157
152
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
158
153
|
// Create a local blob client client inside the local network, no http connectivity
|
|
@@ -164,42 +159,6 @@ const localAnvil = foundry;
|
|
|
164
159
|
}, {
|
|
165
160
|
genesis
|
|
166
161
|
});
|
|
167
|
-
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
168
|
-
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
169
|
-
// warping time out from under an in-progress block.
|
|
170
|
-
watcher?.setGetPendingTxCount(()=>node.getPendingTxCount());
|
|
171
|
-
const sequencer = node.getSequencer()?.getSequencer();
|
|
172
|
-
if (sequencer) {
|
|
173
|
-
const idleStates = new Set([
|
|
174
|
-
SequencerState.STOPPED,
|
|
175
|
-
SequencerState.STOPPING,
|
|
176
|
-
SequencerState.IDLE,
|
|
177
|
-
SequencerState.SYNCHRONIZING
|
|
178
|
-
]);
|
|
179
|
-
watcher?.setIsSequencerBuilding(()=>!idleStates.has(sequencer.getState()));
|
|
180
|
-
// Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
|
|
181
|
-
// but the proposer for slot N has already built the checkpoint during slot N-1 and is
|
|
182
|
-
// waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
|
|
183
|
-
// we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
|
|
184
|
-
// checkpoint_proposal_job's background submission task until the archiver has synced past
|
|
185
|
-
// the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
|
|
186
|
-
// that state transition would be circular (L1 has to advance before the state we'd use to
|
|
187
|
-
// advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
|
|
188
|
-
// emits once each block is built. In sandbox single-block-per-slot mode this is
|
|
189
|
-
// effectively "checkpoint built", and the watcher warp is harmless if a subsequent
|
|
190
|
-
// assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
|
|
191
|
-
// cascade absorbs.
|
|
192
|
-
if (watcher) {
|
|
193
|
-
sequencer.on('block-proposed', ({ slot })=>watcher.setProposedTargetSlot(Number(slot)));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
let epochTestSettler;
|
|
197
|
-
if (!aztecNodeConfig.p2pEnabled) {
|
|
198
|
-
epochTestSettler = new EpochTestSettler(cheatcodes, rollupAddress, node.getBlockSource(), logger.createChild('epoch-settler'), {
|
|
199
|
-
pollingIntervalMs: 200
|
|
200
|
-
});
|
|
201
|
-
await epochTestSettler.start();
|
|
202
|
-
}
|
|
203
162
|
if (initialAccounts.length) {
|
|
204
163
|
const wallet = await EmbeddedWallet.create(node, {
|
|
205
164
|
pxeConfig: {
|
|
@@ -208,7 +167,7 @@ const localAnvil = foundry;
|
|
|
208
167
|
ephemeral: true
|
|
209
168
|
});
|
|
210
169
|
userLog('Setting up funded test accounts...');
|
|
211
|
-
const accountManagers = await
|
|
170
|
+
const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
|
|
212
171
|
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
213
172
|
userLog(accLogs.join(''));
|
|
214
173
|
userLog('Publishing standard AuthRegistry contract...');
|
|
@@ -220,8 +179,6 @@ const localAnvil = foundry;
|
|
|
220
179
|
}
|
|
221
180
|
const stop = async ()=>{
|
|
222
181
|
await node.stop();
|
|
223
|
-
await watcher?.stop();
|
|
224
|
-
await epochTestSettler?.stop();
|
|
225
182
|
};
|
|
226
183
|
return {
|
|
227
184
|
node,
|
|
@@ -238,7 +195,7 @@ const localAnvil = foundry;
|
|
|
238
195
|
...getConfigEnvVars(),
|
|
239
196
|
...config
|
|
240
197
|
};
|
|
241
|
-
const node = await
|
|
198
|
+
const node = await createAztecNodeService(aztecNodeConfig, {
|
|
242
199
|
...deps,
|
|
243
200
|
proverNodeDeps: {
|
|
244
201
|
broker: deps.proverBroker
|
|
@@ -1,44 +1,37 @@
|
|
|
1
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
-
import type { AutomineSequencer } from '@aztec/sequencer-client';
|
|
4
3
|
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @deprecated
|
|
8
|
-
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
9
|
-
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
5
|
+
* Wrapper for Aztec Debug API.
|
|
6
|
+
* @deprecated use the AztecNode debug API directly.
|
|
10
7
|
*/
|
|
11
8
|
export declare class CheatCodes {
|
|
12
9
|
/** Cheat codes for L1.*/
|
|
13
10
|
eth: EthCheatCodes;
|
|
14
11
|
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
15
12
|
rollup: RollupCheatCodes;
|
|
16
|
-
/** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
|
|
17
|
-
private automine?;
|
|
18
|
-
private logger;
|
|
19
13
|
constructor(
|
|
20
14
|
/** Cheat codes for L1.*/
|
|
21
15
|
eth: EthCheatCodes,
|
|
22
16
|
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
23
|
-
rollup: RollupCheatCodes
|
|
24
|
-
|
|
25
|
-
automine?: AutomineSequencer | undefined);
|
|
26
|
-
static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider, automine?: AutomineSequencer): Promise<CheatCodes>;
|
|
17
|
+
rollup: RollupCheatCodes);
|
|
18
|
+
static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes>;
|
|
27
19
|
/**
|
|
28
|
-
* Warps the L1 timestamp to
|
|
29
|
-
* the target
|
|
30
|
-
*
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
20
|
+
* Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
|
|
21
|
+
* the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
|
|
22
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
23
|
+
* @param targetTimestamp - The target timestamp to warp to (in seconds).
|
|
24
|
+
* @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
|
|
33
25
|
*/
|
|
34
26
|
warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void>;
|
|
35
27
|
/**
|
|
36
|
-
* Warps the L1 timestamp forward by
|
|
37
|
-
* least by the duration.
|
|
38
|
-
*
|
|
39
|
-
* @param node - The Aztec node
|
|
40
|
-
* @param duration - The duration to advance time by (in seconds)
|
|
28
|
+
* Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
|
|
29
|
+
* least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
|
|
30
|
+
* queue.
|
|
31
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
32
|
+
* @param duration - The duration to advance time by (in seconds).
|
|
33
|
+
* @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
|
|
41
34
|
*/
|
|
42
35
|
warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void>;
|
|
43
36
|
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlYXRfY29kZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2NoZWF0X2NvZGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsY0FBYyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakY7OztHQUdHO0FBQ0gscUJBQWEsVUFBVTtJQUVuQix5QkFBeUI7SUFDbEIsR0FBRyxFQUFFLGFBQWE7SUFDekIsdURBQXVEO0lBQ2hELE1BQU0sRUFBRSxnQkFBZ0I7SUFKakM7SUFDRSx5QkFBeUI7SUFDbEIsR0FBRyxFQUFFLGFBQWE7SUFDekIsdURBQXVEO0lBQ2hELE1BQU0sRUFBRSxnQkFBZ0IsRUFDN0I7SUFFSixPQUFhLE1BQU0sQ0FBQyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQUUsSUFBSSxFQUFFLFNBQVMsRUFBRSxZQUFZLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FPdkc7SUFFRDs7Ozs7O09BTUc7SUFDSCxtQkFBbUIsQ0FBQyxJQUFJLEVBQUUsU0FBUyxHQUFHLGNBQWMsRUFBRSxlQUFlLEVBQUUsTUFBTSxHQUFHLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBRXJHO0lBRUQ7Ozs7Ozs7T0FPRztJQUNILG1CQUFtQixDQUFDLElBQUksRUFBRSxTQUFTLEdBQUcsY0FBYyxFQUFFLFFBQVEsRUFBRSxNQUFNLEdBQUcsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFOUY7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cheat_codes.d.ts","sourceRoot":"","sources":["../../src/testing/cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"cheat_codes.d.ts","sourceRoot":"","sources":["../../src/testing/cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjF;;;GAGG;AACH,qBAAa,UAAU;IAEnB,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB;IAJjC;IACE,yBAAyB;IAClB,GAAG,EAAE,aAAa;IACzB,uDAAuD;IAChD,MAAM,EAAE,gBAAgB,EAC7B;IAEJ,OAAa,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAOvG;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAErG;IAED;;;;;;;OAOG;IACH,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9F;CACF"}
|
|
@@ -1,98 +1,36 @@
|
|
|
1
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @deprecated
|
|
7
|
-
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
8
|
-
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
3
|
+
* Wrapper for Aztec Debug API.
|
|
4
|
+
* @deprecated use the AztecNode debug API directly.
|
|
9
5
|
*/ export class CheatCodes {
|
|
10
6
|
eth;
|
|
11
7
|
rollup;
|
|
12
|
-
|
|
13
|
-
logger;
|
|
14
|
-
constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup, /** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */ automine){
|
|
8
|
+
constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup){
|
|
15
9
|
this.eth = eth;
|
|
16
10
|
this.rollup = rollup;
|
|
17
|
-
this.automine = automine;
|
|
18
|
-
this.logger = createLogger('aztecjs:cheat_codes');
|
|
19
11
|
}
|
|
20
|
-
static async create(rpcUrls, node, dateProvider
|
|
12
|
+
static async create(rpcUrls, node, dateProvider) {
|
|
21
13
|
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
22
14
|
const rollupCheatCodes = new RollupCheatCodes(ethCheatCodes, await node.getNodeInfo().then((n)=>n.l1ContractAddresses));
|
|
23
|
-
return new CheatCodes(ethCheatCodes, rollupCheatCodes
|
|
15
|
+
return new CheatCodes(ethCheatCodes, rollupCheatCodes);
|
|
24
16
|
}
|
|
25
17
|
/**
|
|
26
|
-
* Warps the L1 timestamp to
|
|
27
|
-
* the target
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
34
|
-
if (targetBigInt <= currentTimestamp) {
|
|
35
|
-
throw new Error(`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`);
|
|
36
|
-
}
|
|
37
|
-
// AutomineSequencer owns time control through its serial queue — delegate to keep warps atomic
|
|
38
|
-
// with respect to any in-flight build, and avoid the mineBlock-loop hack below.
|
|
39
|
-
// `warpTo` internally builds an empty L2 checkpoint, which auto-mines exactly one L1 block at
|
|
40
|
-
// the target slot boundary, so no separate `node.mineBlock()` is needed here.
|
|
41
|
-
if (this.automine) {
|
|
42
|
-
await this.automine.warpTo(Number(targetBigInt));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const currentSlot = await this.rollup.getSlot();
|
|
46
|
-
const targetSlot = await this.rollup.getSlotAt(targetBigInt);
|
|
47
|
-
let effectiveTimestamp = targetBigInt;
|
|
48
|
-
let effectiveTargetSlot = targetSlot;
|
|
49
|
-
if (targetSlot <= currentSlot) {
|
|
50
|
-
// Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
|
|
51
|
-
const nextSlot = SlotNumber(currentSlot + 1);
|
|
52
|
-
const nextSlotTimestamp = await this.rollup.getTimestampForSlot(nextSlot);
|
|
53
|
-
this.logger.warn(`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} falls in current slot ${currentSlot}. ` + `Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`);
|
|
54
|
-
effectiveTimestamp = nextSlotTimestamp;
|
|
55
|
-
effectiveTargetSlot = nextSlot;
|
|
56
|
-
}
|
|
57
|
-
await this.eth.warp(effectiveTimestamp, {
|
|
58
|
-
resetBlockInterval: true
|
|
59
|
-
});
|
|
60
|
-
// The sequencer's polling loop may have a `work()` cycle in flight that captured pre-warp slot/timestamp values
|
|
61
|
-
// just before our warp landed. That cycle would mine an L2 block at the stale slot — the L1 sync prunes such a
|
|
62
|
-
// block from the canonical chain, but it lingers in local world state and the PXE will use it as the anchor for
|
|
63
|
-
// subsequent txs, leading to `expiration_timestamp` values that are already in the past relative to L1. Mine
|
|
64
|
-
// until we observe an L2 block at (or past) the post-warp slot, ensuring the next tx anchors to a fresh block.
|
|
65
|
-
const maxAttempts = 5;
|
|
66
|
-
for(let attempt = 1; attempt <= maxAttempts; attempt++){
|
|
67
|
-
await node.mineBlock();
|
|
68
|
-
const blockData = await node.getBlockData('latest');
|
|
69
|
-
const blockSlot = blockData?.header.globalVariables.slotNumber;
|
|
70
|
-
if (blockSlot !== undefined && BigInt(blockSlot) >= BigInt(effectiveTargetSlot)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.logger.warn(`warpL2TimeAtLeastTo: mined L2 block at slot ${blockSlot}, expected at least ${effectiveTargetSlot}. ` + `Retrying mineBlock (attempt ${attempt}/${maxAttempts}).`);
|
|
74
|
-
}
|
|
75
|
-
throw new Error(`warpL2TimeAtLeastTo: failed to mine an L2 block at or past slot ${effectiveTargetSlot} after ${maxAttempts} attempts.`);
|
|
18
|
+
* Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
|
|
19
|
+
* the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
|
|
20
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
21
|
+
* @param targetTimestamp - The target timestamp to warp to (in seconds).
|
|
22
|
+
* @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
|
|
23
|
+
*/ warpL2TimeAtLeastTo(node, targetTimestamp) {
|
|
24
|
+
return node.warpL2TimeAtLeastTo(Number(targetTimestamp));
|
|
76
25
|
}
|
|
77
26
|
/**
|
|
78
|
-
* Warps the L1 timestamp forward by
|
|
79
|
-
* least by the duration.
|
|
80
|
-
*
|
|
81
|
-
* @param node - The Aztec node
|
|
82
|
-
* @param duration - The duration to advance time by (in seconds)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
// Advance relative to whichever clock leads. A live sequencer mines L2 blocks at slot boundaries that can run
|
|
88
|
-
// ahead of anvil's L1 timestamp, so basing the target on L1 alone would advance the L2 timestamp by less than
|
|
89
|
-
// `duration`. Anchoring to the latest L2 block timestamp when it leads guarantees the post-warp L2 block is at
|
|
90
|
-
// least `duration` ahead of the current one.
|
|
91
|
-
const currentL1Timestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
92
|
-
const latestBlockData = await node.getBlockData('latest');
|
|
93
|
-
const latestL2Timestamp = latestBlockData ? BigInt(latestBlockData.header.globalVariables.timestamp) : 0n;
|
|
94
|
-
const baseTimestamp = latestL2Timestamp > currentL1Timestamp ? latestL2Timestamp : currentL1Timestamp;
|
|
95
|
-
const targetTimestamp = baseTimestamp + BigInt(duration);
|
|
96
|
-
await this.warpL2TimeAtLeastTo(node, targetTimestamp);
|
|
27
|
+
* Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
|
|
28
|
+
* least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
|
|
29
|
+
* queue.
|
|
30
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
31
|
+
* @param duration - The duration to advance time by (in seconds).
|
|
32
|
+
* @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
|
|
33
|
+
*/ warpL2TimeAtLeastBy(node, duration) {
|
|
34
|
+
return node.warpL2TimeAtLeastBy(Number(duration));
|
|
97
35
|
}
|
|
98
36
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EthCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import {
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
4
|
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
5
5
|
export declare class EpochTestSettler {
|
|
@@ -16,4 +16,4 @@ export declare class EpochTestSettler {
|
|
|
16
16
|
stop(): Promise<void>;
|
|
17
17
|
handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean>;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfdGVzdF9zZXR0bGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9lcG9jaF90ZXN0X3NldHRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssYUFBYSxFQUFvQixNQUFNLHNCQUFzQixDQUFDO0FBQzVFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ25FLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUVyRSxxQkFBYSxnQkFBZ0I7SUFPekIsT0FBTyxDQUFDLGFBQWE7SUFDckIsT0FBTyxDQUFDLEdBQUc7SUFDWCxPQUFPLENBQUMsT0FBTztJQVJqQixPQUFPLENBQUMsZ0JBQWdCLENBQW1CO0lBQzNDLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBZTtJQUVwQyxZQUNFLFVBQVUsRUFBRSxhQUFhLEVBQ3pCLGFBQWEsRUFBRSxVQUFVLEVBQ2pCLGFBQWEsRUFBRSxhQUFhLEVBQzVCLEdBQUcsRUFBRSxNQUFNLEVBQ1gsT0FBTyxFQUFFO1FBQUUsaUJBQWlCLEVBQUUsTUFBTSxDQUFDO1FBQUMsY0FBYyxDQUFDLEVBQUUsTUFBTSxDQUFBO0tBQUUsRUFHeEU7SUFFSyxLQUFLLGtCQUlWO0lBRUssSUFBSSxrQkFFVDtJQUVLLHVCQUF1QixDQUFDLEtBQUssRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQWNsRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch_test_settler.d.ts","sourceRoot":"","sources":["../../src/testing/epoch_test_settler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"epoch_test_settler.d.ts","sourceRoot":"","sources":["../../src/testing/epoch_test_settler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAErE,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,OAAO;IARjB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAe;IAEpC,YACE,UAAU,EAAE,aAAa,EACzB,aAAa,EAAE,UAAU,EACjB,aAAa,EAAE,aAAa,EAC5B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,EAGxE;IAEK,KAAK,kBAIV;IAEK,IAAI,kBAET;IAEK,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAclE;CACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import {
|
|
2
|
+
import { settleEpochOutbox } from '@aztec/prover-client/test';
|
|
3
3
|
import { EpochMonitor } from '@aztec/prover-node';
|
|
4
|
-
import { computeEpochOutHash } from '@aztec/stdlib/messaging';
|
|
5
4
|
export class EpochTestSettler {
|
|
6
5
|
l2BlockSource;
|
|
7
6
|
log;
|
|
@@ -27,32 +26,12 @@ export class EpochTestSettler {
|
|
|
27
26
|
await this.epochMonitor?.stop();
|
|
28
27
|
}
|
|
29
28
|
async handleEpochReadyToProve(epoch) {
|
|
30
|
-
const
|
|
29
|
+
const lastCheckpoint = await settleEpochOutbox({
|
|
30
|
+
rollupCheatCodes: this.rollupCheatCodes,
|
|
31
|
+
l2BlockSource: this.l2BlockSource,
|
|
31
32
|
epoch,
|
|
32
|
-
|
|
33
|
+
log: this.log
|
|
33
34
|
});
|
|
34
|
-
this.log.info(`Settling epoch ${epoch} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`, {
|
|
35
|
-
blocks: blocks.map((b)=>b.toBlockInfo())
|
|
36
|
-
});
|
|
37
|
-
const messagesInEpoch = [];
|
|
38
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
39
|
-
let checkpointIndex = -1;
|
|
40
|
-
for (const block of blocks){
|
|
41
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
42
|
-
if (slotNumber !== previousSlotNumber) {
|
|
43
|
-
checkpointIndex++;
|
|
44
|
-
messagesInEpoch[checkpointIndex] = [];
|
|
45
|
-
previousSlotNumber = slotNumber;
|
|
46
|
-
}
|
|
47
|
-
messagesInEpoch[checkpointIndex].push(block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs));
|
|
48
|
-
}
|
|
49
|
-
const outHash = computeEpochOutHash(messagesInEpoch);
|
|
50
|
-
if (!outHash.isZero()) {
|
|
51
|
-
await this.rollupCheatCodes.insertOutbox(epoch, messagesInEpoch.length, outHash.toBigInt());
|
|
52
|
-
} else {
|
|
53
|
-
this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
|
|
54
|
-
}
|
|
55
|
-
const lastCheckpoint = blocks.at(-1)?.checkpointNumber;
|
|
56
35
|
if (lastCheckpoint !== undefined) {
|
|
57
36
|
await this.rollupCheatCodes.markAsProven(lastCheckpoint);
|
|
58
37
|
} else {
|