@aztec/end-to-end 0.0.0-test.1 → 0.0.1-commit.5476d83
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/bench/client_flows/benchmark.d.ts +61 -0
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/benchmark.js +261 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +80 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +334 -0
- package/dest/bench/client_flows/config.d.ts +14 -0
- package/dest/bench/client_flows/config.d.ts.map +1 -0
- package/dest/bench/client_flows/config.js +106 -0
- package/dest/bench/client_flows/data_extractor.d.ts +2 -0
- package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
- package/dest/bench/client_flows/data_extractor.js +77 -0
- package/dest/bench/utils.d.ts +12 -38
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +26 -66
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +21 -13
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +19 -25
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +50 -70
- package/dest/e2e_deploy_contract/deploy_test.d.ts +16 -8
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +13 -19
- package/dest/e2e_epochs/epochs_test.d.ts +59 -18
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +226 -44
- package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/e2e_fees/bridging_race.notest.js +63 -0
- package/dest/e2e_fees/fees_test.d.ts +21 -10
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +103 -109
- package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/e2e_l1_publisher/write_json.js +58 -0
- package/dest/e2e_multi_validator/utils.d.ts +12 -0
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
- package/dest/e2e_multi_validator/utils.js +214 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +10 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +24 -20
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +139 -0
- package/dest/e2e_p2p/p2p_network.d.ts +275 -23
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +184 -131
- package/dest/e2e_p2p/shared.d.ts +43 -7
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +164 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +12 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +50 -26
- package/dest/fixtures/e2e_prover_test.d.ts +63 -0
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +104 -105
- package/dest/fixtures/fixtures.d.ts +6 -7
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- package/dest/fixtures/get_acvm_config.d.ts +2 -2
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- package/dest/fixtures/get_bb_config.d.ts +2 -2
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/index.d.ts +1 -1
- package/dest/fixtures/l1_to_l2_messaging.d.ts +9 -6
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
- package/dest/fixtures/l1_to_l2_messaging.js +44 -18
- package/dest/fixtures/logging.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts +476 -5
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +4 -4
- package/dest/fixtures/setup_p2p_test.d.ts +15 -14
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +81 -21
- package/dest/fixtures/snapshot_manager.d.ts +17 -9
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +147 -121
- package/dest/fixtures/token_utils.d.ts +10 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +28 -12
- package/dest/fixtures/utils.d.ts +524 -40
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -369
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- package/dest/fixtures/with_telemetry_utils.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts +2 -2
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +39 -34
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +104 -50
- package/dest/shared/gas_portal_test_harness.d.ts +29 -31
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +51 -30
- package/dest/shared/index.d.ts +1 -1
- package/dest/shared/jest_setup.d.ts +1 -1
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +6 -4
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +14 -12
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +146 -116
- package/dest/simulators/index.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts +7 -11
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +15 -16
- package/dest/simulators/token_simulator.d.ts +6 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +16 -13
- package/dest/spartan/setup_test_wallets.d.ts +26 -11
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +201 -58
- package/dest/spartan/utils.d.ts +118 -313
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +472 -135
- package/package.json +65 -58
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +447 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +89 -0
- package/src/bench/utils.ts +22 -76
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +65 -106
- package/src/e2e_deploy_contract/deploy_test.ts +24 -39
- package/src/e2e_epochs/epochs_test.ts +276 -55
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +142 -138
- package/src/e2e_l1_publisher/write_json.ts +77 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +29 -19
- package/src/e2e_p2p/inactivity_slash_test.ts +182 -0
- package/src/e2e_p2p/p2p_network.ts +279 -169
- package/src/e2e_p2p/shared.ts +247 -29
- package/src/e2e_token_contract/token_contract_test.ts +43 -39
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +107 -152
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +3 -11
- package/src/fixtures/get_bb_config.ts +18 -13
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +6 -7
- package/src/fixtures/setup_p2p_test.ts +126 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +32 -15
- package/src/fixtures/utils.ts +580 -434
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +7 -15
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +108 -79
- package/src/shared/gas_portal_test_harness.ts +59 -50
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +181 -184
- package/src/simulators/lending_simulator.ts +14 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +251 -93
- package/src/spartan/utils.ts +536 -136
- package/dest/e2e_prover/e2e_prover_test.d.ts +0 -56
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
- package/dest/sample-dapp/connect.js +0 -12
- package/dest/sample-dapp/contracts.js +0 -10
- package/dest/sample-dapp/deploy.js +0 -35
- package/dest/sample-dapp/index.js +0 -98
- package/src/sample-dapp/connect.mjs +0 -16
- package/src/sample-dapp/contracts.mjs +0 -14
- package/src/sample-dapp/deploy.mjs +0 -40
- package/src/sample-dapp/index.mjs +0 -128
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { getTimestampRangeForEpoch } from '@aztec/aztec.js/block';
|
|
3
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
4
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
6
|
+
import { MerkleTreeId } from '@aztec/aztec.js/trees';
|
|
7
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { EpochCache } from '@aztec/epoch-cache';
|
|
9
|
+
import { DefaultL1ContractsConfig, type ExtendedViemWalletClient, createExtendedL1Client } from '@aztec/ethereum';
|
|
4
10
|
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
-
import { DelayedTxUtils, type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/test';
|
|
11
|
+
import { ChainMonitor, DelayedTxUtils, type Delayer, waitUntilL1Timestamp, withDelayer } from '@aztec/ethereum/test';
|
|
12
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
13
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
6
14
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
7
15
|
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
8
|
-
import {
|
|
16
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
17
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
18
|
+
import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
19
|
+
import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
20
|
+
import { ProverNode, type ProverNodeConfig, ProverNodePublisher } from '@aztec/prover-node';
|
|
9
21
|
import type { TestProverNode } from '@aztec/prover-node/test';
|
|
10
|
-
import
|
|
22
|
+
import {
|
|
23
|
+
type SequencerClient,
|
|
24
|
+
type SequencerEvents,
|
|
25
|
+
type SequencerPublisher,
|
|
26
|
+
SequencerState,
|
|
27
|
+
} from '@aztec/sequencer-client';
|
|
11
28
|
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
12
|
-
import type
|
|
13
|
-
import type
|
|
14
|
-
import {
|
|
29
|
+
import { EthAddress, type L2BlockNumber } from '@aztec/stdlib/block';
|
|
30
|
+
import { type L1RollupConstants, getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
31
|
+
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
15
32
|
|
|
16
33
|
import { join } from 'path';
|
|
17
|
-
import type { Hex
|
|
34
|
+
import type { Hex } from 'viem';
|
|
35
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
18
36
|
|
|
19
37
|
import {
|
|
20
38
|
type EndToEndContext,
|
|
@@ -24,15 +42,20 @@ import {
|
|
|
24
42
|
setup,
|
|
25
43
|
} from '../fixtures/utils.js';
|
|
26
44
|
|
|
27
|
-
// This can be lowered to as much as 2s in non-CI
|
|
28
|
-
export const L1_BLOCK_TIME_IN_S = process.env.L1_BLOCK_TIME ? parseInt(process.env.L1_BLOCK_TIME) : 8;
|
|
29
|
-
export const EPOCH_DURATION_IN_L2_SLOTS = 4;
|
|
30
|
-
export const L2_SLOT_DURATION_IN_L1_SLOTS = 2;
|
|
31
45
|
export const WORLD_STATE_BLOCK_HISTORY = 2;
|
|
32
46
|
export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
|
|
33
47
|
export const ARCHIVER_POLL_INTERVAL = 50;
|
|
48
|
+
export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
|
|
49
|
+
|
|
50
|
+
export type EpochsTestOpts = Partial<SetupOptions> & { numberOfAccounts?: number };
|
|
34
51
|
|
|
35
|
-
export type
|
|
52
|
+
export type TrackedSequencerEvent = {
|
|
53
|
+
[K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
|
|
54
|
+
type: K;
|
|
55
|
+
sequencerIndex: number;
|
|
56
|
+
validator: EthAddress;
|
|
57
|
+
};
|
|
58
|
+
}[keyof SequencerEvents];
|
|
36
59
|
|
|
37
60
|
/**
|
|
38
61
|
* Tests building of epochs using fast block times and short epochs.
|
|
@@ -41,46 +64,72 @@ export type EpochsTestOpts = Partial<Pick<SetupOptions, 'startProverNode'>>;
|
|
|
41
64
|
*/
|
|
42
65
|
export class EpochsTestContext {
|
|
43
66
|
public context!: EndToEndContext;
|
|
44
|
-
public l1Client!:
|
|
67
|
+
public l1Client!: ExtendedViemWalletClient;
|
|
45
68
|
public rollup!: RollupContract;
|
|
46
69
|
public constants!: L1RollupConstants;
|
|
47
70
|
public logger!: Logger;
|
|
48
71
|
public monitor!: ChainMonitor;
|
|
72
|
+
public epochCache!: EpochCache;
|
|
49
73
|
public proverDelayer!: Delayer;
|
|
50
74
|
public sequencerDelayer!: Delayer;
|
|
51
75
|
|
|
52
76
|
public proverNodes: ProverNode[] = [];
|
|
53
77
|
public nodes: AztecNodeService[] = [];
|
|
54
78
|
|
|
79
|
+
public epochDuration!: number;
|
|
80
|
+
|
|
81
|
+
public L1_BLOCK_TIME_IN_S!: number;
|
|
82
|
+
public L2_SLOT_DURATION_IN_S!: number;
|
|
83
|
+
|
|
55
84
|
public static async setup(opts: EpochsTestOpts = {}) {
|
|
56
85
|
const test = new EpochsTestContext();
|
|
57
86
|
await test.setup(opts);
|
|
58
87
|
return test;
|
|
59
88
|
}
|
|
60
89
|
|
|
90
|
+
public static getSlotDurations(opts: EpochsTestOpts = {}) {
|
|
91
|
+
const envEthereumSlotDuration = process.env.L1_BLOCK_TIME
|
|
92
|
+
? parseInt(process.env.L1_BLOCK_TIME)
|
|
93
|
+
: DEFAULT_L1_BLOCK_TIME;
|
|
94
|
+
const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
|
|
95
|
+
const aztecSlotDuration = opts.aztecSlotDuration ?? ethereumSlotDuration * 2;
|
|
96
|
+
const aztecEpochDuration = opts.aztecEpochDuration ?? 6;
|
|
97
|
+
const aztecProofSubmissionEpochs = opts.aztecProofSubmissionEpochs ?? 1;
|
|
98
|
+
return { ethereumSlotDuration, aztecSlotDuration, aztecEpochDuration, aztecProofSubmissionEpochs };
|
|
99
|
+
}
|
|
100
|
+
|
|
61
101
|
public async setup(opts: EpochsTestOpts = {}) {
|
|
102
|
+
const { ethereumSlotDuration, aztecSlotDuration, aztecEpochDuration, aztecProofSubmissionEpochs } =
|
|
103
|
+
EpochsTestContext.getSlotDurations(opts);
|
|
104
|
+
|
|
105
|
+
this.L1_BLOCK_TIME_IN_S = ethereumSlotDuration;
|
|
106
|
+
this.L2_SLOT_DURATION_IN_S = aztecSlotDuration;
|
|
107
|
+
|
|
62
108
|
// Set up system without any account nor protocol contracts
|
|
63
109
|
// and with faster block times and shorter epochs.
|
|
64
|
-
const context = await setup(0, {
|
|
110
|
+
const context = await setup(opts.numberOfAccounts ?? 0, {
|
|
111
|
+
automineL1Setup: true,
|
|
65
112
|
checkIntervalMs: 50,
|
|
66
113
|
archiverPollingIntervalMS: ARCHIVER_POLL_INTERVAL,
|
|
67
114
|
worldStateBlockCheckIntervalMS: WORLD_STATE_BLOCK_CHECK_INTERVAL,
|
|
68
115
|
skipProtocolContracts: true,
|
|
69
116
|
salt: 1,
|
|
70
|
-
aztecEpochDuration
|
|
71
|
-
aztecSlotDuration
|
|
72
|
-
ethereumSlotDuration
|
|
73
|
-
|
|
117
|
+
aztecEpochDuration,
|
|
118
|
+
aztecSlotDuration,
|
|
119
|
+
ethereumSlotDuration,
|
|
120
|
+
aztecProofSubmissionEpochs,
|
|
121
|
+
aztecTargetCommitteeSize: opts.initialValidators?.length ?? 0,
|
|
74
122
|
minTxsPerBlock: 0,
|
|
75
123
|
realProofs: false,
|
|
76
124
|
startProverNode: true,
|
|
125
|
+
proverTestDelayMs: opts.proverTestDelayMs ?? 0,
|
|
77
126
|
// We use numeric incremental prover ids for simplicity, but we can switch to
|
|
78
127
|
// using the prover's eth address if the proverId is used for something in the rollup contract
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// but not so much to hang the sequencer and timeout the teardown
|
|
82
|
-
txPropagationMaxQueryAttempts: 12,
|
|
128
|
+
// Use numeric EthAddress for deterministic prover id
|
|
129
|
+
proverId: EthAddress.fromNumber(1),
|
|
83
130
|
worldStateBlockHistory: WORLD_STATE_BLOCK_HISTORY,
|
|
131
|
+
exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,
|
|
132
|
+
slasherFlavor: 'none',
|
|
84
133
|
...opts,
|
|
85
134
|
});
|
|
86
135
|
|
|
@@ -88,32 +137,38 @@ export class EpochsTestContext {
|
|
|
88
137
|
this.proverNodes = context.proverNode ? [context.proverNode] : [];
|
|
89
138
|
this.nodes = context.aztecNode ? [context.aztecNode as AztecNodeService] : [];
|
|
90
139
|
this.logger = context.logger;
|
|
91
|
-
this.l1Client = context.deployL1ContractsValues.
|
|
140
|
+
this.l1Client = context.deployL1ContractsValues.l1Client;
|
|
92
141
|
this.rollup = RollupContract.getFromConfig(context.config);
|
|
142
|
+
this.epochCache = await EpochCache.create(this.rollup, context.config, { dateProvider: context.dateProvider });
|
|
93
143
|
|
|
94
144
|
// Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
|
|
95
|
-
this.monitor = new ChainMonitor(this.rollup, this.logger).start();
|
|
145
|
+
this.monitor = new ChainMonitor(this.rollup, context.dateProvider, this.logger).start();
|
|
96
146
|
|
|
97
147
|
// This is hideous.
|
|
98
148
|
// We ought to have a definite reference to the l1TxUtils that we're using in both places, provided by the test context.
|
|
99
149
|
this.proverDelayer = context.proverNode
|
|
100
150
|
? (((context.proverNode as TestProverNode).publisher as ProverNodePublisher).l1TxUtils as DelayedTxUtils).delayer!
|
|
101
151
|
: undefined!;
|
|
102
|
-
this.sequencerDelayer =
|
|
103
|
-
(
|
|
104
|
-
|
|
152
|
+
this.sequencerDelayer = context.sequencer
|
|
153
|
+
? (
|
|
154
|
+
((context.sequencer as TestSequencerClient).sequencer.publisher as SequencerPublisher)
|
|
155
|
+
.l1TxUtils as DelayedTxUtils
|
|
156
|
+
).delayer!
|
|
157
|
+
: undefined!;
|
|
105
158
|
|
|
106
|
-
if ((context.proverNode && !this.proverDelayer) || !this.sequencerDelayer) {
|
|
159
|
+
if ((context.proverNode && !this.proverDelayer) || (context.sequencer && !this.sequencerDelayer)) {
|
|
107
160
|
throw new Error(`Could not find prover or sequencer delayer`);
|
|
108
161
|
}
|
|
109
162
|
|
|
110
163
|
// Constants used for time calculation
|
|
164
|
+
this.epochDuration = aztecEpochDuration;
|
|
111
165
|
this.constants = {
|
|
112
|
-
epochDuration:
|
|
113
|
-
slotDuration:
|
|
166
|
+
epochDuration: aztecEpochDuration,
|
|
167
|
+
slotDuration: aztecSlotDuration,
|
|
114
168
|
l1StartBlock: await this.rollup.getL1StartBlock(),
|
|
115
169
|
l1GenesisTime: await this.rollup.getL1GenesisTime(),
|
|
116
|
-
ethereumSlotDuration
|
|
170
|
+
ethereumSlotDuration,
|
|
171
|
+
proofSubmissionEpochs: Number(await this.rollup.getProofSubmissionEpochs()),
|
|
117
172
|
};
|
|
118
173
|
|
|
119
174
|
this.logger.info(
|
|
@@ -122,38 +177,98 @@ export class EpochsTestContext {
|
|
|
122
177
|
}
|
|
123
178
|
|
|
124
179
|
public async teardown() {
|
|
125
|
-
this.monitor.stop();
|
|
126
|
-
await Promise.all(this.proverNodes.map(node => node.
|
|
127
|
-
await Promise.all(this.nodes.map(node => node.
|
|
180
|
+
await this.monitor.stop();
|
|
181
|
+
await Promise.all(this.proverNodes.map(node => tryStop(node, this.logger)));
|
|
182
|
+
await Promise.all(this.nodes.map(node => tryStop(node, this.logger)));
|
|
128
183
|
await this.context.teardown();
|
|
129
184
|
}
|
|
130
185
|
|
|
131
|
-
public async createProverNode() {
|
|
186
|
+
public async createProverNode(opts: { dontStart?: boolean } & Partial<ProverNodeConfig> = {}) {
|
|
132
187
|
this.logger.warn('Creating and syncing a simulated prover node...');
|
|
133
188
|
const proverNodePrivateKey = this.getNextPrivateKey();
|
|
134
189
|
const suffix = (this.proverNodes.length + 1).toString();
|
|
135
190
|
const proverNode = await withLogNameSuffix(suffix, () =>
|
|
136
191
|
createAndSyncProverNode(
|
|
137
192
|
proverNodePrivateKey,
|
|
138
|
-
{ ...this.context.config
|
|
193
|
+
{ ...this.context.config },
|
|
194
|
+
{
|
|
195
|
+
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
|
|
196
|
+
proverId: EthAddress.fromNumber(parseInt(suffix, 10)),
|
|
197
|
+
dontStart: opts.dontStart,
|
|
198
|
+
...opts,
|
|
199
|
+
},
|
|
139
200
|
this.context.aztecNode,
|
|
140
|
-
|
|
201
|
+
undefined,
|
|
202
|
+
{ dateProvider: this.context.dateProvider },
|
|
141
203
|
),
|
|
142
204
|
);
|
|
143
205
|
this.proverNodes.push(proverNode);
|
|
144
206
|
return proverNode;
|
|
145
207
|
}
|
|
146
208
|
|
|
147
|
-
public
|
|
209
|
+
public createNonValidatorNode(opts: Partial<AztecNodeConfig> = {}) {
|
|
148
210
|
this.logger.warn('Creating and syncing a node without a validator...');
|
|
211
|
+
return this.createNode({ ...opts, disableValidator: true });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public createValidatorNode(
|
|
215
|
+
privateKeys: `0x${string}`[],
|
|
216
|
+
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
217
|
+
) {
|
|
218
|
+
this.logger.warn('Creating and syncing a validator node...');
|
|
219
|
+
return this.createNode({ ...opts, disableValidator: false, validatorPrivateKeys: new SecretValue(privateKeys) });
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private async createNode(
|
|
223
|
+
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
224
|
+
) {
|
|
149
225
|
const suffix = (this.nodes.length + 1).toString();
|
|
226
|
+
const { mockGossipSubNetwork } = this.context;
|
|
227
|
+
const resolvedConfig = { ...this.context.config, ...opts };
|
|
228
|
+
const p2pEnabled = resolvedConfig.p2pEnabled || mockGossipSubNetwork !== undefined;
|
|
229
|
+
const p2pIp = resolvedConfig.p2pIp ?? (p2pEnabled ? '127.0.0.1' : undefined);
|
|
150
230
|
const node = await withLogNameSuffix(suffix, () =>
|
|
151
|
-
AztecNodeService.createAndSync(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
231
|
+
AztecNodeService.createAndSync(
|
|
232
|
+
{
|
|
233
|
+
...resolvedConfig,
|
|
234
|
+
dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')),
|
|
235
|
+
validatorPrivateKeys: opts.validatorPrivateKeys ?? new SecretValue([]),
|
|
236
|
+
p2pEnabled,
|
|
237
|
+
p2pIp,
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
dateProvider: this.context.dateProvider,
|
|
241
|
+
p2pClientDeps: {
|
|
242
|
+
p2pServiceFactory: mockGossipSubNetwork ? getMockPubSubP2PServiceFactory(mockGossipSubNetwork) : undefined,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
prefilledPublicData: this.context.prefilledPublicData,
|
|
247
|
+
...opts,
|
|
248
|
+
},
|
|
249
|
+
),
|
|
156
250
|
);
|
|
251
|
+
|
|
252
|
+
// REFACTOR: We're getting too much into the internals of the sequencer here.
|
|
253
|
+
// We should have a single method for constructing an aztec node that returns a TestAztecNodeService
|
|
254
|
+
// which directly exposes the delayer and sets any test config.
|
|
255
|
+
if (opts.txDelayerMaxInclusionTimeIntoSlot !== undefined) {
|
|
256
|
+
this.logger.info(
|
|
257
|
+
`Setting tx delayer max inclusion time into slot to ${opts.txDelayerMaxInclusionTimeIntoSlot} seconds`,
|
|
258
|
+
);
|
|
259
|
+
// Here we reach into the sequencer and hook in a tx delayer. The problem is that the sequencer's l1 utils only uses a public client, not a wallet.
|
|
260
|
+
// The delayer needs a wallet (a client that can sign), so we have to create one here.
|
|
261
|
+
const l1Client = createExtendedL1Client(
|
|
262
|
+
resolvedConfig.l1RpcUrls!,
|
|
263
|
+
resolvedConfig.publisherPrivateKeys![0]!.getValue(),
|
|
264
|
+
);
|
|
265
|
+
const sequencer = node.getSequencer() as TestSequencerClient;
|
|
266
|
+
const publisher = sequencer.sequencer.publisher;
|
|
267
|
+
const delayed = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, this.L1_BLOCK_TIME_IN_S, l1Client);
|
|
268
|
+
delayed.delayer!.setMaxInclusionTimeIntoSlot(opts.txDelayerMaxInclusionTimeIntoSlot);
|
|
269
|
+
publisher.l1TxUtils = delayed;
|
|
270
|
+
}
|
|
271
|
+
|
|
157
272
|
this.nodes.push(node);
|
|
158
273
|
return node;
|
|
159
274
|
}
|
|
@@ -165,16 +280,21 @@ export class EpochsTestContext {
|
|
|
165
280
|
|
|
166
281
|
/** Waits until the epoch begins (ie until the immediately previous L1 block is mined). */
|
|
167
282
|
public async waitUntilEpochStarts(epoch: number) {
|
|
168
|
-
const [start] = getTimestampRangeForEpoch(
|
|
283
|
+
const [start] = getTimestampRangeForEpoch(EpochNumber(epoch), this.constants);
|
|
169
284
|
this.logger.info(`Waiting until L1 timestamp ${start} is reached as the start of epoch ${epoch}`);
|
|
170
|
-
await waitUntilL1Timestamp(
|
|
285
|
+
await waitUntilL1Timestamp(
|
|
286
|
+
this.l1Client,
|
|
287
|
+
start - BigInt(this.L1_BLOCK_TIME_IN_S),
|
|
288
|
+
undefined,
|
|
289
|
+
30 * this.epochDuration,
|
|
290
|
+
);
|
|
171
291
|
return start;
|
|
172
292
|
}
|
|
173
293
|
|
|
174
294
|
/** Waits until the given L2 block number is mined. */
|
|
175
295
|
public async waitUntilL2BlockNumber(target: number, timeout = 60) {
|
|
176
296
|
await retryUntil(
|
|
177
|
-
() => Promise.resolve(target
|
|
297
|
+
() => Promise.resolve(target <= this.monitor.checkpointNumber),
|
|
178
298
|
`Wait until L2 block ${target}`,
|
|
179
299
|
timeout,
|
|
180
300
|
0.1,
|
|
@@ -184,34 +304,135 @@ export class EpochsTestContext {
|
|
|
184
304
|
/** Waits until the given L2 block number is marked as proven. */
|
|
185
305
|
public async waitUntilProvenL2BlockNumber(t: number, timeout = 60) {
|
|
186
306
|
await retryUntil(
|
|
187
|
-
() => Promise.resolve(t
|
|
307
|
+
() => Promise.resolve(t <= this.monitor.provenCheckpointNumber),
|
|
188
308
|
`Wait proven L2 block ${t}`,
|
|
189
309
|
timeout,
|
|
190
310
|
0.1,
|
|
191
311
|
);
|
|
312
|
+
return this.monitor.provenCheckpointNumber;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Waits until the last slot of the proof submission window for a given epoch. */
|
|
316
|
+
public async waitUntilLastSlotOfProofSubmissionWindow(epochNumber: number | bigint) {
|
|
317
|
+
const deadline = getProofSubmissionDeadlineTimestamp(EpochNumber.fromBigInt(BigInt(epochNumber)), this.constants);
|
|
318
|
+
const oneSlotBefore = deadline - BigInt(this.constants.slotDuration);
|
|
319
|
+
const date = new Date(Number(oneSlotBefore) * 1000);
|
|
320
|
+
this.logger.info(`Waiting until last slot of submission window for epoch ${epochNumber} at ${date}`, {
|
|
321
|
+
oneSlotBefore,
|
|
322
|
+
});
|
|
323
|
+
await waitUntilL1Timestamp(this.l1Client, oneSlotBefore);
|
|
192
324
|
}
|
|
193
325
|
|
|
194
326
|
/** Waits for the aztec node to sync to the target block number. */
|
|
195
|
-
public async waitForNodeToSync(blockNumber: number, type: '
|
|
327
|
+
public async waitForNodeToSync(blockNumber: number, type: 'proven' | 'finalized' | 'historic') {
|
|
196
328
|
const waitTime = ARCHIVER_POLL_INTERVAL + WORLD_STATE_BLOCK_CHECK_INTERVAL;
|
|
197
329
|
let synched = false;
|
|
198
330
|
while (!synched) {
|
|
199
331
|
await sleep(waitTime);
|
|
200
|
-
const syncState = await
|
|
201
|
-
|
|
202
|
-
|
|
332
|
+
const [syncState, tips] = await Promise.all([
|
|
333
|
+
this.context.aztecNode.getWorldStateSyncStatus(),
|
|
334
|
+
await this.context.aztecNode.getL2Tips(),
|
|
335
|
+
]);
|
|
336
|
+
this.logger.info(`Wait for node synch ${blockNumber} ${type}`, { blockNumber, type, syncState, tips });
|
|
337
|
+
if (type === 'proven') {
|
|
338
|
+
synched = tips.proven.number >= blockNumber && syncState.latestBlockNumber >= blockNumber;
|
|
339
|
+
} else if (type === 'finalized') {
|
|
340
|
+
synched = syncState.finalizedBlockNumber >= blockNumber;
|
|
203
341
|
} else {
|
|
204
342
|
synched = syncState.oldestHistoricBlockNumber >= blockNumber;
|
|
205
343
|
}
|
|
206
344
|
}
|
|
207
345
|
}
|
|
208
346
|
|
|
347
|
+
/** Registers the SpamContract on the given wallet. */
|
|
348
|
+
public async registerSpamContract(wallet: Wallet, salt = Fr.ZERO) {
|
|
349
|
+
const instance = await getContractInstanceFromInstantiationParams(SpamContract.artifact, {
|
|
350
|
+
constructorArgs: [],
|
|
351
|
+
constructorArtifact: undefined,
|
|
352
|
+
salt,
|
|
353
|
+
publicKeys: undefined,
|
|
354
|
+
deployer: undefined,
|
|
355
|
+
});
|
|
356
|
+
await wallet.registerContract(instance, SpamContract.artifact);
|
|
357
|
+
return SpamContract.at(instance.address, wallet);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** Creates an L1 client using a fresh account with funds from anvil, with a tx delayer already set up. */
|
|
361
|
+
public async createL1Client() {
|
|
362
|
+
const { client, delayer } = withDelayer(
|
|
363
|
+
createExtendedL1Client(
|
|
364
|
+
[...this.l1Client.chain.rpcUrls.default.http],
|
|
365
|
+
privateKeyToAccount(this.getNextPrivateKey()),
|
|
366
|
+
this.l1Client.chain,
|
|
367
|
+
),
|
|
368
|
+
this.context.dateProvider!,
|
|
369
|
+
{ ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S },
|
|
370
|
+
);
|
|
371
|
+
expect(await client.getBalance({ address: client.account.address })).toBeGreaterThan(0n);
|
|
372
|
+
return { client, delayer };
|
|
373
|
+
}
|
|
374
|
+
|
|
209
375
|
/** Verifies whether the given block number is found on the aztec node. */
|
|
210
376
|
public async verifyHistoricBlock(blockNumber: L2BlockNumber, expectedSuccess: boolean) {
|
|
377
|
+
// We use `findLeavesIndexes` here, but could use any function that queries the world-state
|
|
378
|
+
// at a particular block, so we know whether that historic block is available or has been
|
|
379
|
+
// pruned. Note that `getBlock` would not work here, since it only hits the archiver.
|
|
211
380
|
const result = await this.context.aztecNode
|
|
212
|
-
.
|
|
381
|
+
.findLeavesIndexes(blockNumber, MerkleTreeId.NULLIFIER_TREE, [Fr.ZERO])
|
|
213
382
|
.then(_ => true)
|
|
214
383
|
.catch(_ => false);
|
|
215
384
|
expect(result).toBe(expectedSuccess);
|
|
216
385
|
}
|
|
386
|
+
|
|
387
|
+
public watchSequencerEvents(
|
|
388
|
+
sequencers: SequencerClient[],
|
|
389
|
+
getMetadata: (i: number) => Record<string, any> = () => ({}),
|
|
390
|
+
) {
|
|
391
|
+
const stateChanges: TrackedSequencerEvent[] = [];
|
|
392
|
+
const failEvents: TrackedSequencerEvent[] = [];
|
|
393
|
+
|
|
394
|
+
// Note we do not include the 'tx-count-check-failed' event here, since it is fine if we dont build
|
|
395
|
+
// due to lack of txs available.
|
|
396
|
+
const failEventsKeys: (keyof SequencerEvents)[] = [
|
|
397
|
+
'block-build-failed',
|
|
398
|
+
'block-publish-failed',
|
|
399
|
+
'proposer-rollup-check-failed',
|
|
400
|
+
];
|
|
401
|
+
|
|
402
|
+
const makeEvent = (
|
|
403
|
+
i: number,
|
|
404
|
+
eventName: keyof SequencerEvents,
|
|
405
|
+
args: Parameters<SequencerEvents[keyof SequencerEvents]>[0],
|
|
406
|
+
) =>
|
|
407
|
+
({
|
|
408
|
+
...args,
|
|
409
|
+
type: eventName,
|
|
410
|
+
sequencerIndex: i + 2,
|
|
411
|
+
...getMetadata(i),
|
|
412
|
+
}) as TrackedSequencerEvent;
|
|
413
|
+
|
|
414
|
+
sequencers.forEach((sequencer, i) => {
|
|
415
|
+
const sequencerIndex = i + 2;
|
|
416
|
+
sequencer.getSequencer().on('state-changed', (args: Parameters<SequencerEvents['state-changed']>[0]) => {
|
|
417
|
+
const noisyStates = [SequencerState.IDLE, SequencerState.PROPOSER_CHECK, SequencerState.SYNCHRONIZING];
|
|
418
|
+
if (!noisyStates.includes(args.newState)) {
|
|
419
|
+
const evt = makeEvent(i, 'state-changed', args);
|
|
420
|
+
stateChanges.push(evt);
|
|
421
|
+
this.logger.verbose(
|
|
422
|
+
`Sequencer ${sequencerIndex} transitioned from state ${args.oldState} to state ${args.newState}`,
|
|
423
|
+
evt,
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
failEventsKeys.forEach(eventName => {
|
|
428
|
+
sequencer.getSequencer().on(eventName, (args: Parameters<SequencerEvents[typeof eventName]>[0]) => {
|
|
429
|
+
const evt = makeEvent(i, eventName, args);
|
|
430
|
+
failEvents.push(evt);
|
|
431
|
+
this.logger.error(`Failed event ${eventName} from sequencer ${sequencerIndex}`, undefined, evt);
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
return { failEvents, stateChanges };
|
|
437
|
+
}
|
|
217
438
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import { Fq } from '@aztec/foundation/fields';
|
|
5
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
6
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
8
|
+
|
|
9
|
+
import { jest } from '@jest/globals';
|
|
10
|
+
import type { Hex } from 'viem';
|
|
11
|
+
|
|
12
|
+
import { FeesTest } from './fees_test.js';
|
|
13
|
+
|
|
14
|
+
jest.setTimeout(300_000);
|
|
15
|
+
|
|
16
|
+
// Regression for https://github.com/AztecProtocol/aztec-packages/issues/12366
|
|
17
|
+
// Similar to e2e_fees/account_init but with no automine
|
|
18
|
+
describe('e2e_fees bridging_race', () => {
|
|
19
|
+
const ETHEREUM_SLOT_DURATION = 4;
|
|
20
|
+
const AZTEC_SLOT_DURATION = ETHEREUM_SLOT_DURATION * 2;
|
|
21
|
+
|
|
22
|
+
const t = new FeesTest('bridging_race', 1, {
|
|
23
|
+
ethereumSlotDuration: ETHEREUM_SLOT_DURATION,
|
|
24
|
+
aztecSlotDuration: AZTEC_SLOT_DURATION,
|
|
25
|
+
minTxsPerBlock: 0,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
beforeAll(async () => {
|
|
29
|
+
await t.applyInitialAccountsSnapshot();
|
|
30
|
+
await t.applyPublicDeployAccountsSnapshot();
|
|
31
|
+
await t.applySetupFeeJuiceSnapshot();
|
|
32
|
+
|
|
33
|
+
({ wallet, logger } = await t.setup());
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterAll(async () => {
|
|
37
|
+
await t.teardown();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
let logger: Logger;
|
|
41
|
+
let bobsAddress: AztecAddress;
|
|
42
|
+
let wallet: TestWallet;
|
|
43
|
+
|
|
44
|
+
beforeEach(async () => {
|
|
45
|
+
const bobsSecretKey = Fr.random();
|
|
46
|
+
const bobsPrivateSigningKey = Fq.random();
|
|
47
|
+
const bobsSalt = Fr.random();
|
|
48
|
+
const bobsAccountManager = await wallet.createAccount({
|
|
49
|
+
secret: bobsSecretKey,
|
|
50
|
+
salt: bobsSalt,
|
|
51
|
+
contract: new SchnorrAccountContract(bobsPrivateSigningKey),
|
|
52
|
+
});
|
|
53
|
+
bobsAddress = bobsAccountManager.address;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Alice bridges funds to Bob', async () => {
|
|
57
|
+
// Tweak the token manager so the bridging happens immediately before the end of the current L2 slot
|
|
58
|
+
// This caused the message to be "not in state" when tried to be used
|
|
59
|
+
const l1TokenManager = t.feeJuiceBridgeTestHarness.l1TokenManager;
|
|
60
|
+
const origApprove = l1TokenManager.approve.bind(l1TokenManager);
|
|
61
|
+
l1TokenManager.approve = async (amount: bigint, address: Hex, addressName = '') => {
|
|
62
|
+
await origApprove(amount, address, addressName);
|
|
63
|
+
const sleepTime = (Number(t.chainMonitor.checkpointTimestamp) + AZTEC_SLOT_DURATION) * 1000 - Date.now() - 500;
|
|
64
|
+
logger.info(`Sleeping for ${sleepTime}ms until near end of L2 slot before sending L1 fee juice to L2 inbox`);
|
|
65
|
+
await sleep(sleepTime);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Waiting for the archiver to sync the message _before_ waiting for the mandatory 2 L2 blocks to pass fixed it
|
|
69
|
+
// This was added everywhere we wait for two blocks, which is spread across three different places in the codebase
|
|
70
|
+
// Yes, we need to REFACTOR it at some point
|
|
71
|
+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(bobsAddress);
|
|
72
|
+
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
73
|
+
await t.feeJuiceContract.methods
|
|
74
|
+
.claim(bobsAddress, claim.claimAmount, secret, index)
|
|
75
|
+
.send({ from: bobsAddress })
|
|
76
|
+
.wait();
|
|
77
|
+
const [balance] = await t.getGasBalanceFn(bobsAddress);
|
|
78
|
+
expect(balance).toEqual(claim.claimAmount);
|
|
79
|
+
});
|
|
80
|
+
});
|