@aztec/aztec 5.0.0-rc.1 → 5.0.0-rc.2
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_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_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +9 -7
- 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 +19 -48
- package/dest/local-network/local-network.d.ts +3 -4
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +3 -3
- 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 -80
- 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 +3 -3
- package/src/bin/index.ts +2 -0
- 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_node.ts +9 -16
- package/src/cli/cmds/utils/artifacts.ts +5 -0
- package/src/cli/util.ts +20 -61
- package/src/local-network/local-network.ts +3 -3
- package/src/testing/cheat_codes.ts +19 -100
- package/src/testing/token_allowed_setup.ts +15 -8
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
} from '@aztec/aztec-node';
|
|
7
7
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
8
8
|
import { getL1Config } from '@aztec/cli/config';
|
|
9
|
-
import { getPublicClient } from '@aztec/ethereum/client';
|
|
10
9
|
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
11
10
|
import { type NetworkNames, SecretValue } from '@aztec/foundation/config';
|
|
12
11
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
@@ -30,14 +29,9 @@ import {
|
|
|
30
29
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
31
30
|
|
|
32
31
|
import { createAztecNode } from '../../local-network/index.js';
|
|
33
|
-
import {
|
|
34
|
-
extractNamespacedOptions,
|
|
35
|
-
extractRelevantOptions,
|
|
36
|
-
preloadCrsDataForVerifying,
|
|
37
|
-
setupVersionChecker,
|
|
38
|
-
} from '../util.js';
|
|
32
|
+
import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying } from '../util.js';
|
|
39
33
|
import { getVersions } from '../versioning.js';
|
|
40
|
-
import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
|
|
34
|
+
import { computeExpectedGenesisRoot, setupAutoShutdown, waitForCompatibleRollup } from './standby.js';
|
|
41
35
|
import { startProverBroker } from './start_prover_broker.js';
|
|
42
36
|
|
|
43
37
|
export async function startNode(
|
|
@@ -165,7 +159,7 @@ export async function startNode(
|
|
|
165
159
|
// Register prover-node services if the prover node subsystem is running
|
|
166
160
|
const proverNode = node.getProverNode();
|
|
167
161
|
if (proverNode) {
|
|
168
|
-
|
|
162
|
+
adminServices.prover = [proverNode, ProverNodeApiSchema];
|
|
169
163
|
if (!nodeConfig.proverBrokerUrl) {
|
|
170
164
|
services.provingJobSource = [proverNode.getProver().getProvingJobSource(), ProvingJobConsumerSchema];
|
|
171
165
|
}
|
|
@@ -184,15 +178,14 @@ export async function startNode(
|
|
|
184
178
|
await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
|
|
185
179
|
}
|
|
186
180
|
|
|
187
|
-
if (nodeConfig.
|
|
188
|
-
const cacheDir = process.env.DATA_DIRECTORY ? `${process.env.DATA_DIRECTORY}/cache` : undefined;
|
|
181
|
+
if (nodeConfig.enableAutoShutdown && networkName !== 'local' && followsCanonicalRollup) {
|
|
189
182
|
try {
|
|
190
|
-
await
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
183
|
+
await setupAutoShutdown(
|
|
184
|
+
nodeConfig,
|
|
185
|
+
nodeConfig.registryAddress,
|
|
186
|
+
(nodeConfig.rollupVersion as number | 'canonical') ?? 'canonical',
|
|
187
|
+
{ genesisArchiveRoot, vkTreeRoot: getVKTreeRoot(), protocolContractsHash },
|
|
194
188
|
signalHandlers,
|
|
195
|
-
cacheDir,
|
|
196
189
|
);
|
|
197
190
|
} catch {
|
|
198
191
|
/* no-op */
|
|
@@ -6,6 +6,11 @@ export interface CompiledArtifact {
|
|
|
6
6
|
file_map: unknown;
|
|
7
7
|
functions: ContractFunction[];
|
|
8
8
|
bytecode?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Set to true by the AVM transpiler (invoked via `bb aztec_process`) once the contract has been transpiled and its
|
|
11
|
+
* verification keys generated. Absent on raw `nargo compile` output, hence optional.
|
|
12
|
+
*/
|
|
13
|
+
transpiled?: boolean;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export interface ContractFunction {
|
package/src/cli/util.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import type { AztecNodeConfig } from '@aztec/aztec-node';
|
|
2
2
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
3
|
-
import {
|
|
4
|
-
import { RegistryContract } from '@aztec/ethereum/contracts';
|
|
5
|
-
import type { ViemClient } from '@aztec/ethereum/types';
|
|
6
|
-
import type { ConfigMappingsType, NetworkNames } from '@aztec/foundation/config';
|
|
3
|
+
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
7
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
8
|
-
import {
|
|
5
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
9
6
|
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import { type VersionCheck, getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
11
7
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
12
8
|
|
|
13
9
|
import chalk from 'chalk';
|
|
14
10
|
import type { Command } from 'commander';
|
|
15
|
-
import type { Hex } from 'viem';
|
|
16
11
|
|
|
17
12
|
import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
|
|
18
13
|
|
|
@@ -51,6 +46,24 @@ export function isShuttingDown(): boolean {
|
|
|
51
46
|
return shutdownPromise !== undefined;
|
|
52
47
|
}
|
|
53
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Stops the node's subsystems (via the registered signal handlers) without exiting the process, leaving
|
|
51
|
+
* the HTTP health server listening so K8s liveness/readiness probes keep passing. Unlike {@link shutdown}
|
|
52
|
+
* this deliberately does not latch `shutdownPromise` or call `process.exit`; instead it re-arms
|
|
53
|
+
* SIGTERM/SIGINT so a later K8s pod deletion still terminates the wound-down pod with a clean exit.
|
|
54
|
+
*/
|
|
55
|
+
export async function softShutdown(logFn: LogFn, signalHandlers: Array<() => Promise<void>>): Promise<void> {
|
|
56
|
+
logFn('Canonical rollup upgrade detected: stopping subsystems, health server stays up.', {
|
|
57
|
+
exitCode: ExitCode.ROLLUP_UPGRADE,
|
|
58
|
+
});
|
|
59
|
+
await Promise.allSettled(signalHandlers.map(fn => fn()));
|
|
60
|
+
for (const sig of ['SIGTERM', 'SIGINT'] as const) {
|
|
61
|
+
process.removeAllListeners(sig);
|
|
62
|
+
process.once(sig, () => process.exit(ExitCode.ROLLUP_UPGRADE));
|
|
63
|
+
}
|
|
64
|
+
logFn('Subsystems stopped due to rollup upgrade. Health server remains active.');
|
|
65
|
+
}
|
|
66
|
+
|
|
54
67
|
export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<void>>) => {
|
|
55
68
|
const signals = [
|
|
56
69
|
['SIGINT', ExitCode.SIGINT],
|
|
@@ -291,60 +304,6 @@ export async function preloadCrsDataForServerSideProving(
|
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
306
|
|
|
294
|
-
export async function setupVersionChecker(
|
|
295
|
-
network: NetworkNames,
|
|
296
|
-
followsCanonicalRollup: boolean,
|
|
297
|
-
publicClient: ViemClient,
|
|
298
|
-
signalHandlers: Array<() => Promise<void>>,
|
|
299
|
-
cacheDir?: string,
|
|
300
|
-
): Promise<void> {
|
|
301
|
-
const networkConfig = await getNetworkConfig(network, cacheDir);
|
|
302
|
-
if (!networkConfig) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const { VersionChecker } = await import('@aztec/stdlib/update-checker');
|
|
307
|
-
|
|
308
|
-
const logger = createLogger('version_check');
|
|
309
|
-
const registry = new RegistryContract(publicClient, networkConfig.registryAddress as Hex);
|
|
310
|
-
|
|
311
|
-
const checks: Array<VersionCheck> = [];
|
|
312
|
-
checks.push({
|
|
313
|
-
name: 'node',
|
|
314
|
-
currentVersion: getPackageVersion(),
|
|
315
|
-
getLatestVersion: async () => {
|
|
316
|
-
const cfg = await getNetworkConfig(network, cacheDir);
|
|
317
|
-
return cfg?.nodeVersion;
|
|
318
|
-
},
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
if (followsCanonicalRollup) {
|
|
322
|
-
const getLatestVersion = async () => {
|
|
323
|
-
const version = (await registry.getRollupVersions()).at(-1);
|
|
324
|
-
return version !== undefined ? String(version) : undefined;
|
|
325
|
-
};
|
|
326
|
-
const currentVersion = await getLatestVersion();
|
|
327
|
-
if (currentVersion !== undefined) {
|
|
328
|
-
checks.push({
|
|
329
|
-
name: 'rollup',
|
|
330
|
-
currentVersion,
|
|
331
|
-
getLatestVersion,
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const checker = new VersionChecker(checks, 600_000, logger);
|
|
337
|
-
checker.on('newVersion', ({ name, latestVersion, currentVersion }) => {
|
|
338
|
-
if (isShuttingDown()) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
|
|
343
|
-
});
|
|
344
|
-
checker.start();
|
|
345
|
-
signalHandlers.push(() => checker.stop());
|
|
346
|
-
}
|
|
347
|
-
|
|
348
307
|
export function stringifyConfig(config: object): string {
|
|
349
308
|
return Object.entries(config)
|
|
350
309
|
.map(([key, value]) => `${key}=${jsonStringify(value)}`)
|
|
@@ -1,6 +1,6 @@
|
|
|
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 { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
|
|
5
5
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
6
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
@@ -166,7 +166,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
166
166
|
|
|
167
167
|
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
168
168
|
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
169
|
-
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.
|
|
169
|
+
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
|
|
170
170
|
const fundedAddresses = [
|
|
171
171
|
...initialAccounts.map(a => a.address),
|
|
172
172
|
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
@@ -237,7 +237,7 @@ export async function createAztecNode(
|
|
|
237
237
|
...getConfigEnvVars(),
|
|
238
238
|
...config,
|
|
239
239
|
};
|
|
240
|
-
const node = await
|
|
240
|
+
const node = await createAztecNodeService(
|
|
241
241
|
aztecNodeConfig,
|
|
242
242
|
{ ...deps, proverNodeDeps: { broker: deps.proverBroker } },
|
|
243
243
|
options,
|
|
@@ -1,129 +1,48 @@
|
|
|
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
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type { AutomineSequencer } from '@aztec/sequencer-client/automine';
|
|
6
3
|
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @deprecated
|
|
11
|
-
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
12
|
-
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
6
|
+
* Wrapper for Aztec Debug API.
|
|
7
|
+
* @deprecated use the AztecNode debug API directly.
|
|
13
8
|
*/
|
|
14
9
|
export class CheatCodes {
|
|
15
|
-
private logger = createLogger('aztecjs:cheat_codes');
|
|
16
|
-
|
|
17
10
|
constructor(
|
|
18
11
|
/** Cheat codes for L1.*/
|
|
19
12
|
public eth: EthCheatCodes,
|
|
20
13
|
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
21
14
|
public rollup: RollupCheatCodes,
|
|
22
|
-
/** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
|
|
23
|
-
private automine?: AutomineSequencer,
|
|
24
15
|
) {}
|
|
25
16
|
|
|
26
|
-
static async create(
|
|
27
|
-
rpcUrls: string[],
|
|
28
|
-
node: AztecNode,
|
|
29
|
-
dateProvider: DateProvider,
|
|
30
|
-
automine?: AutomineSequencer,
|
|
31
|
-
): Promise<CheatCodes> {
|
|
17
|
+
static async create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes> {
|
|
32
18
|
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
33
19
|
const rollupCheatCodes = new RollupCheatCodes(
|
|
34
20
|
ethCheatCodes,
|
|
35
21
|
await node.getNodeInfo().then(n => n.l1ContractAddresses),
|
|
36
22
|
);
|
|
37
|
-
return new CheatCodes(ethCheatCodes, rollupCheatCodes
|
|
23
|
+
return new CheatCodes(ethCheatCodes, rollupCheatCodes);
|
|
38
24
|
}
|
|
39
25
|
|
|
40
26
|
/**
|
|
41
|
-
* Warps the L1 timestamp to
|
|
42
|
-
* the target
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @
|
|
27
|
+
* Warps the L1 timestamp to at least `targetTimestamp` and mines an L2 block advancing the L2 timestamp to at least
|
|
28
|
+
* the target. Forwards to the node's debug API, which serializes the warp through the automine sequencer queue.
|
|
29
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
30
|
+
* @param targetTimestamp - The target timestamp to warp to (in seconds).
|
|
31
|
+
* @deprecated Call `node.warpL2TimeAtLeastTo(targetTimestamp)` on the node debug API directly.
|
|
46
32
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
50
|
-
|
|
51
|
-
if (targetBigInt <= currentTimestamp) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// AutomineSequencer owns time control through its serial queue — delegate to keep warps atomic
|
|
58
|
-
// with respect to any in-flight build, and avoid the mineBlock-loop hack below.
|
|
59
|
-
// `warpTo` internally builds an empty L2 checkpoint, which auto-mines exactly one L1 block at
|
|
60
|
-
// the target slot boundary, so no separate `node.mineBlock()` is needed here.
|
|
61
|
-
if (this.automine) {
|
|
62
|
-
await this.automine.warpTo(Number(targetBigInt));
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const currentSlot = await this.rollup.getSlot();
|
|
67
|
-
let effectiveTargetSlot = await this.rollup.getSlotAt(targetBigInt);
|
|
68
|
-
let effectiveTimestamp = await this.rollup.getTimestampForSlot(effectiveTargetSlot);
|
|
69
|
-
|
|
70
|
-
if (effectiveTimestamp < targetBigInt || effectiveTargetSlot <= currentSlot) {
|
|
71
|
-
const adjustedSlot = SlotNumber(Math.max(effectiveTargetSlot + 1, currentSlot + 1));
|
|
72
|
-
const adjustedTimestamp = await this.rollup.getTimestampForSlot(adjustedSlot);
|
|
73
|
-
this.logger.warn(
|
|
74
|
-
`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} does not align with a future L2 slot boundary. ` +
|
|
75
|
-
`Auto-adjusting to start of slot ${adjustedSlot} at timestamp ${adjustedTimestamp}.`,
|
|
76
|
-
);
|
|
77
|
-
effectiveTimestamp = adjustedTimestamp;
|
|
78
|
-
effectiveTargetSlot = adjustedSlot;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
await this.eth.warp(effectiveTimestamp, { resetBlockInterval: true });
|
|
82
|
-
|
|
83
|
-
// The sequencer's polling loop may have a `work()` cycle in flight that captured pre-warp slot/timestamp values
|
|
84
|
-
// just before our warp landed. That cycle would mine an L2 block at the stale slot — the L1 sync prunes such a
|
|
85
|
-
// block from the canonical chain, but it lingers in local world state and the PXE will use it as the anchor for
|
|
86
|
-
// subsequent txs, leading to `expiration_timestamp` values that are already in the past relative to L1. Mine
|
|
87
|
-
// until we observe an L2 block at (or past) the post-warp slot, ensuring the next tx anchors to a fresh block.
|
|
88
|
-
const maxAttempts = 5;
|
|
89
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
90
|
-
await node.mineBlock();
|
|
91
|
-
const blockData = await node.getBlockData('latest');
|
|
92
|
-
const blockSlot = blockData?.header.globalVariables.slotNumber;
|
|
93
|
-
if (blockSlot !== undefined && BigInt(blockSlot) >= BigInt(effectiveTargetSlot)) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this.logger.warn(
|
|
97
|
-
`warpL2TimeAtLeastTo: mined L2 block at slot ${blockSlot}, expected at least ${effectiveTargetSlot}. ` +
|
|
98
|
-
`Retrying mineBlock (attempt ${attempt}/${maxAttempts}).`,
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
throw new Error(
|
|
102
|
-
`warpL2TimeAtLeastTo: failed to mine an L2 block at or past slot ${effectiveTargetSlot} after ${maxAttempts} attempts.`,
|
|
103
|
-
);
|
|
33
|
+
warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void> {
|
|
34
|
+
return node.warpL2TimeAtLeastTo(Number(targetTimestamp));
|
|
104
35
|
}
|
|
105
36
|
|
|
106
37
|
/**
|
|
107
|
-
* Warps the L1 timestamp forward by
|
|
108
|
-
* least by the duration.
|
|
109
|
-
*
|
|
110
|
-
* @param node - The Aztec node
|
|
111
|
-
* @param duration - The duration to advance time by (in seconds)
|
|
38
|
+
* Warps the L1 timestamp forward by at least `duration` seconds and mines an L2 block advancing the L2 timestamp at
|
|
39
|
+
* least by the duration. Forwards to the node's debug API, which serializes the warp through the automine sequencer
|
|
40
|
+
* queue.
|
|
41
|
+
* @param node - The Aztec node whose debug API performs the warp. Must run an automine sequencer.
|
|
42
|
+
* @param duration - The duration to advance time by (in seconds).
|
|
43
|
+
* @deprecated Call `node.warpL2TimeAtLeastBy(duration)` on the node debug API directly.
|
|
112
44
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Advance relative to whichever clock leads. A live sequencer mines L2 blocks at slot boundaries that can run
|
|
119
|
-
// ahead of anvil's L1 timestamp, so basing the target on L1 alone would advance the L2 timestamp by less than
|
|
120
|
-
// `duration`. Anchoring to the latest L2 block timestamp when it leads guarantees the post-warp L2 block is at
|
|
121
|
-
// least `duration` ahead of the current one.
|
|
122
|
-
const currentL1Timestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
123
|
-
const latestBlockData = await node.getBlockData('latest');
|
|
124
|
-
const latestL2Timestamp = latestBlockData ? BigInt(latestBlockData.header.globalVariables.timestamp) : 0n;
|
|
125
|
-
const baseTimestamp = latestL2Timestamp > currentL1Timestamp ? latestL2Timestamp : currentL1Timestamp;
|
|
126
|
-
const targetTimestamp = baseTimestamp + BigInt(duration);
|
|
127
|
-
await this.warpL2TimeAtLeastTo(node, targetTimestamp);
|
|
45
|
+
warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void> {
|
|
46
|
+
return node.warpL2TimeAtLeastBy(Number(duration));
|
|
128
47
|
}
|
|
129
48
|
}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
2
2
|
import { buildAllowedElement } from '@aztec/p2p/msg_validators';
|
|
3
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
3
4
|
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
4
5
|
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* Returns
|
|
8
|
-
*
|
|
8
|
+
* Returns the allowlist entries needed for FPC-based fee payments, keyed by the contract class of
|
|
9
|
+
* the `artifact` actually deployed as the fee token (defaults to canonical Token). The setup-phase
|
|
10
|
+
* validator matches these entries by class id, so a test deploying the codegen'd TestToken as its
|
|
11
|
+
* fee vehicle must pass `TestTokenContract.artifact` here -- otherwise the FPC fee calls are matched
|
|
12
|
+
* against the wrong class and rejected. Test-only: FPC fee payment with custom tokens won't work on
|
|
13
|
+
* mainnet alpha.
|
|
9
14
|
*/
|
|
10
|
-
export async function getTokenAllowedSetupFunctions(
|
|
11
|
-
|
|
15
|
+
export async function getTokenAllowedSetupFunctions(
|
|
16
|
+
artifact: ContractArtifact = TokenContractArtifact,
|
|
17
|
+
): Promise<AllowedElement[]> {
|
|
18
|
+
const tokenClassId = (await getContractClassFromArtifact(artifact)).id;
|
|
12
19
|
const target = { classId: tokenClassId };
|
|
13
20
|
return Promise.all([
|
|
14
|
-
//
|
|
15
|
-
buildAllowedElement(
|
|
16
|
-
//
|
|
17
|
-
buildAllowedElement(
|
|
21
|
+
// needed for private transfers via FPC (transfer_to_public enqueues this)
|
|
22
|
+
buildAllowedElement(artifact, target, '_increase_public_balance', { onlySelf: true }),
|
|
23
|
+
// needed for public transfers via FPC (fee_entrypoint_public enqueues this)
|
|
24
|
+
buildAllowedElement(artifact, target, 'transfer_in_public'),
|
|
18
25
|
]);
|
|
19
26
|
}
|