@aztec/end-to-end 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.17
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/README.md +2 -0
- package/dest/bench/utils.d.ts +70 -0
- package/dest/bench/utils.d.ts.map +1 -0
- package/dest/bench/utils.js +24 -8
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +46 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +17 -17
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +47 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +27 -16
- package/dest/e2e_deploy_contract/deploy_test.d.ts +28 -0
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -0
- package/dest/e2e_deploy_contract/deploy_test.js +4 -7
- package/dest/e2e_epochs/epochs_test.d.ts +51 -0
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -0
- package/dest/e2e_epochs/epochs_test.js +155 -0
- package/dest/e2e_fees/fees_test.d.ts +73 -0
- package/dest/e2e_fees/fees_test.d.ts.map +1 -0
- package/dest/e2e_fees/fees_test.js +75 -32
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +26 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -0
- package/dest/e2e_nested_contract/nested_contract_test.js +14 -12
- package/dest/e2e_p2p/p2p_network.d.ts +61 -0
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -0
- package/dest/e2e_p2p/p2p_network.js +54 -30
- package/dest/e2e_p2p/shared.d.ts +10 -0
- package/dest/e2e_p2p/shared.d.ts.map +1 -0
- package/dest/e2e_p2p/shared.js +7 -8
- package/dest/e2e_prover/e2e_prover_test.d.ts +56 -0
- package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -0
- package/dest/e2e_prover/e2e_prover_test.js +20 -24
- package/dest/e2e_token_contract/token_contract_test.d.ts +29 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -0
- package/dest/e2e_token_contract/token_contract_test.js +4 -7
- package/dest/fixtures/fixtures.d.ts +17 -0
- package/dest/fixtures/fixtures.d.ts.map +1 -0
- package/dest/fixtures/fixtures.js +2 -2
- package/dest/fixtures/get_acvm_config.d.ts +8 -0
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -0
- package/dest/fixtures/get_acvm_config.js +10 -5
- package/dest/fixtures/get_bb_config.d.ts +6 -0
- package/dest/fixtures/get_bb_config.d.ts.map +1 -0
- package/dest/fixtures/get_bb_config.js +9 -4
- package/dest/fixtures/index.d.ts +6 -0
- package/dest/fixtures/index.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts +13 -0
- package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -0
- package/dest/fixtures/l1_to_l2_messaging.js +1 -1
- package/dest/fixtures/logging.d.ts +8 -0
- package/dest/fixtures/logging.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.d.ts +6 -0
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -0
- package/dest/fixtures/setup_l1_contracts.js +6 -4
- package/dest/fixtures/setup_p2p_test.d.ts +22 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -0
- package/dest/fixtures/setup_p2p_test.js +5 -3
- package/dest/fixtures/snapshot_manager.d.ts +87 -0
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -0
- package/dest/fixtures/snapshot_manager.js +67 -74
- package/dest/fixtures/token_utils.d.ts +6 -0
- package/dest/fixtures/token_utils.d.ts.map +1 -0
- package/dest/fixtures/token_utils.js +1 -1
- package/dest/fixtures/utils.d.ts +155 -0
- package/dest/fixtures/utils.d.ts.map +1 -0
- package/dest/fixtures/utils.js +97 -71
- package/dest/fixtures/with_telemetry_utils.d.ts +3 -0
- package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.d.ts +41 -0
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -0
- package/dest/quality_of_service/alert_checker.js +4 -1
- package/dest/sample-dapp/index.js +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +124 -0
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -0
- package/dest/shared/cross_chain_test_harness.js +6 -17
- package/dest/shared/gas_portal_test_harness.d.ts +80 -0
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -0
- package/dest/shared/gas_portal_test_harness.js +11 -4
- package/dest/shared/index.d.ts +2 -0
- package/dest/shared/index.d.ts.map +1 -0
- package/dest/shared/index.js +0 -1
- package/dest/shared/jest_setup.d.ts +2 -0
- package/dest/shared/jest_setup.d.ts.map +1 -0
- package/dest/shared/submit-transactions.d.ts +4 -0
- package/dest/shared/submit-transactions.d.ts.map +1 -0
- package/dest/shared/submit-transactions.js +9 -17
- package/dest/shared/uniswap_l1_l2.d.ts +25 -0
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -0
- package/dest/shared/uniswap_l1_l2.js +5 -10
- package/dest/simulators/index.d.ts +3 -0
- package/dest/simulators/index.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.d.ts +69 -0
- package/dest/simulators/lending_simulator.d.ts.map +1 -0
- package/dest/simulators/lending_simulator.js +1 -3
- package/dest/simulators/token_simulator.d.ts +29 -0
- package/dest/simulators/token_simulator.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.d.ts +20 -0
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -0
- package/dest/spartan/setup_test_wallets.js +72 -38
- package/dest/spartan/utils.d.ts +485 -0
- package/dest/spartan/utils.d.ts.map +1 -0
- package/dest/spartan/utils.js +110 -2
- package/package.json +35 -40
- package/src/bench/utils.ts +30 -13
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +40 -30
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +34 -18
- package/src/e2e_deploy_contract/deploy_test.ts +6 -11
- package/src/e2e_epochs/epochs_test.ts +217 -0
- package/src/e2e_fees/fees_test.ts +84 -38
- package/src/e2e_nested_contract/nested_contract_test.ts +14 -16
- package/src/e2e_p2p/p2p_network.ts +67 -47
- package/src/e2e_p2p/shared.ts +16 -10
- package/src/e2e_prover/e2e_prover_test.ts +56 -37
- package/src/e2e_token_contract/token_contract_test.ts +10 -11
- package/src/fixtures/fixtures.ts +2 -2
- package/src/fixtures/get_acvm_config.ts +7 -3
- package/src/fixtures/get_bb_config.ts +6 -2
- package/src/fixtures/l1_to_l2_messaging.ts +6 -13
- package/src/fixtures/setup_l1_contracts.ts +8 -7
- package/src/fixtures/setup_p2p_test.ts +8 -6
- package/src/fixtures/snapshot_manager.ts +72 -79
- package/src/fixtures/token_utils.ts +2 -2
- package/src/fixtures/utils.ts +135 -97
- package/src/guides/up_quick_start.sh +10 -5
- package/src/quality_of_service/alert_checker.ts +6 -2
- package/src/sample-dapp/index.mjs +1 -1
- package/src/shared/cross_chain_test_harness.ts +17 -35
- package/src/shared/gas_portal_test_harness.ts +21 -11
- package/src/shared/index.ts +0 -1
- package/src/shared/submit-transactions.ts +16 -20
- package/src/shared/uniswap_l1_l2.ts +35 -26
- package/src/simulators/lending_simulator.ts +5 -6
- package/src/simulators/token_simulator.ts +1 -1
- package/src/spartan/setup_test_wallets.ts +111 -37
- package/src/spartan/utils.ts +88 -3
- package/dest/shared/browser.js +0 -163
- package/src/shared/browser.ts +0 -272
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
2
|
+
import { Fr, getTimestampRangeForEpoch, retryUntil, sleep } from '@aztec/aztec.js';
|
|
3
|
+
import { ChainMonitor } from '@aztec/aztec.js/ethereum';
|
|
4
|
+
import { RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import { waitUntilL1Timestamp } from '@aztec/ethereum/test';
|
|
6
|
+
import { randomBytes } from '@aztec/foundation/crypto';
|
|
7
|
+
import { withLogNameSuffix } from '@aztec/foundation/log';
|
|
8
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
import { createAndSyncProverNode, getPrivateKeyFromIndex, setup } from '../fixtures/utils.js';
|
|
11
|
+
// This can be lowered to as much as 2s in non-CI
|
|
12
|
+
export const L1_BLOCK_TIME_IN_S = process.env.L1_BLOCK_TIME ? parseInt(process.env.L1_BLOCK_TIME) : 8;
|
|
13
|
+
export const EPOCH_DURATION_IN_L2_SLOTS = 4;
|
|
14
|
+
export const L2_SLOT_DURATION_IN_L1_SLOTS = 2;
|
|
15
|
+
export const WORLD_STATE_BLOCK_HISTORY = 2;
|
|
16
|
+
export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
|
|
17
|
+
export const ARCHIVER_POLL_INTERVAL = 50;
|
|
18
|
+
/**
|
|
19
|
+
* Tests building of epochs using fast block times and short epochs.
|
|
20
|
+
* Spawns an aztec node and a prover node with fake proofs.
|
|
21
|
+
* Sequencer is allowed to build empty blocks.
|
|
22
|
+
*/ export class EpochsTestContext {
|
|
23
|
+
context;
|
|
24
|
+
l1Client;
|
|
25
|
+
rollup;
|
|
26
|
+
constants;
|
|
27
|
+
logger;
|
|
28
|
+
monitor;
|
|
29
|
+
proverDelayer;
|
|
30
|
+
sequencerDelayer;
|
|
31
|
+
proverNodes = [];
|
|
32
|
+
nodes = [];
|
|
33
|
+
static async setup(opts = {}) {
|
|
34
|
+
const test = new EpochsTestContext();
|
|
35
|
+
await test.setup(opts);
|
|
36
|
+
return test;
|
|
37
|
+
}
|
|
38
|
+
async setup(opts = {}) {
|
|
39
|
+
// Set up system without any account nor protocol contracts
|
|
40
|
+
// and with faster block times and shorter epochs.
|
|
41
|
+
const context = await setup(0, {
|
|
42
|
+
checkIntervalMs: 50,
|
|
43
|
+
archiverPollingIntervalMS: ARCHIVER_POLL_INTERVAL,
|
|
44
|
+
worldStateBlockCheckIntervalMS: WORLD_STATE_BLOCK_CHECK_INTERVAL,
|
|
45
|
+
skipProtocolContracts: true,
|
|
46
|
+
salt: 1,
|
|
47
|
+
aztecEpochDuration: EPOCH_DURATION_IN_L2_SLOTS,
|
|
48
|
+
aztecSlotDuration: L1_BLOCK_TIME_IN_S * L2_SLOT_DURATION_IN_L1_SLOTS,
|
|
49
|
+
ethereumSlotDuration: L1_BLOCK_TIME_IN_S,
|
|
50
|
+
aztecProofSubmissionWindow: EPOCH_DURATION_IN_L2_SLOTS * 2 - 1,
|
|
51
|
+
minTxsPerBlock: 0,
|
|
52
|
+
realProofs: false,
|
|
53
|
+
startProverNode: true,
|
|
54
|
+
// We use numeric incremental prover ids for simplicity, but we can switch to
|
|
55
|
+
// using the prover's eth address if the proverId is used for something in the rollup contract
|
|
56
|
+
proverId: Fr.fromString('1'),
|
|
57
|
+
// This must be enough so that the tx from the prover is delayed properly,
|
|
58
|
+
// but not so much to hang the sequencer and timeout the teardown
|
|
59
|
+
txPropagationMaxQueryAttempts: 12,
|
|
60
|
+
worldStateBlockHistory: WORLD_STATE_BLOCK_HISTORY,
|
|
61
|
+
...opts
|
|
62
|
+
});
|
|
63
|
+
this.context = context;
|
|
64
|
+
this.proverNodes = context.proverNode ? [
|
|
65
|
+
context.proverNode
|
|
66
|
+
] : [];
|
|
67
|
+
this.nodes = context.aztecNode ? [
|
|
68
|
+
context.aztecNode
|
|
69
|
+
] : [];
|
|
70
|
+
this.logger = context.logger;
|
|
71
|
+
this.l1Client = context.deployL1ContractsValues.publicClient;
|
|
72
|
+
this.rollup = RollupContract.getFromConfig(context.config);
|
|
73
|
+
// Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
|
|
74
|
+
this.monitor = new ChainMonitor(this.rollup, this.logger).start();
|
|
75
|
+
// This is hideous.
|
|
76
|
+
// We ought to have a definite reference to the l1TxUtils that we're using in both places, provided by the test context.
|
|
77
|
+
this.proverDelayer = context.proverNode ? context.proverNode.publisher.l1TxUtils.delayer : undefined;
|
|
78
|
+
this.sequencerDelayer = context.sequencer.sequencer.publisher.l1TxUtils.delayer;
|
|
79
|
+
if (context.proverNode && !this.proverDelayer || !this.sequencerDelayer) {
|
|
80
|
+
throw new Error(`Could not find prover or sequencer delayer`);
|
|
81
|
+
}
|
|
82
|
+
// Constants used for time calculation
|
|
83
|
+
this.constants = {
|
|
84
|
+
epochDuration: EPOCH_DURATION_IN_L2_SLOTS,
|
|
85
|
+
slotDuration: L1_BLOCK_TIME_IN_S * L2_SLOT_DURATION_IN_L1_SLOTS,
|
|
86
|
+
l1StartBlock: await this.rollup.getL1StartBlock(),
|
|
87
|
+
l1GenesisTime: await this.rollup.getL1GenesisTime(),
|
|
88
|
+
ethereumSlotDuration: L1_BLOCK_TIME_IN_S
|
|
89
|
+
};
|
|
90
|
+
this.logger.info(`L2 genesis at L1 block ${this.constants.l1StartBlock} (timestamp ${this.constants.l1GenesisTime})`);
|
|
91
|
+
}
|
|
92
|
+
async teardown() {
|
|
93
|
+
this.monitor.stop();
|
|
94
|
+
await Promise.all(this.proverNodes.map((node)=>node.stop()));
|
|
95
|
+
await Promise.all(this.nodes.map((node)=>node.stop()));
|
|
96
|
+
await this.context.teardown();
|
|
97
|
+
}
|
|
98
|
+
async createProverNode() {
|
|
99
|
+
this.logger.warn('Creating and syncing a simulated prover node...');
|
|
100
|
+
const proverNodePrivateKey = this.getNextPrivateKey();
|
|
101
|
+
const suffix = (this.proverNodes.length + 1).toString();
|
|
102
|
+
const proverNode = await withLogNameSuffix(suffix, ()=>createAndSyncProverNode(proverNodePrivateKey, {
|
|
103
|
+
...this.context.config,
|
|
104
|
+
proverId: Fr.fromString(suffix)
|
|
105
|
+
}, this.context.aztecNode, join(this.context.config.dataDirectory, randomBytes(8).toString('hex'))));
|
|
106
|
+
this.proverNodes.push(proverNode);
|
|
107
|
+
return proverNode;
|
|
108
|
+
}
|
|
109
|
+
async createNonValidatorNode() {
|
|
110
|
+
this.logger.warn('Creating and syncing a node without a validator...');
|
|
111
|
+
const suffix = (this.nodes.length + 1).toString();
|
|
112
|
+
const node = await withLogNameSuffix(suffix, ()=>AztecNodeService.createAndSync({
|
|
113
|
+
...this.context.config,
|
|
114
|
+
disableValidator: true,
|
|
115
|
+
dataDirectory: join(this.context.config.dataDirectory, randomBytes(8).toString('hex'))
|
|
116
|
+
}));
|
|
117
|
+
this.nodes.push(node);
|
|
118
|
+
return node;
|
|
119
|
+
}
|
|
120
|
+
getNextPrivateKey() {
|
|
121
|
+
const key = getPrivateKeyFromIndex(this.nodes.length + this.proverNodes.length + 1);
|
|
122
|
+
return `0x${key.toString('hex')}`;
|
|
123
|
+
}
|
|
124
|
+
/** Waits until the epoch begins (ie until the immediately previous L1 block is mined). */ async waitUntilEpochStarts(epoch) {
|
|
125
|
+
const [start] = getTimestampRangeForEpoch(BigInt(epoch), this.constants);
|
|
126
|
+
this.logger.info(`Waiting until L1 timestamp ${start} is reached as the start of epoch ${epoch}`);
|
|
127
|
+
await waitUntilL1Timestamp(this.l1Client, start - BigInt(L1_BLOCK_TIME_IN_S));
|
|
128
|
+
return start;
|
|
129
|
+
}
|
|
130
|
+
/** Waits until the given L2 block number is mined. */ async waitUntilL2BlockNumber(target, timeout = 60) {
|
|
131
|
+
await retryUntil(()=>Promise.resolve(target === this.monitor.l2BlockNumber), `Wait until L2 block ${target}`, timeout, 0.1);
|
|
132
|
+
}
|
|
133
|
+
/** Waits until the given L2 block number is marked as proven. */ async waitUntilProvenL2BlockNumber(t, timeout = 60) {
|
|
134
|
+
await retryUntil(()=>Promise.resolve(t === this.monitor.l2ProvenBlockNumber), `Wait proven L2 block ${t}`, timeout, 0.1);
|
|
135
|
+
}
|
|
136
|
+
/** Waits for the aztec node to sync to the target block number. */ async waitForNodeToSync(blockNumber, type) {
|
|
137
|
+
const waitTime = ARCHIVER_POLL_INTERVAL + WORLD_STATE_BLOCK_CHECK_INTERVAL;
|
|
138
|
+
let synched = false;
|
|
139
|
+
while(!synched){
|
|
140
|
+
await sleep(waitTime);
|
|
141
|
+
const syncState = await this.context.aztecNode.getWorldStateSyncStatus();
|
|
142
|
+
if (type === 'finalised') {
|
|
143
|
+
synched = syncState.finalisedBlockNumber >= blockNumber;
|
|
144
|
+
} else {
|
|
145
|
+
synched = syncState.oldestHistoricBlockNumber >= blockNumber;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Verifies whether the given block number is found on the aztec node. */ async verifyHistoricBlock(blockNumber, expectedSuccess) {
|
|
150
|
+
const result = await this.context.aztecNode.findBlockNumbersForIndexes(blockNumber, MerkleTreeId.NULLIFIER_TREE, [
|
|
151
|
+
0n
|
|
152
|
+
]).then((_)=>true).catch((_)=>false);
|
|
153
|
+
expect(result).toBe(expectedSuccess);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type AccountWallet, type AztecAddress, type AztecNode, ChainMonitor, CheatCodes, type Logger, type PXE } from '@aztec/aztec.js';
|
|
2
|
+
import { type DeployL1ContractsArgs } from '@aztec/ethereum';
|
|
3
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
|
|
5
|
+
import { CounterContract } from '@aztec/noir-contracts.js/Counter';
|
|
6
|
+
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
7
|
+
import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
8
|
+
import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
|
|
9
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
10
|
+
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
11
|
+
import { type BalancesFn, type SetupOptions } from '../fixtures/utils.js';
|
|
12
|
+
import { type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
|
|
13
|
+
/**
|
|
14
|
+
* Test fixture for testing fees. Provides the following snapshots:
|
|
15
|
+
* InitialAccounts: Initializes 3 Schnorr account contracts.
|
|
16
|
+
* PublicDeployAccounts: Deploys the accounts publicly.
|
|
17
|
+
* DeployFeeJuice: Deploys the Fee Juice contract.
|
|
18
|
+
* FPCSetup: Deploys BananaCoin and FPC contracts, and bridges gas from L1.
|
|
19
|
+
* FundAlice: Mints private and public bananas to Alice.
|
|
20
|
+
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
21
|
+
*/
|
|
22
|
+
export declare class FeesTest {
|
|
23
|
+
private numberOfAccounts;
|
|
24
|
+
private snapshotManager;
|
|
25
|
+
private wallets;
|
|
26
|
+
logger: Logger;
|
|
27
|
+
pxe: PXE;
|
|
28
|
+
aztecNode: AztecNode;
|
|
29
|
+
cheatCodes: CheatCodes;
|
|
30
|
+
aliceWallet: AccountWallet;
|
|
31
|
+
aliceAddress: AztecAddress;
|
|
32
|
+
bobWallet: AccountWallet;
|
|
33
|
+
bobAddress: AztecAddress;
|
|
34
|
+
sequencerAddress: AztecAddress;
|
|
35
|
+
coinbase: EthAddress;
|
|
36
|
+
fpcAdmin: AztecAddress;
|
|
37
|
+
gasSettings: GasSettings;
|
|
38
|
+
feeJuiceContract: FeeJuiceContract;
|
|
39
|
+
bananaCoin: BananaCoin;
|
|
40
|
+
bananaFPC: FPCContract;
|
|
41
|
+
counterContract: CounterContract;
|
|
42
|
+
subscriptionContract: AppSubscriptionContract;
|
|
43
|
+
feeJuiceBridgeTestHarness: GasBridgingTestHarness;
|
|
44
|
+
context: SubsystemsContext;
|
|
45
|
+
chainMonitor: ChainMonitor;
|
|
46
|
+
getCoinbaseBalance: () => Promise<bigint>;
|
|
47
|
+
getCoinbaseSequencerRewards: () => Promise<bigint>;
|
|
48
|
+
getGasBalanceFn: BalancesFn;
|
|
49
|
+
getBananaPublicBalanceFn: BalancesFn;
|
|
50
|
+
getBananaPrivateBalanceFn: BalancesFn;
|
|
51
|
+
getProverFee: (blockNumber: number) => Promise<bigint>;
|
|
52
|
+
readonly ALICE_INITIAL_BANANAS: bigint;
|
|
53
|
+
readonly SUBSCRIPTION_AMOUNT: bigint;
|
|
54
|
+
readonly APP_SPONSORED_TX_GAS_LIMIT: bigint;
|
|
55
|
+
constructor(testName: string, numberOfAccounts?: number, setupOptions?: Partial<SetupOptions & DeployL1ContractsArgs>);
|
|
56
|
+
setup(): Promise<this>;
|
|
57
|
+
teardown(): Promise<void>;
|
|
58
|
+
setIsMarkingAsProven(b: boolean): void;
|
|
59
|
+
catchUpProvenChain(): Promise<void>;
|
|
60
|
+
mintAndBridgeFeeJuice(address: AztecAddress, amount: bigint): Promise<void>;
|
|
61
|
+
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
|
|
62
|
+
mintPrivateBananas(amount: bigint, address: AztecAddress): Promise<void>;
|
|
63
|
+
applyBaseSnapshots(): Promise<void>;
|
|
64
|
+
applyInitialAccountsSnapshot(): Promise<void>;
|
|
65
|
+
applyPublicDeployAccountsSnapshot(): Promise<void>;
|
|
66
|
+
applySetupFeeJuiceSnapshot(): Promise<void>;
|
|
67
|
+
applyDeployBananaTokenSnapshot(): Promise<void>;
|
|
68
|
+
applyFPCSetupSnapshot(): Promise<void>;
|
|
69
|
+
applyFundAliceWithBananas(): Promise<void>;
|
|
70
|
+
applyFundAliceWithPrivateBananas(): Promise<void>;
|
|
71
|
+
applySetupSubscription(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=fees_test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fees_test.d.ts","sourceRoot":"","sources":["../../src/e2e_fees/fees_test.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,YAAY,EACZ,UAAU,EACV,KAAK,MAAM,EACX,KAAK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norrWallet } from '@aztec/accounts/schnorr';
|
|
2
|
+
import { ChainMonitor, CheatCodes, createLogger, sleep } from '@aztec/aztec.js';
|
|
3
|
+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT } from '@aztec/constants';
|
|
4
|
+
import { RollupContract, createL1Clients } from '@aztec/ethereum';
|
|
5
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts';
|
|
7
7
|
import { AppSubscriptionContract } from '@aztec/noir-contracts.js/AppSubscription';
|
|
8
8
|
import { CounterContract } from '@aztec/noir-contracts.js/Counter';
|
|
9
9
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
@@ -11,9 +11,11 @@ import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
|
|
|
11
11
|
import { TokenContract as BananaCoin } from '@aztec/noir-contracts.js/Token';
|
|
12
12
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
13
13
|
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
|
|
14
|
+
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
15
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
|
14
16
|
import { getContract } from 'viem';
|
|
15
17
|
import { MNEMONIC } from '../fixtures/fixtures.js';
|
|
16
|
-
import {
|
|
18
|
+
import { createSnapshotManager, deployAccounts } from '../fixtures/snapshot_manager.js';
|
|
17
19
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
18
20
|
import { ensureAccountsPubliclyDeployed, getBalancesFn, setupCanonicalFeeJuice } from '../fixtures/utils.js';
|
|
19
21
|
import { FeeJuicePortalTestingHarnessFactory } from '../shared/gas_portal_test_harness.js';
|
|
@@ -27,8 +29,9 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
27
29
|
* FundAlice: Mints private and public bananas to Alice.
|
|
28
30
|
* SetupSubscription: Deploys a counter contract and a subscription contract, and mints Fee Juice to the subscription contract.
|
|
29
31
|
*/ export class FeesTest {
|
|
32
|
+
numberOfAccounts;
|
|
30
33
|
snapshotManager;
|
|
31
|
-
wallets
|
|
34
|
+
wallets;
|
|
32
35
|
logger;
|
|
33
36
|
pxe;
|
|
34
37
|
aztecNode;
|
|
@@ -47,16 +50,33 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
47
50
|
counterContract;
|
|
48
51
|
subscriptionContract;
|
|
49
52
|
feeJuiceBridgeTestHarness;
|
|
53
|
+
context;
|
|
54
|
+
chainMonitor;
|
|
50
55
|
getCoinbaseBalance;
|
|
56
|
+
getCoinbaseSequencerRewards;
|
|
51
57
|
getGasBalanceFn;
|
|
52
58
|
getBananaPublicBalanceFn;
|
|
53
59
|
getBananaPrivateBalanceFn;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
getProverFee;
|
|
61
|
+
ALICE_INITIAL_BANANAS;
|
|
62
|
+
SUBSCRIPTION_AMOUNT;
|
|
63
|
+
APP_SPONSORED_TX_GAS_LIMIT;
|
|
64
|
+
constructor(testName, numberOfAccounts = 3, setupOptions = {}){
|
|
65
|
+
this.numberOfAccounts = numberOfAccounts;
|
|
66
|
+
this.wallets = [];
|
|
67
|
+
this.ALICE_INITIAL_BANANAS = BigInt(1e22);
|
|
68
|
+
this.SUBSCRIPTION_AMOUNT = BigInt(1e19);
|
|
69
|
+
this.APP_SPONSORED_TX_GAS_LIMIT = BigInt(10e9);
|
|
70
|
+
if (!numberOfAccounts) {
|
|
71
|
+
throw new Error('There must be at least 1 initial account.');
|
|
72
|
+
}
|
|
58
73
|
this.logger = createLogger(`e2e:e2e_fees:${testName}`);
|
|
59
|
-
this.snapshotManager = createSnapshotManager(`e2e_fees/${testName}`, dataPath
|
|
74
|
+
this.snapshotManager = createSnapshotManager(`e2e_fees/${testName}-${numberOfAccounts}`, dataPath, {
|
|
75
|
+
startProverNode: true,
|
|
76
|
+
...setupOptions
|
|
77
|
+
}, {
|
|
78
|
+
...setupOptions
|
|
79
|
+
});
|
|
60
80
|
}
|
|
61
81
|
async setup() {
|
|
62
82
|
const context = await this.snapshotManager.setup();
|
|
@@ -64,11 +84,17 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
64
84
|
feeRecipient: this.sequencerAddress,
|
|
65
85
|
coinbase: this.coinbase
|
|
66
86
|
});
|
|
87
|
+
const rollupContract = RollupContract.getFromConfig(context.aztecNodeConfig);
|
|
88
|
+
this.chainMonitor = new ChainMonitor(rollupContract, this.logger, 200).start();
|
|
67
89
|
return this;
|
|
68
90
|
}
|
|
69
91
|
async teardown() {
|
|
92
|
+
this.chainMonitor.stop();
|
|
70
93
|
await this.snapshotManager.teardown();
|
|
71
94
|
}
|
|
95
|
+
setIsMarkingAsProven(b) {
|
|
96
|
+
this.context.watcher.setIsMarkingAsProven(b);
|
|
97
|
+
}
|
|
72
98
|
async catchUpProvenChain() {
|
|
73
99
|
const bn = await this.aztecNode.getBlockNumber();
|
|
74
100
|
while(await this.aztecNode.getProvenBlockNumber() < bn){
|
|
@@ -93,16 +119,14 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
93
119
|
await this.applyDeployBananaTokenSnapshot();
|
|
94
120
|
}
|
|
95
121
|
async applyInitialAccountsSnapshot() {
|
|
96
|
-
await this.snapshotManager.snapshot('initial_accounts',
|
|
122
|
+
await this.snapshotManager.snapshot('initial_accounts', deployAccounts(this.numberOfAccounts, this.logger), async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig })=>{
|
|
97
123
|
this.pxe = pxe;
|
|
98
124
|
this.aztecNode = aztecNode;
|
|
99
125
|
this.gasSettings = GasSettings.default({
|
|
100
126
|
maxFeesPerGas: (await this.aztecNode.getCurrentBaseFees()).mul(2)
|
|
101
127
|
});
|
|
102
|
-
this.cheatCodes = await CheatCodes.create(aztecNodeConfig.
|
|
103
|
-
|
|
104
|
-
await Promise.all(accountManagers.map((a)=>a.register()));
|
|
105
|
-
this.wallets = await Promise.all(accountManagers.map((a)=>a.getWallet()));
|
|
128
|
+
this.cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
129
|
+
this.wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
106
130
|
this.wallets.forEach((w, i)=>this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
107
131
|
[this.aliceWallet, this.bobWallet] = this.wallets.slice(0, 2);
|
|
108
132
|
[this.aliceAddress, this.bobAddress, this.sequencerAddress] = this.wallets.map((w)=>w.getAddress());
|
|
@@ -110,13 +134,12 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
110
134
|
this.fpcAdmin = this.aliceAddress;
|
|
111
135
|
const canonicalFeeJuice = await getCanonicalFeeJuice();
|
|
112
136
|
this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.aliceWallet);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
137
|
+
if (this.numberOfAccounts > 1) {
|
|
138
|
+
const bobInstance = (await this.bobWallet.getContractMetadata(this.bobAddress)).contractInstance;
|
|
139
|
+
await this.aliceWallet.registerAccount(deployedAccounts[1].secret, await computePartialAddress(bobInstance));
|
|
116
140
|
}
|
|
117
|
-
await this.aliceWallet.registerAccount(accountKeys[1][0], await computePartialAddress(bobInstance));
|
|
118
141
|
this.coinbase = EthAddress.random();
|
|
119
|
-
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.
|
|
142
|
+
const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
120
143
|
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
121
144
|
aztecNode: aztecNode,
|
|
122
145
|
pxeService: pxe,
|
|
@@ -132,11 +155,12 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
132
155
|
}
|
|
133
156
|
async applySetupFeeJuiceSnapshot() {
|
|
134
157
|
await this.snapshotManager.snapshot('setup_fee_juice', async (context)=>{
|
|
135
|
-
await setupCanonicalFeeJuice(
|
|
158
|
+
await setupCanonicalFeeJuice(context.pxe);
|
|
136
159
|
}, async (_data, context)=>{
|
|
160
|
+
this.context = context;
|
|
137
161
|
this.feeJuiceContract = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, this.aliceWallet);
|
|
138
162
|
this.getGasBalanceFn = getBalancesFn('⛽', this.feeJuiceContract.methods.balance_of_public, this.logger);
|
|
139
|
-
const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.
|
|
163
|
+
const { publicClient, walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
140
164
|
this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
|
|
141
165
|
aztecNode: context.aztecNode,
|
|
142
166
|
pxeService: context.pxe,
|
|
@@ -169,7 +193,8 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
169
193
|
return {
|
|
170
194
|
bananaFPCAddress: bananaFPC.address,
|
|
171
195
|
feeJuiceAddress: feeJuiceContract.address,
|
|
172
|
-
l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress
|
|
196
|
+
l1FeeJuiceAddress: this.feeJuiceBridgeTestHarness.l1FeeJuiceAddress,
|
|
197
|
+
rollupAddress: context.deployL1ContractsValues.l1ContractAddresses.rollupAddress
|
|
173
198
|
};
|
|
174
199
|
}, async (data, context)=>{
|
|
175
200
|
const bananaFPC = await FPCContract.at(data.bananaFPCAddress, this.aliceWallet);
|
|
@@ -178,7 +203,7 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
178
203
|
this.getBananaPublicBalanceFn = getBalancesFn('🍌.public', this.bananaCoin.methods.balance_of_public, logger);
|
|
179
204
|
this.getBananaPrivateBalanceFn = getBalancesFn('🍌.private', this.bananaCoin.methods.balance_of_private, logger);
|
|
180
205
|
this.getCoinbaseBalance = async ()=>{
|
|
181
|
-
const { walletClient } = createL1Clients(context.aztecNodeConfig.
|
|
206
|
+
const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
182
207
|
const gasL1 = getContract({
|
|
183
208
|
address: data.l1FeeJuiceAddress.toString(),
|
|
184
209
|
abi: TestERC20Abi,
|
|
@@ -188,6 +213,29 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
188
213
|
this.coinbase.toString()
|
|
189
214
|
]);
|
|
190
215
|
};
|
|
216
|
+
this.getCoinbaseSequencerRewards = async ()=>{
|
|
217
|
+
const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
218
|
+
const rollup = getContract({
|
|
219
|
+
address: data.rollupAddress.toString(),
|
|
220
|
+
abi: RollupAbi,
|
|
221
|
+
client: walletClient
|
|
222
|
+
});
|
|
223
|
+
return await rollup.read.getSequencerRewards([
|
|
224
|
+
this.coinbase.toString()
|
|
225
|
+
]);
|
|
226
|
+
};
|
|
227
|
+
this.getProverFee = async (blockNumber)=>{
|
|
228
|
+
const { walletClient } = createL1Clients(context.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
229
|
+
const rollup = getContract({
|
|
230
|
+
address: data.rollupAddress.toString(),
|
|
231
|
+
abi: RollupAbi,
|
|
232
|
+
client: walletClient
|
|
233
|
+
});
|
|
234
|
+
const provingCostPerMana = await rollup.read.getProvingCostPerManaInFeeAsset();
|
|
235
|
+
const block = await this.pxe.getBlock(blockNumber);
|
|
236
|
+
const mana = block.header.totalManaUsed.toBigInt();
|
|
237
|
+
return mana * provingCostPerMana;
|
|
238
|
+
};
|
|
191
239
|
});
|
|
192
240
|
}
|
|
193
241
|
async applyFundAliceWithBananas() {
|
|
@@ -201,11 +249,6 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
201
249
|
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
|
|
202
250
|
}, ()=>Promise.resolve());
|
|
203
251
|
}
|
|
204
|
-
async applyFundAliceWithFeeJuice() {
|
|
205
|
-
await this.snapshotManager.snapshot('fund_alice_with_fee_juice', async ()=>{
|
|
206
|
-
await this.mintAndBridgeFeeJuice(this.aliceAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT);
|
|
207
|
-
}, ()=>Promise.resolve());
|
|
208
|
-
}
|
|
209
252
|
async applySetupSubscription() {
|
|
210
253
|
await this.snapshotManager.snapshot('setup_subscription', async ()=>{
|
|
211
254
|
const counterContract = await CounterContract.deploy(this.bobWallet, 0, this.bobAddress).send().deployed();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AccountWallet, type CompleteAddress, type Logger, type PXE } from '@aztec/aztec.js';
|
|
2
|
+
import { ChildContract } from '@aztec/noir-contracts.js/Child';
|
|
3
|
+
import { ParentContract } from '@aztec/noir-contracts.js/Parent';
|
|
4
|
+
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
5
|
+
export declare class NestedContractTest {
|
|
6
|
+
private numberOfAccounts;
|
|
7
|
+
private snapshotManager;
|
|
8
|
+
logger: Logger;
|
|
9
|
+
wallets: AccountWallet[];
|
|
10
|
+
accounts: CompleteAddress[];
|
|
11
|
+
pxe: PXE;
|
|
12
|
+
parentContract: ParentContract;
|
|
13
|
+
childContract: ChildContract;
|
|
14
|
+
constructor(testName: string, numberOfAccounts?: number);
|
|
15
|
+
/**
|
|
16
|
+
* Adds two state shifts to snapshot manager.
|
|
17
|
+
* 1. Add 3 accounts.
|
|
18
|
+
* 2. Publicly deploy accounts
|
|
19
|
+
*/
|
|
20
|
+
applyBaseSnapshots(): Promise<void>;
|
|
21
|
+
setup(): Promise<void>;
|
|
22
|
+
teardown(): Promise<void>;
|
|
23
|
+
snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
|
|
24
|
+
applyManualSnapshots(): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=nested_contract_test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nested_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_nested_contract/nested_contract_test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,MAAM,EAAE,KAAK,GAAG,EAAgB,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AAIzC,qBAAa,kBAAkB;IAUC,OAAO,CAAC,gBAAgB;IATtD,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,EAAE,CAAM;IAC9B,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,GAAG,EAAG,GAAG,CAAC;IAEV,cAAc,EAAG,cAAc,CAAC;IAChC,aAAa,EAAG,aAAa,CAAC;gBAElB,QAAQ,EAAE,MAAM,EAAU,gBAAgB,SAAI;IAK1D;;;;OAIG;IACG,kBAAkB;IAsBlB,KAAK;IAIL,QAAQ;IAId,QAAQ,YACA,MAAM,SACL,CAAC,OAAO,EAAE,iBAAiB,KAAK,QAAQ,CAAC,CAAC,YACxC,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,QAAQ,IAAI,CAAC,KACtE,QAAQ,IAAI,CAAC,CAAwD;IAElE,oBAAoB;CAc3B"}
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { createLogger } from '@aztec/aztec.js';
|
|
3
3
|
import { ChildContract } from '@aztec/noir-contracts.js/Child';
|
|
4
4
|
import { ParentContract } from '@aztec/noir-contracts.js/Parent';
|
|
5
|
-
import {
|
|
5
|
+
import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
|
|
6
6
|
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
7
7
|
export class NestedContractTest {
|
|
8
|
+
numberOfAccounts;
|
|
8
9
|
snapshotManager;
|
|
9
10
|
logger;
|
|
10
|
-
wallets
|
|
11
|
-
accounts
|
|
11
|
+
wallets;
|
|
12
|
+
accounts;
|
|
12
13
|
pxe;
|
|
13
14
|
parentContract;
|
|
14
15
|
childContract;
|
|
15
|
-
constructor(testName){
|
|
16
|
+
constructor(testName, numberOfAccounts = 1){
|
|
17
|
+
this.numberOfAccounts = numberOfAccounts;
|
|
18
|
+
this.wallets = [];
|
|
19
|
+
this.accounts = [];
|
|
20
|
+
this.snapshot = (name, apply, restore = ()=>Promise.resolve())=>this.snapshotManager.snapshot(name, apply, restore);
|
|
16
21
|
this.logger = createLogger(`e2e:e2e_nested_contract:${testName}`);
|
|
17
|
-
this.snapshotManager = createSnapshotManager(`e2e_nested_contract/${testName}`, dataPath);
|
|
22
|
+
this.snapshotManager = createSnapshotManager(`e2e_nested_contract/${testName}-${numberOfAccounts}`, dataPath);
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
20
25
|
* Adds two state shifts to snapshot manager.
|
|
21
26
|
* 1. Add 3 accounts.
|
|
22
27
|
* 2. Publicly deploy accounts
|
|
23
28
|
*/ async applyBaseSnapshots() {
|
|
24
|
-
await this.snapshotManager.snapshot('
|
|
25
|
-
this.wallets = await Promise.all(
|
|
26
|
-
const account = await getSchnorrAccount(pxe, ak[0], ak[1], 1);
|
|
27
|
-
return account.getWallet();
|
|
28
|
-
}));
|
|
29
|
+
await this.snapshotManager.snapshot('accounts', deployAccounts(this.numberOfAccounts, this.logger), async ({ deployedAccounts }, { pxe })=>{
|
|
30
|
+
this.wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
29
31
|
this.accounts = await pxe.getRegisteredAccounts();
|
|
30
32
|
this.wallets.forEach((w, i)=>this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
31
33
|
this.pxe = pxe;
|
|
@@ -41,7 +43,7 @@ export class NestedContractTest {
|
|
|
41
43
|
async teardown() {
|
|
42
44
|
await this.snapshotManager.teardown();
|
|
43
45
|
}
|
|
44
|
-
snapshot
|
|
46
|
+
snapshot;
|
|
45
47
|
async applyManualSnapshots() {
|
|
46
48
|
await this.snapshotManager.snapshot('manual', async ()=>{
|
|
47
49
|
const parentContract = await ParentContract.deploy(this.wallets[0]).send().deployed();
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
3
|
+
import type { AccountWalletWithSecretKey } from '@aztec/aztec.js';
|
|
4
|
+
import { ChainMonitor } from '@aztec/aztec.js/ethereum';
|
|
5
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
6
|
+
import { SpamContract } from '@aztec/noir-contracts.js/Spam';
|
|
7
|
+
import type { BootstrapNode } from '@aztec/p2p/bootstrap';
|
|
8
|
+
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
9
|
+
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
10
|
+
export declare const WAIT_FOR_TX_TIMEOUT: number;
|
|
11
|
+
export declare const SHORTENED_BLOCK_TIME_CONFIG: {
|
|
12
|
+
aztecSlotDuration: number;
|
|
13
|
+
ethereumSlotDuration: number;
|
|
14
|
+
};
|
|
15
|
+
export declare class P2PNetworkTest {
|
|
16
|
+
bootstrapNodeEnr: string;
|
|
17
|
+
bootNodePort: number;
|
|
18
|
+
private numberOfNodes;
|
|
19
|
+
private metricsPort?;
|
|
20
|
+
private snapshotManager;
|
|
21
|
+
private baseAccount;
|
|
22
|
+
logger: Logger;
|
|
23
|
+
monitor: ChainMonitor;
|
|
24
|
+
ctx: SubsystemsContext;
|
|
25
|
+
attesterPrivateKeys: `0x${string}`[];
|
|
26
|
+
attesterPublicKeys: string[];
|
|
27
|
+
proposerPrivateKeys: `0x${string}`[];
|
|
28
|
+
peerIdPrivateKeys: string[];
|
|
29
|
+
deployedAccounts: InitialAccountData[];
|
|
30
|
+
prefilledPublicData: PublicDataTreeLeaf[];
|
|
31
|
+
wallet?: AccountWalletWithSecretKey;
|
|
32
|
+
spamContract?: SpamContract;
|
|
33
|
+
bootstrapNode?: BootstrapNode;
|
|
34
|
+
private cleanupInterval;
|
|
35
|
+
private gasUtils;
|
|
36
|
+
constructor(testName: string, bootstrapNodeEnr: string, bootNodePort: number, numberOfNodes: number, initialValidatorConfig: AztecNodeConfig, metricsPort?: number | undefined);
|
|
37
|
+
static create({ testName, numberOfNodes, basePort, metricsPort, initialConfig, }: {
|
|
38
|
+
testName: string;
|
|
39
|
+
numberOfNodes: number;
|
|
40
|
+
basePort?: number;
|
|
41
|
+
metricsPort?: number;
|
|
42
|
+
initialConfig?: Partial<AztecNodeConfig>;
|
|
43
|
+
}): Promise<P2PNetworkTest>;
|
|
44
|
+
get fundedAccount(): InitialAccountData;
|
|
45
|
+
/**
|
|
46
|
+
* Start a loop to sync the mock system time with the L1 block time
|
|
47
|
+
*/
|
|
48
|
+
startSyncMockSystemTimeInterval(): void;
|
|
49
|
+
/**
|
|
50
|
+
* When using fake timers, we need to keep the system and anvil clocks in sync.
|
|
51
|
+
*/
|
|
52
|
+
syncMockSystemTime(): Promise<void>;
|
|
53
|
+
applyBaseSnapshots(): Promise<void>;
|
|
54
|
+
setupAccount(): Promise<void>;
|
|
55
|
+
deploySpamContract(): Promise<void>;
|
|
56
|
+
removeInitialNode(): Promise<void>;
|
|
57
|
+
setup(): Promise<void>;
|
|
58
|
+
stopNodes(nodes: AztecNodeService[]): Promise<void>;
|
|
59
|
+
teardown(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceM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