@aztec/end-to-end 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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 +60 -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 +69 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
- package/dest/bench/client_flows/client_flows_benchmark.js +315 -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 -27
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +27 -43
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +15 -7
- 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 +66 -38
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -18
- 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 +34 -53
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -6
- package/dest/e2e_epochs/epochs_test.d.ts +56 -17
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +222 -42
- 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 +60 -0
- package/dest/e2e_fees/fees_test.d.ts +16 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +87 -88
- package/dest/e2e_l1_publisher/write_json.d.ts +8 -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 +5 -5
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +19 -14
- 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 +132 -0
- package/dest/e2e_p2p/p2p_network.d.ts +56 -21
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +154 -125
- package/dest/e2e_p2p/shared.d.ts +41 -3
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +146 -6
- package/dest/e2e_token_contract/token_contract_test.d.ts +10 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +51 -24
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +7 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
- package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +67 -62
- 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.map +1 -1
- package/dest/fixtures/get_acvm_config.js +2 -14
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +8 -15
- 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 +3 -3
- package/dest/fixtures/setup_p2p_test.d.ts +14 -6
- 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 +8 -3
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +120 -104
- package/dest/fixtures/token_utils.d.ts +4 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +24 -7
- package/dest/fixtures/utils.d.ts +65 -22
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +439 -318
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +42 -0
- package/dest/shared/cross_chain_test_harness.d.ts +28 -18
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +97 -41
- package/dest/shared/gas_portal_test_harness.d.ts +23 -18
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +43 -25
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +5 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +136 -90
- package/dest/simulators/lending_simulator.d.ts +5 -6
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +11 -15
- package/dest/simulators/token_simulator.d.ts +2 -1
- 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 +8 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -22
- package/dest/spartan/utils.d.ts +60 -307
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +200 -115
- package/package.json +60 -56
- package/src/bench/client_flows/benchmark.ts +341 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +422 -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 +26 -52
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +60 -40
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -75
- package/src/e2e_deploy_contract/deploy_test.ts +11 -8
- package/src/e2e_epochs/epochs_test.ts +276 -54
- package/src/e2e_fees/bridging_race.notest.ts +75 -0
- package/src/e2e_fees/fees_test.ts +121 -108
- package/src/e2e_l1_publisher/write_json.ts +74 -0
- package/src/e2e_multi_validator/utils.ts +258 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +22 -14
- package/src/e2e_p2p/inactivity_slash_test.ts +174 -0
- package/src/e2e_p2p/p2p_network.ts +212 -144
- package/src/e2e_p2p/shared.ts +234 -14
- package/src/e2e_token_contract/token_contract_test.ts +42 -38
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +62 -69
- package/src/fixtures/fixtures.ts +4 -3
- package/src/fixtures/get_acvm_config.ts +2 -10
- package/src/fixtures/get_bb_config.ts +15 -11
- package/src/fixtures/l1_to_l2_messaging.ts +53 -23
- package/src/fixtures/setup_l1_contracts.ts +5 -6
- package/src/fixtures/setup_p2p_test.ts +112 -30
- package/src/fixtures/snapshot_manager.ts +150 -102
- package/src/fixtures/token_utils.ts +33 -8
- package/src/fixtures/utils.ts +530 -352
- package/src/fixtures/web3signer.ts +46 -0
- package/src/guides/up_quick_start.sh +4 -4
- package/src/shared/cross_chain_test_harness.ts +92 -52
- package/src/shared/gas_portal_test_harness.ts +47 -31
- package/src/shared/uniswap_l1_l2.ts +127 -124
- package/src/simulators/lending_simulator.ts +11 -15
- package/src/simulators/token_simulator.ts +17 -12
- package/src/spartan/DEVELOP.md +116 -0
- package/src/spartan/setup_test_wallets.ts +144 -29
- package/src/spartan/utils.ts +194 -116
- 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,24 +1,28 @@
|
|
|
1
1
|
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { TxStatus } from '@aztec/aztec.js';
|
|
2
|
+
import { Fr, TxStatus, getContractInstanceFromInstantiationParams, retryUntil } from '@aztec/aztec.js';
|
|
3
|
+
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
4
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
5
|
+
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
3
6
|
import { createPXEService, getPXEServiceConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
7
|
+
import { getRoundForOffense } from '@aztec/slasher';
|
|
4
8
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
5
9
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
6
|
-
export const submitComplexTxsTo = async (logger, spamContract, numTxs, opts = {})=>{
|
|
10
|
+
export const submitComplexTxsTo = async (logger, from, spamContract, numTxs, opts = {})=>{
|
|
7
11
|
const txs = [];
|
|
8
12
|
const seed = 1234n;
|
|
9
13
|
const spamCount = 15;
|
|
10
14
|
for(let i = 0; i < numTxs; i++){
|
|
11
15
|
const tx = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic).send({
|
|
12
|
-
|
|
16
|
+
from
|
|
13
17
|
});
|
|
14
18
|
const txHash = await tx.getTxHash();
|
|
15
|
-
logger.info(`Tx sent with hash ${txHash}`);
|
|
19
|
+
logger.info(`Tx sent with hash ${txHash.toString()}`);
|
|
16
20
|
const receipt = await tx.getReceipt();
|
|
17
21
|
expect(receipt).toEqual(expect.objectContaining({
|
|
18
22
|
status: TxStatus.PENDING,
|
|
19
23
|
error: ''
|
|
20
24
|
}));
|
|
21
|
-
logger.info(`Receipt received for ${txHash}`);
|
|
25
|
+
logger.info(`Receipt received for ${txHash.toString()}`);
|
|
22
26
|
txs.push(tx);
|
|
23
27
|
}
|
|
24
28
|
return txs;
|
|
@@ -26,7 +30,10 @@ export const submitComplexTxsTo = async (logger, spamContract, numTxs, opts = {}
|
|
|
26
30
|
// creates an instance of the PXE and submit a given number of transactions to it.
|
|
27
31
|
export const createPXEServiceAndSubmitTransactions = async (logger, node, numTxs, fundedAccount)=>{
|
|
28
32
|
const rpcConfig = getRpcConfig();
|
|
29
|
-
|
|
33
|
+
rpcConfig.proverEnabled = false;
|
|
34
|
+
const pxeService = await createPXEService(node, rpcConfig, {
|
|
35
|
+
useLogSuffix: true
|
|
36
|
+
});
|
|
30
37
|
const account = await getSchnorrAccount(pxeService, fundedAccount.secret, fundedAccount.signingKey, fundedAccount.salt);
|
|
31
38
|
await account.register();
|
|
32
39
|
const wallet = await account.getWallet();
|
|
@@ -37,3 +44,136 @@ export const createPXEServiceAndSubmitTransactions = async (logger, node, numTxs
|
|
|
37
44
|
node
|
|
38
45
|
};
|
|
39
46
|
};
|
|
47
|
+
export async function createPXEServiceAndPrepareTransactions(logger, node, numTxs, fundedAccount) {
|
|
48
|
+
const rpcConfig = getRpcConfig();
|
|
49
|
+
rpcConfig.proverEnabled = false;
|
|
50
|
+
const pxe = await createPXEService(node, rpcConfig, {
|
|
51
|
+
useLogSuffix: true
|
|
52
|
+
});
|
|
53
|
+
const account = await getSchnorrAccount(pxe, fundedAccount.secret, fundedAccount.signingKey, fundedAccount.salt);
|
|
54
|
+
await account.register();
|
|
55
|
+
const wallet = await account.getWallet();
|
|
56
|
+
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {});
|
|
57
|
+
await wallet.registerContract({
|
|
58
|
+
instance: testContractInstance,
|
|
59
|
+
artifact: TestContractArtifact
|
|
60
|
+
});
|
|
61
|
+
const contract = await TestContract.at(testContractInstance.address, wallet);
|
|
62
|
+
const txs = await timesAsync(numTxs, async ()=>{
|
|
63
|
+
const tx = await contract.methods.emit_nullifier(Fr.random()).prove({
|
|
64
|
+
from: account.getAddress()
|
|
65
|
+
});
|
|
66
|
+
const txHash = tx.getTxHash();
|
|
67
|
+
logger.info(`Tx prepared with hash ${txHash}`);
|
|
68
|
+
return tx;
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
txs,
|
|
72
|
+
pxeService: pxe,
|
|
73
|
+
node
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function awaitProposalExecution(slashingProposer, timeoutSeconds, logger) {
|
|
77
|
+
return new Promise((resolve, reject)=>{
|
|
78
|
+
const timeout = setTimeout(()=>{
|
|
79
|
+
logger.warn(`Timed out waiting for proposal execution`);
|
|
80
|
+
reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
|
|
81
|
+
}, timeoutSeconds * 1000);
|
|
82
|
+
if (slashingProposer.type === 'empire') {
|
|
83
|
+
const unwatch = slashingProposer.listenToPayloadSubmitted((args)=>{
|
|
84
|
+
logger.warn(`Proposal ${args.payload} from round ${args.round} executed`);
|
|
85
|
+
clearTimeout(timeout);
|
|
86
|
+
unwatch();
|
|
87
|
+
resolve(args.round);
|
|
88
|
+
});
|
|
89
|
+
} else if (slashingProposer.type === 'tally') {
|
|
90
|
+
const unwatch = slashingProposer.listenToRoundExecuted((args)=>{
|
|
91
|
+
logger.warn(`Slash from round ${args.round} executed`);
|
|
92
|
+
clearTimeout(timeout);
|
|
93
|
+
unwatch();
|
|
94
|
+
resolve(args.round);
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
clearTimeout(timeout);
|
|
98
|
+
reject(new Error(`Unknown slashing proposer type: ${slashingProposer.type}`));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export async function awaitCommitteeExists({ rollup, logger }) {
|
|
103
|
+
logger.info(`Waiting for committee to be set`);
|
|
104
|
+
let committee;
|
|
105
|
+
await retryUntil(async ()=>{
|
|
106
|
+
committee = await rollup.getCurrentEpochCommittee();
|
|
107
|
+
return committee && committee.length > 0;
|
|
108
|
+
}, 'non-empty committee', 60);
|
|
109
|
+
return committee;
|
|
110
|
+
}
|
|
111
|
+
export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount }) {
|
|
112
|
+
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
113
|
+
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
114
|
+
const offenses = await retryUntil(async ()=>{
|
|
115
|
+
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
116
|
+
if (offenses.length >= targetOffenseCount) {
|
|
117
|
+
return offenses;
|
|
118
|
+
}
|
|
119
|
+
}, 'non-empty offenses', 60);
|
|
120
|
+
logger.info(`Hit ${offenses.length} offenses on rounds ${unique(offenses.map((o)=>getRoundForOffense(o, {
|
|
121
|
+
slashingRoundSize,
|
|
122
|
+
epochDuration
|
|
123
|
+
})))}`, offenses);
|
|
124
|
+
return offenses;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Await the committee to be slashed out of the validator set.
|
|
128
|
+
* Currently assumes that the committee is the same size as the validator set.
|
|
129
|
+
*/ export async function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashFactory, slashingProposer, slashingRoundSize, aztecSlotDuration, logger, dateProvider }) {
|
|
130
|
+
if (!slashingProposer) {
|
|
131
|
+
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
132
|
+
}
|
|
133
|
+
logger.info(`Advancing epochs so we start slashing`);
|
|
134
|
+
await cheatCodes.debugRollup();
|
|
135
|
+
await cheatCodes.advanceToEpoch(await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n, {
|
|
136
|
+
updateDateProvider: dateProvider
|
|
137
|
+
});
|
|
138
|
+
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
139
|
+
if (slashingProposer.type === 'empire') {
|
|
140
|
+
const slashPayloadEvents = await retryUntil(async ()=>{
|
|
141
|
+
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
142
|
+
return events.length > 0 ? events : undefined;
|
|
143
|
+
}, 'slash payload created', 120, 1);
|
|
144
|
+
expect(slashPayloadEvents.length).toBe(1);
|
|
145
|
+
// 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)
|
|
146
|
+
expect(unique(slashPayloadEvents[0].slashes.map((slash)=>slash.validator.toString()))).toHaveLength(committee.length);
|
|
147
|
+
}
|
|
148
|
+
const attestersPre = await rollup.getAttesters();
|
|
149
|
+
expect(attestersPre.length).toBe(committee.length);
|
|
150
|
+
for (const attester of attestersPre){
|
|
151
|
+
const attesterInfo = await rollup.getAttesterView(attester);
|
|
152
|
+
expect(attesterInfo.status).toEqual(1); // Validating
|
|
153
|
+
}
|
|
154
|
+
const timeout = slashingRoundSize * 2 * aztecSlotDuration;
|
|
155
|
+
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
156
|
+
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
157
|
+
// The attesters should still form the committee but they should be reduced to the "living" status
|
|
158
|
+
await cheatCodes.debugRollup();
|
|
159
|
+
const committeePostSlashing = await rollup.getCurrentEpochCommittee();
|
|
160
|
+
expect(committeePostSlashing?.length).toBe(attestersPre.length);
|
|
161
|
+
const attestersPostSlashing = await rollup.getAttesters();
|
|
162
|
+
expect(attestersPostSlashing.length).toBe(0);
|
|
163
|
+
for (const attester of attestersPre){
|
|
164
|
+
const attesterInfo = await rollup.getAttesterView(attester);
|
|
165
|
+
expect(attesterInfo.status).toEqual(2); // Living
|
|
166
|
+
}
|
|
167
|
+
logger.info(`Advancing to check current committee`);
|
|
168
|
+
await cheatCodes.debugRollup();
|
|
169
|
+
await cheatCodes.advanceToEpoch(await cheatCodes.getEpoch() + await rollup.getLagInEpochs() + 1n, {
|
|
170
|
+
updateDateProvider: dateProvider
|
|
171
|
+
});
|
|
172
|
+
await cheatCodes.debugRollup();
|
|
173
|
+
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
174
|
+
// The committee should be undefined, since the validator set is empty
|
|
175
|
+
// and the tests currently using this helper always set a target committee size.
|
|
176
|
+
expect(committeeNextEpoch).toBeUndefined();
|
|
177
|
+
const attestersNextEpoch = await rollup.getAttesters();
|
|
178
|
+
expect(attestersNextEpoch.length).toBe(0);
|
|
179
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AccountWallet, type
|
|
2
|
-
import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
|
|
1
|
+
import { type AccountWallet, AztecAddress, type AztecNode, type Logger } from '@aztec/aztec.js';
|
|
3
2
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
3
|
+
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
4
4
|
import { type SubsystemsContext } from '../fixtures/snapshot_manager.js';
|
|
5
5
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
6
6
|
export declare class TokenContractTest {
|
|
@@ -9,11 +9,16 @@ export declare class TokenContractTest {
|
|
|
9
9
|
static TOKEN_DECIMALS: bigint;
|
|
10
10
|
private snapshotManager;
|
|
11
11
|
logger: Logger;
|
|
12
|
-
wallets: AccountWallet[];
|
|
13
|
-
accounts: CompleteAddress[];
|
|
14
12
|
asset: TokenContract;
|
|
15
13
|
tokenSim: TokenSimulator;
|
|
16
|
-
|
|
14
|
+
node: AztecNode;
|
|
15
|
+
badAccount: InvalidAccountContract;
|
|
16
|
+
admin: AccountWallet;
|
|
17
|
+
adminAddress: AztecAddress;
|
|
18
|
+
account1: AccountWallet;
|
|
19
|
+
account1Address: AztecAddress;
|
|
20
|
+
account2: AccountWallet;
|
|
21
|
+
account2Address: AztecAddress;
|
|
17
22
|
constructor(testName: string);
|
|
18
23
|
/**
|
|
19
24
|
* 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":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"token_contract_test.d.ts","sourceRoot":"","sources":["../../src/e2e_token_contract/token_contract_test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAItF,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,KAAK,EAAG,aAAa,CAAC;IACtB,YAAY,EAAG,YAAY,CAAC;IAC5B,QAAQ,EAAG,aAAa,CAAC;IACzB,eAAe,EAAG,YAAY,CAAC;IAC/B,QAAQ,EAAG,aAAa,CAAC;IACzB,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,7 @@
|
|
|
1
1
|
import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { createLogger } from '@aztec/aztec.js';
|
|
3
|
-
import { DocsExampleContract } from '@aztec/noir-contracts.js/DocsExample';
|
|
4
3
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
|
+
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
5
5
|
import { jest } from '@jest/globals';
|
|
6
6
|
import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
|
|
7
7
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
@@ -13,11 +13,16 @@ export class TokenContractTest {
|
|
|
13
13
|
static TOKEN_DECIMALS = 18n;
|
|
14
14
|
snapshotManager;
|
|
15
15
|
logger;
|
|
16
|
-
wallets = [];
|
|
17
|
-
accounts = [];
|
|
18
16
|
asset;
|
|
19
17
|
tokenSim;
|
|
18
|
+
node;
|
|
20
19
|
badAccount;
|
|
20
|
+
admin;
|
|
21
|
+
adminAddress;
|
|
22
|
+
account1;
|
|
23
|
+
account1Address;
|
|
24
|
+
account2;
|
|
25
|
+
account2Address;
|
|
21
26
|
constructor(testName){
|
|
22
27
|
this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
|
|
23
28
|
this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
|
|
@@ -31,20 +36,29 @@ export class TokenContractTest {
|
|
|
31
36
|
*/ async applyBaseSnapshots() {
|
|
32
37
|
// Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
|
|
33
38
|
jest.setTimeout(120_000);
|
|
34
|
-
await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe })=>{
|
|
35
|
-
this.
|
|
36
|
-
|
|
39
|
+
await this.snapshotManager.snapshot('3_accounts', deployAccounts(3, this.logger), async ({ deployedAccounts }, { pxe, aztecNode })=>{
|
|
40
|
+
this.node = aztecNode;
|
|
41
|
+
const wallets = await Promise.all(deployedAccounts.map((a)=>getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
42
|
+
[this.admin, this.account1, this.account2] = wallets;
|
|
43
|
+
[this.adminAddress, this.account1Address, this.account2Address] = wallets.map((w)=>w.getAddress());
|
|
37
44
|
});
|
|
38
45
|
await this.snapshotManager.snapshot('e2e_token_contract', async ()=>{
|
|
39
46
|
// Create the token contract state.
|
|
40
47
|
// Move this account thing to addAccounts above?
|
|
41
48
|
this.logger.verbose(`Public deploy accounts...`);
|
|
42
|
-
await publicDeployAccounts(this.
|
|
49
|
+
await publicDeployAccounts(this.admin, [
|
|
50
|
+
this.adminAddress,
|
|
51
|
+
this.account1Address
|
|
52
|
+
]);
|
|
43
53
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
44
|
-
const asset = await TokenContract.deploy(this.
|
|
54
|
+
const asset = await TokenContract.deploy(this.admin, this.adminAddress, TokenContractTest.TOKEN_NAME, TokenContractTest.TOKEN_SYMBOL, TokenContractTest.TOKEN_DECIMALS).send({
|
|
55
|
+
from: this.adminAddress
|
|
56
|
+
}).deployed();
|
|
45
57
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
46
58
|
this.logger.verbose(`Deploying bad account...`);
|
|
47
|
-
this.badAccount = await
|
|
59
|
+
this.badAccount = await InvalidAccountContract.deploy(this.admin).send({
|
|
60
|
+
from: this.adminAddress
|
|
61
|
+
}).deployed();
|
|
48
62
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
49
63
|
return {
|
|
50
64
|
tokenContractAddress: asset.address,
|
|
@@ -52,12 +66,17 @@ export class TokenContractTest {
|
|
|
52
66
|
};
|
|
53
67
|
}, async ({ tokenContractAddress, badAccountAddress })=>{
|
|
54
68
|
// Restore the token contract state.
|
|
55
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
69
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.admin);
|
|
56
70
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
57
|
-
this.tokenSim = new TokenSimulator(this.asset, this.
|
|
58
|
-
|
|
71
|
+
this.tokenSim = new TokenSimulator(this.asset, this.admin, this.adminAddress, this.logger, [
|
|
72
|
+
this.adminAddress,
|
|
73
|
+
this.account1Address
|
|
74
|
+
]);
|
|
75
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.admin);
|
|
59
76
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
60
|
-
expect(await this.asset.methods.get_admin().simulate(
|
|
77
|
+
expect(await this.asset.methods.get_admin().simulate({
|
|
78
|
+
from: this.adminAddress
|
|
79
|
+
})).toBe(this.adminAddress.toBigInt());
|
|
61
80
|
});
|
|
62
81
|
// TokenContract.artifact.functions.forEach(fn => {
|
|
63
82
|
// const sig = decodeFunctionSignature(fn.name, fn.parameters);
|
|
@@ -73,27 +92,35 @@ export class TokenContractTest {
|
|
|
73
92
|
}
|
|
74
93
|
async applyMintSnapshot() {
|
|
75
94
|
await this.snapshotManager.snapshot('mint', async ()=>{
|
|
76
|
-
const { asset,
|
|
95
|
+
const { asset, admin, adminAddress } = this;
|
|
77
96
|
const amount = 10000n;
|
|
78
97
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
79
|
-
await asset.methods.mint_to_public(
|
|
98
|
+
await asset.methods.mint_to_public(adminAddress, amount).send({
|
|
99
|
+
from: adminAddress
|
|
100
|
+
}).wait();
|
|
80
101
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
81
|
-
await mintTokensToPrivate(asset,
|
|
102
|
+
await mintTokensToPrivate(asset, adminAddress, admin, adminAddress, amount);
|
|
82
103
|
this.logger.verbose(`Minting complete.`);
|
|
83
104
|
return {
|
|
84
105
|
amount
|
|
85
106
|
};
|
|
86
107
|
}, async ({ amount })=>{
|
|
87
|
-
const { asset,
|
|
88
|
-
tokenSim.mintPublic(
|
|
89
|
-
const publicBalance = await asset.methods.balance_of_public(
|
|
108
|
+
const { asset, adminAddress, tokenSim } = this;
|
|
109
|
+
tokenSim.mintPublic(adminAddress, amount);
|
|
110
|
+
const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({
|
|
111
|
+
from: adminAddress
|
|
112
|
+
});
|
|
90
113
|
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(
|
|
114
|
+
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
|
|
115
|
+
tokenSim.mintPrivate(adminAddress, amount);
|
|
116
|
+
const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({
|
|
117
|
+
from: adminAddress
|
|
118
|
+
});
|
|
94
119
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
95
|
-
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(
|
|
96
|
-
const totalSupply = await asset.methods.total_supply().simulate(
|
|
120
|
+
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
|
|
121
|
+
const totalSupply = await asset.methods.total_supply().simulate({
|
|
122
|
+
from: adminAddress
|
|
123
|
+
});
|
|
97
124
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
98
125
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
99
126
|
return Promise.resolve();
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
|
-
import { type AccountWalletWithSecretKey, type AztecNode, type
|
|
2
|
+
import { type AccountWalletWithSecretKey, type AztecNode, type CompleteAddress, EthAddress, type Logger } from '@aztec/aztec.js';
|
|
3
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
3
4
|
import { type ClientProtocolCircuitVerifier } from '@aztec/bb-prover';
|
|
4
5
|
import type { BlobSinkServer } from '@aztec/blob-sink/server';
|
|
6
|
+
import type { DeployL1ContractsReturnType } from '@aztec/ethereum';
|
|
5
7
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
8
|
import type { PXEService } from '@aztec/pxe/server';
|
|
7
|
-
import {
|
|
9
|
+
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
8
10
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
11
|
+
import { type SubsystemsContext } from './snapshot_manager.js';
|
|
9
12
|
/**
|
|
10
13
|
* Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
|
|
11
14
|
* However, we then setup a second PXE with a full prover instance.
|
|
@@ -26,6 +29,7 @@ export declare class FullProverTest {
|
|
|
26
29
|
fakeProofsAsset: TokenContract;
|
|
27
30
|
tokenSim: TokenSimulator;
|
|
28
31
|
aztecNode: AztecNode;
|
|
32
|
+
aztecNodeAdmin: AztecNodeAdmin;
|
|
29
33
|
pxe: PXEService;
|
|
30
34
|
cheatCodes: CheatCodes;
|
|
31
35
|
blobSink: BlobSinkServer;
|
|
@@ -47,10 +51,9 @@ export declare class FullProverTest {
|
|
|
47
51
|
*/
|
|
48
52
|
applyBaseSnapshots(): Promise<void>;
|
|
49
53
|
setup(): Promise<this>;
|
|
50
|
-
private
|
|
54
|
+
private mintFeeJuice;
|
|
51
55
|
snapshot: <T>(name: string, apply: (context: SubsystemsContext) => Promise<T>, restore?: (snapshotData: T, context: SubsystemsContext) => Promise<void>) => Promise<void>;
|
|
52
56
|
teardown(): Promise<void>;
|
|
53
57
|
applyMintSnapshot(): Promise<void>;
|
|
54
|
-
deployVerifier(): Promise<void>;
|
|
55
58
|
}
|
|
56
59
|
//# 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":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,UAAU,EACV,KAAK,MAAM,EAGZ,MAAM,iBAAiB,CAAC;AACzB,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,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAMtE,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,gBAAgB,EAAE,kBAAkB,EAAE,CAAM;IAC5C,OAAO,EAAE,0BAA0B,EAAE,CAAM;IAC3C,QAAQ,EAAE,eAAe,EAAE,CAAM;IACjC,eAAe,EAAG,aAAa,CAAC;IAChC,QAAQ,EAAG,cAAc,CAAC;IAC1B,SAAS,EAAG,SAAS,CAAC;IACtB,cAAc,EAAG,cAAc,CAAC;IAChC,GAAG,EAAG,UAAU,CAAC;IACjB,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,YAAY,EAAE,aAAa,EAAE,CAAM;IACnC,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;IAwDlB,KAAK;YAkKG,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;CAiDxB"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact, getSchnorrAccount, getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
|
|
2
2
|
import { createArchiver } from '@aztec/archiver';
|
|
3
|
-
import { EthAddress, createLogger
|
|
4
|
-
import { BBCircuitVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
3
|
+
import { EthAddress, createLogger } from '@aztec/aztec.js';
|
|
4
|
+
import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
|
|
5
5
|
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
6
6
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
7
|
-
import {
|
|
7
|
+
import { SecretValue } from '@aztec/foundation/config';
|
|
8
|
+
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
8
9
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
9
10
|
import { createProverNode } from '@aztec/prover-node';
|
|
10
11
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
11
12
|
import { getContract } from 'viem';
|
|
12
13
|
import { privateKeyToAddress } from 'viem/accounts';
|
|
13
|
-
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
14
|
-
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
15
|
-
import { createSnapshotManager, deployAccounts, publicDeployAccounts } from '../fixtures/snapshot_manager.js';
|
|
16
|
-
import { getPrivateKeyFromIndex, setupPXEService } from '../fixtures/utils.js';
|
|
17
14
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
15
|
+
import { getACVMConfig } from './get_acvm_config.js';
|
|
16
|
+
import { getBBConfig } from './get_bb_config.js';
|
|
17
|
+
import { createSnapshotManager, deployAccounts, publicDeployAccounts } from './snapshot_manager.js';
|
|
18
|
+
import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEService } from './utils.js';
|
|
18
19
|
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
19
20
|
/**
|
|
20
21
|
* Largely taken from the e2e_token_contract test file. We deploy 2 accounts and a token contract.
|
|
@@ -35,6 +36,7 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
35
36
|
fakeProofsAsset;
|
|
36
37
|
tokenSim;
|
|
37
38
|
aztecNode;
|
|
39
|
+
aztecNodeAdmin;
|
|
38
40
|
pxe;
|
|
39
41
|
cheatCodes;
|
|
40
42
|
blobSink;
|
|
@@ -62,7 +64,9 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
62
64
|
startProverNode: true,
|
|
63
65
|
fundRewardDistributor: true,
|
|
64
66
|
coinbase
|
|
65
|
-
}, {
|
|
67
|
+
}, {
|
|
68
|
+
realVerifier: realProofs
|
|
69
|
+
});
|
|
66
70
|
}
|
|
67
71
|
/**
|
|
68
72
|
* Adds two state shifts to snapshot manager.
|
|
@@ -79,9 +83,11 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
79
83
|
// Create the token contract state.
|
|
80
84
|
// Move this account thing to addAccounts above?
|
|
81
85
|
this.logger.verbose(`Public deploy accounts...`);
|
|
82
|
-
await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2)
|
|
86
|
+
await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
|
|
83
87
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
84
|
-
const asset = await TokenContract.deploy(this.wallets[0], this.accounts[0], FullProverTest.TOKEN_NAME, FullProverTest.TOKEN_SYMBOL, FullProverTest.TOKEN_DECIMALS).send(
|
|
88
|
+
const asset = await TokenContract.deploy(this.wallets[0], this.accounts[0], FullProverTest.TOKEN_NAME, FullProverTest.TOKEN_SYMBOL, FullProverTest.TOKEN_DECIMALS).send({
|
|
89
|
+
from: this.wallets[0].getAddress()
|
|
90
|
+
}).deployed();
|
|
85
91
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
86
92
|
return {
|
|
87
93
|
tokenContractAddress: asset.address
|
|
@@ -90,8 +96,10 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
90
96
|
// Restore the token contract state.
|
|
91
97
|
this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.wallets[0]);
|
|
92
98
|
this.logger.verbose(`Token contract address: ${this.fakeProofsAsset.address}`);
|
|
93
|
-
this.tokenSim = new TokenSimulator(this.fakeProofsAsset, this.wallets[0], this.logger, this.accounts.map((a)=>a.address));
|
|
94
|
-
expect(await this.fakeProofsAsset.methods.get_admin().simulate(
|
|
99
|
+
this.tokenSim = new TokenSimulator(this.fakeProofsAsset, this.wallets[0], this.wallets[0].getAddress(), this.logger, this.accounts.map((a)=>a.address));
|
|
100
|
+
expect(await this.fakeProofsAsset.methods.get_admin().simulate({
|
|
101
|
+
from: this.accounts[0].address
|
|
102
|
+
})).toBe(this.accounts[0].address.toBigInt());
|
|
95
103
|
});
|
|
96
104
|
}
|
|
97
105
|
async setup() {
|
|
@@ -100,6 +108,7 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
100
108
|
this.context.watcher.setIsMarkingAsProven(false);
|
|
101
109
|
this.simulatedProverNode = this.context.proverNode;
|
|
102
110
|
({ pxe: this.pxe, aztecNode: this.aztecNode, deployL1ContractsValues: this.l1Contracts, cheatCodes: this.cheatCodes, blobSink: this.blobSink } = this.context);
|
|
111
|
+
this.aztecNodeAdmin = this.context.aztecNode;
|
|
103
112
|
const blobSinkClient = createBlobSinkClient({
|
|
104
113
|
blobSinkUrl: `http://localhost:${this.blobSink.port}`
|
|
105
114
|
});
|
|
@@ -119,16 +128,17 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
119
128
|
if (!bbConfig?.bbWorkingDirectory || !bbConfig?.bbBinaryPath) {
|
|
120
129
|
throw new Error(`Test must be run with BB native configuration`);
|
|
121
130
|
}
|
|
122
|
-
|
|
131
|
+
const verifier = await BBCircuitVerifier.new(bbConfig);
|
|
132
|
+
this.circuitProofVerifier = new QueuedIVCVerifier(bbConfig, verifier);
|
|
123
133
|
this.logger.debug(`Configuring the node for real proofs...`);
|
|
124
|
-
await this.
|
|
134
|
+
await this.aztecNodeAdmin.setConfig({
|
|
125
135
|
realProofs: true,
|
|
126
136
|
minTxsPerBlock: this.minNumberOfTxsPerBlock
|
|
127
137
|
});
|
|
128
138
|
} else {
|
|
129
139
|
this.logger.debug(`Configuring the node min txs per block ${this.minNumberOfTxsPerBlock}...`);
|
|
130
140
|
this.circuitProofVerifier = new TestCircuitVerifier();
|
|
131
|
-
await this.
|
|
141
|
+
await this.aztecNodeAdmin.setConfig({
|
|
132
142
|
minTxsPerBlock: this.minNumberOfTxsPerBlock
|
|
133
143
|
});
|
|
134
144
|
}
|
|
@@ -171,7 +181,9 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
171
181
|
const archiver = await createArchiver({
|
|
172
182
|
...this.context.aztecNodeConfig,
|
|
173
183
|
dataDirectory: undefined
|
|
174
|
-
},
|
|
184
|
+
}, {
|
|
185
|
+
blobSinkClient
|
|
186
|
+
}, {
|
|
175
187
|
blockUntilSync: true
|
|
176
188
|
});
|
|
177
189
|
// The simulated prover node (now shutdown) used private key index 2
|
|
@@ -179,24 +191,30 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
179
191
|
const proverNodeSenderAddress = privateKeyToAddress(new Buffer32(proverNodePrivateKey).toString());
|
|
180
192
|
this.proverAddress = EthAddress.fromString(proverNodeSenderAddress);
|
|
181
193
|
this.logger.verbose(`Funding prover node at ${proverNodeSenderAddress}`);
|
|
182
|
-
await this.
|
|
194
|
+
await this.mintFeeJuice(proverNodeSenderAddress);
|
|
183
195
|
this.logger.verbose('Starting prover node');
|
|
184
196
|
const proverConfig = {
|
|
185
197
|
...this.context.aztecNodeConfig,
|
|
186
|
-
|
|
198
|
+
txCollectionNodeRpcUrls: [],
|
|
187
199
|
dataDirectory: undefined,
|
|
188
|
-
proverId: this.proverAddress
|
|
200
|
+
proverId: this.proverAddress,
|
|
189
201
|
realProofs: this.realProofs,
|
|
190
202
|
proverAgentCount: 2,
|
|
191
|
-
|
|
203
|
+
publisherPrivateKeys: [
|
|
204
|
+
new SecretValue(`0x${proverNodePrivateKey.toString('hex')}`)
|
|
205
|
+
],
|
|
192
206
|
proverNodeMaxPendingJobs: 100,
|
|
193
207
|
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
194
208
|
proverNodePollingIntervalMs: 100,
|
|
195
|
-
txGatheringTimeoutMs: 60000,
|
|
196
209
|
txGatheringIntervalMs: 1000,
|
|
197
|
-
|
|
210
|
+
txGatheringBatchSize: 10,
|
|
211
|
+
txGatheringMaxParallelRequestsPerNode: 100,
|
|
212
|
+
txGatheringTimeoutMs: 24_000,
|
|
213
|
+
proverNodeFailedEpochStore: undefined,
|
|
214
|
+
proverNodeEpochProvingDelayMs: undefined
|
|
198
215
|
};
|
|
199
|
-
const
|
|
216
|
+
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
217
|
+
const { prefilledPublicData } = await getGenesisValues(this.context.initialFundedAccounts.map((a)=>a.address).concat(sponsoredFPCAddress));
|
|
200
218
|
this.proverNode = await createProverNode(proverConfig, {
|
|
201
219
|
aztecNodeTxProvider: this.aztecNode,
|
|
202
220
|
archiver: archiver,
|
|
@@ -204,23 +222,23 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
204
222
|
}, {
|
|
205
223
|
prefilledPublicData
|
|
206
224
|
});
|
|
207
|
-
this.proverNode.start();
|
|
225
|
+
await this.proverNode.start();
|
|
208
226
|
this.logger.warn(`Proofs are now enabled`);
|
|
209
227
|
return this;
|
|
210
228
|
}
|
|
211
|
-
async
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
229
|
+
async mintFeeJuice(recipient) {
|
|
230
|
+
const handlerAddress = this.context.deployL1ContractsValues.l1ContractAddresses.feeAssetHandlerAddress;
|
|
231
|
+
this.logger.verbose(`Minting fee juice to ${recipient} using handler at ${handlerAddress}`);
|
|
232
|
+
const client = this.context.deployL1ContractsValues.l1Client;
|
|
233
|
+
const handler = getContract({
|
|
234
|
+
abi: FeeAssetHandlerAbi,
|
|
235
|
+
address: handlerAddress.toString(),
|
|
217
236
|
client
|
|
218
237
|
});
|
|
219
|
-
const hash = await
|
|
220
|
-
recipient
|
|
221
|
-
amount
|
|
238
|
+
const hash = await handler.write.mint([
|
|
239
|
+
recipient
|
|
222
240
|
]);
|
|
223
|
-
await this.context.deployL1ContractsValues.
|
|
241
|
+
await this.context.deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
224
242
|
hash
|
|
225
243
|
});
|
|
226
244
|
}
|
|
@@ -241,13 +259,14 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
241
259
|
const { fakeProofsAsset: asset, accounts } = this;
|
|
242
260
|
const privateAmount = 10000n;
|
|
243
261
|
const publicAmount = 10000n;
|
|
244
|
-
const waitOpts = {
|
|
245
|
-
proven: false
|
|
246
|
-
};
|
|
247
262
|
this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
|
|
248
|
-
await asset.methods.mint_to_public(accounts[0].address, privateAmount + publicAmount).send(
|
|
263
|
+
await asset.methods.mint_to_public(accounts[0].address, privateAmount + publicAmount).send({
|
|
264
|
+
from: accounts[0].address
|
|
265
|
+
}).wait();
|
|
249
266
|
this.logger.verbose(`Transferring ${privateAmount} to private...`);
|
|
250
|
-
await asset.methods.transfer_to_private(accounts[0].address, privateAmount).send(
|
|
267
|
+
await asset.methods.transfer_to_private(accounts[0].address, privateAmount).send({
|
|
268
|
+
from: accounts[0].address
|
|
269
|
+
}).wait();
|
|
251
270
|
this.logger.verbose(`Minting complete.`);
|
|
252
271
|
return {
|
|
253
272
|
amount: publicAmount
|
|
@@ -255,37 +274,23 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
255
274
|
}, async ({ amount })=>{
|
|
256
275
|
const { fakeProofsAsset: asset, accounts: [{ address }], tokenSim } = this;
|
|
257
276
|
tokenSim.mintPublic(address, amount);
|
|
258
|
-
const publicBalance = await asset.methods.balance_of_public(address).simulate(
|
|
277
|
+
const publicBalance = await asset.methods.balance_of_public(address).simulate({
|
|
278
|
+
from: address
|
|
279
|
+
});
|
|
259
280
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
260
281
|
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
|
|
261
282
|
tokenSim.mintPrivate(address, amount);
|
|
262
|
-
const privateBalance = await asset.methods.balance_of_private(address).simulate(
|
|
283
|
+
const privateBalance = await asset.methods.balance_of_private(address).simulate({
|
|
284
|
+
from: address
|
|
285
|
+
});
|
|
263
286
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
264
287
|
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
|
|
265
|
-
const totalSupply = await asset.methods.total_supply().simulate(
|
|
288
|
+
const totalSupply = await asset.methods.total_supply().simulate({
|
|
289
|
+
from: address
|
|
290
|
+
});
|
|
266
291
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
267
292
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
268
293
|
return Promise.resolve();
|
|
269
294
|
});
|
|
270
295
|
}
|
|
271
|
-
async deployVerifier() {
|
|
272
|
-
if (!this.realProofs) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (!this.circuitProofVerifier) {
|
|
276
|
-
throw new Error('No verifier');
|
|
277
|
-
}
|
|
278
|
-
const { walletClient, publicClient, l1ContractAddresses } = this.context.deployL1ContractsValues;
|
|
279
|
-
const rollup = getContract({
|
|
280
|
-
abi: RollupAbi,
|
|
281
|
-
address: l1ContractAddresses.rollupAddress.toString(),
|
|
282
|
-
client: walletClient
|
|
283
|
-
});
|
|
284
|
-
const { address: verifierAddress } = await deployL1Contract(walletClient, publicClient, HonkVerifierAbi, HonkVerifierBytecode);
|
|
285
|
-
this.logger.info(`Deployed honk verifier at ${verifierAddress}`);
|
|
286
|
-
await rollup.write.setEpochVerifier([
|
|
287
|
-
verifierAddress.toString()
|
|
288
|
-
]);
|
|
289
|
-
this.logger.info('Rollup only accepts valid proofs now');
|
|
290
|
-
}
|
|
291
296
|
}
|