@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-c83136db25
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 +73 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +311 -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 +99 -0
- package/dest/bench/utils.d.ts +10 -36
- 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 +20 -12
- 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 +18 -24
- 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 +48 -69
- package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
- 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 +58 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +224 -43
- 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 +20 -9
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +98 -107
- 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 +57 -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 +9 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
- 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 +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +69 -22
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +180 -129
- package/dest/e2e_p2p/shared.d.ts +41 -5
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +163 -19
- package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
- 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/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
- package/dest/fixtures/fixtures.d.ts +5 -6
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +4 -3
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- 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 +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +10 -17
- package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
- 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/setup_l1_contracts.d.ts +3 -3
- 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 +14 -13
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +73 -21
- package/dest/fixtures/snapshot_manager.d.ts +15 -7
- 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 +6 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +23 -10
- package/dest/fixtures/utils.d.ts +76 -37
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +464 -368
- 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/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +41 -25
- 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 +32 -24
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +50 -29
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- 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 +13 -11
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +138 -108
- package/dest/simulators/lending_simulator.d.ts +6 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +13 -16
- package/dest/simulators/token_simulator.d.ts +5 -2
- 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 +23 -10
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +167 -58
- package/dest/spartan/utils.d.ts +100 -303
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +407 -130
- package/package.json +61 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +402 -0
- package/src/bench/client_flows/config.ts +61 -0
- package/src/bench/client_flows/data_extractor.ts +111 -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 +63 -105
- package/src/e2e_deploy_contract/deploy_test.ts +23 -38
- package/src/e2e_epochs/epochs_test.ts +274 -54
- package/src/e2e_fees/bridging_race.notest.ts +80 -0
- package/src/e2e_fees/fees_test.ts +137 -136
- package/src/e2e_l1_publisher/write_json.ts +76 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +272 -166
- package/src/e2e_p2p/shared.ts +244 -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 +101 -145
- 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 +112 -38
- package/src/fixtures/snapshot_manager.ts +187 -139
- package/src/fixtures/token_utils.ts +29 -12
- package/src/fixtures/utils.ts +552 -425
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +6 -14
- 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 +58 -49
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +173 -176
- package/src/simulators/lending_simulator.ts +12 -15
- package/src/simulators/token_simulator.ts +21 -13
- package/src/spartan/DEVELOP.md +121 -0
- package/src/spartan/setup_test_wallets.ts +215 -93
- package/src/spartan/utils.ts +458 -130
- 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
package/dest/e2e_p2p/shared.js
CHANGED
|
@@ -1,39 +1,183 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { TxStatus } from '@aztec/aztec.js/tx';
|
|
4
|
+
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
6
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
7
|
+
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
8
|
+
import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
9
|
+
import { getRoundForOffense } from '@aztec/slasher';
|
|
10
|
+
import { TestWallet, proveInteraction } from '@aztec/test-wallet/server';
|
|
4
11
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
5
12
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
6
|
-
export const submitComplexTxsTo = async (logger, spamContract, numTxs, opts = {})=>{
|
|
13
|
+
export const submitComplexTxsTo = async (logger, from, spamContract, numTxs, opts = {})=>{
|
|
7
14
|
const txs = [];
|
|
8
15
|
const seed = 1234n;
|
|
9
16
|
const spamCount = 15;
|
|
10
17
|
for(let i = 0; i < numTxs; i++){
|
|
11
18
|
const tx = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic).send({
|
|
12
|
-
|
|
19
|
+
from
|
|
13
20
|
});
|
|
14
21
|
const txHash = await tx.getTxHash();
|
|
15
|
-
logger.info(`Tx sent with hash ${txHash}`);
|
|
22
|
+
logger.info(`Tx sent with hash ${txHash.toString()}`);
|
|
16
23
|
const receipt = await tx.getReceipt();
|
|
17
24
|
expect(receipt).toEqual(expect.objectContaining({
|
|
18
25
|
status: TxStatus.PENDING,
|
|
19
26
|
error: ''
|
|
20
27
|
}));
|
|
21
|
-
logger.info(`Receipt received for ${txHash}`);
|
|
28
|
+
logger.info(`Receipt received for ${txHash.toString()}`);
|
|
22
29
|
txs.push(tx);
|
|
23
30
|
}
|
|
24
31
|
return txs;
|
|
25
32
|
};
|
|
26
|
-
// creates
|
|
27
|
-
export const
|
|
33
|
+
// creates a wallet and submit a given number of transactions through it.
|
|
34
|
+
export const submitTransactions = async (logger, node, numTxs, fundedAccount)=>{
|
|
28
35
|
const rpcConfig = getRpcConfig();
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
36
|
+
rpcConfig.proverEnabled = false;
|
|
37
|
+
const wallet = await TestWallet.create(node, {
|
|
38
|
+
...getPXEConfig(),
|
|
39
|
+
proverEnabled: false
|
|
40
|
+
}, {
|
|
41
|
+
useLogSuffix: true
|
|
42
|
+
});
|
|
43
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
44
|
+
return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
|
|
39
45
|
};
|
|
46
|
+
export async function prepareTransactions(logger, node, numTxs, fundedAccount) {
|
|
47
|
+
const rpcConfig = getRpcConfig();
|
|
48
|
+
rpcConfig.proverEnabled = false;
|
|
49
|
+
const wallet = await TestWallet.create(node, {
|
|
50
|
+
...getPXEConfig(),
|
|
51
|
+
proverEnabled: false
|
|
52
|
+
}, {
|
|
53
|
+
useLogSuffix: true
|
|
54
|
+
});
|
|
55
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
56
|
+
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
57
|
+
salt: Fr.random()
|
|
58
|
+
});
|
|
59
|
+
await wallet.registerContract(testContractInstance, TestContractArtifact);
|
|
60
|
+
const contract = await TestContract.at(testContractInstance.address, wallet);
|
|
61
|
+
return timesAsync(numTxs, async ()=>{
|
|
62
|
+
const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
|
|
63
|
+
from: fundedAccountManager.address
|
|
64
|
+
});
|
|
65
|
+
const txHash = tx.getTxHash();
|
|
66
|
+
logger.info(`Tx prepared with hash ${txHash}`);
|
|
67
|
+
return tx;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
export function awaitProposalExecution(slashingProposer, timeoutSeconds, logger) {
|
|
71
|
+
return new Promise((resolve, reject)=>{
|
|
72
|
+
const timeout = setTimeout(()=>{
|
|
73
|
+
logger.warn(`Timed out waiting for proposal execution`);
|
|
74
|
+
reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
|
|
75
|
+
}, timeoutSeconds * 1000);
|
|
76
|
+
if (slashingProposer.type === 'empire') {
|
|
77
|
+
const unwatch = slashingProposer.listenToPayloadSubmitted((args)=>{
|
|
78
|
+
logger.warn(`Proposal ${args.payload} from round ${args.round} executed`);
|
|
79
|
+
clearTimeout(timeout);
|
|
80
|
+
unwatch();
|
|
81
|
+
resolve(args.round);
|
|
82
|
+
});
|
|
83
|
+
} else if (slashingProposer.type === 'tally') {
|
|
84
|
+
const unwatch = slashingProposer.listenToRoundExecuted((args)=>{
|
|
85
|
+
logger.warn(`Slash from round ${args.round} executed`);
|
|
86
|
+
clearTimeout(timeout);
|
|
87
|
+
unwatch();
|
|
88
|
+
resolve(args.round);
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
clearTimeout(timeout);
|
|
92
|
+
reject(new Error(`Unknown slashing proposer type: ${slashingProposer.type}`));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export async function awaitCommitteeExists({ rollup, logger }) {
|
|
97
|
+
logger.info(`Waiting for committee to be set`);
|
|
98
|
+
let committee;
|
|
99
|
+
await retryUntil(async ()=>{
|
|
100
|
+
committee = await rollup.getCurrentEpochCommittee();
|
|
101
|
+
return committee && committee.length > 0;
|
|
102
|
+
}, 'non-empty committee', 60);
|
|
103
|
+
return committee;
|
|
104
|
+
}
|
|
105
|
+
export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, timeoutSeconds = 120 }) {
|
|
106
|
+
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
107
|
+
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
108
|
+
const offenses = await retryUntil(async ()=>{
|
|
109
|
+
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
110
|
+
if (offenses.length >= targetOffenseCount) {
|
|
111
|
+
return offenses;
|
|
112
|
+
}
|
|
113
|
+
}, 'non-empty offenses', timeoutSeconds);
|
|
114
|
+
logger.info(`Hit ${offenses.length} offenses on rounds ${unique(offenses.map((o)=>getRoundForOffense(o, {
|
|
115
|
+
slashingRoundSize,
|
|
116
|
+
epochDuration
|
|
117
|
+
})))}`, {
|
|
118
|
+
offenses
|
|
119
|
+
});
|
|
120
|
+
return offenses;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Await the committee to be slashed out of the validator set.
|
|
124
|
+
* Currently assumes that the committee is the same size as the validator set.
|
|
125
|
+
*/ export async function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, aztecEpochDuration, logger, offenseEpoch }) {
|
|
126
|
+
if (!slashingProposer) {
|
|
127
|
+
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
128
|
+
}
|
|
129
|
+
await cheatCodes.debugRollup();
|
|
130
|
+
if (slashingProposer.type === 'empire') {
|
|
131
|
+
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
132
|
+
const targetEpoch = await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n;
|
|
133
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
134
|
+
await cheatCodes.advanceToEpoch(targetEpoch);
|
|
135
|
+
const slashPayloadEvents = await retryUntil(async ()=>{
|
|
136
|
+
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
137
|
+
return events.length > 0 ? events : undefined;
|
|
138
|
+
}, 'slash payload created', 120, 1);
|
|
139
|
+
expect(slashPayloadEvents.length).toBe(1);
|
|
140
|
+
// The uniqueness check is needed since a validator may be slashed more than once on the same round (eg because they let two epochs be pruned)
|
|
141
|
+
expect(unique(slashPayloadEvents[0].slashes.map((slash)=>slash.validator.toString()))).toHaveLength(committee.length);
|
|
142
|
+
} else {
|
|
143
|
+
// Use the slash offset to ensure we are in the right epoch for tally
|
|
144
|
+
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
145
|
+
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
146
|
+
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
147
|
+
const firstEpochInOffenseRound = offenseEpoch - offenseEpoch % slashingRoundSizeInEpochs;
|
|
148
|
+
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
149
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
150
|
+
await cheatCodes.advanceToEpoch(targetEpoch, {
|
|
151
|
+
offset: -aztecSlotDuration / 2
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const attestersPre = await rollup.getAttesters();
|
|
155
|
+
expect(attestersPre.length).toBe(committee.length);
|
|
156
|
+
for (const attester of attestersPre){
|
|
157
|
+
const attesterInfo = await rollup.getAttesterView(attester);
|
|
158
|
+
expect(attesterInfo.status).toEqual(1); // Validating
|
|
159
|
+
}
|
|
160
|
+
const timeout = slashingRoundSize * 2 * aztecSlotDuration + 30;
|
|
161
|
+
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
162
|
+
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
163
|
+
// The attesters should still form the committee but they should be reduced to the "living" status
|
|
164
|
+
await cheatCodes.debugRollup();
|
|
165
|
+
const committeePostSlashing = await rollup.getCurrentEpochCommittee();
|
|
166
|
+
expect(committeePostSlashing?.length).toBe(attestersPre.length);
|
|
167
|
+
const attestersPostSlashing = await rollup.getAttesters();
|
|
168
|
+
expect(attestersPostSlashing.length).toBe(0);
|
|
169
|
+
for (const attester of attestersPre){
|
|
170
|
+
const attesterInfo = await rollup.getAttesterView(attester);
|
|
171
|
+
expect(attesterInfo.status).toEqual(2); // Living
|
|
172
|
+
}
|
|
173
|
+
logger.info(`Advancing to check current committee`);
|
|
174
|
+
await cheatCodes.debugRollup();
|
|
175
|
+
await cheatCodes.advanceToEpoch(await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n);
|
|
176
|
+
await cheatCodes.debugRollup();
|
|
177
|
+
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
178
|
+
// The committee should be undefined, since the validator set is empty
|
|
179
|
+
// and the tests currently using this helper always set a target committee size.
|
|
180
|
+
expect(committeeNextEpoch).toBeUndefined();
|
|
181
|
+
const attestersNextEpoch = await rollup.getAttesters();
|
|
182
|
+
expect(attestersNextEpoch.length).toBe(0);
|
|
183
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
+
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
6
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
4
7
|
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
5
8
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
6
9
|
export declare class TokenContractTest {
|
|
@@ -9,11 +12,14 @@ export declare class TokenContractTest {
|
|
|
9
12
|
static TOKEN_DECIMALS: bigint;
|
|
10
13
|
private snapshotManager;
|
|
11
14
|
logger: Logger;
|
|
12
|
-
wallets: AccountWallet[];
|
|
13
|
-
accounts: CompleteAddress[];
|
|
14
15
|
asset: TokenContract;
|
|
15
16
|
tokenSim: TokenSimulator;
|
|
16
|
-
|
|
17
|
+
node: AztecNode;
|
|
18
|
+
badAccount: InvalidAccountContract;
|
|
19
|
+
wallet: TestWallet;
|
|
20
|
+
adminAddress: AztecAddress;
|
|
21
|
+
account1Address: AztecAddress;
|
|
22
|
+
account2Address: AztecAddress;
|
|
17
23
|
constructor(testName: string);
|
|
18
24
|
/**
|
|
19
25
|
* Adds two state shifts to snapshot manager.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_token_contract/token_contract_test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_token_contract/token_contract_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAIlE,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,UAAU,SAAU;IAC3B,MAAM,CAAC,YAAY,SAAS;IAC5B,MAAM,CAAC,cAAc,SAAO;IAC5B,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAG,aAAa,CAAC;IACtB,QAAQ,EAAG,cAAc,CAAC;IAC1B,IAAI,EAAG,SAAS,CAAC;IAEjB,UAAU,EAAG,sBAAsB,CAAC;IACpC,MAAM,EAAG,UAAU,CAAC;IACpB,YAAY,EAAG,YAAY,CAAC;IAC5B,eAAe,EAAG,YAAY,CAAC;IAC/B,eAAe,EAAG,YAAY,CAAC;gBAEnB,QAAQ,EAAE,MAAM;IAO5B;;;;OAIG;IACG,kBAAkB;IAkElB,KAAK;IAIX,QAAQ,GAAI,CAAC,EACX,MAAM,MAAM,EACZ,OAAO,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACjD,UAAS,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAA2B,KAChG,OAAO,CAAC,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAIR,iBAAiB;CAqCxB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createLogger } from '@aztec/aztec.js';
|
|
3
|
-
import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
|
|
1
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
4
2
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
|
+
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
5
4
|
import { jest } from '@jest/globals';
|
|
6
5
|
import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
|
|
7
6
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
@@ -13,11 +12,14 @@ export class TokenContractTest {
|
|
|
13
12
|
static TOKEN_DECIMALS = 18n;
|
|
14
13
|
snapshotManager;
|
|
15
14
|
logger;
|
|
16
|
-
wallets = [];
|
|
17
|
-
accounts = [];
|
|
18
15
|
asset;
|
|
19
16
|
tokenSim;
|
|
17
|
+
node;
|
|
20
18
|
badAccount;
|
|
19
|
+
wallet;
|
|
20
|
+
adminAddress;
|
|
21
|
+
account1Address;
|
|
22
|
+
account2Address;
|
|
21
23
|
constructor(testName){
|
|
22
24
|
this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
|
|
23
25
|
this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
|
|
@@ -31,20 +33,29 @@ export class TokenContractTest {
|
|
|
31
33
|
*/ async applyBaseSnapshots() {
|
|
32
34
|
// Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
|
|
33
35
|
jest.setTimeout(120_000);
|
|
34
|
-
await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger),
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
36
|
+
await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), ({ deployedAccounts }, { wallet, aztecNode })=>{
|
|
37
|
+
this.node = aztecNode;
|
|
38
|
+
this.wallet = wallet;
|
|
39
|
+
[this.adminAddress, this.account1Address, this.account2Address] = deployedAccounts.map((acc)=>acc.address);
|
|
40
|
+
return Promise.resolve();
|
|
37
41
|
});
|
|
38
42
|
await this.snapshotManager.snapshot('e2e_token_contract', async ()=>{
|
|
39
43
|
// Create the token contract state.
|
|
40
44
|
// Move this account thing to addAccounts above?
|
|
41
45
|
this.logger.verbose(`Public deploy accounts...`);
|
|
42
|
-
await publicDeployAccounts(this.
|
|
46
|
+
await publicDeployAccounts(this.wallet, [
|
|
47
|
+
this.adminAddress,
|
|
48
|
+
this.account1Address
|
|
49
|
+
]);
|
|
43
50
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
44
|
-
const asset = await TokenContract.deploy(this.
|
|
51
|
+
const asset = await TokenContract.deploy(this.wallet, this.adminAddress, TokenContractTest.TOKEN_NAME, TokenContractTest.TOKEN_SYMBOL, TokenContractTest.TOKEN_DECIMALS).send({
|
|
52
|
+
from: this.adminAddress
|
|
53
|
+
}).deployed();
|
|
45
54
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
46
55
|
this.logger.verbose(`Deploying bad account...`);
|
|
47
|
-
this.badAccount = await
|
|
56
|
+
this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({
|
|
57
|
+
from: this.adminAddress
|
|
58
|
+
}).deployed();
|
|
48
59
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
49
60
|
return {
|
|
50
61
|
tokenContractAddress: asset.address,
|
|
@@ -52,12 +63,17 @@ export class TokenContractTest {
|
|
|
52
63
|
};
|
|
53
64
|
}, async ({ tokenContractAddress, badAccountAddress })=>{
|
|
54
65
|
// Restore the token contract state.
|
|
55
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
66
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.wallet);
|
|
56
67
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
57
|
-
this.tokenSim = new TokenSimulator(this.asset, this.
|
|
58
|
-
|
|
68
|
+
this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
|
|
69
|
+
this.adminAddress,
|
|
70
|
+
this.account1Address
|
|
71
|
+
]);
|
|
72
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallet);
|
|
59
73
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
60
|
-
expect(await this.asset.methods.get_admin().simulate(
|
|
74
|
+
expect(await this.asset.methods.get_admin().simulate({
|
|
75
|
+
from: this.adminAddress
|
|
76
|
+
})).toBe(this.adminAddress.toBigInt());
|
|
61
77
|
});
|
|
62
78
|
// TokenContract.artifact.functions.forEach(fn => {
|
|
63
79
|
// const sig = decodeFunctionSignature(fn.name, fn.parameters);
|
|
@@ -73,27 +89,35 @@ export class TokenContractTest {
|
|
|
73
89
|
}
|
|
74
90
|
async applyMintSnapshot() {
|
|
75
91
|
await this.snapshotManager.snapshot('mint', async ()=>{
|
|
76
|
-
const { asset,
|
|
92
|
+
const { asset, adminAddress } = this;
|
|
77
93
|
const amount = 10000n;
|
|
78
94
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
79
|
-
await asset.methods.mint_to_public(
|
|
95
|
+
await asset.methods.mint_to_public(adminAddress, amount).send({
|
|
96
|
+
from: adminAddress
|
|
97
|
+
}).wait();
|
|
80
98
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
81
|
-
await mintTokensToPrivate(asset,
|
|
99
|
+
await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
|
|
82
100
|
this.logger.verbose(`Minting complete.`);
|
|
83
101
|
return {
|
|
84
102
|
amount
|
|
85
103
|
};
|
|
86
104
|
}, async ({ amount })=>{
|
|
87
|
-
const { asset,
|
|
88
|
-
tokenSim.mintPublic(
|
|
89
|
-
const publicBalance = await asset.methods.balance_of_public(
|
|
105
|
+
const { asset, adminAddress, tokenSim } = this;
|
|
106
|
+
tokenSim.mintPublic(adminAddress, amount);
|
|
107
|
+
const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({
|
|
108
|
+
from: adminAddress
|
|
109
|
+
});
|
|
90
110
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
91
|
-
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(
|
|
92
|
-
tokenSim.mintPrivate(
|
|
93
|
-
const privateBalance = await asset.methods.balance_of_private(
|
|
111
|
+
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
|
|
112
|
+
tokenSim.mintPrivate(adminAddress, amount);
|
|
113
|
+
const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({
|
|
114
|
+
from: adminAddress
|
|
115
|
+
});
|
|
94
116
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
95
|
-
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(
|
|
96
|
-
const totalSupply = await asset.methods.total_supply().simulate(
|
|
117
|
+
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
|
|
118
|
+
const totalSupply = await asset.methods.total_supply().simulate({
|
|
119
|
+
from: adminAddress
|
|
120
|
+
});
|
|
97
121
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
98
122
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
99
123
|
return Promise.resolve();
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import {
|
|
2
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { type Logger } from '@aztec/aztec.js/log';
|
|
4
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
5
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
3
6
|
import { type ClientProtocolCircuitVerifier } from '@aztec/bb-prover';
|
|
4
7
|
import type { BlobSinkServer } from '@aztec/blob-sink/server';
|
|
8
|
+
import type { DeployL1ContractsReturnType } from '@aztec/ethereum';
|
|
5
9
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
10
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
8
12
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
13
|
+
import { type SubsystemsContext } from './snapshot_manager.js';
|
|
9
14
|
/**
|
|
10
15
|
* Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
|
|
11
16
|
* However, we then setup a second PXE with a full prover instance.
|
|
@@ -20,20 +25,21 @@ export declare class FullProverTest {
|
|
|
20
25
|
static TOKEN_DECIMALS: bigint;
|
|
21
26
|
private snapshotManager;
|
|
22
27
|
logger: Logger;
|
|
28
|
+
wallet: TestWallet;
|
|
29
|
+
provenWallet: TestWallet;
|
|
30
|
+
accounts: AztecAddress[];
|
|
23
31
|
deployedAccounts: InitialAccountData[];
|
|
24
|
-
wallets: AccountWalletWithSecretKey[];
|
|
25
|
-
accounts: CompleteAddress[];
|
|
26
32
|
fakeProofsAsset: TokenContract;
|
|
27
33
|
tokenSim: TokenSimulator;
|
|
28
34
|
aztecNode: AztecNode;
|
|
29
|
-
|
|
35
|
+
aztecNodeAdmin: AztecNodeAdmin;
|
|
30
36
|
cheatCodes: CheatCodes;
|
|
31
37
|
blobSink: BlobSinkServer;
|
|
32
38
|
private provenComponents;
|
|
33
39
|
private bbConfigCleanup?;
|
|
34
40
|
private acvmConfigCleanup?;
|
|
35
41
|
circuitProofVerifier?: ClientProtocolCircuitVerifier;
|
|
36
|
-
|
|
42
|
+
provenAsset: TokenContract;
|
|
37
43
|
private context;
|
|
38
44
|
private proverNode;
|
|
39
45
|
private simulatedProverNode;
|
|
@@ -47,10 +53,9 @@ export declare class FullProverTest {
|
|
|
47
53
|
*/
|
|
48
54
|
applyBaseSnapshots(): Promise<void>;
|
|
49
55
|
setup(): Promise<this>;
|
|
50
|
-
private
|
|
56
|
+
private mintFeeJuice;
|
|
51
57
|
snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
|
|
52
58
|
teardown(): Promise<void>;
|
|
53
59
|
applyMintSnapshot(): Promise<void>;
|
|
54
|
-
deployVerifier(): Promise<void>;
|
|
55
60
|
}
|
|
56
61
|
//# sourceMappingURL=e2e_prover_test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"e2e_prover_test.d.ts","sourceRoot":"","sources":["../../src/fixtures/e2e_prover_test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAEL,KAAK,6BAA6B,EAGnC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAInE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAMvD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAEL,KAAK,iBAAiB,EAIvB,MAAM,uBAAuB,CAAC;AAU/B;;;;;GAKG;AAEH,qBAAa,cAAc;IA6BvB,OAAO,CAAC,sBAAsB;IAE9B,OAAO,CAAC,UAAU;IA9BpB,MAAM,CAAC,UAAU,SAAU;IAC3B,MAAM,CAAC,YAAY,SAAS;IAC5B,MAAM,CAAC,cAAc,SAAO;IAC5B,OAAO,CAAC,eAAe,CAAmB;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAG,UAAU,CAAC;IACpB,YAAY,EAAG,UAAU,CAAC;IAC1B,QAAQ,EAAE,YAAY,EAAE,CAAM;IAC9B,gBAAgB,EAAG,kBAAkB,EAAE,CAAC;IACxC,eAAe,EAAG,aAAa,CAAC;IAChC,QAAQ,EAAG,cAAc,CAAC;IAC1B,SAAS,EAAG,SAAS,CAAC;IACtB,cAAc,EAAG,cAAc,CAAC;IAChC,UAAU,EAAG,UAAU,CAAC;IACxB,QAAQ,EAAG,cAAc,CAAC;IAC1B,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,eAAe,CAAC,CAAsB;IAC9C,OAAO,CAAC,iBAAiB,CAAC,CAAsB;IAChD,oBAAoB,CAAC,EAAE,6BAA6B,CAAC;IACrD,WAAW,EAAG,aAAa,CAAC;IAC5B,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,mBAAmB,CAAc;IAClC,WAAW,EAAG,2BAA2B,CAAC;IAC1C,aAAa,EAAG,UAAU,CAAC;gBAGhC,QAAQ,EAAE,MAAM,EACR,sBAAsB,EAAE,MAAM,EACtC,QAAQ,EAAE,UAAU,EACZ,UAAU,UAAO;IAa3B;;;;OAIG;IACG,kBAAkB;IAsDlB,KAAK;YA6IG,YAAY;IAS1B,QAAQ,GAAI,CAAC,EACX,MAAM,MAAM,EACZ,OAAO,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACjD,UAAS,CAAC,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAA2B,KAChG,OAAO,CAAC,IAAI,CAAC,CAAwD;IAElE,QAAQ;IAeR,iBAAiB;CA8CxB"}
|