@aztec/aztec 4.0.4-rc.9 → 4.1.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/cli/cmds/standby.d.ts +27 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +78 -0
- 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 +5 -67
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +5 -0
- package/dest/examples/token.js +4 -4
- package/dest/local-network/banana_fpc.js +1 -1
- package/dest/local-network/local-network.d.ts +1 -1
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +37 -1
- package/package.json +34 -34
- package/src/cli/cmds/standby.ts +111 -0
- package/src/cli/cmds/start_node.ts +5 -96
- package/src/cli/cmds/start_prover_broker.ts +6 -0
- package/src/examples/token.ts +6 -4
- package/src/local-network/banana_fpc.ts +1 -1
- package/src/local-network/local-network.ts +42 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
+
import type { GenesisStateConfig } from '@aztec/ethereum/config';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
5
|
+
/**
|
|
6
|
+
* Computes the expected genesis archive root from the genesis state config.
|
|
7
|
+
* Reads test accounts and sponsored FPC addresses as specified, then computes
|
|
8
|
+
* the genesis values including the archive root and prefilled public data.
|
|
9
|
+
*/
|
|
10
|
+
export declare function computeExpectedGenesisRoot(config: GenesisStateConfig, userLog: LogFn): Promise<{
|
|
11
|
+
genesisArchiveRoot: Fr;
|
|
12
|
+
prefilledPublicData: import("@aztec/stdlib/trees").PublicDataTreeLeaf[];
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
16
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
17
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s until a compatible rollup appears.
|
|
18
|
+
*/
|
|
19
|
+
export declare function waitForCompatibleRollup(config: {
|
|
20
|
+
l1RpcUrls: string[];
|
|
21
|
+
l1ChainId: number;
|
|
22
|
+
l1Contracts: {
|
|
23
|
+
registryAddress: EthAddress;
|
|
24
|
+
};
|
|
25
|
+
rollupVersion?: number;
|
|
26
|
+
}, expectedGenesisRoot: Fr, port: number | undefined, userLog: LogFn): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhbmRieS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YW5kYnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVqRSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUVoRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVNuRDs7OztHQUlHO0FBQ0gsd0JBQXNCLDBCQUEwQixDQUFDLE1BQU0sRUFBRSxrQkFBa0IsRUFBRSxPQUFPLEVBQUUsS0FBSzs7O0dBYTFGO0FBRUQ7Ozs7R0FJRztBQUNILHdCQUFzQix1QkFBdUIsQ0FDM0MsTUFBTSxFQUFFO0lBQ04sU0FBUyxFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQ3BCLFNBQVMsRUFBRSxNQUFNLENBQUM7SUFDbEIsV0FBVyxFQUFFO1FBQUUsZUFBZSxFQUFFLFVBQVUsQ0FBQTtLQUFFLENBQUM7SUFDN0MsYUFBYSxDQUFDLEVBQUUsTUFBTSxDQUFDO0NBQ3hCLEVBQ0QsbUJBQW1CLEVBQUUsRUFBRSxFQUN2QixJQUFJLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDeEIsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUMsSUFBSSxDQUFDLENBMERmIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standby.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/standby.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK;;;GAa1F;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QAAE,eAAe,EAAE,UAAU,CAAA;KAAE,CAAC;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,EACD,mBAAmB,EAAE,EAAE,EACvB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,KAAK,GACb,OAAO,CAAC,IAAI,CAAC,CA0Df"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
3
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
4
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
6
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
7
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
9
|
+
import Koa from 'koa';
|
|
10
|
+
const ROLLUP_POLL_INTERVAL_S = 60;
|
|
11
|
+
/**
|
|
12
|
+
* Computes the expected genesis archive root from the genesis state config.
|
|
13
|
+
* Reads test accounts and sponsored FPC addresses as specified, then computes
|
|
14
|
+
* the genesis values including the archive root and prefilled public data.
|
|
15
|
+
*/ export async function computeExpectedGenesisRoot(config, userLog) {
|
|
16
|
+
const testAccounts = config.testAccounts ? (await getInitialTestAccountsData()).map((a)=>a.address) : [];
|
|
17
|
+
const sponsoredFPCAccounts = config.sponsoredFPC ? [
|
|
18
|
+
await getSponsoredFPCAddress()
|
|
19
|
+
] : [];
|
|
20
|
+
const prefundAddresses = (config.prefundAddresses ?? []).map((a)=>AztecAddress.fromString(a));
|
|
21
|
+
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
|
|
22
|
+
userLog(`Initial funded accounts: ${initialFundedAccounts.map((a)=>a.toString()).join(', ')}`);
|
|
23
|
+
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
24
|
+
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
25
|
+
return {
|
|
26
|
+
genesisArchiveRoot,
|
|
27
|
+
prefilledPublicData
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
32
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
33
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s until a compatible rollup appears.
|
|
34
|
+
*/ export async function waitForCompatibleRollup(config, expectedGenesisRoot, port, userLog) {
|
|
35
|
+
const publicClient = getPublicClient(config);
|
|
36
|
+
const rollupVersion = config.rollupVersion ?? 'canonical';
|
|
37
|
+
const registry = new RegistryContract(publicClient, config.l1Contracts.registryAddress);
|
|
38
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
39
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
40
|
+
let l1GenesisRoot;
|
|
41
|
+
try {
|
|
42
|
+
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
43
|
+
} catch (err) {
|
|
44
|
+
throw new Error(`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`);
|
|
45
|
+
}
|
|
46
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
userLog(`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` + `Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_S}s for a compatible rollup...`);
|
|
50
|
+
const standbyServer = await startHttpRpcServer({
|
|
51
|
+
getApp: ()=>new Koa(),
|
|
52
|
+
isHealthy: ()=>true
|
|
53
|
+
}, {
|
|
54
|
+
port
|
|
55
|
+
});
|
|
56
|
+
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
57
|
+
try {
|
|
58
|
+
await retryUntil(async ()=>{
|
|
59
|
+
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
60
|
+
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
61
|
+
let currentGenesisRoot;
|
|
62
|
+
try {
|
|
63
|
+
currentGenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
64
|
+
} catch {
|
|
65
|
+
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (currentGenesisRoot.equals(expectedGenesisRoot)) {
|
|
69
|
+
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${currentGenesisRoot}.`);
|
|
73
|
+
return undefined;
|
|
74
|
+
}, 'compatible rollup', 0, ROLLUP_POLL_INTERVAL_S);
|
|
75
|
+
} finally{
|
|
76
|
+
await new Promise((resolve, reject)=>standbyServer.close((err)=>err ? reject(err) : resolve()));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -5,4 +5,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
5
5
|
export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn, networkName: NetworkNames): Promise<{
|
|
6
6
|
config: AztecNodeConfig;
|
|
7
7
|
}>;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBS3BHLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBZSxNQUFNLDBCQUEwQixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUF3Qm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssRUFDZCxXQUFXLEVBQUUsWUFBWSxHQUN4QixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQStKdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAKpG,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAwBnD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,KAAK,EACd,WAAW,EAAE,YAAY,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CA+JtC"}
|
|
@@ -1,74 +1,21 @@
|
|
|
1
|
-
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
1
|
import { aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
2
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
5
3
|
import { getL1Config } from '@aztec/cli/config';
|
|
6
4
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
7
|
-
import {
|
|
5
|
+
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
8
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
9
|
-
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
10
7
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
11
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
12
8
|
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
13
9
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
14
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
10
|
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
16
11
|
import { P2PApiSchema, ProverNodeApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
17
12
|
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
18
13
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
19
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
20
|
-
import Koa from 'koa';
|
|
21
14
|
import { createAztecNode } from '../../local-network/index.js';
|
|
22
15
|
import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying, setupVersionChecker } from '../util.js';
|
|
23
16
|
import { getVersions } from '../versioning.js';
|
|
17
|
+
import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
|
|
24
18
|
import { startProverBroker } from './start_prover_broker.js';
|
|
25
|
-
const ROLLUP_POLL_INTERVAL_MS = 600_000;
|
|
26
|
-
/**
|
|
27
|
-
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
28
|
-
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
29
|
-
* starts a lightweight HTTP server for K8s liveness probes and polls until a compatible rollup appears.
|
|
30
|
-
*/ async function waitForCompatibleRollup(publicClient, registryAddress, rollupVersion, expectedGenesisRoot, port, userLog) {
|
|
31
|
-
const registry = new RegistryContract(publicClient, registryAddress);
|
|
32
|
-
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
33
|
-
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
34
|
-
let l1GenesisRoot;
|
|
35
|
-
try {
|
|
36
|
-
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
37
|
-
} catch (err) {
|
|
38
|
-
throw new Error(`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`);
|
|
39
|
-
}
|
|
40
|
-
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
userLog(`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` + `Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_MS / 1000}s for a compatible rollup...`);
|
|
44
|
-
const standbyServer = await startHttpRpcServer({
|
|
45
|
-
getApp: ()=>new Koa(),
|
|
46
|
-
isHealthy: ()=>true
|
|
47
|
-
}, {
|
|
48
|
-
port
|
|
49
|
-
});
|
|
50
|
-
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
51
|
-
try {
|
|
52
|
-
while(true){
|
|
53
|
-
await sleep(ROLLUP_POLL_INTERVAL_MS);
|
|
54
|
-
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
55
|
-
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
56
|
-
try {
|
|
57
|
-
l1GenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
58
|
-
} catch {
|
|
59
|
-
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
63
|
-
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${l1GenesisRoot}.`);
|
|
67
|
-
}
|
|
68
|
-
} finally{
|
|
69
|
-
await new Promise((resolve, reject)=>standbyServer.close((err)=>err ? reject(err) : resolve()));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
19
|
export async function startNode(options, signalHandlers, services, adminServices, userLog, networkName) {
|
|
73
20
|
// All options set from environment variables
|
|
74
21
|
const configFromEnvVars = getConfigEnvVars();
|
|
@@ -115,24 +62,15 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
115
62
|
}
|
|
116
63
|
}
|
|
117
64
|
await preloadCrsDataForVerifying(nodeConfig, userLog);
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
await getSponsoredFPCAddress()
|
|
121
|
-
] : [];
|
|
122
|
-
const prefundAddresses = (nodeConfig.prefundAddresses ?? []).map((a)=>AztecAddress.fromString(a));
|
|
123
|
-
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
|
|
124
|
-
userLog(`Initial funded accounts: ${initialFundedAccounts.map((a)=>a.toString()).join(', ')}`);
|
|
125
|
-
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
126
|
-
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
65
|
+
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
66
|
+
const { genesisArchiveRoot, prefilledPublicData } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
127
67
|
const followsCanonicalRollup = typeof nodeConfig.rollupVersion !== 'number' || nodeConfig.rollupVersion === 'canonical';
|
|
128
68
|
if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
|
|
129
69
|
throw new Error('L1 registry address is required to start Aztec Node');
|
|
130
70
|
}
|
|
131
71
|
// Wait for a compatible rollup before proceeding with full L1 config fetch.
|
|
132
72
|
// This prevents crashes when the canonical rollup hasn't been upgraded yet.
|
|
133
|
-
|
|
134
|
-
const rollupVersion = nodeConfig.rollupVersion ?? 'canonical';
|
|
135
|
-
await waitForCompatibleRollup(publicClient, nodeConfig.l1Contracts.registryAddress, rollupVersion, genesisArchiveRoot, options.port, userLog);
|
|
73
|
+
await waitForCompatibleRollup(nodeConfig, genesisArchiveRoot, options.port, userLog);
|
|
136
74
|
const { addresses, config } = await getL1Config(nodeConfig.l1Contracts.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, nodeConfig.rollupVersion);
|
|
137
75
|
process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
|
|
138
76
|
if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
|
|
@@ -6,4 +6,4 @@ export declare function startProverBroker(options: any, signalHandlers: (() => P
|
|
|
6
6
|
broker: ProvingJobBroker;
|
|
7
7
|
config: ProverBrokerConfig;
|
|
8
8
|
}>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2Jyb2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X3Byb3Zlcl9icm9rZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSw2QkFBNkIsQ0FBQztBQUVyQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBTXhFLHdCQUFzQixpQkFBaUIsQ0FDckMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZ0JBQWdCLENBQUM7SUFBQyxNQUFNLEVBQUUsa0JBQWtCLENBQUE7Q0FBRSxDQUFDLENBdUNuRSJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_prover_broker.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_broker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start_prover_broker.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_broker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMxE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAuCnE"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { getL1Config } from '@aztec/cli/config';
|
|
2
|
+
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
2
3
|
import { ProvingJobBrokerSchema, ProvingJobBrokerSchemaWithDebug, createAndStartProvingBroker, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
|
|
3
4
|
import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node';
|
|
4
5
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
5
6
|
import { extractRelevantOptions } from '../util.js';
|
|
7
|
+
import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
|
|
6
8
|
export async function startProverBroker(options, signalHandlers, services, userLog) {
|
|
7
9
|
if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
|
|
8
10
|
userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
|
|
@@ -15,6 +17,9 @@ export async function startProverBroker(options, signalHandlers, services, userL
|
|
|
15
17
|
if (!config.l1Contracts.registryAddress || config.l1Contracts.registryAddress.isZero()) {
|
|
16
18
|
throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
|
|
17
19
|
}
|
|
20
|
+
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
21
|
+
const { genesisArchiveRoot } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
22
|
+
await waitForCompatibleRollup(config, genesisArchiveRoot, options.port, userLog);
|
|
18
23
|
const { addresses, config: rollupConfig } = await getL1Config(config.l1Contracts.registryAddress, config.l1RpcUrls, config.l1ChainId, config.rollupVersion);
|
|
19
24
|
config.l1Contracts = addresses;
|
|
20
25
|
config.rollupVersion = rollupConfig.rollupVersion;
|
package/dest/examples/token.js
CHANGED
|
@@ -21,7 +21,7 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
21
21
|
const bob = bobInitialAccountData.address;
|
|
22
22
|
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
23
23
|
logger.info('Deploying Token...');
|
|
24
|
-
const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
24
|
+
const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
25
25
|
from: alice
|
|
26
26
|
});
|
|
27
27
|
logger.info('Token deployed');
|
|
@@ -31,7 +31,7 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
31
31
|
from: alice
|
|
32
32
|
});
|
|
33
33
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
34
|
-
const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({
|
|
34
|
+
const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({
|
|
35
35
|
from: alice
|
|
36
36
|
});
|
|
37
37
|
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
@@ -41,11 +41,11 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
41
41
|
from: alice
|
|
42
42
|
});
|
|
43
43
|
// Check the new balances
|
|
44
|
-
const aliceBalance = await token.methods.balance_of_private(alice).simulate({
|
|
44
|
+
const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({
|
|
45
45
|
from: alice
|
|
46
46
|
});
|
|
47
47
|
logger.info(`Alice's balance ${aliceBalance}`);
|
|
48
|
-
const bobBalance = await token.methods.balance_of_private(bob).simulate({
|
|
48
|
+
const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({
|
|
49
49
|
from: bob
|
|
50
50
|
});
|
|
51
51
|
logger.info(`Bob's balance ${bobBalance}`);
|
|
@@ -46,7 +46,7 @@ export async function getBananaFPCAddress(initialAccounts) {
|
|
|
46
46
|
export async function setupBananaFPC(initialAccounts, wallet, log) {
|
|
47
47
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
48
48
|
const admin = getBananaAdmin(initialAccounts);
|
|
49
|
-
const [bananaCoin, fpc] = await Promise.all([
|
|
49
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
50
50
|
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
|
|
51
51
|
from: admin,
|
|
52
52
|
contractAddressSalt: BANANA_COIN_SALT,
|
|
@@ -70,4 +70,4 @@ export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?
|
|
|
70
70
|
}, options?: {
|
|
71
71
|
prefilledPublicData?: PublicDataTreeLeaf[];
|
|
72
72
|
}): Promise<AztecNodeService>;
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbmV0d29yay5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvY2FsLW5ldHdvcmsvbG9jYWwtbmV0d29yay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDckQsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFvQixNQUFNLDBCQUEwQixDQUFDO0FBQ2xGLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUU1QyxPQUFPLEVBQUUsS0FBSyxtQkFBbUIsRUFBb0IsTUFBTSwyQkFBMkIsQ0FBQztBQVN2RixPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxFQUFFLFlBQVksRUFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQVN6RSxPQUFPLEtBQUssRUFBa0IsZ0JBQWdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUN4RixPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQzlELE9BQU8sRUFDTCxLQUFLLGVBQWUsRUFHckIsTUFBTSx5QkFBeUIsQ0FBQztBQUtqQyxPQUFPLEVBQUUsS0FBSyxHQUFHLEVBQTJELE1BQU0sTUFBTSxDQUFDO0FBK0N6Rjs7OztHQUlHO0FBQ0gsd0JBQXNCLG1CQUFtQixDQUN2QyxlQUFlLEVBQUUsZUFBZSxFQUNoQyxVQUFVLEVBQUUsR0FBRyxFQUNmLElBQUksR0FBRTtJQUNKLGtCQUFrQixDQUFDLEVBQUUsRUFBRSxDQUFDO0lBQ3hCLDRCQUE0QixDQUFDLEVBQUUsTUFBTSxDQUFDO0NBQ2xDOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQW9CUDtBQUVELDhCQUE4QjtBQUM5QixNQUFNLE1BQU0sa0JBQWtCLEdBQUcsZUFBZSxHQUFHO0lBQ2pELDBEQUEwRDtJQUMxRCxVQUFVLEVBQUUsTUFBTSxDQUFDO0lBQ25CLDZEQUE2RDtJQUM3RCxZQUFZLEVBQUUsT0FBTyxDQUFDO0NBQ3ZCLENBQUM7QUFFRjs7OztHQUlHO0FBQ0gsd0JBQXNCLGtCQUFrQixDQUFDLE1BQU0seUNBQWtDLEVBQUUsT0FBTyxFQUFFLEtBQUs7OztHQXdKaEc7QUFFRDs7O0dBR0c7QUFDSCx3QkFBc0IsZUFBZSxDQUNuQyxNQUFNLEdBQUUsT0FBTyxDQUFDLGVBQWUsQ0FBTSxFQUNyQyxJQUFJLEdBQUU7SUFDSixTQUFTLENBQUMsRUFBRSxlQUFlLENBQUM7SUFDNUIsVUFBVSxDQUFDLEVBQUUsbUJBQW1CLENBQUM7SUFDakMsWUFBWSxDQUFDLEVBQUUsWUFBWSxDQUFDO0lBQzVCLFlBQVksQ0FBQyxFQUFFLGdCQUFnQixDQUFDO0NBQzVCLEVBQ04sT0FBTyxHQUFFO0lBQUUsbUJBQW1CLENBQUMsRUFBRSxrQkFBa0IsRUFBRSxDQUFBO0NBQU8sNkJBZTdEIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-network.d.ts","sourceRoot":"","sources":["../../src/local-network/local-network.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,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;AASvF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-network.d.ts","sourceRoot":"","sources":["../../src/local-network/local-network.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,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;AASvF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;AASzE,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,KAAK,GAAG,EAA2D,MAAM,MAAM,CAAC;AA+CzF;;;;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;;;;;;;;;;;;;;;;;;;;;;;GAoBP;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;;;GAwJhG;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,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAe7D"}
|
|
@@ -15,10 +15,13 @@ import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
|
15
15
|
import { SecretValue } from '@aztec/foundation/config';
|
|
16
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
17
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
18
|
+
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
18
19
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
20
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
21
|
import { SequencerState } from '@aztec/sequencer-client';
|
|
22
|
+
import { FunctionSelector, countArgumentsSize } from '@aztec/stdlib/abi';
|
|
21
23
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
24
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
22
25
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
23
26
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
24
27
|
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
@@ -33,6 +36,32 @@ import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
|
33
36
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
34
37
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
35
38
|
const logger = createLogger('local-network');
|
|
39
|
+
/**
|
|
40
|
+
* Returns Token-specific allowlist entries for FPC-based fee payments.
|
|
41
|
+
* The local network deploys a banana FPC and Token contracts, so the node must allow Token setup functions.
|
|
42
|
+
*/ async function getTokenAllowedSetupFunctions() {
|
|
43
|
+
const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
|
|
44
|
+
const allFunctions = TokenContractArtifact.functions.concat(TokenContractArtifact.nonDispatchPublicFunctions || []);
|
|
45
|
+
const getCalldataLength = (name)=>{
|
|
46
|
+
const fn = allFunctions.find((f)=>f.name === name);
|
|
47
|
+
return 1 + countArgumentsSize(fn);
|
|
48
|
+
};
|
|
49
|
+
const increaseBalanceSelector = await FunctionSelector.fromSignature('_increase_public_balance((Field),u128)');
|
|
50
|
+
const transferInPublicSelector = await FunctionSelector.fromSignature('transfer_in_public((Field),(Field),u128,Field)');
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
classId: tokenClassId,
|
|
54
|
+
selector: increaseBalanceSelector,
|
|
55
|
+
calldataLength: getCalldataLength('_increase_public_balance'),
|
|
56
|
+
onlySelf: true
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
classId: tokenClassId,
|
|
60
|
+
selector: transferInPublicSelector,
|
|
61
|
+
calldataLength: getCalldataLength('transfer_in_public')
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
}
|
|
36
65
|
const localAnvil = foundry;
|
|
37
66
|
/**
|
|
38
67
|
* Function to deploy our L1 contracts to the local network L1
|
|
@@ -68,9 +97,16 @@ const localAnvil = foundry;
|
|
|
68
97
|
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
69
98
|
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
70
99
|
}
|
|
100
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
101
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
102
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
71
103
|
const aztecNodeConfig = {
|
|
72
104
|
...getConfigEnvVars(),
|
|
73
|
-
...config
|
|
105
|
+
...config,
|
|
106
|
+
txPublicSetupAllowListExtend: [
|
|
107
|
+
...tokenAllowList,
|
|
108
|
+
...config.txPublicSetupAllowListExtend ?? []
|
|
109
|
+
]
|
|
74
110
|
};
|
|
75
111
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
76
112
|
if (aztecNodeConfig.sequencerPublisherPrivateKeys == undefined || !aztecNodeConfig.sequencerPublisherPrivateKeys.length || aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0-rc.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,39 +28,39 @@
|
|
|
28
28
|
"../package.common.json"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "4.0
|
|
32
|
-
"@aztec/archiver": "4.0
|
|
33
|
-
"@aztec/aztec-faucet": "4.0
|
|
34
|
-
"@aztec/aztec-node": "4.0
|
|
35
|
-
"@aztec/aztec.js": "4.0
|
|
36
|
-
"@aztec/bb-prover": "4.0
|
|
37
|
-
"@aztec/bb.js": "4.0
|
|
38
|
-
"@aztec/blob-client": "4.0
|
|
39
|
-
"@aztec/bot": "4.0
|
|
40
|
-
"@aztec/builder": "4.0
|
|
41
|
-
"@aztec/cli": "4.0
|
|
42
|
-
"@aztec/constants": "4.0
|
|
43
|
-
"@aztec/entrypoints": "4.0
|
|
44
|
-
"@aztec/ethereum": "4.0
|
|
45
|
-
"@aztec/foundation": "4.0
|
|
46
|
-
"@aztec/kv-store": "4.0
|
|
47
|
-
"@aztec/l1-artifacts": "4.0
|
|
48
|
-
"@aztec/node-lib": "4.0
|
|
49
|
-
"@aztec/noir-contracts.js": "4.0
|
|
50
|
-
"@aztec/noir-protocol-circuits-types": "4.0
|
|
51
|
-
"@aztec/p2p": "4.0
|
|
52
|
-
"@aztec/p2p-bootstrap": "4.0
|
|
53
|
-
"@aztec/protocol-contracts": "4.0
|
|
54
|
-
"@aztec/prover-client": "4.0
|
|
55
|
-
"@aztec/prover-node": "4.0
|
|
56
|
-
"@aztec/pxe": "4.0
|
|
57
|
-
"@aztec/sequencer-client": "4.0
|
|
58
|
-
"@aztec/stdlib": "4.0
|
|
59
|
-
"@aztec/telemetry-client": "4.0
|
|
60
|
-
"@aztec/txe": "4.0
|
|
61
|
-
"@aztec/validator-ha-signer": "4.0
|
|
62
|
-
"@aztec/wallets": "4.0
|
|
63
|
-
"@aztec/world-state": "4.0
|
|
31
|
+
"@aztec/accounts": "4.1.0-rc.2",
|
|
32
|
+
"@aztec/archiver": "4.1.0-rc.2",
|
|
33
|
+
"@aztec/aztec-faucet": "4.1.0-rc.2",
|
|
34
|
+
"@aztec/aztec-node": "4.1.0-rc.2",
|
|
35
|
+
"@aztec/aztec.js": "4.1.0-rc.2",
|
|
36
|
+
"@aztec/bb-prover": "4.1.0-rc.2",
|
|
37
|
+
"@aztec/bb.js": "4.1.0-rc.2",
|
|
38
|
+
"@aztec/blob-client": "4.1.0-rc.2",
|
|
39
|
+
"@aztec/bot": "4.1.0-rc.2",
|
|
40
|
+
"@aztec/builder": "4.1.0-rc.2",
|
|
41
|
+
"@aztec/cli": "4.1.0-rc.2",
|
|
42
|
+
"@aztec/constants": "4.1.0-rc.2",
|
|
43
|
+
"@aztec/entrypoints": "4.1.0-rc.2",
|
|
44
|
+
"@aztec/ethereum": "4.1.0-rc.2",
|
|
45
|
+
"@aztec/foundation": "4.1.0-rc.2",
|
|
46
|
+
"@aztec/kv-store": "4.1.0-rc.2",
|
|
47
|
+
"@aztec/l1-artifacts": "4.1.0-rc.2",
|
|
48
|
+
"@aztec/node-lib": "4.1.0-rc.2",
|
|
49
|
+
"@aztec/noir-contracts.js": "4.1.0-rc.2",
|
|
50
|
+
"@aztec/noir-protocol-circuits-types": "4.1.0-rc.2",
|
|
51
|
+
"@aztec/p2p": "4.1.0-rc.2",
|
|
52
|
+
"@aztec/p2p-bootstrap": "4.1.0-rc.2",
|
|
53
|
+
"@aztec/protocol-contracts": "4.1.0-rc.2",
|
|
54
|
+
"@aztec/prover-client": "4.1.0-rc.2",
|
|
55
|
+
"@aztec/prover-node": "4.1.0-rc.2",
|
|
56
|
+
"@aztec/pxe": "4.1.0-rc.2",
|
|
57
|
+
"@aztec/sequencer-client": "4.1.0-rc.2",
|
|
58
|
+
"@aztec/stdlib": "4.1.0-rc.2",
|
|
59
|
+
"@aztec/telemetry-client": "4.1.0-rc.2",
|
|
60
|
+
"@aztec/txe": "4.1.0-rc.2",
|
|
61
|
+
"@aztec/validator-ha-signer": "4.1.0-rc.2",
|
|
62
|
+
"@aztec/wallets": "4.1.0-rc.2",
|
|
63
|
+
"@aztec/world-state": "4.1.0-rc.2",
|
|
64
64
|
"@types/chalk": "^2.2.0",
|
|
65
65
|
"abitype": "^0.8.11",
|
|
66
66
|
"chalk": "^5.3.0",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
4
|
+
import { getPublicClient } from '@aztec/ethereum/client';
|
|
5
|
+
import type { GenesisStateConfig } from '@aztec/ethereum/config';
|
|
6
|
+
import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
7
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
|
+
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
9
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
10
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
13
|
+
|
|
14
|
+
import Koa from 'koa';
|
|
15
|
+
|
|
16
|
+
const ROLLUP_POLL_INTERVAL_S = 60;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Computes the expected genesis archive root from the genesis state config.
|
|
20
|
+
* Reads test accounts and sponsored FPC addresses as specified, then computes
|
|
21
|
+
* the genesis values including the archive root and prefilled public data.
|
|
22
|
+
*/
|
|
23
|
+
export async function computeExpectedGenesisRoot(config: GenesisStateConfig, userLog: LogFn) {
|
|
24
|
+
const testAccounts = config.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
|
|
25
|
+
const sponsoredFPCAccounts = config.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
|
|
26
|
+
const prefundAddresses = (config.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
|
|
27
|
+
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
|
|
28
|
+
|
|
29
|
+
userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
|
|
30
|
+
|
|
31
|
+
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
32
|
+
|
|
33
|
+
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
34
|
+
|
|
35
|
+
return { genesisArchiveRoot, prefilledPublicData };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
40
|
+
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
41
|
+
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s until a compatible rollup appears.
|
|
42
|
+
*/
|
|
43
|
+
export async function waitForCompatibleRollup(
|
|
44
|
+
config: {
|
|
45
|
+
l1RpcUrls: string[];
|
|
46
|
+
l1ChainId: number;
|
|
47
|
+
l1Contracts: { registryAddress: EthAddress };
|
|
48
|
+
rollupVersion?: number;
|
|
49
|
+
},
|
|
50
|
+
expectedGenesisRoot: Fr,
|
|
51
|
+
port: number | undefined,
|
|
52
|
+
userLog: LogFn,
|
|
53
|
+
): Promise<void> {
|
|
54
|
+
const publicClient = getPublicClient(config);
|
|
55
|
+
const rollupVersion: number | 'canonical' = config.rollupVersion ?? 'canonical';
|
|
56
|
+
|
|
57
|
+
const registry = new RegistryContract(publicClient, config.l1Contracts.registryAddress);
|
|
58
|
+
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
59
|
+
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
60
|
+
|
|
61
|
+
let l1GenesisRoot: Fr;
|
|
62
|
+
try {
|
|
63
|
+
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
64
|
+
} catch (err: any) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
userLog(
|
|
75
|
+
`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` +
|
|
76
|
+
`Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_S}s for a compatible rollup...`,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const standbyServer = await startHttpRpcServer({ getApp: () => new Koa(), isHealthy: () => true }, { port });
|
|
80
|
+
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await retryUntil(
|
|
84
|
+
async () => {
|
|
85
|
+
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
86
|
+
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
87
|
+
|
|
88
|
+
let currentGenesisRoot: Fr;
|
|
89
|
+
try {
|
|
90
|
+
currentGenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
91
|
+
} catch {
|
|
92
|
+
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (currentGenesisRoot.equals(expectedGenesisRoot)) {
|
|
97
|
+
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${currentGenesisRoot}.`);
|
|
102
|
+
return undefined;
|
|
103
|
+
},
|
|
104
|
+
'compatible rollup',
|
|
105
|
+
0,
|
|
106
|
+
ROLLUP_POLL_INTERVAL_S,
|
|
107
|
+
);
|
|
108
|
+
} finally {
|
|
109
|
+
await new Promise<void>((resolve, reject) => standbyServer.close(err => (err ? reject(err) : resolve())));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
1
|
import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
2
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
-
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
5
3
|
import { getL1Config } from '@aztec/cli/config';
|
|
6
4
|
import { getPublicClient } from '@aztec/ethereum/client';
|
|
7
|
-
import {
|
|
5
|
+
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
8
6
|
import { type NetworkNames, SecretValue } from '@aztec/foundation/config';
|
|
9
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
7
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
11
|
-
import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
12
8
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
13
9
|
import type { LogFn } from '@aztec/foundation/log';
|
|
14
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
15
10
|
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
16
11
|
import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
|
|
17
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
18
12
|
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
19
13
|
import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
20
14
|
import {
|
|
@@ -24,9 +18,6 @@ import {
|
|
|
24
18
|
telemetryClientConfigMappings,
|
|
25
19
|
} from '@aztec/telemetry-client';
|
|
26
20
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
27
|
-
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
28
|
-
|
|
29
|
-
import Koa from 'koa';
|
|
30
21
|
|
|
31
22
|
import { createAztecNode } from '../../local-network/index.js';
|
|
32
23
|
import {
|
|
@@ -36,74 +27,9 @@ import {
|
|
|
36
27
|
setupVersionChecker,
|
|
37
28
|
} from '../util.js';
|
|
38
29
|
import { getVersions } from '../versioning.js';
|
|
30
|
+
import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
|
|
39
31
|
import { startProverBroker } from './start_prover_broker.js';
|
|
40
32
|
|
|
41
|
-
const ROLLUP_POLL_INTERVAL_MS = 600_000;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Waits until the canonical rollup's genesis archive root matches the expected local genesis root.
|
|
45
|
-
* If the rollup is not yet compatible (e.g. during L1 contract upgrades), enters standby mode:
|
|
46
|
-
* starts a lightweight HTTP server for K8s liveness probes and polls until a compatible rollup appears.
|
|
47
|
-
*/
|
|
48
|
-
async function waitForCompatibleRollup(
|
|
49
|
-
publicClient: ReturnType<typeof getPublicClient>,
|
|
50
|
-
registryAddress: EthAddress,
|
|
51
|
-
rollupVersion: number | 'canonical',
|
|
52
|
-
expectedGenesisRoot: Fr,
|
|
53
|
-
port: number | undefined,
|
|
54
|
-
userLog: LogFn,
|
|
55
|
-
): Promise<void> {
|
|
56
|
-
const registry = new RegistryContract(publicClient, registryAddress);
|
|
57
|
-
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
58
|
-
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
59
|
-
|
|
60
|
-
let l1GenesisRoot: Fr;
|
|
61
|
-
try {
|
|
62
|
-
l1GenesisRoot = await rollup.getGenesisArchiveTreeRoot();
|
|
63
|
-
} catch (err: any) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`Could not retrieve genesis archive root from canonical rollup at ${rollupAddress}: ${err.message}`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
userLog(
|
|
74
|
-
`Genesis root mismatch: expected ${expectedGenesisRoot}, got ${l1GenesisRoot} from rollup at ${rollupAddress}. ` +
|
|
75
|
-
`Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_MS / 1000}s for a compatible rollup...`,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const standbyServer = await startHttpRpcServer({ getApp: () => new Koa(), isHealthy: () => true }, { port });
|
|
79
|
-
userLog(`Standby status server listening on port ${standbyServer.port}`);
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
while (true) {
|
|
83
|
-
await sleep(ROLLUP_POLL_INTERVAL_MS);
|
|
84
|
-
|
|
85
|
-
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
86
|
-
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
l1GenesisRoot = await currentRollup.getGenesisArchiveTreeRoot();
|
|
90
|
-
} catch {
|
|
91
|
-
userLog(`Failed to fetch genesis root from rollup at ${currentRollupAddress}. Retrying...`);
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (l1GenesisRoot.equals(expectedGenesisRoot)) {
|
|
96
|
-
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
userLog(`Still waiting. Rollup at ${currentRollupAddress} has genesis root ${l1GenesisRoot}.`);
|
|
101
|
-
}
|
|
102
|
-
} finally {
|
|
103
|
-
await new Promise<void>((resolve, reject) => standbyServer.close(err => (err ? reject(err) : resolve())));
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
33
|
export async function startNode(
|
|
108
34
|
options: any,
|
|
109
35
|
signalHandlers: (() => Promise<void>)[],
|
|
@@ -154,16 +80,8 @@ export async function startNode(
|
|
|
154
80
|
|
|
155
81
|
await preloadCrsDataForVerifying(nodeConfig, userLog);
|
|
156
82
|
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const prefundAddresses = (nodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
|
|
160
|
-
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts).concat(prefundAddresses);
|
|
161
|
-
|
|
162
|
-
userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
|
|
163
|
-
|
|
164
|
-
const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
165
|
-
|
|
166
|
-
userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
|
|
83
|
+
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
84
|
+
const { genesisArchiveRoot, prefilledPublicData } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
167
85
|
|
|
168
86
|
const followsCanonicalRollup =
|
|
169
87
|
typeof nodeConfig.rollupVersion !== 'number' || (nodeConfig.rollupVersion as unknown as string) === 'canonical';
|
|
@@ -174,16 +92,7 @@ export async function startNode(
|
|
|
174
92
|
|
|
175
93
|
// Wait for a compatible rollup before proceeding with full L1 config fetch.
|
|
176
94
|
// This prevents crashes when the canonical rollup hasn't been upgraded yet.
|
|
177
|
-
|
|
178
|
-
const rollupVersion: number | 'canonical' = nodeConfig.rollupVersion ?? 'canonical';
|
|
179
|
-
await waitForCompatibleRollup(
|
|
180
|
-
publicClient,
|
|
181
|
-
nodeConfig.l1Contracts.registryAddress,
|
|
182
|
-
rollupVersion,
|
|
183
|
-
genesisArchiveRoot,
|
|
184
|
-
options.port,
|
|
185
|
-
userLog,
|
|
186
|
-
);
|
|
95
|
+
await waitForCompatibleRollup(nodeConfig, genesisArchiveRoot, options.port, userLog);
|
|
187
96
|
|
|
188
97
|
const { addresses, config } = await getL1Config(
|
|
189
98
|
nodeConfig.l1Contracts.registryAddress,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getL1Config } from '@aztec/cli/config';
|
|
2
|
+
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
2
3
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
3
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
4
5
|
import {
|
|
@@ -13,6 +14,7 @@ import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
|
13
14
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
14
15
|
|
|
15
16
|
import { extractRelevantOptions } from '../util.js';
|
|
17
|
+
import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
|
|
16
18
|
|
|
17
19
|
export async function startProverBroker(
|
|
18
20
|
options: any,
|
|
@@ -34,6 +36,10 @@ export async function startProverBroker(
|
|
|
34
36
|
throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
40
|
+
const { genesisArchiveRoot } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
41
|
+
await waitForCompatibleRollup(config, genesisArchiveRoot, options.port, userLog);
|
|
42
|
+
|
|
37
43
|
const { addresses, config: rollupConfig } = await getL1Config(
|
|
38
44
|
config.l1Contracts.registryAddress,
|
|
39
45
|
config.l1RpcUrls,
|
package/src/examples/token.ts
CHANGED
|
@@ -32,7 +32,9 @@ async function main() {
|
|
|
32
32
|
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
33
33
|
|
|
34
34
|
logger.info('Deploying Token...');
|
|
35
|
-
const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
35
|
+
const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
36
|
+
from: alice,
|
|
37
|
+
});
|
|
36
38
|
logger.info('Token deployed');
|
|
37
39
|
|
|
38
40
|
// Mint tokens to Alice
|
|
@@ -41,7 +43,7 @@ async function main() {
|
|
|
41
43
|
|
|
42
44
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
43
45
|
|
|
44
|
-
const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
46
|
+
const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
45
47
|
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
46
48
|
|
|
47
49
|
// We will now transfer tokens from Alice to Bob
|
|
@@ -49,10 +51,10 @@ async function main() {
|
|
|
49
51
|
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
|
|
50
52
|
|
|
51
53
|
// Check the new balances
|
|
52
|
-
const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
54
|
+
const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
53
55
|
logger.info(`Alice's balance ${aliceBalance}`);
|
|
54
56
|
|
|
55
|
-
const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
57
|
+
const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
56
58
|
logger.info(`Bob's balance ${bobBalance}`);
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -48,7 +48,7 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
48
48
|
export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
|
|
49
49
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
50
50
|
const admin = getBananaAdmin(initialAccounts);
|
|
51
|
-
const [bananaCoin, fpc] = await Promise.all([
|
|
51
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
52
52
|
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
|
|
53
53
|
from: admin,
|
|
54
54
|
contractAddressSalt: BANANA_COIN_SALT,
|
|
@@ -16,11 +16,15 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
16
16
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
17
|
import type { LogFn } from '@aztec/foundation/log';
|
|
18
18
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
19
|
+
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
19
20
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
20
21
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
21
22
|
import { SequencerState } from '@aztec/sequencer-client';
|
|
23
|
+
import { FunctionSelector, countArgumentsSize } from '@aztec/stdlib/abi';
|
|
24
|
+
import type { FunctionAbi } from '@aztec/stdlib/abi';
|
|
22
25
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
23
|
-
import
|
|
26
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
27
|
+
import type { AllowedElement, ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
24
28
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
25
29
|
import {
|
|
26
30
|
type TelemetryClient,
|
|
@@ -44,6 +48,38 @@ import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
|
44
48
|
|
|
45
49
|
const logger = createLogger('local-network');
|
|
46
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Returns Token-specific allowlist entries for FPC-based fee payments.
|
|
53
|
+
* The local network deploys a banana FPC and Token contracts, so the node must allow Token setup functions.
|
|
54
|
+
*/
|
|
55
|
+
async function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]> {
|
|
56
|
+
const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
|
|
57
|
+
const allFunctions: FunctionAbi[] = (TokenContractArtifact.functions as FunctionAbi[]).concat(
|
|
58
|
+
TokenContractArtifact.nonDispatchPublicFunctions || [],
|
|
59
|
+
);
|
|
60
|
+
const getCalldataLength = (name: string) => {
|
|
61
|
+
const fn = allFunctions.find(f => f.name === name)!;
|
|
62
|
+
return 1 + countArgumentsSize(fn);
|
|
63
|
+
};
|
|
64
|
+
const increaseBalanceSelector = await FunctionSelector.fromSignature('_increase_public_balance((Field),u128)');
|
|
65
|
+
const transferInPublicSelector = await FunctionSelector.fromSignature(
|
|
66
|
+
'transfer_in_public((Field),(Field),u128,Field)',
|
|
67
|
+
);
|
|
68
|
+
return [
|
|
69
|
+
{
|
|
70
|
+
classId: tokenClassId,
|
|
71
|
+
selector: increaseBalanceSelector,
|
|
72
|
+
calldataLength: getCalldataLength('_increase_public_balance'),
|
|
73
|
+
onlySelf: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
classId: tokenClassId,
|
|
77
|
+
selector: transferInPublicSelector,
|
|
78
|
+
calldataLength: getCalldataLength('transfer_in_public'),
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
|
|
47
83
|
const localAnvil = foundry;
|
|
48
84
|
|
|
49
85
|
/**
|
|
@@ -102,9 +138,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
102
138
|
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
103
139
|
}
|
|
104
140
|
|
|
141
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
142
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
143
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
144
|
+
|
|
105
145
|
const aztecNodeConfig: AztecNodeConfig = {
|
|
106
146
|
...getConfigEnvVars(),
|
|
107
147
|
...config,
|
|
148
|
+
txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
|
|
108
149
|
};
|
|
109
150
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
110
151
|
if (
|