@aztec/aztec 5.0.0-private.20260319 → 5.0.0-rc.1
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 +1 -1
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +16 -24
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +14 -14
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +8 -8
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -1
- package/dest/cli/cmds/profile_gates.d.ts +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +21 -3
- package/dest/cli/cmds/standby.d.ts +3 -5
- package/dest/cli/cmds/standby.d.ts.map +1 -1
- package/dest/cli/cmds/standby.js +3 -3
- package/dest/cli/cmds/start_bot.d.ts +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +8 -4
- package/dest/cli/cmds/start_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +13 -40
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +5 -17
- 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 +11 -8
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +1 -1
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -1
- package/dest/cli/cmds/utils/needs_recompile.js +9 -53
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
- package/dest/cli/util.js +7 -5
- package/dest/examples/token.js +3 -3
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +3 -2
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +11 -7
- package/dest/local-network/local-network.d.ts +6 -29
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +45 -70
- package/dest/testing/cheat_codes.d.ts +18 -17
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +70 -36
- package/dest/testing/epoch_test_settler.d.ts +2 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +6 -25
- package/dest/testing/index.d.ts +1 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +0 -1
- package/package.json +34 -33
- package/scripts/add_crate.sh +11 -60
- package/scripts/aztec.sh +6 -2
- package/scripts/init.sh +5 -5
- package/scripts/new.sh +2 -2
- package/scripts/setup_workspace.sh +3 -2
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +1 -1
- package/src/cli/aztec_start_action.ts +14 -17
- package/src/cli/aztec_start_options.ts +21 -22
- package/src/cli/cmds/compile.ts +10 -9
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +20 -4
- package/src/cli/cmds/standby.ts +4 -4
- package/src/cli/cmds/start_bot.ts +9 -6
- package/src/cli/cmds/start_node.ts +20 -23
- package/src/cli/cmds/start_prover_agent.ts +5 -8
- package/src/cli/cmds/start_prover_broker.ts +10 -11
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +8 -61
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/util.ts +7 -7
- package/src/examples/token.ts +3 -3
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +12 -8
- package/src/local-network/local-network.ts +49 -80
- package/src/testing/cheat_codes.ts +89 -39
- package/src/testing/epoch_test_settler.ts +8 -31
- package/src/testing/index.ts +0 -1
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- package/dest/testing/anvil_test_watcher.d.ts +0 -42
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -181
- package/src/cli/cmds/start_archiver.ts +0 -50
- package/src/testing/anvil_test_watcher.ts +0 -210
|
@@ -3,13 +3,13 @@ import { AztecNodeService } from '@aztec/aztec-node';
|
|
|
3
3
|
import { type AztecNodeConfig } from '@aztec/aztec-node/config';
|
|
4
4
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
5
|
import { type BlobClientInterface } from '@aztec/blob-client/client';
|
|
6
|
-
import {
|
|
6
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
7
7
|
import type { LogFn } from '@aztec/foundation/log';
|
|
8
8
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
9
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import type {
|
|
10
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
11
11
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
12
|
-
import {
|
|
12
|
+
import type { Hex } from 'viem';
|
|
13
13
|
/**
|
|
14
14
|
* Function to deploy our L1 contracts to the local network L1
|
|
15
15
|
* @param aztecNodeConfig - The Aztec Node Config
|
|
@@ -18,30 +18,7 @@ import { type Hex } from 'viem';
|
|
|
18
18
|
export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, privateKey: Hex, opts?: {
|
|
19
19
|
genesisArchiveRoot?: Fr;
|
|
20
20
|
feeJuicePortalInitialBalance?: bigint;
|
|
21
|
-
}): Promise<
|
|
22
|
-
coinIssuerAddress: EthAddress;
|
|
23
|
-
feeJuiceAddress: EthAddress;
|
|
24
|
-
feeJuicePortalAddress: EthAddress;
|
|
25
|
-
governanceAddress: EthAddress;
|
|
26
|
-
governanceProposerAddress: EthAddress;
|
|
27
|
-
inboxAddress: EthAddress;
|
|
28
|
-
outboxAddress: EthAddress;
|
|
29
|
-
registryAddress: EthAddress;
|
|
30
|
-
rewardDistributorAddress: EthAddress;
|
|
31
|
-
rollupAddress: EthAddress;
|
|
32
|
-
stakingAssetAddress: EthAddress;
|
|
33
|
-
} & {
|
|
34
|
-
slashFactoryAddress?: EthAddress | undefined;
|
|
35
|
-
feeAssetHandlerAddress?: EthAddress | undefined;
|
|
36
|
-
stakingAssetHandlerAddress?: EthAddress | undefined;
|
|
37
|
-
zkPassportVerifierAddress?: EthAddress | undefined;
|
|
38
|
-
gseAddress?: EthAddress | undefined;
|
|
39
|
-
dateGatedRelayerAddress?: EthAddress | undefined;
|
|
40
|
-
} & {
|
|
41
|
-
rollupAddress: EthAddress;
|
|
42
|
-
} & Pick<import("@aztec/ethereum/l1-contract-addresses").L1ContractAddresses, "rollupAddress"> & {
|
|
43
|
-
rollupAddress: EthAddress;
|
|
44
|
-
}>;
|
|
21
|
+
}): Promise<L1ContractAddresses>;
|
|
45
22
|
/** Local network settings. */
|
|
46
23
|
export type LocalNetworkConfig = AztecNodeConfig & {
|
|
47
24
|
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
@@ -68,6 +45,6 @@ export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?
|
|
|
68
45
|
dateProvider?: DateProvider;
|
|
69
46
|
proverBroker?: ProvingJobBroker;
|
|
70
47
|
}, options?: {
|
|
71
|
-
|
|
48
|
+
genesis?: GenesisData;
|
|
72
49
|
}): Promise<AztecNodeService>;
|
|
73
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
50
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtbmV0d29yay5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xvY2FsLW5ldHdvcmsvbG9jYWwtbmV0d29yay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDckQsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFvQixNQUFNLDBCQUEwQixDQUFDO0FBQ2xGLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUU1QyxPQUFPLEVBQUUsS0FBSyxtQkFBbUIsRUFBb0IsTUFBTSwyQkFBMkIsQ0FBQztBQU12RixPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLHVDQUF1Q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FJLEdBQUU7SUFDSixTQUFTLENBQUMsRUFBRSxlQUFlLENBQUM7SUFDNUIsVUFBVSxDQUFDLEVBQUUsbUJBQW1CLENBQUM7SUFDakMsWUFBWSxDQUFDLEVBQUUsWUFBWSxDQUFDO0lBQzVCLFlBQVksQ0FBQyxFQUFFLGdCQUFnQixDQUFDO0NBQzVCLEVBQ04sT0FBTyxHQUFFO0lBQUUsT0FBTyxDQUFDLEVBQUUsV0FBVyxDQUFBO0NBQU8sNkJBY3hDIn0=
|
|
@@ -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;
|
|
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;AAMvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAoB,MAAM,yBAAyB,CAAC;AAIzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAmBhC;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,GAAG,EACf,IAAI,GAAE;IACJ,kBAAkB,CAAC,EAAE,EAAE,CAAC;IACxB,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAClC,GACL,OAAO,CAAC,mBAAmB,CAAC,CAmB9B;AAED,8BAA8B;AAC9B,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,yCAAkC,EAAE,OAAO,EAAE,KAAK;;;GAwHhG;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IACJ,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,EACN,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,WAAW,CAAA;CAAO,6BAcxC"}
|
|
@@ -6,35 +6,37 @@ import { Fr } from '@aztec/aztec.js/fields';
|
|
|
6
6
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
7
7
|
import { createBlobClient } from '@aztec/blob-client/client';
|
|
8
8
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
-
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
9
|
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
11
10
|
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
11
|
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
13
12
|
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
14
|
-
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
15
13
|
import { SecretValue } from '@aztec/foundation/config';
|
|
16
14
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
15
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
18
16
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
19
17
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
20
|
-
import { SequencerState } from '@aztec/sequencer-client';
|
|
21
18
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
19
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
22
20
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
23
21
|
import { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
24
|
-
import {
|
|
22
|
+
import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
|
|
25
23
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
26
|
-
import { createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
27
24
|
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
28
25
|
import { foundry } from 'viem/chains';
|
|
29
26
|
import { createAccountLogs } from '../cli/util.js';
|
|
30
27
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
31
|
-
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
32
|
-
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
33
28
|
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
29
|
+
import { publishStandardAuthRegistry } from './auth_registry.js';
|
|
34
30
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
35
31
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
36
32
|
const logger = createLogger('local-network');
|
|
37
|
-
|
|
33
|
+
// The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
|
|
34
|
+
// proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
|
|
35
|
+
// pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
|
|
36
|
+
// P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
|
|
37
|
+
const setupWaitOpts = {
|
|
38
|
+
waitForStatus: TxStatus.CHECKPOINTED
|
|
39
|
+
};
|
|
38
40
|
/**
|
|
39
41
|
* Function to deploy our L1 contracts to the local network L1
|
|
40
42
|
* @param aztecNodeConfig - The Aztec Node Config
|
|
@@ -49,12 +51,12 @@ const localAnvil = foundry;
|
|
|
49
51
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
50
52
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
51
53
|
aztecTargetCommitteeSize: 0,
|
|
52
|
-
|
|
54
|
+
slasherEnabled: false,
|
|
53
55
|
realVerifier: false
|
|
54
56
|
});
|
|
55
|
-
aztecNodeConfig
|
|
57
|
+
Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
|
|
56
58
|
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
57
|
-
return
|
|
59
|
+
return l1Contracts.l1ContractAddresses;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
@@ -72,13 +74,32 @@ const localAnvil = foundry;
|
|
|
72
74
|
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
73
75
|
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
74
76
|
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
77
|
+
const envConfig = getConfigEnvVars();
|
|
75
78
|
const aztecNodeConfig = {
|
|
76
|
-
...
|
|
79
|
+
...envConfig,
|
|
77
80
|
...config,
|
|
81
|
+
skipOrphanProposedBlockPruning: true,
|
|
78
82
|
txPublicSetupAllowListExtend: [
|
|
79
83
|
...tokenAllowList,
|
|
80
84
|
...config.txPublicSetupAllowListExtend ?? []
|
|
81
|
-
]
|
|
85
|
+
],
|
|
86
|
+
// The local network runs against anvil with no committee, so it defaults to the deterministic
|
|
87
|
+
// AutomineSequencer, which owns L1 time control (warps the dateProvider and L1 timestamps to slot
|
|
88
|
+
// boundaries as it builds), replacing the deleted AnvilTestWatcher. This remains true when p2p is
|
|
89
|
+
// enabled for local peer testing; local-network is not a mode for connecting to an existing network.
|
|
90
|
+
useAutomineSequencer: config.useAutomineSequencer ?? true,
|
|
91
|
+
// The AutomineSequencer owns epoch proving in the local network — it writes epoch out hashes to
|
|
92
|
+
// the L1 Outbox and advances the proven tip as checkpoints land, through the same serial queue as
|
|
93
|
+
// its builds — replacing the standalone EpochTestSettler that used to race the build loop.
|
|
94
|
+
automineEnableProveEpoch: config.automineEnableProveEpoch ?? true,
|
|
95
|
+
// Defaults for the local network / sandbox; callers (e.g. the CLI) may override. No real proving
|
|
96
|
+
// happens here — the AutomineSequencer synthetically settles epochs. Short epochs let it write out
|
|
97
|
+
// hashes quickly (so users can consume L2-to-L1 messages without a long wait), with a wider
|
|
98
|
+
// proof-submission window so the synthetic settler has headroom before the rollup would prune an
|
|
99
|
+
// unproven checkpoint.
|
|
100
|
+
realProofs: config.realProofs ?? false,
|
|
101
|
+
aztecEpochDuration: config.aztecEpochDuration ?? 4,
|
|
102
|
+
aztecProofSubmissionEpochs: config.aztecProofSubmissionEpochs ?? 2
|
|
82
103
|
};
|
|
83
104
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
84
105
|
if (aztecNodeConfig.sequencerPublisherPrivateKeys == undefined || !aztecNodeConfig.sequencerPublisherPrivateKeys.length || aztecNodeConfig.sequencerPublisherPrivateKeys[0].getValue() === NULL_KEY) {
|
|
@@ -97,7 +118,7 @@ const localAnvil = foundry;
|
|
|
97
118
|
const initialAccounts = await (async ()=>{
|
|
98
119
|
if (config.testAccounts === true || config.testAccounts === undefined) {
|
|
99
120
|
if (aztecNodeConfig.p2pEnabled) {
|
|
100
|
-
userLog(`Not setting up test accounts
|
|
121
|
+
userLog(`Not setting up test accounts when p2p is enabled`);
|
|
101
122
|
} else {
|
|
102
123
|
userLog(`Setting up test accounts`);
|
|
103
124
|
return await getInitialTestAccountsData();
|
|
@@ -116,34 +137,13 @@ const localAnvil = foundry;
|
|
|
116
137
|
] : [],
|
|
117
138
|
...prefundAddresses
|
|
118
139
|
];
|
|
119
|
-
const { genesisArchiveRoot,
|
|
140
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
120
141
|
const dateProvider = new TestDateProvider();
|
|
121
|
-
let cheatcodes;
|
|
122
|
-
let rollupAddress;
|
|
123
|
-
let watcher;
|
|
124
142
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
125
|
-
|
|
143
|
+
await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
|
|
126
144
|
genesisArchiveRoot,
|
|
127
145
|
feeJuicePortalInitialBalance: fundingNeeded
|
|
128
|
-
}));
|
|
129
|
-
const chain = aztecNodeConfig.l1RpcUrls.length > 0 ? createEthereumChain([
|
|
130
|
-
l1RpcUrl
|
|
131
|
-
], aztecNodeConfig.l1ChainId) : {
|
|
132
|
-
chainInfo: localAnvil
|
|
133
|
-
};
|
|
134
|
-
const publicClient = createPublicClient({
|
|
135
|
-
chain: chain.chainInfo,
|
|
136
|
-
transport: fallback([
|
|
137
|
-
httpViemTransport(l1RpcUrl)
|
|
138
|
-
])
|
|
139
146
|
});
|
|
140
|
-
cheatcodes = new EthCheatCodes([
|
|
141
|
-
l1RpcUrl
|
|
142
|
-
], dateProvider);
|
|
143
|
-
watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
|
|
144
|
-
watcher.setisLocalNetwork(true);
|
|
145
|
-
watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
|
|
146
|
-
await watcher.start();
|
|
147
147
|
}
|
|
148
148
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
149
149
|
// Create a local blob client client inside the local network, no http connectivity
|
|
@@ -153,29 +153,8 @@ const localAnvil = foundry;
|
|
|
153
153
|
blobClient,
|
|
154
154
|
dateProvider
|
|
155
155
|
}, {
|
|
156
|
-
|
|
156
|
+
genesis
|
|
157
157
|
});
|
|
158
|
-
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
159
|
-
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
160
|
-
// warping time out from under an in-progress block.
|
|
161
|
-
watcher?.setGetPendingTxCount(()=>node.getPendingTxCount());
|
|
162
|
-
const sequencer = node.getSequencer()?.getSequencer();
|
|
163
|
-
if (sequencer) {
|
|
164
|
-
const idleStates = new Set([
|
|
165
|
-
SequencerState.STOPPED,
|
|
166
|
-
SequencerState.STOPPING,
|
|
167
|
-
SequencerState.IDLE,
|
|
168
|
-
SequencerState.SYNCHRONIZING
|
|
169
|
-
]);
|
|
170
|
-
watcher?.setIsSequencerBuilding(()=>!idleStates.has(sequencer.getState()));
|
|
171
|
-
}
|
|
172
|
-
let epochTestSettler;
|
|
173
|
-
if (!aztecNodeConfig.p2pEnabled) {
|
|
174
|
-
epochTestSettler = new EpochTestSettler(cheatcodes, rollupAddress, node.getBlockSource(), logger.createChild('epoch-settler'), {
|
|
175
|
-
pollingIntervalMs: 200
|
|
176
|
-
});
|
|
177
|
-
await epochTestSettler.start();
|
|
178
|
-
}
|
|
179
158
|
if (initialAccounts.length) {
|
|
180
159
|
const wallet = await EmbeddedWallet.create(node, {
|
|
181
160
|
pxeConfig: {
|
|
@@ -184,18 +163,18 @@ const localAnvil = foundry;
|
|
|
184
163
|
ephemeral: true
|
|
185
164
|
});
|
|
186
165
|
userLog('Setting up funded test accounts...');
|
|
187
|
-
const accountManagers = await
|
|
166
|
+
const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
|
|
188
167
|
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
189
168
|
userLog(accLogs.join(''));
|
|
190
|
-
|
|
169
|
+
userLog('Publishing standard AuthRegistry contract...');
|
|
170
|
+
await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
|
|
171
|
+
await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
|
|
191
172
|
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
192
173
|
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
193
174
|
await wallet.stop();
|
|
194
175
|
}
|
|
195
176
|
const stop = async ()=>{
|
|
196
177
|
await node.stop();
|
|
197
|
-
await watcher?.stop();
|
|
198
|
-
await epochTestSettler?.stop();
|
|
199
178
|
};
|
|
200
179
|
return {
|
|
201
180
|
node,
|
|
@@ -207,14 +186,10 @@ const localAnvil = foundry;
|
|
|
207
186
|
* @param config - Optional Aztec node settings.
|
|
208
187
|
*/ export async function createAztecNode(config = {}, deps = {}, options = {}) {
|
|
209
188
|
// TODO(#12272): will clean this up. This is criminal.
|
|
210
|
-
|
|
189
|
+
// Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
|
|
211
190
|
const aztecNodeConfig = {
|
|
212
|
-
...
|
|
213
|
-
...config
|
|
214
|
-
l1Contracts: {
|
|
215
|
-
...l1Contracts,
|
|
216
|
-
...config.l1Contracts
|
|
217
|
-
}
|
|
191
|
+
...getConfigEnvVars(),
|
|
192
|
+
...config
|
|
218
193
|
};
|
|
219
194
|
const node = await AztecNodeService.createAndSync(aztecNodeConfig, {
|
|
220
195
|
...deps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
2
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
-
import type {
|
|
4
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { AutomineSequencer } from '@aztec/sequencer-client/automine';
|
|
4
|
+
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
5
5
|
/**
|
|
6
6
|
* A class that provides utility functions for interacting with the chain.
|
|
7
7
|
* @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
|
|
@@ -13,31 +13,32 @@ export declare class CheatCodes {
|
|
|
13
13
|
eth: EthCheatCodes;
|
|
14
14
|
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
15
15
|
rollup: RollupCheatCodes;
|
|
16
|
+
/** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
|
|
17
|
+
private automine?;
|
|
18
|
+
private logger;
|
|
16
19
|
constructor(
|
|
17
20
|
/** Cheat codes for L1.*/
|
|
18
21
|
eth: EthCheatCodes,
|
|
19
22
|
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
20
|
-
rollup: RollupCheatCodes
|
|
21
|
-
|
|
23
|
+
rollup: RollupCheatCodes,
|
|
24
|
+
/** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */
|
|
25
|
+
automine?: AutomineSequencer | undefined);
|
|
26
|
+
static create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider, automine?: AutomineSequencer): Promise<CheatCodes>;
|
|
22
27
|
/**
|
|
23
28
|
* Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
|
|
24
|
-
* the target timestamp.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
28
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
29
|
+
* the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
|
|
30
|
+
* the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
|
|
31
|
+
* @param node - The Aztec node used to force an empty block to be mined.
|
|
29
32
|
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
30
33
|
*/
|
|
31
|
-
warpL2TimeAtLeastTo(
|
|
34
|
+
warpL2TimeAtLeastTo(node: AztecNode & AztecNodeDebug, targetTimestamp: bigint | number): Promise<void>;
|
|
32
35
|
/**
|
|
33
36
|
* Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
|
|
34
|
-
* least by the duration.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
38
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
37
|
+
* least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
|
|
38
|
+
* extended to the start of the next slot so that `mineBlock()` succeeds.
|
|
39
|
+
* @param node - The Aztec node used to force an empty block to be mined.
|
|
39
40
|
* @param duration - The duration to advance time by (in seconds)
|
|
40
41
|
*/
|
|
41
|
-
warpL2TimeAtLeastBy(
|
|
42
|
+
warpL2TimeAtLeastBy(node: AztecNode & AztecNodeDebug, duration: bigint | number): Promise<void>;
|
|
42
43
|
}
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlYXRfY29kZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2NoZWF0X2NvZGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUd2RSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUF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
|
1
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import {
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
/**
|
|
4
5
|
* A class that provides utility functions for interacting with the chain.
|
|
5
6
|
* @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
|
|
@@ -8,55 +9,88 @@ import { retryUntil } from '@aztec/foundation/retry';
|
|
|
8
9
|
*/ export class CheatCodes {
|
|
9
10
|
eth;
|
|
10
11
|
rollup;
|
|
11
|
-
|
|
12
|
+
automine;
|
|
13
|
+
logger;
|
|
14
|
+
constructor(/** Cheat codes for L1.*/ eth, /** Cheat codes for the Aztec Rollup contract on L1. */ rollup, /** When wired, redirects time-warps through the AutomineSequencer queue (test-only). */ automine){
|
|
12
15
|
this.eth = eth;
|
|
13
16
|
this.rollup = rollup;
|
|
17
|
+
this.automine = automine;
|
|
18
|
+
this.logger = createLogger('aztecjs:cheat_codes');
|
|
14
19
|
}
|
|
15
|
-
static async create(rpcUrls, node, dateProvider) {
|
|
20
|
+
static async create(rpcUrls, node, dateProvider, automine) {
|
|
16
21
|
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
17
22
|
const rollupCheatCodes = new RollupCheatCodes(ethCheatCodes, await node.getNodeInfo().then((n)=>n.l1ContractAddresses));
|
|
18
|
-
return new CheatCodes(ethCheatCodes, rollupCheatCodes);
|
|
23
|
+
return new CheatCodes(ethCheatCodes, rollupCheatCodes, automine);
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
|
|
22
|
-
* the target timestamp.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
26
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
27
|
+
* the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
|
|
28
|
+
* the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
|
|
29
|
+
* @param node - The Aztec node used to force an empty block to be mined.
|
|
27
30
|
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
28
|
-
*/ async warpL2TimeAtLeastTo(
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
*/ async warpL2TimeAtLeastTo(node, targetTimestamp) {
|
|
32
|
+
const targetBigInt = BigInt(targetTimestamp);
|
|
33
|
+
const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
34
|
+
if (targetBigInt <= currentTimestamp) {
|
|
35
|
+
throw new Error(`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`);
|
|
36
|
+
}
|
|
37
|
+
// AutomineSequencer owns time control through its serial queue — delegate to keep warps atomic
|
|
38
|
+
// with respect to any in-flight build, and avoid the mineBlock-loop hack below.
|
|
39
|
+
// `warpTo` internally builds an empty L2 checkpoint, which auto-mines exactly one L1 block at
|
|
40
|
+
// the target slot boundary, so no separate `node.mineBlock()` is needed here.
|
|
41
|
+
if (this.automine) {
|
|
42
|
+
await this.automine.warpTo(Number(targetBigInt));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const currentSlot = await this.rollup.getSlot();
|
|
46
|
+
let effectiveTargetSlot = await this.rollup.getSlotAt(targetBigInt);
|
|
47
|
+
let effectiveTimestamp = await this.rollup.getTimestampForSlot(effectiveTargetSlot);
|
|
48
|
+
if (effectiveTimestamp < targetBigInt || effectiveTargetSlot <= currentSlot) {
|
|
49
|
+
const adjustedSlot = SlotNumber(Math.max(effectiveTargetSlot + 1, currentSlot + 1));
|
|
50
|
+
const adjustedTimestamp = await this.rollup.getTimestampForSlot(adjustedSlot);
|
|
51
|
+
this.logger.warn(`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} does not align with a future L2 slot boundary. ` + `Auto-adjusting to start of slot ${adjustedSlot} at timestamp ${adjustedTimestamp}.`);
|
|
52
|
+
effectiveTimestamp = adjustedTimestamp;
|
|
53
|
+
effectiveTargetSlot = adjustedSlot;
|
|
54
|
+
}
|
|
55
|
+
await this.eth.warp(effectiveTimestamp, {
|
|
32
56
|
resetBlockInterval: true
|
|
33
57
|
});
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
// The sequencer's polling loop may have a `work()` cycle in flight that captured pre-warp slot/timestamp values
|
|
59
|
+
// just before our warp landed. That cycle would mine an L2 block at the stale slot — the L1 sync prunes such a
|
|
60
|
+
// block from the canonical chain, but it lingers in local world state and the PXE will use it as the anchor for
|
|
61
|
+
// subsequent txs, leading to `expiration_timestamp` values that are already in the past relative to L1. Mine
|
|
62
|
+
// until we observe an L2 block at (or past) the post-warp slot, ensuring the next tx anchors to a fresh block.
|
|
63
|
+
const maxAttempts = 5;
|
|
64
|
+
for(let attempt = 1; attempt <= maxAttempts; attempt++){
|
|
65
|
+
await node.mineBlock();
|
|
66
|
+
const blockData = await node.getBlockData('latest');
|
|
67
|
+
const blockSlot = blockData?.header.globalVariables.slotNumber;
|
|
68
|
+
if (blockSlot !== undefined && BigInt(blockSlot) >= BigInt(effectiveTargetSlot)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.logger.warn(`warpL2TimeAtLeastTo: mined L2 block at slot ${blockSlot}, expected at least ${effectiveTargetSlot}. ` + `Retrying mineBlock (attempt ${attempt}/${maxAttempts}).`);
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`warpL2TimeAtLeastTo: failed to mine an L2 block at or past slot ${effectiveTargetSlot} after ${maxAttempts} attempts.`);
|
|
48
74
|
}
|
|
49
75
|
/**
|
|
50
76
|
* Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
|
|
51
|
-
* least by the duration.
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
55
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
77
|
+
* least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
|
|
78
|
+
* extended to the start of the next slot so that `mineBlock()` succeeds.
|
|
79
|
+
* @param node - The Aztec node used to force an empty block to be mined.
|
|
56
80
|
* @param duration - The duration to advance time by (in seconds)
|
|
57
|
-
*/ async warpL2TimeAtLeastBy(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
*/ async warpL2TimeAtLeastBy(node, duration) {
|
|
82
|
+
if (BigInt(duration) <= 0n) {
|
|
83
|
+
throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
|
|
84
|
+
}
|
|
85
|
+
// Advance relative to whichever clock leads. A live sequencer mines L2 blocks at slot boundaries that can run
|
|
86
|
+
// ahead of anvil's L1 timestamp, so basing the target on L1 alone would advance the L2 timestamp by less than
|
|
87
|
+
// `duration`. Anchoring to the latest L2 block timestamp when it leads guarantees the post-warp L2 block is at
|
|
88
|
+
// least `duration` ahead of the current one.
|
|
89
|
+
const currentL1Timestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
90
|
+
const latestBlockData = await node.getBlockData('latest');
|
|
91
|
+
const latestL2Timestamp = latestBlockData ? BigInt(latestBlockData.header.globalVariables.timestamp) : 0n;
|
|
92
|
+
const baseTimestamp = latestL2Timestamp > currentL1Timestamp ? latestL2Timestamp : currentL1Timestamp;
|
|
93
|
+
const targetTimestamp = baseTimestamp + BigInt(duration);
|
|
94
|
+
await this.warpL2TimeAtLeastTo(node, targetTimestamp);
|
|
61
95
|
}
|
|
62
96
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EthCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import {
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
4
|
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
5
5
|
export declare class EpochTestSettler {
|
|
@@ -16,4 +16,4 @@ export declare class EpochTestSettler {
|
|
|
16
16
|
stop(): Promise<void>;
|
|
17
17
|
handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean>;
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfdGVzdF9zZXR0bGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9lcG9jaF90ZXN0X3NldHRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssYUFBYSxFQUFvQixNQUFNLHNCQUFzQixDQUFDO0FBQzVFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ25FLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBR3BELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUVyRSxxQkFBYSxnQkFBZ0I7SUFPekIsT0FBTyxDQUFDLGFBQWE7SUFDckIsT0FBTyxDQUFDLEdBQUc7SUFDWCxPQUFPLENBQUMsT0FBTztJQVJqQixPQUFPLENBQUMsZ0JBQWdCLENBQW1CO0lBQzNDLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBZTtJQUVwQyxZQUNFLFVBQVUsRUFBRSxhQUFhLEVBQ3pCLGFBQWEsRUFBRSxVQUFVLEVBQ2pCLGFBQWEsRUFBRSxhQUFhLEVBQzVCLEdBQUcsRUFBRSxNQUFNLEVBQ1gsT0FBTyxFQUFFO1FBQUUsaUJBQWlCLEVBQUUsTUFBTSxDQUFDO1FBQUMsY0FBYyxDQUFDLEVBQUUsTUFBTSxDQUFBO0tBQUUsRUFHeEU7SUFFSyxLQUFLLGtCQUlWO0lBRUssSUFBSSxrQkFFVDtJQUVLLHVCQUF1QixDQUFDLEtBQUssRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQWNsRTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch_test_settler.d.ts","sourceRoot":"","sources":["../../src/testing/epoch_test_settler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"epoch_test_settler.d.ts","sourceRoot":"","sources":["../../src/testing/epoch_test_settler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAErE,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,OAAO;IARjB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAe;IAEpC,YACE,UAAU,EAAE,aAAa,EACzB,aAAa,EAAE,UAAU,EACjB,aAAa,EAAE,aAAa,EAC5B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,EAGxE;IAEK,KAAK,kBAIV;IAEK,IAAI,kBAET;IAEK,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAclE;CACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import {
|
|
2
|
+
import { settleEpochOutbox } from '@aztec/prover-client/test';
|
|
3
3
|
import { EpochMonitor } from '@aztec/prover-node';
|
|
4
|
-
import { computeEpochOutHash } from '@aztec/stdlib/messaging';
|
|
5
4
|
export class EpochTestSettler {
|
|
6
5
|
l2BlockSource;
|
|
7
6
|
log;
|
|
@@ -27,30 +26,12 @@ export class EpochTestSettler {
|
|
|
27
26
|
await this.epochMonitor?.stop();
|
|
28
27
|
}
|
|
29
28
|
async handleEpochReadyToProve(epoch) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const lastCheckpoint = await settleEpochOutbox({
|
|
30
|
+
rollupCheatCodes: this.rollupCheatCodes,
|
|
31
|
+
l2BlockSource: this.l2BlockSource,
|
|
32
|
+
epoch,
|
|
33
|
+
log: this.log
|
|
34
34
|
});
|
|
35
|
-
const messagesInEpoch = [];
|
|
36
|
-
let previousSlotNumber = SlotNumber.ZERO;
|
|
37
|
-
let checkpointIndex = -1;
|
|
38
|
-
for (const block of blocks){
|
|
39
|
-
const slotNumber = block.header.globalVariables.slotNumber;
|
|
40
|
-
if (slotNumber !== previousSlotNumber) {
|
|
41
|
-
checkpointIndex++;
|
|
42
|
-
messagesInEpoch[checkpointIndex] = [];
|
|
43
|
-
previousSlotNumber = slotNumber;
|
|
44
|
-
}
|
|
45
|
-
messagesInEpoch[checkpointIndex].push(block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs));
|
|
46
|
-
}
|
|
47
|
-
const outHash = computeEpochOutHash(messagesInEpoch);
|
|
48
|
-
if (!outHash.isZero()) {
|
|
49
|
-
await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
|
|
50
|
-
} else {
|
|
51
|
-
this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
|
|
52
|
-
}
|
|
53
|
-
const lastCheckpoint = checkpointedBlocks.at(-1)?.checkpointNumber;
|
|
54
35
|
if (lastCheckpoint !== undefined) {
|
|
55
36
|
await this.rollupCheatCodes.markAsProven(lastCheckpoint);
|
|
56
37
|
} else {
|
package/dest/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { AnvilTestWatcher } from './anvil_test_watcher.js';
|
|
2
1
|
export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
3
2
|
export { CheatCodes } from './cheat_codes.js';
|
|
4
3
|
export { EpochTestSettler } from './epoch_test_settler.js';
|
|
5
4
|
export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0aW5nL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDOUMsT0FBTyxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDM0QsT0FBTyxFQUFFLDZCQUE2QixFQUFFLE1BQU0sMEJBQTBCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dest/testing/index.js
CHANGED