@aztec/end-to-end 5.0.0-rc.2 → 5.0.0
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 +215 -27
- package/dest/automine/automine_test_context.d.ts +85 -0
- package/dest/automine/automine_test_context.d.ts.map +1 -0
- package/dest/automine/automine_test_context.js +98 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/automine/contracts/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.d.ts +1 -1
- package/dest/automine/contracts/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts +48 -0
- package/dest/automine/delivery/interactive_handshake_responder.d.ts.map +1 -0
- package/dest/automine/delivery/interactive_handshake_responder.js +76 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts +19 -0
- package/dest/automine/delivery/onchain_delivery_harness.d.ts.map +1 -0
- package/dest/automine/delivery/onchain_delivery_harness.js +141 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts +49 -0
- package/dest/automine/token/blacklist_token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.js +17 -24
- package/dest/automine/token/token_contract_test.d.ts +40 -0
- package/dest/automine/token/token_contract_test.d.ts.map +1 -0
- package/dest/{e2e_token_contract → automine/token}/token_contract_test.js +22 -28
- package/dest/automine/token/token_test_helpers.d.ts +73 -0
- package/dest/automine/token/token_test_helpers.d.ts.map +1 -0
- package/dest/automine/token/token_test_helpers.js +97 -0
- package/dest/bench/client_flows/benchmark.d.ts +1 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +3 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +16 -4
- package/dest/bench/utils.d.ts +1 -1
- package/dest/composed/ha/ha_full_setup.d.ts +77 -0
- package/dest/composed/ha/ha_full_setup.d.ts.map +1 -0
- package/dest/composed/ha/ha_full_setup.js +383 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts +12 -0
- package/dest/composed/web3signer/multi_validator_keystore_utils.d.ts.map +1 -0
- package/dest/fixtures/e2e_prover_test.d.ts +10 -7
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +30 -11
- package/dest/fixtures/fixtures.d.ts +7 -5
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -4
- package/dest/fixtures/ha_setup.d.ts +3 -3
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +4 -1
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +32 -8
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +165 -160
- package/dest/fixtures/standard_contracts_genesis.d.ts +16 -0
- package/dest/fixtures/standard_contracts_genesis.d.ts.map +1 -0
- package/dest/fixtures/standard_contracts_genesis.js +25 -0
- package/dest/fixtures/timing.d.ts +42 -0
- package/dest/fixtures/timing.d.ts.map +1 -0
- package/dest/fixtures/timing.js +72 -0
- package/dest/fixtures/wait_helpers.d.ts +135 -0
- package/dest/fixtures/wait_helpers.d.ts.map +1 -0
- package/dest/fixtures/wait_helpers.js +154 -0
- package/dest/forward-compatibility/wallet_service.js +1 -1
- package/dest/multi-node/block-production/setup.d.ts +97 -0
- package/dest/multi-node/block-production/setup.d.ts.map +1 -0
- package/dest/multi-node/block-production/setup.js +158 -0
- package/dest/multi-node/governance/setup.d.ts +67 -0
- package/dest/multi-node/governance/setup.d.ts.map +1 -0
- package/dest/multi-node/governance/setup.js +126 -0
- package/dest/multi-node/multi_node_test_context.d.ts +212 -0
- package/dest/multi-node/multi_node_test_context.d.ts.map +1 -0
- package/dest/multi-node/multi_node_test_context.js +347 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts +27 -0
- package/dest/multi-node/slashing/inactivity_setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/inactivity_setup.js +111 -0
- package/dest/multi-node/slashing/setup.d.ts +167 -0
- package/dest/multi-node/slashing/setup.d.ts.map +1 -0
- package/dest/multi-node/slashing/setup.js +275 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.d.ts +9 -1
- package/dest/p2p/p2p_network.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/p2p_network.js +26 -1
- package/dest/p2p/reqresp/utils.d.ts +19 -0
- package/dest/p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/{e2e_p2p → p2p}/reqresp/utils.js +4 -15
- package/dest/p2p/shared.d.ts +72 -0
- package/dest/p2p/shared.d.ts.map +1 -0
- package/dest/p2p/shared.js +212 -0
- package/dest/shared/cross_chain_test_harness.d.ts +3 -3
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +24 -16
- package/dest/shared/gas_portal_test_harness.d.ts +1 -1
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +8 -5
- package/dest/shared/submit-transactions.d.ts +1 -1
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +12 -5
- package/dest/shared/timing_env.d.js +5 -0
- package/dest/shared/timing_env.js +158 -47
- package/dest/shared/wait_for_l1_to_l2_message.js +1 -1
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts +75 -0
- package/dest/single-node/cross-chain/cross_chain_messaging_test.d.ts.map +1 -0
- package/dest/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.js +74 -26
- package/dest/single-node/cross-chain/message_test_helpers.d.ts +38 -0
- package/dest/single-node/cross-chain/message_test_helpers.d.ts.map +1 -0
- package/dest/single-node/cross-chain/message_test_helpers.js +70 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.d.ts +1 -1
- package/dest/single-node/fees/bridging_race.notest.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/bridging_race.notest.js +9 -6
- package/dest/single-node/fees/fees_test.d.ts +95 -0
- package/dest/single-node/fees/fees_test.d.ts.map +1 -0
- package/dest/{e2e_fees → single-node/fees}/fees_test.js +121 -45
- package/dest/single-node/l1-reorgs/setup.d.ts +42 -0
- package/dest/single-node/l1-reorgs/setup.d.ts.map +1 -0
- package/dest/single-node/l1-reorgs/setup.js +57 -0
- package/dest/single-node/partial-proofs/setup.d.ts +5 -0
- package/dest/single-node/partial-proofs/setup.d.ts.map +1 -0
- package/dest/single-node/partial-proofs/setup.js +5 -0
- package/dest/single-node/proving/setup.d.ts +5 -0
- package/dest/single-node/proving/setup.d.ts.map +1 -0
- package/dest/single-node/proving/setup.js +5 -0
- package/dest/single-node/recovery/setup.d.ts +5 -0
- package/dest/single-node/recovery/setup.d.ts.map +1 -0
- package/dest/single-node/recovery/setup.js +5 -0
- package/dest/single-node/setup.d.ts +49 -0
- package/dest/single-node/setup.d.ts.map +1 -0
- package/dest/single-node/setup.js +56 -0
- package/dest/single-node/single_node_test_context.d.ts +373 -0
- package/dest/single-node/single_node_test_context.d.ts.map +1 -0
- package/dest/single-node/single_node_test_context.js +845 -0
- package/dest/spartan/setup_test_wallets.d.ts +1 -1
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +13 -7
- package/dest/spartan/tx_metrics.d.ts +10 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +32 -0
- package/dest/test-wallet/test_wallet.d.ts +23 -4
- package/dest/test-wallet/test_wallet.d.ts.map +1 -1
- package/dest/test-wallet/test_wallet.js +20 -4
- package/dest/test-wallet/utils.d.ts +36 -1
- package/dest/test-wallet/utils.d.ts.map +1 -1
- package/dest/test-wallet/utils.js +64 -4
- package/dest/test-wallet/wallet_worker_script.js +5 -2
- package/dest/test-wallet/worker_wallet.d.ts +5 -5
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
- package/dest/test-wallet/worker_wallet.js +2 -2
- package/dest/test-wallet/worker_wallet_schema.js +2 -1
- package/package.json +40 -40
- package/src/automine/README.md +60 -0
- package/src/automine/automine_test_context.ts +153 -0
- package/src/automine/delivery/interactive_handshake_responder.ts +125 -0
- package/src/automine/delivery/onchain_delivery_harness.ts +213 -0
- package/src/{e2e_blacklist_token_contract → automine/token}/blacklist_token_contract_test.ts +19 -39
- package/src/{e2e_token_contract → automine/token}/token_contract_test.ts +24 -43
- package/src/automine/token/token_test_helpers.ts +138 -0
- package/src/bench/client_flows/benchmark.ts +3 -1
- package/src/bench/client_flows/client_flows_benchmark.ts +17 -4
- package/src/composed/ha/ha_full_setup.ts +466 -0
- package/src/fixtures/e2e_prover_test.ts +36 -20
- package/src/fixtures/fixtures.ts +6 -4
- package/src/fixtures/ha_setup.ts +7 -3
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +202 -161
- package/src/fixtures/standard_contracts_genesis.ts +28 -0
- package/src/fixtures/timing.ts +97 -0
- package/src/fixtures/wait_helpers.ts +333 -0
- package/src/forward-compatibility/wallet_service.ts +2 -2
- package/src/infra/README.md +12 -0
- package/src/multi-node/README.md +96 -0
- package/src/multi-node/block-production/setup.ts +272 -0
- package/src/multi-node/governance/setup.ts +172 -0
- package/src/multi-node/multi_node_test_context.ts +447 -0
- package/src/multi-node/slashing/inactivity_setup.ts +139 -0
- package/src/multi-node/slashing/setup.ts +433 -0
- package/src/p2p/README.md +78 -0
- package/src/{e2e_p2p → p2p}/p2p_network.ts +26 -0
- package/src/{e2e_p2p → p2p}/reqresp/utils.ts +5 -14
- package/src/p2p/shared.ts +329 -0
- package/src/shared/cross_chain_test_harness.ts +22 -13
- package/src/shared/gas_portal_test_harness.ts +13 -5
- package/src/shared/submit-transactions.ts +13 -5
- package/src/shared/timing_env.d.mts +39 -0
- package/src/shared/timing_env.mjs +152 -48
- package/src/shared/wait_for_l1_to_l2_message.ts +1 -1
- package/src/single-node/README.md +66 -0
- package/src/{e2e_cross_chain_messaging → single-node/cross-chain}/cross_chain_messaging_test.ts +100 -38
- package/src/single-node/cross-chain/message_test_helpers.ts +125 -0
- package/src/{e2e_fees → single-node/fees}/bridging_race.notest.ts +11 -7
- package/src/{e2e_fees → single-node/fees}/fees_test.ts +132 -47
- package/src/single-node/l1-reorgs/setup.ts +93 -0
- package/src/single-node/partial-proofs/setup.ts +8 -0
- package/src/single-node/proving/setup.ts +15 -0
- package/src/single-node/recovery/setup.ts +8 -0
- package/src/single-node/setup.ts +63 -0
- package/src/single-node/single_node_test_context.ts +1054 -0
- package/src/spartan/setup_test_wallets.ts +19 -7
- package/src/spartan/tx_metrics.ts +26 -0
- package/src/test-wallet/test_wallet.ts +28 -6
- package/src/test-wallet/utils.ts +102 -5
- package/src/test-wallet/wallet_worker_script.ts +6 -3
- package/src/test-wallet/worker_wallet.ts +5 -9
- package/src/test-wallet/worker_wallet_schema.ts +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +0 -56
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +0 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -59
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts +0 -36
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +0 -1
- package/dest/e2e_deploy_contract/deploy_test.js +0 -42
- package/dest/e2e_epochs/epochs_test.d.ts +0 -137
- package/dest/e2e_epochs/epochs_test.d.ts.map +0 -1
- package/dest/e2e_epochs/epochs_test.js +0 -485
- package/dest/e2e_fees/bridging_race.notest.d.ts.map +0 -1
- package/dest/e2e_fees/fees_test.d.ts +0 -89
- package/dest/e2e_fees/fees_test.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.d.ts +0 -11
- package/dest/e2e_l1_publisher/write_json.d.ts.map +0 -1
- package/dest/e2e_l1_publisher/write_json.js +0 -57
- package/dest/e2e_multi_validator/utils.d.ts +0 -12
- package/dest/e2e_multi_validator/utils.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +0 -22
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +0 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +0 -40
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +0 -31
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +0 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +0 -138
- package/dest/e2e_p2p/p2p_network.d.ts.map +0 -1
- package/dest/e2e_p2p/reqresp/utils.d.ts +0 -22
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.d.ts +0 -100
- package/dest/e2e_p2p/shared.d.ts.map +0 -1
- package/dest/e2e_p2p/shared.js +0 -257
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +0 -2
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +0 -1
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +0 -1
- package/dest/e2e_token_contract/token_contract_test.d.ts +0 -44
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +0 -1
- package/src/e2e_deploy_contract/deploy_test.ts +0 -73
- package/src/e2e_epochs/epochs_test.ts +0 -596
- package/src/e2e_l1_publisher/write_json.ts +0 -78
- package/src/e2e_nested_contract/nested_contract_test.ts +0 -51
- package/src/e2e_p2p/inactivity_slash_test.ts +0 -181
- package/src/e2e_p2p/shared.ts +0 -391
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.js +0 -0
- /package/dest/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.js +0 -0
- /package/dest/{e2e_multi_validator/utils.js → composed/web3signer/multi_validator_keystore_utils.js} +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof.json +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fetcher.ts +0 -0
- /package/src/{e2e_storage_proof → automine/contracts}/fixtures/storage_proof_fixture.ts +0 -0
- /package/src/{e2e_multi_validator/utils.ts → composed/web3signer/multi_validator_keystore_utils.ts} +0 -0
package/dest/e2e_p2p/shared.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { NO_WAIT, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
2
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
-
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
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 { SchnorrHardcodedKeyAccountContract } from '../fixtures/schnorr_hardcoded_account_contract.js';
|
|
11
|
-
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
12
|
-
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
13
|
-
import { proveInteraction } from '../test-wallet/utils.js';
|
|
14
|
-
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
15
|
-
export const submitComplexTxsTo = async (logger, from, spamContract, numTxs, opts = {})=>{
|
|
16
|
-
const txs = [];
|
|
17
|
-
const seed = 1234n;
|
|
18
|
-
const spamCount = 15;
|
|
19
|
-
for(let i = 0; i < numTxs; i++){
|
|
20
|
-
const method = spamContract.methods.spam(seed + BigInt(i * spamCount), spamCount, !!opts.callPublic);
|
|
21
|
-
const { txHash } = await method.send({
|
|
22
|
-
from,
|
|
23
|
-
wait: NO_WAIT
|
|
24
|
-
});
|
|
25
|
-
logger.info(`Tx sent with hash ${txHash.toString()}`);
|
|
26
|
-
txs.push(txHash);
|
|
27
|
-
}
|
|
28
|
-
return txs;
|
|
29
|
-
};
|
|
30
|
-
// creates a wallet and submit a given number of transactions through it.
|
|
31
|
-
export const submitTransactions = async (logger, node, numTxs, fundedAccount)=>{
|
|
32
|
-
const rpcConfig = getRpcConfig();
|
|
33
|
-
rpcConfig.proverEnabled = false;
|
|
34
|
-
const wallet = await TestWallet.create(node, // Use checkpointed chain tip to avoid anchoring on provisional blocks that the archiver can prune
|
|
35
|
-
// when their slot ends without a checkpoint landing on L1.
|
|
36
|
-
{
|
|
37
|
-
...getPXEConfig(),
|
|
38
|
-
proverEnabled: false,
|
|
39
|
-
syncChainTip: 'checkpointed'
|
|
40
|
-
}, {
|
|
41
|
-
loggerActorLabel: 'pxe-tx'
|
|
42
|
-
});
|
|
43
|
-
const contract = new SchnorrHardcodedKeyAccountContract();
|
|
44
|
-
const fundedAccountManager = await wallet.createAccount({
|
|
45
|
-
secret: fundedAccount.secret,
|
|
46
|
-
salt: fundedAccount.salt,
|
|
47
|
-
contract
|
|
48
|
-
});
|
|
49
|
-
return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
|
|
50
|
-
};
|
|
51
|
-
export async function prepareTransactions(logger, node, numTxs, fundedAccount) {
|
|
52
|
-
const rpcConfig = getRpcConfig();
|
|
53
|
-
rpcConfig.proverEnabled = false;
|
|
54
|
-
const wallet = await TestWallet.create(node, {
|
|
55
|
-
...getPXEConfig(),
|
|
56
|
-
proverEnabled: false,
|
|
57
|
-
syncChainTip: 'checkpointed'
|
|
58
|
-
}, {
|
|
59
|
-
loggerActorLabel: 'pxe-tx'
|
|
60
|
-
});
|
|
61
|
-
const accountContract = new SchnorrHardcodedKeyAccountContract();
|
|
62
|
-
const fundedAccountManager = await wallet.createAccount({
|
|
63
|
-
secret: fundedAccount.secret,
|
|
64
|
-
salt: fundedAccount.salt,
|
|
65
|
-
contract: accountContract
|
|
66
|
-
});
|
|
67
|
-
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
68
|
-
salt: Fr.random()
|
|
69
|
-
});
|
|
70
|
-
await wallet.registerContract(testContractInstance, TestContractArtifact);
|
|
71
|
-
const contract = TestContract.at(testContractInstance.address, wallet);
|
|
72
|
-
return timesAsync(numTxs, async ()=>{
|
|
73
|
-
const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
|
|
74
|
-
from: fundedAccountManager.address
|
|
75
|
-
});
|
|
76
|
-
logger.info(`Tx prepared with hash ${tx.getTxHash()}`);
|
|
77
|
-
return tx;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
export function awaitProposalExecution(slashingProposer, timeoutSeconds, logger) {
|
|
81
|
-
return new Promise((resolve, reject)=>{
|
|
82
|
-
const timeout = setTimeout(()=>{
|
|
83
|
-
logger.warn(`Timed out waiting for proposal execution`);
|
|
84
|
-
reject(new Error(`Timeout waiting for proposal execution after ${timeoutSeconds}s`));
|
|
85
|
-
}, timeoutSeconds * 1000);
|
|
86
|
-
const unwatch = slashingProposer.listenToRoundExecuted((args)=>{
|
|
87
|
-
logger.warn(`Slash from round ${args.round} executed`);
|
|
88
|
-
clearTimeout(timeout);
|
|
89
|
-
unwatch();
|
|
90
|
-
resolve(args.round);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
export async function awaitCommitteeExists({ rollup, logger }) {
|
|
95
|
-
logger.info(`Waiting for committee to be set`);
|
|
96
|
-
let committee;
|
|
97
|
-
await retryUntil(async ()=>{
|
|
98
|
-
committee = await rollup.getCurrentEpochCommittee();
|
|
99
|
-
return committee && committee.length > 0;
|
|
100
|
-
}, 'non-empty committee', 60);
|
|
101
|
-
logger.warn(`Committee has been formed`, {
|
|
102
|
-
committee: committee.map((c)=>c.toString())
|
|
103
|
-
});
|
|
104
|
-
return committee.map((c)=>c.toString());
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Scans L2 slots forward from `minLeadSlots` ahead of the current slot, returning the first slot in
|
|
108
|
-
* which `targetProposer` is the proposer.
|
|
109
|
-
*
|
|
110
|
-
* Scanning starts at `currentSlot + minLeadSlots` and only ever moves forward, so every returned slot
|
|
111
|
-
* is at least `minLeadSlots` ahead — a caller can safely warp to `targetSlot - minLeadSlots` for a
|
|
112
|
-
* settle buffer without risking a backwards warp. Stepping by a single slot examines both epoch
|
|
113
|
-
* parities, which matters because the per-slot proposer is a different RANDAO-shuffled committee
|
|
114
|
-
* member: searching only a fixed offset within each epoch can leave a 1-of-N target unexamined when
|
|
115
|
-
* the epoch is short. A candidate in an epoch whose committee isn't sampled yet makes the proposer
|
|
116
|
-
* lookup revert with EpochNotStable; this warps one epoch forward and continues, keeping the
|
|
117
|
-
* candidate at least `minLeadSlots` ahead of the new current slot. Throws after `maxSlotsToScan`.
|
|
118
|
-
*
|
|
119
|
-
* Unlike {@link advanceToEpochBeforeProposer}, this does not stop an epoch early — callers that want
|
|
120
|
-
* to warp close to the target (rather than stage sequencers an epoch ahead) use this and warp the
|
|
121
|
-
* final `minLeadSlots` in themselves.
|
|
122
|
-
*/ export async function findUpcomingProposerSlot({ epochCache, cheatCodes, targetProposer, logger, minLeadSlots, maxSlotsToScan = 100 }) {
|
|
123
|
-
let candidate = Number(await cheatCodes.getSlot()) + minLeadSlots;
|
|
124
|
-
for(let scanned = 0; scanned < maxSlotsToScan; scanned++){
|
|
125
|
-
let proposer;
|
|
126
|
-
try {
|
|
127
|
-
proposer = await epochCache.getProposerAttesterAddressInSlot(SlotNumber(candidate));
|
|
128
|
-
} catch (err) {
|
|
129
|
-
if (!(err instanceof Error) || !err.message.includes('EpochNotStable')) {
|
|
130
|
-
throw err;
|
|
131
|
-
}
|
|
132
|
-
await cheatCodes.advanceToNextEpoch();
|
|
133
|
-
const newCurrentSlot = Number(await cheatCodes.getSlot());
|
|
134
|
-
// Keep the lead after the warp: never return a slot we could no longer warp ahead of.
|
|
135
|
-
candidate = Math.max(candidate, newCurrentSlot + minLeadSlots);
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (proposer && proposer.equals(targetProposer)) {
|
|
139
|
-
logger.warn(`Found target proposer ${targetProposer} at slot ${candidate}`);
|
|
140
|
-
return SlotNumber(candidate);
|
|
141
|
-
}
|
|
142
|
-
candidate++;
|
|
143
|
-
}
|
|
144
|
-
throw new Error(`Target proposer ${targetProposer} not found within ${maxSlotsToScan} slots`);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Advance epochs until we find one where the target proposer is selected for a slot at least
|
|
148
|
-
* `warmupSlots` into the epoch, then stop one epoch before it. This leaves time for the caller to
|
|
149
|
-
* start sequencers before warping to the target epoch, avoiding the race where the target epoch
|
|
150
|
-
* passes before sequencers are ready.
|
|
151
|
-
*
|
|
152
|
-
* The first `warmupSlots` slots of the epoch are skipped on purpose. Callers warp to one slot
|
|
153
|
-
* before the target epoch and, under proposer pipelining, the proposer begins building one slot
|
|
154
|
-
* before its proposal slot. If the proposer were in the first slot of the epoch, that build would
|
|
155
|
-
* begin at the exact instant of the warp, leaving the freshly-started sequencer no warm-up margin;
|
|
156
|
-
* it then serializes its (often AVM-heavy) proposal past the slot boundary and honest receivers
|
|
157
|
-
* reject it as late. Picking a slot at least `warmupSlots` into the epoch guarantees that many full
|
|
158
|
-
* slots of wall-clock between the warp and the start of the proposer's build.
|
|
159
|
-
*
|
|
160
|
-
* Returns the target epoch and the concrete target slot so the caller can warp to it after starting
|
|
161
|
-
* sequencers.
|
|
162
|
-
*/ export async function advanceToEpochBeforeProposer({ epochCache, cheatCodes, targetProposer, logger, maxAttempts = 20, warmupSlots = 1 }) {
|
|
163
|
-
const { epochDuration } = await cheatCodes.getConfig();
|
|
164
|
-
for(let attempt = 0; attempt < maxAttempts; attempt++){
|
|
165
|
-
const currentEpoch = await cheatCodes.getEpoch();
|
|
166
|
-
// Check the NEXT epoch's slots so we stay one epoch before the target,
|
|
167
|
-
// giving the caller time to start sequencers before the target epoch arrives.
|
|
168
|
-
const nextEpoch = Number(currentEpoch) + 1;
|
|
169
|
-
const epochStartSlot = nextEpoch * Number(epochDuration);
|
|
170
|
-
// Skip the first `warmupSlots` slots so the caller keeps a warm-up margin after warping to one
|
|
171
|
-
// slot before the epoch (see the doc comment above).
|
|
172
|
-
const startSlot = epochStartSlot + warmupSlots;
|
|
173
|
-
const endSlot = epochStartSlot + Number(epochDuration);
|
|
174
|
-
logger.info(`Checking next epoch ${nextEpoch} (slots ${startSlot}-${endSlot - 1}) for proposer ${targetProposer} (current epoch: ${currentEpoch})`);
|
|
175
|
-
for(let s = startSlot; s < endSlot; s++){
|
|
176
|
-
const proposer = await epochCache.getProposerAttesterAddressInSlot(SlotNumber(s));
|
|
177
|
-
if (proposer && proposer.equals(targetProposer)) {
|
|
178
|
-
logger.warn(`Found target proposer ${targetProposer} in slot ${s} of epoch ${nextEpoch}. Staying at epoch ${currentEpoch} to allow sequencer startup.`);
|
|
179
|
-
return {
|
|
180
|
-
targetEpoch: EpochNumber(nextEpoch),
|
|
181
|
-
targetSlot: SlotNumber(s)
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
logger.info(`Target proposer not found in epoch ${nextEpoch}, advancing to next epoch`);
|
|
186
|
-
await cheatCodes.advanceToNextEpoch();
|
|
187
|
-
}
|
|
188
|
-
throw new Error(`Target proposer ${targetProposer} not found in any slot after ${maxAttempts} epoch attempts`);
|
|
189
|
-
}
|
|
190
|
-
export async function awaitOffenseDetected({ logger, nodeAdmin, slashingRoundSize, epochDuration, waitUntilOffenseCount, timeoutSeconds = 120 }) {
|
|
191
|
-
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
192
|
-
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
193
|
-
const offenses = await retryUntil(async ()=>{
|
|
194
|
-
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
195
|
-
if (offenses.length >= targetOffenseCount) {
|
|
196
|
-
return offenses;
|
|
197
|
-
}
|
|
198
|
-
}, 'non-empty offenses', timeoutSeconds);
|
|
199
|
-
logger.info(`Hit ${offenses.length} offenses on rounds ${unique(offenses.map((o)=>getRoundForOffense(o, {
|
|
200
|
-
slashingRoundSize,
|
|
201
|
-
epochDuration
|
|
202
|
-
})))}`, {
|
|
203
|
-
offenses
|
|
204
|
-
});
|
|
205
|
-
return offenses;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Await the committee to be slashed out of the validator set.
|
|
209
|
-
* Currently assumes that the committee is the same size as the validator set.
|
|
210
|
-
*/ export async function awaitCommitteeKicked({ rollup, cheatCodes, committee, slashingProposer, slashingRoundSize, aztecSlotDuration, aztecEpochDuration, logger, offenseEpoch }) {
|
|
211
|
-
if (!slashingProposer) {
|
|
212
|
-
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
213
|
-
}
|
|
214
|
-
await cheatCodes.debugRollup();
|
|
215
|
-
// Use the slash offset to ensure we are in the right epoch for tally
|
|
216
|
-
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
217
|
-
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
218
|
-
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
219
|
-
const firstEpochInOffenseRound = offenseEpoch - offenseEpoch % slashingRoundSizeInEpochs;
|
|
220
|
-
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
221
|
-
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
222
|
-
await cheatCodes.advanceToEpoch(EpochNumber(targetEpoch), {
|
|
223
|
-
offset: -aztecSlotDuration / 2
|
|
224
|
-
});
|
|
225
|
-
const attestersPre = await rollup.getAttesters();
|
|
226
|
-
expect(attestersPre.length).toBe(committee.length);
|
|
227
|
-
for (const attester of attestersPre){
|
|
228
|
-
const attesterInfo = await rollup.getAttesterView(attester);
|
|
229
|
-
expect(attesterInfo.status).toEqual(1); // Validating
|
|
230
|
-
}
|
|
231
|
-
// Allow up to four round-lengths so that under proposer pipelining, where individual rounds
|
|
232
|
-
// sometimes fail to gather quorum because parts of the committee miss votes due to chain-state
|
|
233
|
-
// races, we still see a later round execute the slash.
|
|
234
|
-
const timeout = slashingRoundSize * 4 * aztecSlotDuration + 30;
|
|
235
|
-
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
236
|
-
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
237
|
-
// The attesters should still form the committee but they should be reduced to the "living" status
|
|
238
|
-
await cheatCodes.debugRollup();
|
|
239
|
-
const committeePostSlashing = await rollup.getCurrentEpochCommittee();
|
|
240
|
-
expect(committeePostSlashing?.length).toBe(attestersPre.length);
|
|
241
|
-
const attestersPostSlashing = await rollup.getAttesters();
|
|
242
|
-
expect(attestersPostSlashing.length).toBe(0);
|
|
243
|
-
for (const attester of attestersPre){
|
|
244
|
-
const attesterInfo = await rollup.getAttesterView(attester);
|
|
245
|
-
expect(attesterInfo.status).toEqual(2); // Living
|
|
246
|
-
}
|
|
247
|
-
logger.info(`Advancing to check current committee`);
|
|
248
|
-
await cheatCodes.debugRollup();
|
|
249
|
-
await cheatCodes.advanceToEpoch(EpochNumber(await cheatCodes.getEpoch() + await rollup.getLagInEpochsForValidatorSet() + 1));
|
|
250
|
-
await cheatCodes.debugRollup();
|
|
251
|
-
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
252
|
-
// The committee should be undefined, since the validator set is empty
|
|
253
|
-
// and the tests currently using this helper always set a target committee size.
|
|
254
|
-
expect(committeeNextEpoch).toBeUndefined();
|
|
255
|
-
const attestersNextEpoch = await rollup.getAttesters();
|
|
256
|
-
expect(attestersNextEpoch.length).toBe(0);
|
|
257
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZV9wcm9vZl9mZXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZTJlX3N0b3JhZ2VfcHJvb2YvZml4dHVyZXMvc3RvcmFnZV9wcm9vZl9mZXRjaGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage_proof_fetcher.d.ts","sourceRoot":"","sources":["../../../src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage_proof_fixture.d.ts","sourceRoot":"","sources":["../../../src/e2e_storage_proof/fixtures/storage_proof_fixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAwF3C,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,+EAA+E;AAC/E,wBAAgB,oBAAoB,IAAI,gBAAgB,CAavD;AAED,8FAA8F;AAC9F,wBAAsB,yBAAyB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAuDjG"}
|
|
@@ -1,44 +0,0 @@
|
|
|
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';
|
|
4
|
-
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
-
import { GenericProxyContract } from '@aztec/noir-test-contracts.js/GenericProxy';
|
|
6
|
-
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
7
|
-
import { type EndToEndContext, type SetupOptions } from '../fixtures/setup.js';
|
|
8
|
-
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
9
|
-
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
10
|
-
export declare class TokenContractTest {
|
|
11
|
-
static TOKEN_NAME: string;
|
|
12
|
-
static TOKEN_SYMBOL: string;
|
|
13
|
-
static TOKEN_DECIMALS: bigint;
|
|
14
|
-
context: EndToEndContext;
|
|
15
|
-
logger: Logger;
|
|
16
|
-
metricsPort?: number;
|
|
17
|
-
asset: TokenContract;
|
|
18
|
-
tokenSim: TokenSimulator;
|
|
19
|
-
node: AztecNode;
|
|
20
|
-
badAccount: InvalidAccountContract;
|
|
21
|
-
authwitProxy: GenericProxyContract;
|
|
22
|
-
wallet: TestWallet;
|
|
23
|
-
adminAddress: AztecAddress;
|
|
24
|
-
account1Address: AztecAddress;
|
|
25
|
-
account2Address: AztecAddress;
|
|
26
|
-
private shouldApplyBaseSetup;
|
|
27
|
-
private shouldApplyMint;
|
|
28
|
-
constructor(testName: string);
|
|
29
|
-
/**
|
|
30
|
-
* Registers that base setup should be applied during setup().
|
|
31
|
-
* Call this before setup() to deploy 3 accounts, publicly deploy accounts, token contract and a "bad account".
|
|
32
|
-
*/
|
|
33
|
-
applyBaseSnapshots(): void;
|
|
34
|
-
/**
|
|
35
|
-
* Registers that mint should be applied during setup().
|
|
36
|
-
* Call this before setup() to mint tokens to the admin account.
|
|
37
|
-
*/
|
|
38
|
-
applyMintSnapshot(): void;
|
|
39
|
-
private applyBaseSetup;
|
|
40
|
-
setup(opts?: Partial<SetupOptions>): Promise<void>;
|
|
41
|
-
teardown(): Promise<void>;
|
|
42
|
-
private applyMint;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9rZW5fY29udHJhY3RfdGVzdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2UyZV90b2tlbl9jb250cmFjdC90b2tlbl9jb250cmFjdF90ZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0scUJBQXFCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQy9ELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLDRDQUE0QyxDQUFDO0FBQ2xGLE9BQU8sRUFBRSxzQkFBc0IsRUFBRSxNQUFNLDhDQUE4QyxDQUFDO0FBSXRGLE9BQU8sRUFDTCxLQUFLLGVBQWUsRUFDcEIsS0FBSyxZQUFZLEVBSWxCLE1BQU0sc0JBQXNCLENBQUM7QUFFOUIsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBQ2xFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBSWhFLHFCQUFhLGlCQUFpQjtJQUM1QixNQUFNLENBQUMsVUFBVSxTQUFVO0lBQzNCLE1BQU0sQ0FBQyxZQUFZLFNBQVM7SUFDNUIsTUFBTSxDQUFDLGNBQWMsU0FBTztJQUM1QixPQUFPLEVBQUcsZUFBZSxDQUFDO0lBQzFCLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDZixXQUFXLENBQUMsRUFBRSxNQUFNLENBQUM7SUFDckIsS0FBSyxFQUFHLGFBQWEsQ0FBQztJQUN0QixRQUFRLEVBQUcsY0FBYyxDQUFDO0lBQzFCLElBQUksRUFBRyxTQUFTLENBQUM7SUFFakIsVUFBVSxFQUFHLHNCQUFzQixDQUFDO0lBQ3BDLFlBQVksRUFBRyxvQkFBb0IsQ0FBQztJQUNwQyxNQUFNLEVBQUcsVUFBVSxDQUFDO0lBQ3BCLFlBQVksRUFBRyxZQUFZLENBQUM7SUFDNUIsZUFBZSxFQUFHLFlBQVksQ0FBQztJQUMvQixlQUFlLEVBQUcsWUFBWSxDQUFDO0lBRS9CLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBUztJQUNyQyxPQUFPLENBQUMsZUFBZSxDQUFTO0lBRWhDLFlBQVksUUFBUSxFQUFFLE1BQU0sRUFHM0I7SUFFRDs7O09BR0c7SUFDSCxrQkFBa0IsU0FFakI7SUFFRDs7O09BR0c7SUFDSCxpQkFBaUIsU0FFaEI7WUFLYSxjQUFjO0lBOEN0QixLQUFLLENBQUMsSUFBSSxHQUFFLE9BQU8sQ0FBQyxZQUFZLENBQU0saUJBYzNDO0lBRUssUUFBUSxrQkFFYjtZQUVhLFNBQVM7Q0ErQnhCIn0=
|
|
@@ -1 +0,0 @@
|
|
|
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,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AAItF,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,YAAY,EAIlB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,UAAU,SAAU;IAC3B,MAAM,CAAC,YAAY,SAAS;IAC5B,MAAM,CAAC,cAAc,SAAO;IAC5B,OAAO,EAAG,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAG,aAAa,CAAC;IACtB,QAAQ,EAAG,cAAc,CAAC;IAC1B,IAAI,EAAG,SAAS,CAAC;IAEjB,UAAU,EAAG,sBAAsB,CAAC;IACpC,YAAY,EAAG,oBAAoB,CAAC;IACpC,MAAM,EAAG,UAAU,CAAC;IACpB,YAAY,EAAG,YAAY,CAAC;IAC5B,eAAe,EAAG,YAAY,CAAC;IAC/B,eAAe,EAAG,YAAY,CAAC;IAE/B,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,eAAe,CAAS;IAEhC,YAAY,QAAQ,EAAE,MAAM,EAG3B;IAED;;;OAGG;IACH,kBAAkB,SAEjB;IAED;;;OAGG;IACH,iBAAiB,SAEhB;YAKa,cAAc;IA8CtB,KAAK,CAAC,IAAI,GAAE,OAAO,CAAC,YAAY,CAAM,iBAc3C;IAEK,QAAQ,kBAEb;YAEa,SAAS;CA+BxB"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
2
|
-
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
-
import { type ContractBase, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
4
|
-
import { Fr } from '@aztec/aztec.js/fields';
|
|
5
|
-
import type { PublicKeys } from '@aztec/aztec.js/keys';
|
|
6
|
-
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
7
|
-
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
8
|
-
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
9
|
-
import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest';
|
|
10
|
-
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
11
|
-
|
|
12
|
-
import { type EndToEndContext, type SetupOptions, setup, teardown } from '../fixtures/setup.js';
|
|
13
|
-
import type { TestWallet } from '../test-wallet/test_wallet.js';
|
|
14
|
-
|
|
15
|
-
export class DeployTest {
|
|
16
|
-
public context!: EndToEndContext;
|
|
17
|
-
public logger: Logger;
|
|
18
|
-
public wallet!: TestWallet;
|
|
19
|
-
public defaultAccountAddress!: AztecAddress;
|
|
20
|
-
public aztecNode!: AztecNode;
|
|
21
|
-
public aztecNodeAdmin!: AztecNodeAdmin;
|
|
22
|
-
|
|
23
|
-
constructor(testName: string) {
|
|
24
|
-
this.logger = createLogger(`e2e:e2e_deploy_contract:${testName}`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async setup(opts: Partial<SetupOptions> = {}) {
|
|
28
|
-
this.logger.info('Setting up test environment');
|
|
29
|
-
this.context = await setup(1, {
|
|
30
|
-
...opts,
|
|
31
|
-
fundSponsoredFPC: true,
|
|
32
|
-
});
|
|
33
|
-
this.aztecNode = this.context.aztecNodeService;
|
|
34
|
-
this.wallet = this.context.wallet;
|
|
35
|
-
this.aztecNodeAdmin = this.context.aztecNodeService;
|
|
36
|
-
this.defaultAccountAddress = this.context.accounts[0];
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async teardown() {
|
|
41
|
-
await teardown(this.context);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async registerContract<T extends ContractBase>(
|
|
45
|
-
wallet: Wallet,
|
|
46
|
-
contractArtifact: ContractArtifactClass<T>,
|
|
47
|
-
opts: {
|
|
48
|
-
salt?: Fr;
|
|
49
|
-
publicKeys?: PublicKeys;
|
|
50
|
-
initArgs?: any[];
|
|
51
|
-
constructorName?: string;
|
|
52
|
-
deployer?: AztecAddress;
|
|
53
|
-
} = {},
|
|
54
|
-
): Promise<T> {
|
|
55
|
-
const { salt, publicKeys, initArgs, constructorName, deployer } = opts;
|
|
56
|
-
const instance = await getContractInstanceFromInstantiationParams(contractArtifact.artifact, {
|
|
57
|
-
constructorArgs: initArgs ?? [],
|
|
58
|
-
constructorArtifact: constructorName,
|
|
59
|
-
salt: salt ?? Fr.random(),
|
|
60
|
-
publicKeys,
|
|
61
|
-
deployer,
|
|
62
|
-
});
|
|
63
|
-
await wallet.registerContract(instance, contractArtifact.artifact);
|
|
64
|
-
return contractArtifact.at(instance.address, wallet);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type StatefulContractCtorArgs = Parameters<StatefulTestContract['methods']['constructor']>;
|
|
69
|
-
|
|
70
|
-
export type ContractArtifactClass<T extends ContractBase> = {
|
|
71
|
-
at(address: AztecAddress, wallet: Wallet): T;
|
|
72
|
-
artifact: ContractArtifact;
|
|
73
|
-
};
|