@aztec/end-to-end 0.0.1-commit.e558bd1c → 0.0.1-commit.e57c76e
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 +27 -0
- package/dest/bench/client_flows/benchmark.d.ts +15 -1
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +17 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +3 -3
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +36 -39
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/utils.d.ts +1 -1
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +8 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +8 -5
- 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 +36 -17
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +16 -5
- 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 +39 -7
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +2 -1
- package/dest/e2e_epochs/epochs_test.d.ts +33 -8
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +143 -44
- package/dest/e2e_fees/fees_test.d.ts +6 -3
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +50 -17
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +6 -7
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +4 -3
- package/dest/e2e_p2p/p2p_network.d.ts +14 -12
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +70 -34
- package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
- package/dest/e2e_p2p/reqresp/utils.js +67 -14
- package/dest/e2e_p2p/shared.d.ts +37 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +88 -51
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +6 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +23 -11
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +9 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +39 -50
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +74 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +71 -0
- 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 +5 -5
- package/dest/fixtures/ha_setup.d.ts +2 -2
- package/dest/fixtures/ha_setup.d.ts.map +1 -1
- package/dest/fixtures/ha_setup.js +4 -2
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
- package/dest/fixtures/schnorr_hardcoded_account_contract.js +37 -0
- package/dest/fixtures/setup.d.ts +86 -32
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +209 -169
- package/dest/fixtures/setup_p2p_test.d.ts +14 -7
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +18 -15
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +5 -7
- package/dest/fixtures/utils.d.ts +2 -2
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +1 -1
- package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
- package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
- package/dest/forward-compatibility/wallet_service.d.ts +3 -0
- package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
- package/dest/forward-compatibility/wallet_service.js +109 -0
- package/dest/install_legacy_contracts.d.cts +10 -0
- package/dest/install_legacy_contracts.d.cts.map +1 -0
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- package/dest/shared/cross_chain_test_harness.d.ts +4 -2
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +22 -18
- package/dest/shared/gas_portal_test_harness.d.ts +8 -5
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +19 -10
- package/dest/shared/index.d.ts +2 -1
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +2 -2
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +56 -41
- package/dest/shared/wait_for_l1_to_l2_message.d.ts +13 -0
- package/dest/shared/wait_for_l1_to_l2_message.d.ts.map +1 -0
- package/dest/shared/wait_for_l1_to_l2_message.js +10 -0
- package/dest/simulators/lending_simulator.d.ts +10 -3
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +26 -14
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +12 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -41
- package/dest/spartan/tx_metrics.d.ts +18 -4
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +74 -21
- package/dest/spartan/utils/bot.d.ts +3 -2
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +2 -1
- package/dest/spartan/utils/config.d.ts +10 -30
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +3 -1
- package/dest/spartan/utils/index.d.ts +4 -2
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +5 -1
- package/dest/spartan/utils/k8s.d.ts +3 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +6 -0
- package/dest/spartan/utils/nodes.d.ts +4 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +11 -11
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/test-wallet/test_wallet.d.ts +85 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +273 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +66 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +53 -0
- package/dest/test-wallet/worker_wallet.d.ts +53 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +155 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +160 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +22 -0
- package/package.json +49 -45
- package/src/bench/client_flows/benchmark.ts +19 -0
- package/src/bench/client_flows/client_flows_benchmark.ts +64 -49
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +10 -4
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +52 -25
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +53 -15
- package/src/e2e_deploy_contract/deploy_test.ts +6 -5
- package/src/e2e_epochs/epochs_test.ts +166 -68
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +57 -32
- package/src/e2e_nested_contract/nested_contract_test.ts +10 -6
- package/src/e2e_p2p/inactivity_slash_test.ts +8 -7
- package/src/e2e_p2p/p2p_network.ts +93 -49
- package/src/e2e_p2p/reqresp/utils.ts +84 -17
- package/src/e2e_p2p/shared.ts +108 -65
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +38 -11
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +49 -56
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +93 -0
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +7 -3
- package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
- package/src/fixtures/setup.ts +272 -233
- package/src/fixtures/setup_p2p_test.ts +21 -25
- package/src/fixtures/token_utils.ts +3 -3
- package/src/fixtures/utils.ts +2 -0
- package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
- package/src/forward-compatibility/wallet_service.ts +104 -0
- package/src/guides/up_quick_start.sh +3 -5
- package/src/install_legacy_contracts.cjs +75 -0
- package/src/legacy-jest-resolver.cjs +112 -0
- package/src/shared/cross_chain_test_harness.ts +27 -13
- package/src/shared/gas_portal_test_harness.ts +21 -11
- package/src/shared/index.ts +1 -0
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +3 -2
- package/src/shared/uniswap_l1_l2.ts +104 -53
- package/src/shared/wait_for_l1_to_l2_message.ts +23 -0
- package/src/simulators/lending_simulator.ts +32 -14
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/setup_test_wallets.ts +146 -35
- package/src/spartan/tx_metrics.ts +82 -24
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/config.ts +2 -0
- package/src/spartan/utils/index.ts +7 -0
- package/src/spartan/utils/k8s.ts +8 -0
- package/src/spartan/utils/nodes.ts +17 -12
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/test-wallet/test_wallet.ts +376 -0
- package/src/test-wallet/utils.ts +108 -0
- package/src/test-wallet/wallet_worker_script.ts +63 -0
- package/src/test-wallet/worker_wallet.ts +218 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Waits until the archiver has seen the L1 to L2 message and indexed it. Unlike
|
|
7
|
+
* {@link waitForL1ToL2MessageReady} from `@aztec/aztec.js/messaging`, this does not
|
|
8
|
+
* require the L2 chain to have advanced to the message's checkpoint — it only confirms
|
|
9
|
+
* the message has been picked up from L1. Use this in tests that explicitly produce L2
|
|
10
|
+
* blocks afterwards to make the message consumable.
|
|
11
|
+
*/
|
|
12
|
+
export function waitForL1ToL2MessageSeen(
|
|
13
|
+
node: Pick<AztecNode, 'getL1ToL2MessageCheckpoint'>,
|
|
14
|
+
l1ToL2MessageHash: Fr,
|
|
15
|
+
opts: { timeoutSeconds: number },
|
|
16
|
+
) {
|
|
17
|
+
return retryUntil(
|
|
18
|
+
async () => (await node.getL1ToL2MessageCheckpoint(l1ToL2MessageHash)) !== undefined,
|
|
19
|
+
`L1 to L2 message ${l1ToL2MessageHash.toString()} seen`,
|
|
20
|
+
opts.timeoutSeconds,
|
|
21
|
+
1,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -7,6 +7,7 @@ import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
|
7
7
|
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
8
8
|
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
9
9
|
import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
|
|
10
|
+
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
10
11
|
|
|
11
12
|
import type { TokenSimulator } from './token_simulator.js';
|
|
12
13
|
|
|
@@ -92,30 +93,45 @@ export class LendingSimulator {
|
|
|
92
93
|
public stableCoin: TokenSimulator,
|
|
93
94
|
) {}
|
|
94
95
|
|
|
95
|
-
|
|
96
|
+
prepare() {
|
|
96
97
|
this.accumulator = BASE;
|
|
97
|
-
|
|
98
|
-
this.time = Number(await this.rollup.getTimestampForSlot(slot));
|
|
98
|
+
this.time = 0;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Advances the simulator's accumulator and clock to match a block timestamp observed on chain.
|
|
103
|
+
* Call this BEFORE applying any accumulator-sensitive mutation (borrow/repay) so the mutation
|
|
104
|
+
* sees the same accumulator as the contract did during execution.
|
|
105
|
+
*/
|
|
106
|
+
observeBlockTimestamp(ts: number) {
|
|
107
|
+
const diff = ts - this.time;
|
|
108
|
+
if (diff > 0) {
|
|
109
|
+
this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(diff)), BASE);
|
|
110
|
+
}
|
|
111
|
+
this.time = ts;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async progressSlots(diff: number, _dateProvider?: TestDateProvider, node?: AztecNode & AztecNodeDebug) {
|
|
102
115
|
if (diff <= 1) {
|
|
103
116
|
return;
|
|
104
117
|
}
|
|
105
118
|
|
|
106
|
-
const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.
|
|
119
|
+
const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.lastBlockTimestamp()));
|
|
107
120
|
const targetSlot = SlotNumber(slot + diff);
|
|
108
121
|
const ts = Number(await this.rollup.getTimestampForSlot(targetSlot));
|
|
109
|
-
const timeDiff = ts - this.time;
|
|
110
|
-
this.time = ts;
|
|
111
122
|
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
// Queue-aware warp under AutomineSequencer: atomic warp + mineBlock that advances L2 time to the
|
|
124
|
+
// target slot. The cheat code routes through the AutomineSequencer queue when one is installed,
|
|
125
|
+
// and otherwise falls back to a manual warp + mineBlock loop.
|
|
126
|
+
if (node) {
|
|
127
|
+
await this.cc.warpL2TimeAtLeastTo(node, ts);
|
|
128
|
+
} else {
|
|
129
|
+
await this.cc.eth.warp(ts - this.ethereumSlotDuration);
|
|
116
130
|
}
|
|
131
|
+
|
|
132
|
+
// Mark the latest checkpoint as proven so the rollup does not reorg pending checkpoints when
|
|
133
|
+
// time jumps far enough forward to cross an unproven epoch boundary.
|
|
117
134
|
await this.cc.rollup.markAsProven(await this.rollup.getCheckpointNumber());
|
|
118
|
-
this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
|
|
119
135
|
}
|
|
120
136
|
|
|
121
137
|
depositPrivate(from: AztecAddress, onBehalfOf: Fr, amount: bigint) {
|
|
@@ -186,14 +202,16 @@ export class LendingSimulator {
|
|
|
186
202
|
|
|
187
203
|
expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
|
|
188
204
|
|
|
189
|
-
const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
|
|
205
|
+
const { result: asset } = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
|
|
190
206
|
|
|
191
207
|
const interestAccumulator = asset['interest_accumulator'];
|
|
192
208
|
expect(interestAccumulator).toEqual(this.accumulator);
|
|
193
209
|
expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
|
|
194
210
|
|
|
195
211
|
for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
|
|
196
|
-
const privatePos = await this.lendingContract.methods
|
|
212
|
+
const { result: privatePos } = await this.lendingContract.methods
|
|
213
|
+
.get_position(key)
|
|
214
|
+
.simulate({ from: this.account.address });
|
|
197
215
|
expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
|
|
198
216
|
expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
|
|
199
217
|
expect(privatePos['debt']).toEqual(
|
|
@@ -109,7 +109,9 @@ export class TokenSimulator {
|
|
|
109
109
|
await Promise.all(
|
|
110
110
|
chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
|
|
111
111
|
)
|
|
112
|
-
)
|
|
112
|
+
)
|
|
113
|
+
.flatMap(r => r.result)
|
|
114
|
+
.map(r => r.result);
|
|
113
115
|
expect(results[0]).toEqual(this.totalSupply);
|
|
114
116
|
|
|
115
117
|
// Check that all our balances match
|
|
@@ -119,39 +121,13 @@ export class TokenSimulator {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
async checkPrivate() {
|
|
122
|
-
// Private calls
|
|
123
|
-
const defaultLookups = [];
|
|
124
|
-
const nonDefaultLookups = [];
|
|
125
|
-
|
|
126
124
|
for (const address of this.accounts) {
|
|
127
|
-
if (this.lookupProvider.has(address.toString())) {
|
|
128
|
-
nonDefaultLookups.push(address);
|
|
129
|
-
} else {
|
|
130
|
-
defaultLookups.push(address);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
|
|
135
|
-
const results = (
|
|
136
|
-
await Promise.all(
|
|
137
|
-
chunk(defaultCalls, 4).map(batch =>
|
|
138
|
-
new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
|
|
139
|
-
),
|
|
140
|
-
)
|
|
141
|
-
).flat();
|
|
142
|
-
for (let i = 0; i < defaultLookups.length; i++) {
|
|
143
|
-
expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// We are just running individual calls for the non-default lookups
|
|
147
|
-
// @todo We should also batch these
|
|
148
|
-
for (const address of nonDefaultLookups) {
|
|
149
125
|
const wallet = this.lookupProvider.get(address.toString());
|
|
150
126
|
const asset = wallet ? this.token.withWallet(wallet) : this.token;
|
|
151
127
|
|
|
152
|
-
const actualPrivateBalance = await asset.methods
|
|
153
|
-
.balance_of_private(
|
|
154
|
-
.simulate({ from:
|
|
128
|
+
const { result: actualPrivateBalance } = await asset.methods
|
|
129
|
+
.balance_of_private(address)
|
|
130
|
+
.simulate({ from: address });
|
|
155
131
|
expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
|
|
156
132
|
}
|
|
157
133
|
}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
4
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
5
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
5
6
|
import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
|
|
6
7
|
import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
7
8
|
import { Fr } from '@aztec/aztec.js/fields';
|
|
9
|
+
import { waitForL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
8
10
|
import { type AztecNode, createAztecNodeClient, waitForTx } from '@aztec/aztec.js/node';
|
|
9
11
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
10
12
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
13
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
14
|
import type { Logger } from '@aztec/foundation/log';
|
|
13
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
15
|
+
import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
|
|
14
16
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
15
17
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import {
|
|
18
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
19
|
+
import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
|
|
17
20
|
|
|
18
21
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
19
22
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
20
23
|
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
|
|
24
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
25
|
+
import { proveInteraction } from '../test-wallet/utils.js';
|
|
26
|
+
import { WorkerWallet } from '../test-wallet/worker_wallet.js';
|
|
21
27
|
|
|
22
28
|
export interface TestAccounts {
|
|
23
29
|
aztecNode: AztecNode;
|
|
@@ -85,11 +91,19 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
85
91
|
|
|
86
92
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
87
93
|
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
88
|
-
await recipientDeployMethod.send({
|
|
94
|
+
await recipientDeployMethod.send({
|
|
95
|
+
from: NO_FROM,
|
|
96
|
+
fee: { paymentMethod },
|
|
97
|
+
wait: { timeout: 2400 },
|
|
98
|
+
});
|
|
89
99
|
await Promise.all(
|
|
90
100
|
fundedAccounts.map(async a => {
|
|
91
101
|
const deployMethod = await a.getDeployMethod();
|
|
92
|
-
await deployMethod.send({
|
|
102
|
+
await deployMethod.send({
|
|
103
|
+
from: NO_FROM,
|
|
104
|
+
fee: { paymentMethod },
|
|
105
|
+
wait: { timeout: 2400 },
|
|
106
|
+
}); // increase timeout on purpose in order to account for two empty epochs
|
|
93
107
|
logger.info(`Account deployed at ${a.address}`);
|
|
94
108
|
}),
|
|
95
109
|
);
|
|
@@ -118,49 +132,91 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
118
132
|
}
|
|
119
133
|
|
|
120
134
|
async function deployAccountWithDiagnostics(
|
|
121
|
-
account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any },
|
|
135
|
+
account: { getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>; address: any },
|
|
122
136
|
paymentMethod: SponsoredFeePaymentMethod,
|
|
123
137
|
aztecNode: AztecNode,
|
|
124
138
|
logger: Logger,
|
|
125
139
|
accountLabel: string,
|
|
140
|
+
estimateGas?: boolean,
|
|
126
141
|
): Promise<void> {
|
|
127
142
|
const deployMethod = await account.getDeployMethod();
|
|
128
|
-
let
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
logger.info(`${accountLabel}
|
|
133
|
-
} catch (error) {
|
|
134
|
-
const blockNumber = await aztecNode.getBlockNumber();
|
|
135
|
-
let receipt;
|
|
136
|
-
try {
|
|
137
|
-
receipt = await aztecNode.getTxReceipt(txHash);
|
|
138
|
-
} catch {
|
|
139
|
-
receipt = 'unavailable';
|
|
140
|
-
}
|
|
141
|
-
logger.error(`${accountLabel} deployment failed`, {
|
|
142
|
-
txHash: txHash.toString(),
|
|
143
|
-
receipt: JSON.stringify(receipt),
|
|
144
|
-
currentBlockNumber: blockNumber,
|
|
145
|
-
error: String(error),
|
|
146
|
-
});
|
|
147
|
-
throw error;
|
|
143
|
+
let gasSettings: any;
|
|
144
|
+
if (estimateGas) {
|
|
145
|
+
const sim = await deployMethod.simulate({ from: NO_FROM, fee: { paymentMethod } });
|
|
146
|
+
gasSettings = sim.estimatedGas;
|
|
147
|
+
logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
|
|
148
148
|
}
|
|
149
|
+
|
|
150
|
+
// Track the tx hash across retries so we don't re-send when the previous tx is still pending.
|
|
151
|
+
let sentTxHash: { txHash: any } | undefined;
|
|
152
|
+
|
|
153
|
+
await retry(
|
|
154
|
+
async () => {
|
|
155
|
+
// Check if already deployed (handles case where previous attempt succeeded but waitForTx timed out)
|
|
156
|
+
const existing = await aztecNode.getContract(account.address);
|
|
157
|
+
if (existing) {
|
|
158
|
+
logger.info(`${accountLabel} already deployed at ${account.address}, skipping`);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// If we already sent a tx, check if it was dropped before deciding to re-send.
|
|
163
|
+
if (sentTxHash) {
|
|
164
|
+
const prevReceipt = await aztecNode.getTxReceipt(sentTxHash.txHash);
|
|
165
|
+
if (prevReceipt.isDropped()) {
|
|
166
|
+
logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} was dropped, re-sending`);
|
|
167
|
+
sentTxHash = undefined;
|
|
168
|
+
} else {
|
|
169
|
+
logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} still pending, waiting again...`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!sentTxHash) {
|
|
174
|
+
const deployResult = await deployMethod.send({
|
|
175
|
+
from: NO_FROM,
|
|
176
|
+
fee: { paymentMethod, gasSettings },
|
|
177
|
+
wait: NO_WAIT,
|
|
178
|
+
});
|
|
179
|
+
sentTxHash = { txHash: deployResult.txHash };
|
|
180
|
+
logger.info(`${accountLabel} tx sent`, { txHash: sentTxHash.txHash.toString() });
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const receipt = await waitForTx(aztecNode, sentTxHash.txHash, { timeout: 600 });
|
|
184
|
+
if (receipt.isDropped()) {
|
|
185
|
+
sentTxHash = undefined;
|
|
186
|
+
throw new Error(`${accountLabel} tx was dropped, retrying...`);
|
|
187
|
+
}
|
|
188
|
+
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
189
|
+
},
|
|
190
|
+
`deploy ${accountLabel}`,
|
|
191
|
+
makeBackoff([1, 2, 4, 8, 16]),
|
|
192
|
+
logger,
|
|
193
|
+
);
|
|
149
194
|
}
|
|
150
195
|
|
|
151
196
|
async function deployAccountsInBatches(
|
|
152
|
-
accounts: {
|
|
197
|
+
accounts: {
|
|
198
|
+
getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>;
|
|
199
|
+
address: any;
|
|
200
|
+
}[],
|
|
153
201
|
paymentMethod: SponsoredFeePaymentMethod,
|
|
154
202
|
aztecNode: AztecNode,
|
|
155
203
|
logger: Logger,
|
|
156
204
|
labelPrefix: string,
|
|
157
205
|
batchSize = 2,
|
|
206
|
+
estimateGas?: boolean,
|
|
158
207
|
): Promise<void> {
|
|
159
208
|
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
160
209
|
const batch = accounts.slice(i, i + batchSize);
|
|
161
210
|
await Promise.all(
|
|
162
211
|
batch.map((account, idx) =>
|
|
163
|
-
deployAccountWithDiagnostics(
|
|
212
|
+
deployAccountWithDiagnostics(
|
|
213
|
+
account,
|
|
214
|
+
paymentMethod,
|
|
215
|
+
aztecNode,
|
|
216
|
+
logger,
|
|
217
|
+
`${labelPrefix}${i + idx + 1}`,
|
|
218
|
+
estimateGas,
|
|
219
|
+
),
|
|
164
220
|
),
|
|
165
221
|
);
|
|
166
222
|
}
|
|
@@ -171,6 +227,7 @@ export async function deploySponsoredTestAccounts(
|
|
|
171
227
|
aztecNode: AztecNode,
|
|
172
228
|
logger: Logger,
|
|
173
229
|
numberOfFundedWallets = 1,
|
|
230
|
+
opts?: { estimateGas?: boolean },
|
|
174
231
|
): Promise<TestAccountsWithoutTokens> {
|
|
175
232
|
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
176
233
|
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
@@ -180,8 +237,23 @@ export async function deploySponsoredTestAccounts(
|
|
|
180
237
|
|
|
181
238
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
182
239
|
|
|
183
|
-
await deployAccountWithDiagnostics(
|
|
184
|
-
|
|
240
|
+
await deployAccountWithDiagnostics(
|
|
241
|
+
recipientAccount,
|
|
242
|
+
paymentMethod,
|
|
243
|
+
aztecNode,
|
|
244
|
+
logger,
|
|
245
|
+
'Recipient account',
|
|
246
|
+
opts?.estimateGas,
|
|
247
|
+
);
|
|
248
|
+
await deployAccountsInBatches(
|
|
249
|
+
fundedAccounts,
|
|
250
|
+
paymentMethod,
|
|
251
|
+
aztecNode,
|
|
252
|
+
logger,
|
|
253
|
+
'Funded account ',
|
|
254
|
+
2,
|
|
255
|
+
opts?.estimateGas,
|
|
256
|
+
);
|
|
185
257
|
|
|
186
258
|
return {
|
|
187
259
|
aztecNode,
|
|
@@ -219,7 +291,7 @@ export async function deployTestAccountsWithTokens(
|
|
|
219
291
|
fundedAccounts.map(async (a, i) => {
|
|
220
292
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
|
|
221
293
|
const deployMethod = await a.getDeployMethod();
|
|
222
|
-
await deployMethod.send({ from:
|
|
294
|
+
await deployMethod.send({ from: NO_FROM, fee: { paymentMethod } });
|
|
223
295
|
logger.info(`Account deployed at ${a.address}`);
|
|
224
296
|
}),
|
|
225
297
|
);
|
|
@@ -262,9 +334,7 @@ async function bridgeL1FeeJuice(
|
|
|
262
334
|
const portal = await L1FeeJuicePortalManager.new(aztecNode, l1Client, log);
|
|
263
335
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
264
336
|
|
|
265
|
-
|
|
266
|
-
(await aztecNode.getL1ToL2MessageBlock(Fr.fromHexString(claim.messageHash))) !== undefined;
|
|
267
|
-
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
337
|
+
await waitForL1ToL2MessageReady(aztecNode, Fr.fromHexString(claim.messageHash), { timeoutSeconds: 24 });
|
|
268
338
|
|
|
269
339
|
log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
|
|
270
340
|
return claim;
|
|
@@ -306,7 +376,7 @@ async function deployTokenAndMint(
|
|
|
306
376
|
fee: {
|
|
307
377
|
paymentMethod,
|
|
308
378
|
},
|
|
309
|
-
wait: { timeout: 600
|
|
379
|
+
wait: { timeout: 600 },
|
|
310
380
|
});
|
|
311
381
|
|
|
312
382
|
const tokenAddress = tokenContract.address;
|
|
@@ -357,7 +427,9 @@ export async function performTransfers({
|
|
|
357
427
|
|
|
358
428
|
const provenTxs = await Promise.all(txs);
|
|
359
429
|
|
|
360
|
-
|
|
430
|
+
// Wait only for the txs to be proposed, not checkpointed. This is enough to keep the chain
|
|
431
|
+
// loaded for the reorg scenario, and avoids each round blocking on the (slower) checkpoint lag.
|
|
432
|
+
await Promise.all(provenTxs.map(t => t.send({ wait: { timeout: 600, waitForStatus: TxStatus.PROPOSED } })));
|
|
361
433
|
|
|
362
434
|
logger.info(`Completed round ${i + 1} / ${rounds}`);
|
|
363
435
|
}
|
|
@@ -395,3 +467,42 @@ export async function createWalletAndAztecNodeClient(
|
|
|
395
467
|
},
|
|
396
468
|
};
|
|
397
469
|
}
|
|
470
|
+
|
|
471
|
+
export type WorkerWalletWrapper = {
|
|
472
|
+
wallet: WorkerWallet;
|
|
473
|
+
aztecNode: AztecNode;
|
|
474
|
+
cleanup: () => Promise<void>;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
export async function createWorkerWalletClient(
|
|
478
|
+
nodeUrl: string,
|
|
479
|
+
proverEnabled: boolean,
|
|
480
|
+
logger: Logger,
|
|
481
|
+
): Promise<WorkerWalletWrapper> {
|
|
482
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
483
|
+
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
484
|
+
|
|
485
|
+
// Strip cleanup functions — they can't be structured-cloned for worker transfer
|
|
486
|
+
const { cleanup: bbCleanup, ...bbPaths } = bbConfig ?? {};
|
|
487
|
+
const { cleanup: acvmCleanup, ...acvmPaths } = acvmConfig ?? {};
|
|
488
|
+
|
|
489
|
+
const pxeConfig = {
|
|
490
|
+
dataDirectory: undefined,
|
|
491
|
+
dataStoreMapSizeKb: 1024 * 1024,
|
|
492
|
+
...bbPaths,
|
|
493
|
+
...acvmPaths,
|
|
494
|
+
proverEnabled,
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
const wallet = await WorkerWallet.create(nodeUrl, pxeConfig);
|
|
498
|
+
|
|
499
|
+
return {
|
|
500
|
+
wallet,
|
|
501
|
+
aztecNode,
|
|
502
|
+
async cleanup() {
|
|
503
|
+
await wallet.stop();
|
|
504
|
+
await bbCleanup?.();
|
|
505
|
+
await acvmCleanup?.();
|
|
506
|
+
},
|
|
507
|
+
};
|
|
508
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlockResponse } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
import type { TopicType } from '@aztec/stdlib/p2p';
|
|
5
5
|
import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
@@ -134,9 +134,12 @@ export class ProvingMetrics {
|
|
|
134
134
|
|
|
135
135
|
export type TxInclusionData = {
|
|
136
136
|
txHash: string;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
/** Wall-clock at client when the tx was submitted, in ms (Date.now()). */
|
|
138
|
+
sentAtMs: number;
|
|
139
|
+
/** Wall-clock at client when the block containing the tx first became visible, in ms (Date.now()). -1 if never observed. */
|
|
140
|
+
minedAtMs: number;
|
|
141
|
+
/** Reserved for future attestation-observed-at signal; -1 today. */
|
|
142
|
+
attestedAtMs: number;
|
|
140
143
|
blocknumber: number;
|
|
141
144
|
priorityFee: number;
|
|
142
145
|
totalFee: number;
|
|
@@ -147,7 +150,7 @@ export type TxInclusionData = {
|
|
|
147
150
|
export class TxInclusionMetrics {
|
|
148
151
|
private data = new Map<string, TxInclusionData>();
|
|
149
152
|
private groups = new Set<string>();
|
|
150
|
-
private blocks = new Map<number, Promise<
|
|
153
|
+
private blocks = new Map<number, Promise<BlockResponse<{ includeTransactions: true }> | undefined>>();
|
|
151
154
|
|
|
152
155
|
private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
|
|
153
156
|
|
|
@@ -174,9 +177,9 @@ export class TxInclusionMetrics {
|
|
|
174
177
|
|
|
175
178
|
this.data.set(txHash, {
|
|
176
179
|
txHash,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
sentAtMs: Date.now(),
|
|
181
|
+
minedAtMs: -1,
|
|
182
|
+
attestedAtMs: -1,
|
|
180
183
|
blocknumber: -1,
|
|
181
184
|
priorityFee: Number(priorityFees.feePerDaGas + priorityFees.feePerL2Gas),
|
|
182
185
|
totalFee: -1,
|
|
@@ -186,6 +189,28 @@ export class TxInclusionMetrics {
|
|
|
186
189
|
this.groups.add(group);
|
|
187
190
|
}
|
|
188
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Stamp mined-at metadata for any tracked tx contained in this block, using
|
|
194
|
+
* `observedAtMs` (caller-supplied wall-clock at the moment they first saw the
|
|
195
|
+
* block). Idempotent: existing minedAtMs is preserved so the first observer
|
|
196
|
+
* wins (typically the block-watcher; recordMinedTx is a fallback).
|
|
197
|
+
*/
|
|
198
|
+
observeBlockForMinedTxs(
|
|
199
|
+
blockNumber: number,
|
|
200
|
+
txHashes: ReadonlyArray<{ toString(): string }>,
|
|
201
|
+
observedAtMs: number,
|
|
202
|
+
): void {
|
|
203
|
+
txHashes.forEach((txHash, position) => {
|
|
204
|
+
const data = this.data.get(txHash.toString());
|
|
205
|
+
if (!data || data.minedAtMs !== -1) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
data.blocknumber = blockNumber;
|
|
209
|
+
data.minedAtMs = observedAtMs;
|
|
210
|
+
data.positionInBlock = position;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
189
214
|
async recordMinedTx(txReceipt: TxReceipt): Promise<void> {
|
|
190
215
|
const { txHash, blockNumber } = txReceipt;
|
|
191
216
|
if (!txReceipt.isMined() || !txReceipt.hasExecutionSucceeded() || !blockNumber) {
|
|
@@ -197,26 +222,43 @@ export class TxInclusionMetrics {
|
|
|
197
222
|
return;
|
|
198
223
|
}
|
|
199
224
|
|
|
200
|
-
if (!this.blocks.has(blockNumber)) {
|
|
201
|
-
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const block = await this.blocks.get(blockNumber)!;
|
|
205
|
-
if (!block) {
|
|
206
|
-
this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
225
|
const data = this.data.get(txHash.toString());
|
|
210
226
|
if (!data) {
|
|
211
227
|
const message = `Missing sent tx record for mined tx ${txHash.toString()}`;
|
|
212
228
|
this.logger?.warn(message, { txHash: txHash.toString(), blockNumber });
|
|
213
229
|
throw new Error(message);
|
|
214
230
|
}
|
|
215
|
-
data.blocknumber = blockNumber;
|
|
216
|
-
data.minedAt = Number(block.header.globalVariables.timestamp);
|
|
217
|
-
data.attestedAt = -1;
|
|
218
231
|
data.totalFee = Number(txReceipt.transactionFee ?? 0n);
|
|
219
|
-
|
|
232
|
+
|
|
233
|
+
// Fallback path for txs the block-watcher missed (e.g. observed only after
|
|
234
|
+
// the watcher stopped). Stamp with the block's L2 slot timestamp; this is
|
|
235
|
+
// earlier than the true client-observed time by attestation+propagation
|
|
236
|
+
// lag, but it's the only deterministic timestamp available post-hoc.
|
|
237
|
+
if (data.minedAtMs === -1) {
|
|
238
|
+
if (!this.blocks.has(blockNumber)) {
|
|
239
|
+
this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber, { includeTransactions: true }));
|
|
240
|
+
}
|
|
241
|
+
const block = await this.blocks.get(blockNumber)!;
|
|
242
|
+
if (!block) {
|
|
243
|
+
this.logger?.warn('Failed to load block for mined tx receipt', { txHash: txHash.toString(), blockNumber });
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
data.blocknumber = blockNumber;
|
|
247
|
+
data.minedAtMs = Number(block.header.globalVariables.timestamp) * 1000;
|
|
248
|
+
data.positionInBlock = block.body.txEffects.findIndex(txEffect => txEffect.txHash.equals(txHash));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Per-tx inclusion records for a group. Used to serialise out for downstream tooling. */
|
|
253
|
+
getInclusionRecords(group?: string): TxInclusionData[] {
|
|
254
|
+
const out: TxInclusionData[] = [];
|
|
255
|
+
for (const tx of this.data.values()) {
|
|
256
|
+
if (group !== undefined && tx.group !== group) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
out.push({ ...tx });
|
|
260
|
+
}
|
|
261
|
+
return out;
|
|
220
262
|
}
|
|
221
263
|
|
|
222
264
|
public inclusionTimeInSeconds(group: string): {
|
|
@@ -229,12 +271,28 @@ export class TxInclusionMetrics {
|
|
|
229
271
|
p99: number;
|
|
230
272
|
} {
|
|
231
273
|
const histogram = createHistogram({});
|
|
274
|
+
let nonPositive = 0;
|
|
232
275
|
for (const tx of this.data.values()) {
|
|
233
|
-
if (!tx.blocknumber || tx.group !== group || tx.
|
|
276
|
+
if (!tx.blocknumber || tx.group !== group || tx.minedAtMs === -1) {
|
|
234
277
|
continue;
|
|
235
278
|
}
|
|
236
279
|
|
|
237
|
-
|
|
280
|
+
// Both timestamps are client wall-clock (ms). A negative delta should be
|
|
281
|
+
// impossible since the watcher stamps minedAtMs strictly after sentAtMs,
|
|
282
|
+
// but the fallback path (recordMinedTx via L2 slot timestamp) can stamp
|
|
283
|
+
// earlier than sentAtMs. perf_hooks.createHistogram rejects <=0; skip
|
|
284
|
+
// those instead of crashing.
|
|
285
|
+
const deltaMs = tx.minedAtMs - tx.sentAtMs;
|
|
286
|
+
if (deltaMs <= 0) {
|
|
287
|
+
nonPositive++;
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
// Histogram is recorded in seconds (rounded) to match the existing
|
|
291
|
+
// toGithubActionBenchmarkJSON output unit; per-tx records carry the raw ms.
|
|
292
|
+
histogram.record(Math.max(1, Math.round(deltaMs / 1000)));
|
|
293
|
+
}
|
|
294
|
+
if (nonPositive > 0) {
|
|
295
|
+
this.logger?.debug(`Dropped ${nonPositive} tx inclusion samples with non-positive delta`, { group });
|
|
238
296
|
}
|
|
239
297
|
|
|
240
298
|
if (histogram.count === 0) {
|
|
@@ -296,7 +354,7 @@ export class TxInclusionMetrics {
|
|
|
296
354
|
value: stats.mean,
|
|
297
355
|
},
|
|
298
356
|
{
|
|
299
|
-
name: `${group}/
|
|
357
|
+
name: `${group}/p50_inclusion`,
|
|
300
358
|
unit: 's',
|
|
301
359
|
value: stats.median,
|
|
302
360
|
},
|
package/src/spartan/utils/bot.ts
CHANGED
|
@@ -34,7 +34,8 @@ export async function installTransferBot({
|
|
|
34
34
|
logger: log,
|
|
35
35
|
replicas = 1,
|
|
36
36
|
txIntervalSeconds = 10,
|
|
37
|
-
followChain = '
|
|
37
|
+
followChain = 'CHECKPOINTED',
|
|
38
|
+
pxeSyncChainTip = 'proposed',
|
|
38
39
|
mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
|
|
39
40
|
mnemonicStartIndex,
|
|
40
41
|
botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
|
|
@@ -49,6 +50,7 @@ export async function installTransferBot({
|
|
|
49
50
|
replicas?: number;
|
|
50
51
|
txIntervalSeconds?: number;
|
|
51
52
|
followChain?: string;
|
|
53
|
+
pxeSyncChainTip?: string;
|
|
52
54
|
mnemonic?: string;
|
|
53
55
|
mnemonicStartIndex?: number | string;
|
|
54
56
|
botPrivateKey?: string;
|
|
@@ -67,6 +69,7 @@ export async function installTransferBot({
|
|
|
67
69
|
'bot.replicaCount': replicas,
|
|
68
70
|
'bot.txIntervalSeconds': txIntervalSeconds,
|
|
69
71
|
'bot.followChain': followChain,
|
|
72
|
+
'bot.pxeSyncChainTip': pxeSyncChainTip,
|
|
70
73
|
'bot.botPrivateKey': botPrivateKey,
|
|
71
74
|
'bot.nodeUrl': resolvedNodeUrl,
|
|
72
75
|
'bot.mnemonic': mnemonic,
|
|
@@ -8,6 +8,7 @@ const logger = createLogger('e2e:k8s-utils');
|
|
|
8
8
|
const testConfigSchema = z.object({
|
|
9
9
|
NAMESPACE: z.string().default('scenario'),
|
|
10
10
|
REAL_VERIFIER: schemas.Boolean.optional().default(true),
|
|
11
|
+
DEBUG_FORCE_TX_PROOF_VERIFICATION: schemas.Boolean.optional().default(true),
|
|
11
12
|
CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
|
|
12
13
|
L1_RPC_URLS_JSON: z.string().optional(),
|
|
13
14
|
L1_ACCOUNT_MNEMONIC: z.string().optional(),
|
|
@@ -16,6 +17,7 @@ const testConfigSchema = z.object({
|
|
|
16
17
|
AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
|
|
17
18
|
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
|
|
18
19
|
FUNDING_PRIVATE_KEY: z.string().optional(),
|
|
20
|
+
AZTEC_ADMIN_API_KEY: z.string().optional(),
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
export type TestConfig = z.infer<typeof testConfigSchema>;
|