@aztec/end-to-end 0.0.1-commit.1bea0213 → 0.0.1-commit.21ecf947b
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/client_flows_benchmark.d.ts +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +3 -3
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
- 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 +10 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- 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 +3 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +7 -1
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +37 -12
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +5 -5
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -7
- package/dest/e2e_p2p/p2p_network.d.ts +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +153 -0
- package/dest/e2e_p2p/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +7 -3
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +10 -0
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +30 -0
- package/dest/fixtures/e2e_prover_test.d.ts +2 -2
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +1 -1
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +17 -17
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +40 -94
- package/dest/fixtures/setup_p2p_test.d.ts +12 -8
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +29 -21
- package/dest/shared/index.d.ts +2 -1
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +2 -2
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +8 -6
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -23
- package/dest/spartan/setup_test_wallets.d.ts +2 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +3 -1
- package/dest/spartan/tx_metrics.d.ts +35 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +150 -0
- package/dest/spartan/utils/bot.d.ts +1 -1
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +1 -1
- package/dest/spartan/utils/config.d.ts +4 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +2 -1
- package/dest/spartan/utils/index.d.ts +4 -4
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +2 -2
- package/dest/spartan/utils/k8s.d.ts +29 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +118 -0
- package/dest/spartan/utils/nodes.d.ts +11 -1
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +198 -27
- package/dest/spartan/utils/scripts.d.ts +18 -4
- package/dest/spartan/utils/scripts.d.ts.map +1 -1
- package/dest/spartan/utils/scripts.js +19 -4
- package/dest/test-wallet/test_wallet.d.ts +83 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +214 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +71 -0
- package/package.json +43 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +8 -12
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +1 -1
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +11 -2
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
- package/src/e2e_deploy_contract/deploy_test.ts +3 -3
- package/src/e2e_epochs/epochs_test.ts +44 -13
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +11 -26
- package/src/e2e_l1_publisher/write_json.ts +1 -6
- package/src/e2e_nested_contract/nested_contract_test.ts +1 -1
- package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
- package/src/e2e_p2p/p2p_network.ts +5 -5
- package/src/e2e_p2p/reqresp/utils.ts +207 -0
- package/src/e2e_p2p/shared.ts +13 -3
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +11 -2
- package/src/fixtures/authwit_proxy.ts +50 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +5 -5
- package/src/fixtures/ha_setup.ts +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +44 -122
- package/src/fixtures/setup_p2p_test.ts +31 -27
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +2 -1
- package/src/shared/uniswap_l1_l2.ts +9 -11
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +3 -1
- package/src/spartan/tx_metrics.ts +126 -0
- package/src/spartan/utils/bot.ts +1 -1
- package/src/spartan/utils/config.ts +1 -0
- package/src/spartan/utils/index.ts +3 -1
- package/src/spartan/utils/k8s.ts +152 -0
- package/src/spartan/utils/nodes.ts +239 -24
- package/src/spartan/utils/scripts.ts +43 -7
- package/src/test-wallet/test_wallet.ts +306 -0
- package/src/test-wallet/utils.ts +112 -0
|
@@ -20,13 +20,13 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
|
20
20
|
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
|
|
21
21
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
22
22
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
23
|
-
import { TestWallet } from '@aztec/test-wallet/server';
|
|
24
23
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
25
24
|
|
|
26
25
|
import { type Hex, getContract } from 'viem';
|
|
27
26
|
import { privateKeyToAddress } from 'viem/accounts';
|
|
28
27
|
|
|
29
28
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
29
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
30
30
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
31
31
|
import { getBBConfig } from './get_bb_config.js';
|
|
32
32
|
import {
|
|
@@ -144,7 +144,7 @@ export class FullProverTest {
|
|
|
144
144
|
this.logger.info(`Enabling proving`, { realProofs: this.realProofs });
|
|
145
145
|
|
|
146
146
|
// We don't wish to mark as proven automatically, so we set the flag to false
|
|
147
|
-
this.context.watcher
|
|
147
|
+
this.context.watcher.setIsMarkingAsProven(false);
|
|
148
148
|
|
|
149
149
|
this.simulatedProverNode = this.context.proverNode!;
|
|
150
150
|
({
|
|
@@ -152,7 +152,7 @@ export class FullProverTest {
|
|
|
152
152
|
deployL1ContractsValues: this.l1Contracts,
|
|
153
153
|
cheatCodes: this.cheatCodes,
|
|
154
154
|
} = this.context);
|
|
155
|
-
this.aztecNodeAdmin = this.context.aztecNodeService
|
|
155
|
+
this.aztecNodeAdmin = this.context.aztecNodeService;
|
|
156
156
|
|
|
157
157
|
const config = this.context.aztecNodeConfig;
|
|
158
158
|
const blobClient = await createBlobClientWithFileStores(config, this.logger);
|
|
@@ -198,7 +198,7 @@ export class FullProverTest {
|
|
|
198
198
|
this.aztecNode,
|
|
199
199
|
{ proverEnabled: this.realProofs },
|
|
200
200
|
undefined,
|
|
201
|
-
|
|
201
|
+
'pxe-proven',
|
|
202
202
|
);
|
|
203
203
|
this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`);
|
|
204
204
|
await provenWallet.registerContract(this.fakeProofsAssetInstance, TokenContract.artifact);
|
|
@@ -225,7 +225,7 @@ export class FullProverTest {
|
|
|
225
225
|
this.logger.verbose('Starting archiver for new prover node');
|
|
226
226
|
const archiver = await createArchiver(
|
|
227
227
|
{ ...this.context.aztecNodeConfig, dataDirectory: undefined },
|
|
228
|
-
{ blobClient, dateProvider: this.context.dateProvider
|
|
228
|
+
{ blobClient, dateProvider: this.context.dateProvider },
|
|
229
229
|
{ blockUntilSync: true },
|
|
230
230
|
);
|
|
231
231
|
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
5
|
+
|
|
6
|
+
import { Pool } from 'pg';
|
|
7
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for HA database connection
|
|
11
|
+
*/
|
|
12
|
+
export interface HADatabaseConfig {
|
|
13
|
+
/** PostgreSQL connection URL */
|
|
14
|
+
databaseUrl: string;
|
|
15
|
+
/** Node ID for HA coordination */
|
|
16
|
+
nodeId: string;
|
|
17
|
+
/** Enable HA signing */
|
|
18
|
+
haSigningEnabled: boolean;
|
|
19
|
+
/** Polling interval in ms */
|
|
20
|
+
pollingIntervalMs: number;
|
|
21
|
+
/** Signing timeout in ms */
|
|
22
|
+
signingTimeoutMs: number;
|
|
23
|
+
/** Max stuck duties age in ms */
|
|
24
|
+
maxStuckDutiesAgeMs: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get database configuration from environment variables
|
|
29
|
+
*/
|
|
30
|
+
export function createHADatabaseConfig(nodeId: string): HADatabaseConfig {
|
|
31
|
+
const databaseUrl = process.env.DATABASE_URL || 'postgresql://aztec:aztec@localhost:5432/aztec_ha_test';
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
databaseUrl,
|
|
35
|
+
nodeId,
|
|
36
|
+
haSigningEnabled: true,
|
|
37
|
+
pollingIntervalMs: 100,
|
|
38
|
+
signingTimeoutMs: 3000,
|
|
39
|
+
maxStuckDutiesAgeMs: 72000,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Setup PostgreSQL database connection pool for HA tests
|
|
45
|
+
*
|
|
46
|
+
* Note: Database migrations should be run separately before starting tests,
|
|
47
|
+
* either via docker-compose entrypoint or manually with: aztec migrate-ha-db up
|
|
48
|
+
*/
|
|
49
|
+
export function setupHADatabase(databaseUrl: string, logger?: Logger): Pool {
|
|
50
|
+
try {
|
|
51
|
+
// Create connection pool for test usage
|
|
52
|
+
// Migrations are already run by docker-compose entrypoint before tests start
|
|
53
|
+
const pool = new Pool({ connectionString: databaseUrl });
|
|
54
|
+
|
|
55
|
+
logger?.info('Connected to HA database (migrations should already be applied)');
|
|
56
|
+
|
|
57
|
+
return pool;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger?.error(`Failed to connect to HA database: ${error}`);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Clean up HA database - drop all tables
|
|
66
|
+
* Use this between tests to ensure clean state
|
|
67
|
+
*/
|
|
68
|
+
export async function cleanupHADatabase(pool: Pool, logger?: Logger): Promise<void> {
|
|
69
|
+
try {
|
|
70
|
+
// Drop all HA tables
|
|
71
|
+
await pool.query('DROP TABLE IF EXISTS validator_duties CASCADE');
|
|
72
|
+
await pool.query('DROP TABLE IF EXISTS schema_version CASCADE');
|
|
73
|
+
// Drop migration tracking table (node-pg-migrate uses 'pgmigrations' by default)
|
|
74
|
+
// This ensures migrations will run fresh on next startup
|
|
75
|
+
await pool.query('DROP TABLE IF EXISTS pgmigrations CASCADE');
|
|
76
|
+
|
|
77
|
+
logger?.info('HA database cleaned up successfully');
|
|
78
|
+
} catch (error) {
|
|
79
|
+
logger?.error(`Failed to cleanup HA database: ${error}`);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Query validator duties from the database
|
|
86
|
+
*/
|
|
87
|
+
export async function getValidatorDuties(
|
|
88
|
+
pool: Pool,
|
|
89
|
+
slot: bigint,
|
|
90
|
+
dutyType?: 'ATTESTATION' | 'BLOCK_PROPOSAL' | 'GOVERNANCE_VOTE' | 'SLASHING_VOTE',
|
|
91
|
+
): Promise<
|
|
92
|
+
Array<{
|
|
93
|
+
slot: string;
|
|
94
|
+
dutyType: string;
|
|
95
|
+
validatorAddress: string;
|
|
96
|
+
nodeId: string;
|
|
97
|
+
startedAt: Date;
|
|
98
|
+
completedAt: Date | undefined;
|
|
99
|
+
}>
|
|
100
|
+
> {
|
|
101
|
+
const query = dutyType
|
|
102
|
+
? 'SELECT slot, duty_type, validator_address, node_id, started_at, completed_at FROM validator_duties WHERE slot = $1 AND duty_type = $2 ORDER BY started_at'
|
|
103
|
+
: 'SELECT slot, duty_type, validator_address, node_id, started_at, completed_at FROM validator_duties WHERE slot = $1 ORDER BY started_at';
|
|
104
|
+
|
|
105
|
+
const params = dutyType ? [slot.toString(), dutyType] : [slot.toString()];
|
|
106
|
+
|
|
107
|
+
const result = await pool.query<{
|
|
108
|
+
slot: string;
|
|
109
|
+
duty_type: string;
|
|
110
|
+
validator_address: string;
|
|
111
|
+
node_id: string;
|
|
112
|
+
started_at: Date;
|
|
113
|
+
completed_at: Date | undefined;
|
|
114
|
+
}>(query, params);
|
|
115
|
+
|
|
116
|
+
return result.rows.map(row => ({
|
|
117
|
+
slot: row.slot,
|
|
118
|
+
dutyType: row.duty_type,
|
|
119
|
+
validatorAddress: row.validator_address,
|
|
120
|
+
nodeId: row.node_id,
|
|
121
|
+
startedAt: row.started_at,
|
|
122
|
+
completedAt: row.completed_at,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Convert private keys to Ethereum addresses
|
|
128
|
+
*/
|
|
129
|
+
export function getAddressesFromPrivateKeys(privateKeys: `0x${string}`[]): string[] {
|
|
130
|
+
return privateKeys.map(pk => {
|
|
131
|
+
const account = privateKeyToAccount(pk);
|
|
132
|
+
return account.address;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Create initial validators from private keys for L1 contract deployment
|
|
138
|
+
*/
|
|
139
|
+
export function createInitialValidatorsFromPrivateKeys(attesterPrivateKeys: `0x${string}`[]): Array<{
|
|
140
|
+
attester: EthAddress;
|
|
141
|
+
withdrawer: EthAddress;
|
|
142
|
+
privateKey: `0x${string}`;
|
|
143
|
+
bn254SecretKey: SecretValue<bigint>;
|
|
144
|
+
}> {
|
|
145
|
+
return attesterPrivateKeys.map(pk => {
|
|
146
|
+
const account = privateKeyToAccount(pk);
|
|
147
|
+
return {
|
|
148
|
+
attester: EthAddress.fromString(account.address),
|
|
149
|
+
withdrawer: EthAddress.fromString(account.address),
|
|
150
|
+
privateKey: pk,
|
|
151
|
+
bn254SecretKey: new SecretValue(Fr.random().toBigInt()),
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Verify no duplicate attestations per validator (HA coordination check)
|
|
158
|
+
* Groups duties by validator address and verifies each validator attested exactly once
|
|
159
|
+
*/
|
|
160
|
+
export function verifyNoDuplicateAttestations(
|
|
161
|
+
attestationDuties: Array<{
|
|
162
|
+
validatorAddress: string;
|
|
163
|
+
nodeId: string;
|
|
164
|
+
completedAt: Date | undefined;
|
|
165
|
+
}>,
|
|
166
|
+
logger?: Logger,
|
|
167
|
+
): Map<string, typeof attestationDuties> {
|
|
168
|
+
const dutiesByValidator = new Map<string, typeof attestationDuties>();
|
|
169
|
+
for (const duty of attestationDuties) {
|
|
170
|
+
const existing = dutiesByValidator.get(duty.validatorAddress) || [];
|
|
171
|
+
existing.push(duty);
|
|
172
|
+
dutiesByValidator.set(duty.validatorAddress, existing);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
for (const [validatorAddress, validatorDuties] of dutiesByValidator.entries()) {
|
|
176
|
+
if (validatorDuties.length !== 1) {
|
|
177
|
+
throw new Error(`Validator ${validatorAddress} attested ${validatorDuties.length} times (expected exactly once)`);
|
|
178
|
+
}
|
|
179
|
+
if (!validatorDuties[0].completedAt) {
|
|
180
|
+
throw new Error(`Validator ${validatorAddress} attestation duty not completed`);
|
|
181
|
+
}
|
|
182
|
+
logger?.info(`Validator ${validatorAddress} attested once via node ${validatorDuties[0].nodeId}`);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return dutiesByValidator;
|
|
186
|
+
}
|
package/src/fixtures/index.ts
CHANGED
package/src/fixtures/setup.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type InitialAccountData, generateSchnorrAccounts
|
|
2
|
+
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
3
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
5
|
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
14
14
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
15
15
|
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
16
|
-
import {
|
|
16
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
17
17
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
18
18
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
19
19
|
import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
|
|
@@ -41,7 +41,7 @@ import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
|
41
41
|
import { SecretValue } from '@aztec/foundation/config';
|
|
42
42
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
43
43
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
44
|
-
import {
|
|
44
|
+
import { withLoggerBindings } from '@aztec/foundation/log/server';
|
|
45
45
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
46
46
|
import { sleep } from '@aztec/foundation/sleep';
|
|
47
47
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
initTelemetryClient,
|
|
68
68
|
} from '@aztec/telemetry-client';
|
|
69
69
|
import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
|
|
70
|
-
import {
|
|
70
|
+
import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
|
|
71
71
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
72
72
|
|
|
73
73
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -84,6 +84,7 @@ import {
|
|
|
84
84
|
} from 'viem/accounts';
|
|
85
85
|
import { type Chain, foundry } from 'viem/chains';
|
|
86
86
|
|
|
87
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
87
88
|
import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
88
89
|
import { getACVMConfig } from './get_acvm_config.js';
|
|
89
90
|
import { getBBConfig } from './get_bb_config.js';
|
|
@@ -92,9 +93,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
|
92
93
|
|
|
93
94
|
export { startAnvil };
|
|
94
95
|
|
|
95
|
-
const { AZTEC_NODE_URL = '' } = process.env;
|
|
96
|
-
const getAztecUrl = () => AZTEC_NODE_URL;
|
|
97
|
-
|
|
98
96
|
let telemetry: TelemetryClient | undefined = undefined;
|
|
99
97
|
async function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
|
|
100
98
|
if (!telemetry) {
|
|
@@ -125,14 +123,14 @@ export async function setupSharedBlobStorage(config: { dataDirectory?: string }
|
|
|
125
123
|
* @param aztecNode - An instance of Aztec Node.
|
|
126
124
|
* @param opts - Partial configuration for the PXE.
|
|
127
125
|
* @param logger - The logger to be used.
|
|
128
|
-
* @param
|
|
126
|
+
* @param actor - Actor label to include in log output (e.g., 'pxe-test').
|
|
129
127
|
* @returns A test wallet, logger and teardown function.
|
|
130
128
|
*/
|
|
131
129
|
export async function setupPXEAndGetWallet(
|
|
132
130
|
aztecNode: AztecNode,
|
|
133
131
|
opts: Partial<PXEConfig> = {},
|
|
134
132
|
logger = getLogger(),
|
|
135
|
-
|
|
133
|
+
actor?: string,
|
|
136
134
|
): Promise<{
|
|
137
135
|
wallet: TestWallet;
|
|
138
136
|
logger: Logger;
|
|
@@ -150,9 +148,7 @@ export async function setupPXEAndGetWallet(
|
|
|
150
148
|
|
|
151
149
|
const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
|
|
152
150
|
|
|
153
|
-
const wallet = await TestWallet.create(aztecNode, PXEConfig, {
|
|
154
|
-
useLogSuffix,
|
|
155
|
-
});
|
|
151
|
+
const wallet = await TestWallet.create(aztecNode, PXEConfig, { loggerActorLabel: actor });
|
|
156
152
|
|
|
157
153
|
return {
|
|
158
154
|
wallet,
|
|
@@ -219,13 +215,13 @@ export type EndToEndContext = {
|
|
|
219
215
|
anvil: Anvil | undefined;
|
|
220
216
|
/** The Aztec Node service or client a connected to it. */
|
|
221
217
|
aztecNode: AztecNode;
|
|
222
|
-
/** The Aztec Node as a service
|
|
223
|
-
aztecNodeService: AztecNodeService
|
|
224
|
-
/** Client to the Aztec Node admin interface
|
|
225
|
-
aztecNodeAdmin: AztecNodeAdmin
|
|
218
|
+
/** The Aztec Node as a service. */
|
|
219
|
+
aztecNodeService: AztecNodeService;
|
|
220
|
+
/** Client to the Aztec Node admin interface. */
|
|
221
|
+
aztecNodeAdmin: AztecNodeAdmin;
|
|
226
222
|
/** The prover node service (only set if startProverNode is true) */
|
|
227
223
|
proverNode: ProverNode | undefined;
|
|
228
|
-
/** A client to the sequencer service
|
|
224
|
+
/** A client to the sequencer service. */
|
|
229
225
|
sequencer: SequencerClient | undefined;
|
|
230
226
|
/** Return values from deployAztecL1Contracts function. */
|
|
231
227
|
deployL1ContractsValues: DeployAztecL1ContractsReturnType;
|
|
@@ -245,12 +241,12 @@ export type EndToEndContext = {
|
|
|
245
241
|
cheatCodes: CheatCodes;
|
|
246
242
|
/** The cheat codes for L1 */
|
|
247
243
|
ethCheatCodes: EthCheatCodes;
|
|
248
|
-
/** The anvil test watcher
|
|
249
|
-
watcher: AnvilTestWatcher
|
|
250
|
-
/** Allows tweaking current system time, used by the epoch cache only
|
|
251
|
-
dateProvider: TestDateProvider
|
|
244
|
+
/** The anvil test watcher. */
|
|
245
|
+
watcher: AnvilTestWatcher;
|
|
246
|
+
/** Allows tweaking current system time, used by the epoch cache only. */
|
|
247
|
+
dateProvider: TestDateProvider;
|
|
252
248
|
/** Telemetry client */
|
|
253
|
-
telemetryClient: TelemetryClient
|
|
249
|
+
telemetryClient: TelemetryClient;
|
|
254
250
|
/** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
|
|
255
251
|
mockGossipSubNetwork: MockGossipSubNetwork | undefined;
|
|
256
252
|
/** Prefilled public data used for setting up nodes. */
|
|
@@ -260,87 +256,11 @@ export type EndToEndContext = {
|
|
|
260
256
|
/** BB config (only set if running locally). */
|
|
261
257
|
bbConfig: Awaited<ReturnType<typeof getBBConfig>>;
|
|
262
258
|
/** Directory to cleanup on teardown. */
|
|
263
|
-
directoryToCleanup: string
|
|
259
|
+
directoryToCleanup: string;
|
|
264
260
|
/** Function to stop the started services. */
|
|
265
261
|
teardown: () => Promise<void>;
|
|
266
262
|
};
|
|
267
263
|
|
|
268
|
-
/**
|
|
269
|
-
* Function to setup the test against a remote deployment. It is assumed that L1 contract are already deployed
|
|
270
|
-
*/
|
|
271
|
-
async function setupWithRemoteEnvironment(
|
|
272
|
-
account: HDAccount | PrivateKeyAccount,
|
|
273
|
-
config: AztecNodeConfig & SetupOptions,
|
|
274
|
-
logger: Logger,
|
|
275
|
-
numberOfAccounts: number,
|
|
276
|
-
): Promise<EndToEndContext> {
|
|
277
|
-
const aztecNodeUrl = getAztecUrl();
|
|
278
|
-
logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
|
|
279
|
-
const aztecNode = createAztecNodeClient(aztecNodeUrl);
|
|
280
|
-
await waitForNode(aztecNode, logger);
|
|
281
|
-
logger.verbose('JSON RPC client connected to Aztec Node');
|
|
282
|
-
logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
|
|
283
|
-
const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
284
|
-
|
|
285
|
-
const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
|
|
286
|
-
|
|
287
|
-
const deployL1ContractsValues: DeployAztecL1ContractsReturnType = {
|
|
288
|
-
l1ContractAddresses,
|
|
289
|
-
l1Client,
|
|
290
|
-
rollupVersion,
|
|
291
|
-
};
|
|
292
|
-
const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
|
|
293
|
-
const wallet = await TestWallet.create(aztecNode);
|
|
294
|
-
|
|
295
|
-
if (config.walletMinFeePadding !== undefined) {
|
|
296
|
-
wallet.setMinFeePadding(config.walletMinFeePadding);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
|
|
300
|
-
const teardown = () => Promise.resolve();
|
|
301
|
-
|
|
302
|
-
logger.verbose('Populating wallet from already registered accounts...');
|
|
303
|
-
const initialFundedAccounts = await getInitialTestAccountsData();
|
|
304
|
-
|
|
305
|
-
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
306
|
-
throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const testAccounts = await Promise.all(
|
|
310
|
-
initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
|
|
311
|
-
const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
|
|
312
|
-
return accountManager.address;
|
|
313
|
-
}),
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
return {
|
|
317
|
-
anvil: undefined,
|
|
318
|
-
aztecNode,
|
|
319
|
-
aztecNodeService: undefined,
|
|
320
|
-
aztecNodeAdmin: undefined,
|
|
321
|
-
sequencer: undefined,
|
|
322
|
-
proverNode: undefined,
|
|
323
|
-
deployL1ContractsValues,
|
|
324
|
-
config,
|
|
325
|
-
aztecNodeConfig: config,
|
|
326
|
-
initialFundedAccounts,
|
|
327
|
-
wallet,
|
|
328
|
-
accounts: testAccounts,
|
|
329
|
-
logger,
|
|
330
|
-
cheatCodes,
|
|
331
|
-
ethCheatCodes,
|
|
332
|
-
prefilledPublicData: undefined,
|
|
333
|
-
mockGossipSubNetwork: undefined,
|
|
334
|
-
watcher: undefined,
|
|
335
|
-
dateProvider: undefined,
|
|
336
|
-
telemetryClient: undefined,
|
|
337
|
-
acvmConfig: undefined,
|
|
338
|
-
bbConfig: undefined,
|
|
339
|
-
directoryToCleanup: undefined,
|
|
340
|
-
teardown,
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
|
|
344
264
|
/**
|
|
345
265
|
* Sets up the environment for the end-to-end tests.
|
|
346
266
|
* @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
|
|
@@ -370,6 +290,8 @@ export async function setup(
|
|
|
370
290
|
config.enforceTimeTable = !!opts.enforceTimeTable;
|
|
371
291
|
config.listenAddress = '127.0.0.1';
|
|
372
292
|
|
|
293
|
+
config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
|
|
294
|
+
|
|
373
295
|
const logger = getLogger();
|
|
374
296
|
|
|
375
297
|
// Create a temp directory for any services that need it and cleanup later
|
|
@@ -383,16 +305,10 @@ export async function setup(
|
|
|
383
305
|
if (!isAnvilTestChain(chain.id)) {
|
|
384
306
|
throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
|
|
385
307
|
}
|
|
386
|
-
if (AZTEC_NODE_URL) {
|
|
387
|
-
throw new Error(
|
|
388
|
-
`AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
308
|
const res = await startAnvil({
|
|
393
309
|
l1BlockTime: opts.ethereumSlotDuration,
|
|
394
310
|
accounts: opts.anvilAccounts,
|
|
395
|
-
port: opts.anvilPort,
|
|
311
|
+
port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
|
|
396
312
|
});
|
|
397
313
|
anvil = res.anvil;
|
|
398
314
|
config.l1RpcUrls = [res.rpcUrl];
|
|
@@ -443,11 +359,6 @@ export async function setup(
|
|
|
443
359
|
config.coinbase = EthAddress.fromString(publisherHdAccount.address);
|
|
444
360
|
}
|
|
445
361
|
|
|
446
|
-
if (AZTEC_NODE_URL) {
|
|
447
|
-
// we are setting up against a remote environment, l1 contracts are assumed to already be deployed
|
|
448
|
-
return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
362
|
// Determine which addresses to fund in genesis
|
|
452
363
|
const initialFundedAccounts =
|
|
453
364
|
opts.initialFundedAccounts ??
|
|
@@ -504,9 +415,14 @@ export async function setup(
|
|
|
504
415
|
if (enableAutomine) {
|
|
505
416
|
await ethCheatCodes.setAutomine(false);
|
|
506
417
|
await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
|
|
507
|
-
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
508
418
|
}
|
|
509
419
|
|
|
420
|
+
// Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
|
|
421
|
+
// In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
|
|
422
|
+
// warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
|
|
423
|
+
// slot from its dateProvider and cannot propose blocks.
|
|
424
|
+
dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
|
|
425
|
+
|
|
510
426
|
if (opts.l2StartTime) {
|
|
511
427
|
await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
|
|
512
428
|
}
|
|
@@ -574,10 +490,12 @@ export async function setup(
|
|
|
574
490
|
}
|
|
575
491
|
}
|
|
576
492
|
|
|
577
|
-
const aztecNodeService = await
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
493
|
+
const aztecNodeService = await withLoggerBindings({ actor: 'node-0' }, () =>
|
|
494
|
+
AztecNodeService.createAndSync(
|
|
495
|
+
config,
|
|
496
|
+
{ dateProvider, telemetry: telemetryClient, p2pClientDeps },
|
|
497
|
+
{ prefilledPublicData },
|
|
498
|
+
),
|
|
581
499
|
);
|
|
582
500
|
const sequencerClient = aztecNodeService.getSequencer();
|
|
583
501
|
|
|
@@ -595,7 +513,7 @@ export async function setup(
|
|
|
595
513
|
const proverNodeConfig = {
|
|
596
514
|
...config.proverNodeConfig,
|
|
597
515
|
dataDirectory: proverNodeDataDirectory,
|
|
598
|
-
p2pEnabled:
|
|
516
|
+
p2pEnabled: !!mockGossipSubNetwork,
|
|
599
517
|
};
|
|
600
518
|
proverNode = await createAndSyncProverNode(
|
|
601
519
|
proverNodePrivateKeyHex,
|
|
@@ -603,6 +521,11 @@ export async function setup(
|
|
|
603
521
|
proverNodeConfig,
|
|
604
522
|
aztecNodeService,
|
|
605
523
|
prefilledPublicData,
|
|
524
|
+
{
|
|
525
|
+
p2pClientDeps: mockGossipSubNetwork
|
|
526
|
+
? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
|
|
527
|
+
: undefined,
|
|
528
|
+
},
|
|
606
529
|
);
|
|
607
530
|
}
|
|
608
531
|
|
|
@@ -611,7 +534,7 @@ export async function setup(
|
|
|
611
534
|
pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
612
535
|
// For tests we only want proving enabled if specifically requested
|
|
613
536
|
pxeConfig.proverEnabled = !!pxeOpts.proverEnabled;
|
|
614
|
-
const wallet = await TestWallet.create(aztecNodeService, pxeConfig);
|
|
537
|
+
const wallet = await TestWallet.create(aztecNodeService, pxeConfig, { loggerActorLabel: 'pxe-0' });
|
|
615
538
|
|
|
616
539
|
if (opts.walletMinFeePadding !== undefined) {
|
|
617
540
|
wallet.setMinFeePadding(opts.walletMinFeePadding);
|
|
@@ -683,7 +606,7 @@ export async function setup(
|
|
|
683
606
|
logger.error(`Error during e2e test teardown`, err);
|
|
684
607
|
} finally {
|
|
685
608
|
try {
|
|
686
|
-
await telemetryClient
|
|
609
|
+
await telemetryClient.stop();
|
|
687
610
|
} catch (err) {
|
|
688
611
|
logger.error(`Error during telemetry client stop`, err);
|
|
689
612
|
}
|
|
@@ -797,7 +720,7 @@ export function createAndSyncProverNode(
|
|
|
797
720
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
798
721
|
proverNodeDeps: ProverNodeDeps = {},
|
|
799
722
|
) {
|
|
800
|
-
return
|
|
723
|
+
return withLoggerBindings({ actor: 'prover-0' }, async () => {
|
|
801
724
|
const aztecNodeTxProvider = aztecNode && {
|
|
802
725
|
getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
|
|
803
726
|
getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
|
|
@@ -870,12 +793,11 @@ export type BalancesFn = ReturnType<typeof getBalancesFn>;
|
|
|
870
793
|
export function getBalancesFn(
|
|
871
794
|
symbol: string,
|
|
872
795
|
method: ContractMethod,
|
|
873
|
-
from: AztecAddress,
|
|
874
796
|
logger: any,
|
|
875
797
|
): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
|
|
876
798
|
const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
|
|
877
799
|
const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
|
|
878
|
-
const b = await Promise.all(addresses.map(address => method(address).simulate({ from })));
|
|
800
|
+
const b = await Promise.all(addresses.map(address => method(address).simulate({ from: address })));
|
|
879
801
|
const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
|
|
880
802
|
logger.verbose(debugString);
|
|
881
803
|
return b;
|