@aztec/aztec 0.0.0-test.1 → 0.0.1-commit.b655e406
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 +20 -12
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +32 -33
- package/dest/cli/aztec_start_options.d.ts +4 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +137 -207
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +4 -0
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +18 -10
- package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -1
- package/dest/cli/cmds/start_blob_sink.js +17 -1
- package/dest/cli/cmds/start_bot.d.ts +3 -6
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +24 -13
- 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 +66 -79
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +9 -4
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +31 -2
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +9 -3
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_node.js +43 -45
- package/dest/cli/preload_crs.d.ts +3 -0
- package/dest/cli/preload_crs.d.ts.map +1 -0
- package/dest/cli/preload_crs.js +6 -0
- package/dest/cli/release_version.d.ts +2 -0
- package/dest/cli/release_version.d.ts.map +1 -0
- package/dest/cli/release_version.js +14 -0
- package/dest/cli/util.d.ts +36 -5
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +198 -28
- package/dest/cli/versioning.js +3 -3
- package/dest/examples/token.js +31 -18
- package/dest/examples/util.d.ts +4 -5
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +5 -6
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/sandbox/banana_fpc.d.ts +4 -5
- package/dest/sandbox/banana_fpc.d.ts.map +1 -1
- package/dest/sandbox/banana_fpc.js +19 -21
- package/dest/sandbox/index.d.ts +2 -3
- package/dest/sandbox/index.d.ts.map +1 -1
- package/dest/sandbox/index.js +2 -3
- package/dest/sandbox/sandbox.d.ts +25 -27
- package/dest/sandbox/sandbox.d.ts.map +1 -1
- package/dest/sandbox/sandbox.js +51 -49
- package/dest/sandbox/sponsored_fpc.d.ts +3 -5
- package/dest/sandbox/sponsored_fpc.d.ts.map +1 -1
- package/dest/sandbox/sponsored_fpc.js +10 -18
- package/dest/testing/anvil_test_watcher.d.ts +34 -0
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -0
- package/dest/testing/anvil_test_watcher.js +142 -0
- package/dest/testing/cheat_codes.d.ts +43 -0
- package/dest/testing/cheat_codes.d.ts.map +1 -0
- package/dest/testing/cheat_codes.js +62 -0
- package/dest/testing/index.d.ts +4 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +3 -0
- package/package.json +47 -41
- package/src/bin/index.ts +24 -12
- package/src/cli/aztec_start_action.ts +27 -30
- package/src/cli/aztec_start_options.ts +155 -207
- package/src/cli/cli.ts +8 -0
- package/src/cli/cmds/start_archiver.ts +19 -13
- package/src/cli/cmds/start_blob_sink.ts +27 -1
- package/src/cli/cmds/start_bot.ts +35 -12
- package/src/cli/cmds/start_node.ts +89 -84
- package/src/cli/cmds/start_p2p_bootstrap.ts +12 -4
- package/src/cli/cmds/start_prover_agent.ts +22 -2
- package/src/cli/cmds/start_prover_broker.ts +23 -3
- package/src/cli/cmds/start_prover_node.ts +53 -50
- package/src/cli/preload_crs.ts +7 -0
- package/src/cli/release_version.ts +21 -0
- package/src/cli/util.ts +208 -34
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +23 -19
- package/src/examples/util.ts +6 -8
- package/src/index.ts +3 -4
- package/src/sandbox/banana_fpc.ts +20 -25
- package/src/sandbox/index.ts +5 -3
- package/src/sandbox/sandbox.ts +70 -57
- package/src/sandbox/sponsored_fpc.ts +12 -25
- package/src/testing/anvil_test_watcher.ts +164 -0
- package/src/testing/cheat_codes.ts +78 -0
- package/src/testing/index.ts +3 -0
- package/dest/cli/chain_l2_config.d.ts +0 -19
- package/dest/cli/chain_l2_config.d.ts.map +0 -1
- package/dest/cli/chain_l2_config.js +0 -56
- package/dest/cli/cmds/start_faucet.d.ts +0 -4
- package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
- package/dest/cli/cmds/start_faucet.js +0 -20
- package/dest/cli/cmds/start_pxe.d.ts +0 -16
- package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
- package/dest/cli/cmds/start_pxe.js +0 -95
- package/dest/cli/get_l1_config.d.ts +0 -7
- package/dest/cli/get_l1_config.d.ts.map +0 -1
- package/dest/cli/get_l1_config.js +0 -13
- package/dest/sandbox/sponsored_fee_payment_method.d.ts +0 -23
- package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fee_payment_method.js +0 -36
- package/src/cli/chain_l2_config.ts +0 -74
- package/src/cli/cmds/start_faucet.ts +0 -34
- package/src/cli/cmds/start_pxe.ts +0 -129
- package/src/cli/get_l1_config.ts +0 -18
- package/src/sandbox/sponsored_fee_payment_method.ts +0 -46
package/src/sandbox/sandbox.ts
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import {
|
|
3
|
-
import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
4
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
-
import {
|
|
4
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
6
5
|
import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
7
|
-
import {
|
|
8
|
-
import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
|
|
6
|
+
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
7
|
import {
|
|
10
8
|
NULL_KEY,
|
|
11
9
|
createEthereumChain,
|
|
12
10
|
deployL1Contracts,
|
|
11
|
+
deployMulticall3,
|
|
13
12
|
getL1ContractsConfigEnvVars,
|
|
14
13
|
waitForPublicClient,
|
|
15
14
|
} from '@aztec/ethereum';
|
|
15
|
+
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
16
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
16
17
|
import { Fr } from '@aztec/foundation/fields';
|
|
17
18
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
19
|
+
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
18
20
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
|
-
import {
|
|
20
|
-
import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
21
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
21
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
22
22
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
23
23
|
import {
|
|
24
24
|
type TelemetryClient,
|
|
25
25
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
26
26
|
initTelemetryClient,
|
|
27
27
|
} from '@aztec/telemetry-client';
|
|
28
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
28
29
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
29
30
|
|
|
30
31
|
import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
31
|
-
import { mnemonicToAccount } from 'viem/accounts';
|
|
32
|
+
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
32
33
|
import { foundry } from 'viem/chains';
|
|
33
34
|
|
|
34
35
|
import { createAccountLogs } from '../cli/util.js';
|
|
35
36
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
37
|
+
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
36
38
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
37
|
-
import { getSponsoredFPCAddress
|
|
39
|
+
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
38
40
|
|
|
39
41
|
const logger = createLogger('sandbox');
|
|
40
42
|
|
|
@@ -49,7 +51,12 @@ export async function deployContractsToL1(
|
|
|
49
51
|
aztecNodeConfig: AztecNodeConfig,
|
|
50
52
|
hdAccount: HDAccount | PrivateKeyAccount,
|
|
51
53
|
contractDeployLogger = logger,
|
|
52
|
-
opts: {
|
|
54
|
+
opts: {
|
|
55
|
+
assumeProvenThroughBlockNumber?: number;
|
|
56
|
+
salt?: number;
|
|
57
|
+
genesisArchiveRoot?: Fr;
|
|
58
|
+
feeJuicePortalInitialBalance?: bigint;
|
|
59
|
+
} = {},
|
|
53
60
|
) {
|
|
54
61
|
const chain =
|
|
55
62
|
aztecNodeConfig.l1RpcUrls.length > 0
|
|
@@ -66,16 +73,21 @@ export async function deployContractsToL1(
|
|
|
66
73
|
{
|
|
67
74
|
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
68
75
|
...aztecNodeConfig,
|
|
69
|
-
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
|
|
70
76
|
vkTreeRoot: getVKTreeRoot(),
|
|
71
|
-
|
|
77
|
+
protocolContractsHash,
|
|
72
78
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
73
|
-
genesisBlockHash: opts.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
|
|
74
79
|
salt: opts.salt,
|
|
80
|
+
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
81
|
+
aztecTargetCommitteeSize: 0, // no committee in sandbox
|
|
82
|
+
slasherFlavor: 'none', // no slashing in sandbox
|
|
83
|
+
realVerifier: false,
|
|
75
84
|
},
|
|
76
85
|
);
|
|
77
86
|
|
|
87
|
+
await deployMulticall3(l1Contracts.l1Client, logger);
|
|
88
|
+
|
|
78
89
|
aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
|
|
90
|
+
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
79
91
|
|
|
80
92
|
return aztecNodeConfig.l1Contracts;
|
|
81
93
|
}
|
|
@@ -85,9 +97,7 @@ export type SandboxConfig = AztecNodeConfig & {
|
|
|
85
97
|
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
86
98
|
l1Mnemonic: string;
|
|
87
99
|
/** Salt used to deploy L1 contracts.*/
|
|
88
|
-
|
|
89
|
-
/** Whether to expose PXE service on sandbox start.*/
|
|
90
|
-
noPXE: boolean;
|
|
100
|
+
deployAztecContractsSalt: string;
|
|
91
101
|
/** Whether to deploy test accounts on sandbox start.*/
|
|
92
102
|
testAccounts: boolean;
|
|
93
103
|
};
|
|
@@ -108,23 +118,29 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
108
118
|
}
|
|
109
119
|
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
|
|
110
120
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
111
|
-
if (
|
|
121
|
+
if (
|
|
122
|
+
aztecNodeConfig.publisherPrivateKeys == undefined ||
|
|
123
|
+
!aztecNodeConfig.publisherPrivateKeys.length ||
|
|
124
|
+
aztecNodeConfig.publisherPrivateKeys[0].getValue() === NULL_KEY
|
|
125
|
+
) {
|
|
112
126
|
const privKey = hdAccount.getHdKey().privateKey;
|
|
113
|
-
aztecNodeConfig.
|
|
127
|
+
aztecNodeConfig.publisherPrivateKeys = [new SecretValue(`0x${Buffer.from(privKey!).toString('hex')}` as const)];
|
|
114
128
|
}
|
|
115
|
-
if (!aztecNodeConfig.
|
|
129
|
+
if (!aztecNodeConfig.validatorPrivateKeys?.getValue().length) {
|
|
116
130
|
const privKey = hdAccount.getHdKey().privateKey;
|
|
117
|
-
aztecNodeConfig.
|
|
131
|
+
aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${Buffer.from(privKey!).toString('hex')}`]);
|
|
118
132
|
}
|
|
133
|
+
aztecNodeConfig.coinbase = EthAddress.fromString(
|
|
134
|
+
privateKeyToAddress(aztecNodeConfig.validatorPrivateKeys.getValue()[0]),
|
|
135
|
+
);
|
|
119
136
|
|
|
120
137
|
const initialAccounts = await (async () => {
|
|
121
|
-
if (config.testAccounts) {
|
|
138
|
+
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
122
139
|
if (aztecNodeConfig.p2pEnabled) {
|
|
123
140
|
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
124
|
-
} else if (config.noPXE) {
|
|
125
|
-
userLog(`Not setting up test accounts as we are not exposing a PXE`);
|
|
126
141
|
} else {
|
|
127
|
-
|
|
142
|
+
userLog(`Setting up test accounts`);
|
|
143
|
+
return await getInitialTestAccountsData();
|
|
128
144
|
}
|
|
129
145
|
}
|
|
130
146
|
return [];
|
|
@@ -135,15 +151,16 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
135
151
|
const fundedAddresses = initialAccounts.length
|
|
136
152
|
? [...initialAccounts.map(a => a.address), bananaFPC, sponsoredFPC]
|
|
137
153
|
: [];
|
|
138
|
-
const { genesisArchiveRoot,
|
|
154
|
+
const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
139
155
|
|
|
140
156
|
let watcher: AnvilTestWatcher | undefined = undefined;
|
|
157
|
+
const dateProvider = new TestDateProvider();
|
|
141
158
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
142
159
|
const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
|
|
143
160
|
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
144
161
|
genesisArchiveRoot,
|
|
145
|
-
|
|
146
|
-
|
|
162
|
+
salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
|
|
163
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
147
164
|
});
|
|
148
165
|
|
|
149
166
|
const chain =
|
|
@@ -156,7 +173,12 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
156
173
|
transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
|
|
157
174
|
});
|
|
158
175
|
|
|
159
|
-
watcher = new AnvilTestWatcher(
|
|
176
|
+
watcher = new AnvilTestWatcher(
|
|
177
|
+
new EthCheatCodes([l1RpcUrl], dateProvider),
|
|
178
|
+
l1ContractAddresses.rollupAddress,
|
|
179
|
+
publicClient,
|
|
180
|
+
dateProvider,
|
|
181
|
+
);
|
|
160
182
|
watcher.setIsSandbox(true);
|
|
161
183
|
await watcher.start();
|
|
162
184
|
}
|
|
@@ -164,29 +186,31 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
164
186
|
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
165
187
|
// Create a local blob sink client inside the sandbox, no http connectivity
|
|
166
188
|
const blobSinkClient = createBlobSinkClient();
|
|
167
|
-
const node = await createAztecNode(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
new SignerlessWallet(pxe),
|
|
172
|
-
aztecNodeConfig.l1Contracts.feeJuicePortalAddress,
|
|
173
|
-
undefined,
|
|
174
|
-
logger.info,
|
|
189
|
+
const node = await createAztecNode(
|
|
190
|
+
aztecNodeConfig,
|
|
191
|
+
{ telemetry, blobSinkClient, dateProvider },
|
|
192
|
+
{ prefilledPublicData },
|
|
175
193
|
);
|
|
176
194
|
|
|
177
195
|
if (initialAccounts.length) {
|
|
196
|
+
const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
197
|
+
const wallet = await TestWallet.create(node, PXEConfig);
|
|
198
|
+
|
|
178
199
|
userLog('Setting up funded test accounts...');
|
|
179
|
-
const
|
|
180
|
-
const accountsWithSecrets =
|
|
181
|
-
account,
|
|
200
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
|
|
201
|
+
const accountsWithSecrets = accountManagers.map((manager, i) => ({
|
|
202
|
+
account: manager,
|
|
182
203
|
secretKey: initialAccounts[i].secret,
|
|
183
204
|
}));
|
|
184
|
-
const accLogs = await createAccountLogs(accountsWithSecrets,
|
|
205
|
+
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
185
206
|
userLog(accLogs.join(''));
|
|
186
207
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
await
|
|
208
|
+
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
209
|
+
|
|
210
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
211
|
+
|
|
212
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
213
|
+
await wallet.stop();
|
|
190
214
|
}
|
|
191
215
|
|
|
192
216
|
const stop = async () => {
|
|
@@ -194,7 +218,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
194
218
|
await watcher?.stop();
|
|
195
219
|
};
|
|
196
220
|
|
|
197
|
-
return { node,
|
|
221
|
+
return { node, stop };
|
|
198
222
|
}
|
|
199
223
|
|
|
200
224
|
/**
|
|
@@ -203,7 +227,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
203
227
|
*/
|
|
204
228
|
export async function createAztecNode(
|
|
205
229
|
config: Partial<AztecNodeConfig> = {},
|
|
206
|
-
deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface } = {},
|
|
230
|
+
deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
|
|
207
231
|
options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
|
|
208
232
|
) {
|
|
209
233
|
// TODO(#12272): will clean this up. This is criminal.
|
|
@@ -213,17 +237,6 @@ export async function createAztecNode(
|
|
|
213
237
|
...config,
|
|
214
238
|
l1Contracts: { ...l1Contracts, ...config.l1Contracts },
|
|
215
239
|
};
|
|
216
|
-
logger.info('createAztecNode', aztecNodeConfig);
|
|
217
240
|
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
218
241
|
return node;
|
|
219
242
|
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Create and start a new Aztec PXE HTTP Server
|
|
223
|
-
* @param config - Optional PXE settings.
|
|
224
|
-
*/
|
|
225
|
-
export async function createAztecPXE(node: AztecNode, config: Partial<PXEServiceConfig> = {}) {
|
|
226
|
-
const pxeServiceConfig: PXEServiceConfig = { ...getPXEServiceConfig(), ...config };
|
|
227
|
-
const pxe = await createPXEService(node, pxeServiceConfig);
|
|
228
|
-
return pxe;
|
|
229
|
-
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ContractInstanceWithAddress,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@aztec/
|
|
8
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
getContractInstanceFromInstantiationParams,
|
|
4
|
+
} from '@aztec/aztec.js/contracts';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
7
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
9
8
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
10
9
|
|
|
11
|
-
const SPONSORED_FPC_SALT = new Fr(0);
|
|
12
|
-
|
|
13
10
|
async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
|
|
14
|
-
return await
|
|
15
|
-
salt: SPONSORED_FPC_SALT,
|
|
11
|
+
return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
12
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
16
13
|
});
|
|
17
14
|
}
|
|
18
15
|
|
|
@@ -20,19 +17,9 @@ export async function getSponsoredFPCAddress() {
|
|
|
20
17
|
return (await getSponsoredFPCInstance()).address;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export async function
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
log(`SponsoredFPC: ${deployed.address}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export async function getDeployedSponsoredFPCAddress(pxe: PXE) {
|
|
32
|
-
const fpc = await getSponsoredFPCAddress();
|
|
33
|
-
const contracts = await pxe.getContracts();
|
|
34
|
-
if (!contracts.find(c => c.equals(fpc))) {
|
|
35
|
-
throw new Error('SponsoredFPC not deployed.');
|
|
36
|
-
}
|
|
37
|
-
return fpc;
|
|
20
|
+
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
21
|
+
const fpc = await getSponsoredFPCInstance();
|
|
22
|
+
// The following is no-op if the contract is already registered
|
|
23
|
+
await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
|
|
24
|
+
return fpc.address;
|
|
38
25
|
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { ViemClient } from '@aztec/ethereum';
|
|
2
|
+
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
6
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
7
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
8
|
+
|
|
9
|
+
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a watcher for a rollup contract.
|
|
13
|
+
*
|
|
14
|
+
* It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
|
|
15
|
+
* it will periodically check if the current slot have already been filled, e.g., there was an L2
|
|
16
|
+
* block within the slot. And if so, it will time travel into the next slot.
|
|
17
|
+
*/
|
|
18
|
+
export class AnvilTestWatcher {
|
|
19
|
+
private isSandbox: boolean = false;
|
|
20
|
+
|
|
21
|
+
private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
22
|
+
private rollupCheatCodes: RollupCheatCodes;
|
|
23
|
+
private l2SlotDuration!: bigint;
|
|
24
|
+
|
|
25
|
+
private filledRunningPromise?: RunningPromise;
|
|
26
|
+
private syncDateProviderPromise?: RunningPromise;
|
|
27
|
+
private markingAsProvenRunningPromise?: RunningPromise;
|
|
28
|
+
|
|
29
|
+
private logger: Logger = createLogger(`aztecjs:utils:watcher`);
|
|
30
|
+
|
|
31
|
+
private isMarkingAsProven = true;
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
private cheatcodes: EthCheatCodes,
|
|
35
|
+
rollupAddress: EthAddress,
|
|
36
|
+
l1Client: ViemClient,
|
|
37
|
+
private dateProvider?: TestDateProvider,
|
|
38
|
+
) {
|
|
39
|
+
this.rollup = getContract({
|
|
40
|
+
address: getAddress(rollupAddress.toString()),
|
|
41
|
+
abi: RollupAbi,
|
|
42
|
+
client: l1Client,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
|
|
46
|
+
rollupAddress,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setIsMarkingAsProven(isMarkingAsProven: boolean) {
|
|
53
|
+
this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
|
|
54
|
+
this.isMarkingAsProven = isMarkingAsProven;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setIsSandbox(isSandbox: boolean) {
|
|
58
|
+
this.isSandbox = isSandbox;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async start() {
|
|
62
|
+
if (this.filledRunningPromise) {
|
|
63
|
+
throw new Error('Watcher already watching for filled slot');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const config = await this.rollupCheatCodes.getConfig();
|
|
67
|
+
this.l2SlotDuration = config.slotDuration;
|
|
68
|
+
|
|
69
|
+
// If auto mining is not supported (e.g., we are on a real network), then we
|
|
70
|
+
// will simple do nothing. But if on an anvil or the like, this make sure that
|
|
71
|
+
// the sandbox and tests don't break because time is frozen and we never get to
|
|
72
|
+
// the next slot.
|
|
73
|
+
const isAutoMining = await this.cheatcodes.isAutoMining();
|
|
74
|
+
|
|
75
|
+
if (isAutoMining) {
|
|
76
|
+
this.filledRunningPromise = new RunningPromise(() => this.warpTimeIfNeeded(), this.logger, 200);
|
|
77
|
+
this.filledRunningPromise.start();
|
|
78
|
+
this.syncDateProviderPromise = new RunningPromise(() => this.syncDateProviderToL1IfBehind(), this.logger, 200);
|
|
79
|
+
this.syncDateProviderPromise.start();
|
|
80
|
+
this.markingAsProvenRunningPromise = new RunningPromise(() => this.markAsProven(), this.logger, 200);
|
|
81
|
+
this.markingAsProvenRunningPromise.start();
|
|
82
|
+
this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
|
|
83
|
+
} else {
|
|
84
|
+
this.logger.info(`Watcher not started because not auto mining`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async stop() {
|
|
89
|
+
await this.filledRunningPromise?.stop();
|
|
90
|
+
await this.syncDateProviderPromise?.stop();
|
|
91
|
+
await this.markingAsProvenRunningPromise?.stop();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async trigger() {
|
|
95
|
+
await this.filledRunningPromise?.trigger();
|
|
96
|
+
await this.syncDateProviderPromise?.trigger();
|
|
97
|
+
await this.markingAsProvenRunningPromise?.trigger();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async markAsProven() {
|
|
101
|
+
if (!this.isMarkingAsProven) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
await this.rollupCheatCodes.markAsProven();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async syncDateProviderToL1IfBehind() {
|
|
108
|
+
// this doesn't apply to the sandbox, because we don't have a date provider in the sandbox
|
|
109
|
+
if (!this.dateProvider) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const l1Time = (await this.cheatcodes.timestamp()) * 1000;
|
|
114
|
+
const wallTime = this.dateProvider.now();
|
|
115
|
+
if (l1Time > wallTime) {
|
|
116
|
+
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
117
|
+
this.dateProvider.setTime(l1Time);
|
|
118
|
+
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
119
|
+
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
|
|
120
|
+
await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async warpTimeIfNeeded() {
|
|
125
|
+
try {
|
|
126
|
+
const currentSlot = await this.rollup.read.getCurrentSlot();
|
|
127
|
+
const pendingBlockNumber = BigInt(await this.rollup.read.getPendingBlockNumber());
|
|
128
|
+
const blockLog = await this.rollup.read.getBlock([pendingBlockNumber]);
|
|
129
|
+
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([currentSlot + 1n]));
|
|
130
|
+
|
|
131
|
+
if (currentSlot === blockLog.slotNumber) {
|
|
132
|
+
// We should jump to the next slot
|
|
133
|
+
try {
|
|
134
|
+
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
135
|
+
resetBlockInterval: true,
|
|
136
|
+
});
|
|
137
|
+
} catch (e) {
|
|
138
|
+
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// If we are not in sandbox, we don't need to warp time
|
|
146
|
+
if (!this.isSandbox) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
151
|
+
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
152
|
+
try {
|
|
153
|
+
await this.cheatcodes.warp(nextSlotTimestamp, { resetBlockInterval: true });
|
|
154
|
+
} catch (e) {
|
|
155
|
+
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
159
|
+
}
|
|
160
|
+
} catch {
|
|
161
|
+
this.logger.error('mineIfSlotFilled failed');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
5
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A class that provides utility functions for interacting with the chain.
|
|
9
|
+
* @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
|
|
10
|
+
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
11
|
+
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
12
|
+
*/
|
|
13
|
+
export class CheatCodes {
|
|
14
|
+
constructor(
|
|
15
|
+
/** Cheat codes for L1.*/
|
|
16
|
+
public eth: EthCheatCodes,
|
|
17
|
+
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
18
|
+
public rollup: RollupCheatCodes,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
static async create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes> {
|
|
22
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
23
|
+
const rollupCheatCodes = new RollupCheatCodes(
|
|
24
|
+
ethCheatCodes,
|
|
25
|
+
await node.getNodeInfo().then(n => n.l1ContractAddresses),
|
|
26
|
+
);
|
|
27
|
+
return new CheatCodes(ethCheatCodes, rollupCheatCodes);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
|
|
32
|
+
* the target timestamp. L2 timestamp is not advanced exactly to the target timestamp because it is determined
|
|
33
|
+
* by the slot number, which advances in fixed intervals.
|
|
34
|
+
* This is useful for testing time-dependent contract behavior.
|
|
35
|
+
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
36
|
+
* @param node - The Aztec node used to query if a new block has been mined.
|
|
37
|
+
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
38
|
+
*/
|
|
39
|
+
async warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number) {
|
|
40
|
+
const currentL2BlockNumber = await node.getBlockNumber();
|
|
41
|
+
|
|
42
|
+
// We warp the L1 timestamp
|
|
43
|
+
await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
|
|
44
|
+
|
|
45
|
+
// Wait until an L2 block is mined
|
|
46
|
+
const sequencer = sequencerClient.getSequencer();
|
|
47
|
+
const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
|
|
48
|
+
sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
49
|
+
|
|
50
|
+
await retryUntil(
|
|
51
|
+
async () => {
|
|
52
|
+
const newL2BlockNumber = await node.getBlockNumber();
|
|
53
|
+
return newL2BlockNumber > currentL2BlockNumber;
|
|
54
|
+
},
|
|
55
|
+
'new block after warping L2 time',
|
|
56
|
+
36,
|
|
57
|
+
1,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Restore original minTxsPerBlock
|
|
61
|
+
sequencer.updateConfig({ minTxsPerBlock });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
|
|
66
|
+
* least by the duration. L2 timestamp is not advanced exactly by the duration because it is determined by the slot
|
|
67
|
+
* number, which advances in fixed intervals.
|
|
68
|
+
* This is useful for testing time-dependent contract behavior.
|
|
69
|
+
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
70
|
+
* @param node - The Aztec node used to query if a new block has been mined.
|
|
71
|
+
* @param duration - The duration to advance time by (in seconds)
|
|
72
|
+
*/
|
|
73
|
+
async warpL2TimeAtLeastBy(sequencerClient: SequencerClient, node: AztecNode, duration: bigint | number) {
|
|
74
|
+
const currentTimestamp = await this.eth.timestamp();
|
|
75
|
+
const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
|
|
76
|
+
await this.warpL2TimeAtLeastTo(sequencerClient, node, targetTimestamp);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type NetworkNames = 'testnet-ignition';
|
|
2
|
-
export type L2ChainConfig = {
|
|
3
|
-
l1ChainId: number;
|
|
4
|
-
ethereumSlotDuration: number;
|
|
5
|
-
aztecSlotDuration: number;
|
|
6
|
-
aztecEpochDuration: number;
|
|
7
|
-
aztecProofSubmissionWindow: number;
|
|
8
|
-
testAccounts: boolean;
|
|
9
|
-
p2pEnabled: boolean;
|
|
10
|
-
p2pBootstrapNodes: string[];
|
|
11
|
-
registryAddress: string;
|
|
12
|
-
seqMinTxsPerBlock: number;
|
|
13
|
-
seqMaxTxsPerBlock: number;
|
|
14
|
-
};
|
|
15
|
-
export declare const testnetIgnitionL2ChainConfig: L2ChainConfig;
|
|
16
|
-
export declare function getBootnodes(networkName: NetworkNames): Promise<any>;
|
|
17
|
-
export declare function getL2ChainConfig(networkName: NetworkNames): Promise<L2ChainConfig | undefined>;
|
|
18
|
-
export declare function enrichEnvironmentWithChainConfig(networkName: NetworkNames): Promise<void>;
|
|
19
|
-
//# sourceMappingURL=chain_l2_config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/cli/chain_l2_config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aAY1C,CAAC;AAEF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,gBAQ3D;AAED,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAOpG;AAUD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBAgB/E"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export const testnetIgnitionL2ChainConfig = {
|
|
2
|
-
l1ChainId: 11155111,
|
|
3
|
-
ethereumSlotDuration: 12,
|
|
4
|
-
aztecSlotDuration: 36,
|
|
5
|
-
aztecEpochDuration: 32,
|
|
6
|
-
aztecProofSubmissionWindow: 64,
|
|
7
|
-
testAccounts: true,
|
|
8
|
-
p2pEnabled: true,
|
|
9
|
-
p2pBootstrapNodes: [],
|
|
10
|
-
registryAddress: '0x12b3ebc176a1646b911391eab3760764f2e05fe3',
|
|
11
|
-
seqMinTxsPerBlock: 0,
|
|
12
|
-
seqMaxTxsPerBlock: 0
|
|
13
|
-
};
|
|
14
|
-
export async function getBootnodes(networkName) {
|
|
15
|
-
const url = `http://static.aztec.network/${networkName}/bootnodes.json`;
|
|
16
|
-
const response = await fetch(url);
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
throw new Error(`Failed to fetch basic contract addresses from ${url}`);
|
|
19
|
-
}
|
|
20
|
-
const json = await response.json();
|
|
21
|
-
return json['bootnodes'];
|
|
22
|
-
}
|
|
23
|
-
export async function getL2ChainConfig(networkName) {
|
|
24
|
-
if (networkName === 'testnet-ignition') {
|
|
25
|
-
const config = {
|
|
26
|
-
...testnetIgnitionL2ChainConfig
|
|
27
|
-
};
|
|
28
|
-
config.p2pBootstrapNodes = await getBootnodes(networkName);
|
|
29
|
-
return config;
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
function enrichVar(envVar, value) {
|
|
34
|
-
// Don't override
|
|
35
|
-
if (process.env[envVar]) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
process.env[envVar] = value;
|
|
39
|
-
}
|
|
40
|
-
export async function enrichEnvironmentWithChainConfig(networkName) {
|
|
41
|
-
const config = await getL2ChainConfig(networkName);
|
|
42
|
-
if (!config) {
|
|
43
|
-
throw new Error(`Unknown network name: ${networkName}`);
|
|
44
|
-
}
|
|
45
|
-
enrichVar('ETHEREUM_SLOT_DURATION', config.ethereumSlotDuration.toString());
|
|
46
|
-
enrichVar('AZTEC_SLOT_DURATION', config.aztecSlotDuration.toString());
|
|
47
|
-
enrichVar('AZTEC_EPOCH_DURATION', config.aztecEpochDuration.toString());
|
|
48
|
-
enrichVar('AZTEC_PROOF_SUBMISSION_WINDOW', config.aztecProofSubmissionWindow.toString());
|
|
49
|
-
enrichVar('P2P_BOOTSTRAP_NODES', config.p2pBootstrapNodes.join(','));
|
|
50
|
-
enrichVar('TEST_ACCOUNTS', config.testAccounts.toString());
|
|
51
|
-
enrichVar('P2P_ENABLED', config.p2pEnabled.toString());
|
|
52
|
-
enrichVar('L1_CHAIN_ID', config.l1ChainId.toString());
|
|
53
|
-
enrichVar('REGISTRY_CONTRACT_ADDRESS', config.registryAddress);
|
|
54
|
-
enrichVar('SEQ_MIN_TX_PER_BLOCK', config.seqMinTxsPerBlock.toString());
|
|
55
|
-
enrichVar('SEQ_MAX_TX_PER_BLOCK', config.seqMaxTxsPerBlock.toString());
|
|
56
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
2
|
-
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function startFaucet(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, log: LogFn): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=start_faucet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start_faucet.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_faucet.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,GAAG,EAAE,KAAK,iBAiBX"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Faucet, FaucetSchema, createFaucetHttpServer, faucetConfigMapping, getFaucetConfigFromEnv } from '@aztec/aztec-faucet';
|
|
2
|
-
import { extractNamespacedOptions, extractRelevantOptions } from '../util.js';
|
|
3
|
-
export async function startFaucet(options, signalHandlers, services, log) {
|
|
4
|
-
const faucetOptions = extractNamespacedOptions(options, 'faucet');
|
|
5
|
-
const config = {
|
|
6
|
-
...getFaucetConfigFromEnv(),
|
|
7
|
-
...extractRelevantOptions(options, faucetConfigMapping, 'faucet')
|
|
8
|
-
};
|
|
9
|
-
const faucet = await Faucet.create(config);
|
|
10
|
-
if (faucetOptions.apiServer) {
|
|
11
|
-
const httpServer = createFaucetHttpServer(faucet);
|
|
12
|
-
httpServer.listen(faucetOptions.apiServerPort);
|
|
13
|
-
signalHandlers.push(()=>new Promise((res)=>httpServer.close(()=>res())));
|
|
14
|
-
log(`Faucet now running on port: ${faucetOptions.apiServerPort}`);
|
|
15
|
-
}
|
|
16
|
-
services.faucet = [
|
|
17
|
-
faucet,
|
|
18
|
-
FaucetSchema
|
|
19
|
-
];
|
|
20
|
-
}
|