@aztec/ethereum 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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/account.d.ts +1 -1
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +2 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +6 -2
- package/dest/config.d.ts +22 -68
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +61 -338
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +9 -5
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +8 -4
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +39 -17
- package/dest/contracts/errors.d.ts +1 -1
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +651 -0
- package/dest/contracts/fee_juice.d.ts +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts +18 -16
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +14 -4
- package/dest/contracts/governance_proposer.d.ts +8 -4
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +412 -11
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +24 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +36 -1
- package/dest/contracts/index.d.ts +4 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -0
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.js +1 -0
- package/dest/contracts/multicall.d.ts +2 -2
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +2 -1
- package/dest/contracts/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/registry.d.ts +1 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/rollup.d.ts +195 -123
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +755 -184
- package/dest/contracts/slasher_contract.d.ts +1 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts +15 -7
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +22 -5
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +259 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +413 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +11903 -1961
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +3 -3
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +3 -3
- package/dest/l1_reader.d.ts +4 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +7 -1
- package/dest/l1_tx_utils/config.d.ts +11 -5
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +45 -9
- package/dest/l1_tx_utils/constants.d.ts +8 -2
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +27 -2
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +42 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +4 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +3 -0
- package/dest/l1_tx_utils/interfaces.d.ts +2 -2
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +15 -6
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +64 -17
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +19 -17
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +69 -40
- package/dest/l1_tx_utils/signer.d.ts +1 -1
- package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +65 -36
- package/dest/l1_tx_utils/types.d.ts +1 -1
- package/dest/l1_tx_utils/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/utils.d.ts +1 -1
- package/dest/l1_types.d.ts +1 -1
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +16 -6
- package/dest/test/chain_monitor.d.ts +27 -24
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +33 -36
- package/dest/test/eth_cheat_codes.d.ts +26 -9
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +28 -12
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -2
- package/dest/test/rollup_cheat_codes.d.ts +24 -20
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +97 -41
- package/dest/test/start_anvil.d.ts +4 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +3 -2
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +4 -3
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +16 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +64 -0
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +34 -14
- package/src/client.ts +3 -3
- package/src/config.ts +74 -414
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +8 -5
- package/src/contracts/empire_slashing_proposer.ts +38 -32
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +280 -0
- package/src/contracts/governance.ts +13 -4
- package/src/contracts/governance_proposer.ts +26 -6
- package/src/contracts/inbox.ts +55 -3
- package/src/contracts/index.ts +3 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +433 -167
- package/src/contracts/tally_slashing_proposer.ts +25 -9
- package/src/deploy_aztec_l1_contracts.ts +650 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_contract_addresses.ts +22 -20
- package/src/l1_reader.ts +10 -2
- package/src/l1_tx_utils/config.ts +54 -13
- package/src/l1_tx_utils/constants.ts +13 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +108 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +3 -0
- package/src/l1_tx_utils/interfaces.ts +1 -1
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +76 -21
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +92 -45
- package/src/{test → l1_tx_utils}/tx_delayer.ts +82 -52
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +17 -6
- package/src/test/chain_monitor.ts +51 -49
- package/src/test/eth_cheat_codes.ts +34 -15
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +111 -54
- package/src/test/start_anvil.ts +5 -1
- package/src/test/upgrade_utils.ts +4 -3
- package/src/types.ts +62 -0
- package/src/utils.ts +83 -1
- package/dest/deploy_l1_contracts.d.ts +0 -226
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1459
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/deploy_l1_contracts.ts +0 -1838
- package/src/index.ts +0 -17
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
4
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
6
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import type {
|
|
7
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
6
8
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
7
9
|
|
|
8
10
|
import {
|
|
@@ -14,7 +16,6 @@ import {
|
|
|
14
16
|
hexToBigInt,
|
|
15
17
|
http,
|
|
16
18
|
} from 'viem';
|
|
17
|
-
import { foundry } from 'viem/chains';
|
|
18
19
|
|
|
19
20
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
20
21
|
|
|
@@ -30,8 +31,8 @@ export class RollupCheatCodes {
|
|
|
30
31
|
addresses: Pick<L1ContractAddresses, 'rollupAddress'>,
|
|
31
32
|
) {
|
|
32
33
|
this.client = createPublicClient({
|
|
33
|
-
chain:
|
|
34
|
-
transport: fallback(ethCheatCodes.rpcUrls.map(url => http(url))),
|
|
34
|
+
chain: ethCheatCodes.chain,
|
|
35
|
+
transport: fallback(ethCheatCodes.rpcUrls.map(url => http(url, { batch: false }))),
|
|
35
36
|
});
|
|
36
37
|
this.rollup = getContract({
|
|
37
38
|
abi: RollupAbi,
|
|
@@ -40,21 +41,34 @@ export class RollupCheatCodes {
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
static create(
|
|
44
|
-
|
|
44
|
+
static create(
|
|
45
|
+
rpcUrls: string[],
|
|
46
|
+
addresses: Pick<L1ContractAddresses, 'rollupAddress'>,
|
|
47
|
+
dateProvider: DateProvider,
|
|
48
|
+
): RollupCheatCodes {
|
|
49
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
45
50
|
return new RollupCheatCodes(ethCheatCodes, addresses);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
/** Returns the current slot */
|
|
49
|
-
public async getSlot() {
|
|
54
|
+
public async getSlot(): Promise<SlotNumber> {
|
|
50
55
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
51
|
-
return await this.rollup.read.getSlotAt([ts]);
|
|
56
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([ts]));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */
|
|
60
|
+
public async getSecondsUntilSlot(slot: SlotNumber): Promise<number> {
|
|
61
|
+
const [currentTimestamp, targetTimestamp] = await Promise.all([
|
|
62
|
+
this.client.getBlock().then(b => BigInt(b.timestamp)),
|
|
63
|
+
this.rollup.read.getTimestampForSlot([BigInt(slot)]),
|
|
64
|
+
]);
|
|
65
|
+
return Math.max(0, Number(targetTimestamp - currentTimestamp));
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
/** Returns the current epoch */
|
|
55
|
-
public async getEpoch() {
|
|
69
|
+
public async getEpoch(): Promise<EpochNumber> {
|
|
56
70
|
const slotNumber = await this.getSlot();
|
|
57
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
71
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
/**
|
|
@@ -62,13 +76,13 @@ export class RollupCheatCodes {
|
|
|
62
76
|
* @returns The pending and proven chain tips
|
|
63
77
|
*/
|
|
64
78
|
public async getTips(): Promise<{
|
|
65
|
-
/** The pending chain tip */ pending:
|
|
66
|
-
/** The proven chain tip */ proven:
|
|
79
|
+
/** The pending chain tip */ pending: CheckpointNumber;
|
|
80
|
+
/** The proven chain tip */ proven: CheckpointNumber;
|
|
67
81
|
}> {
|
|
68
|
-
const
|
|
82
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
69
83
|
return {
|
|
70
|
-
pending:
|
|
71
|
-
proven:
|
|
84
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
85
|
+
proven: CheckpointNumber.fromBigInt(proven),
|
|
72
86
|
};
|
|
73
87
|
}
|
|
74
88
|
|
|
@@ -77,16 +91,16 @@ export class RollupCheatCodes {
|
|
|
77
91
|
*/
|
|
78
92
|
public async debugRollup() {
|
|
79
93
|
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
80
|
-
const pendingNum = await rollup.
|
|
81
|
-
const provenNum = await rollup.
|
|
94
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
95
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
82
96
|
const validators = await rollup.getAttesters();
|
|
83
97
|
const committee = await rollup.getCurrentEpochCommittee();
|
|
84
98
|
const archive = await rollup.archive();
|
|
85
99
|
const slot = await this.getSlot();
|
|
86
100
|
const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
|
|
87
101
|
|
|
88
|
-
this.logger.info(`Pending
|
|
89
|
-
this.logger.info(`Proven
|
|
102
|
+
this.logger.info(`Pending checkpoint num: ${pendingNum}`);
|
|
103
|
+
this.logger.info(`Proven checkpoint num: ${provenNum}`);
|
|
90
104
|
this.logger.info(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
91
105
|
this.logger.info(`Committee: ${committee?.map(v => v.toString()).join(', ')}`);
|
|
92
106
|
this.logger.info(`Archive: ${archive}`);
|
|
@@ -97,13 +111,13 @@ export class RollupCheatCodes {
|
|
|
97
111
|
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
98
112
|
public async getConfig(): Promise<{
|
|
99
113
|
/** Epoch duration */ epochDuration: bigint;
|
|
100
|
-
/** Slot duration */ slotDuration:
|
|
114
|
+
/** Slot duration */ slotDuration: number;
|
|
101
115
|
}> {
|
|
102
116
|
const [epochDuration, slotDuration] = await Promise.all([
|
|
103
117
|
this.rollup.read.getEpochDuration(),
|
|
104
118
|
this.rollup.read.getSlotDuration(),
|
|
105
119
|
]);
|
|
106
|
-
return { epochDuration, slotDuration };
|
|
120
|
+
return { epochDuration, slotDuration: Number(slotDuration) };
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
/**
|
|
@@ -112,20 +126,18 @@ export class RollupCheatCodes {
|
|
|
112
126
|
* @param opts - Options
|
|
113
127
|
*/
|
|
114
128
|
public async advanceToEpoch(
|
|
115
|
-
epoch:
|
|
129
|
+
epoch: EpochNumber,
|
|
116
130
|
opts: {
|
|
117
|
-
/** Optional test date provider to update with the epoch timestamp */
|
|
118
|
-
updateDateProvider?: TestDateProvider;
|
|
119
131
|
/** Offset in seconds */
|
|
120
132
|
offset?: number;
|
|
121
133
|
} = {},
|
|
122
134
|
) {
|
|
123
135
|
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
124
|
-
const
|
|
125
|
-
|
|
136
|
+
const slotNumber = SlotNumber(Number(epoch) * Number(slotsInEpoch));
|
|
137
|
+
const timestamp = (await this.rollup.read.getTimestampForSlot([BigInt(slotNumber)])) + BigInt(opts.offset ?? 0);
|
|
126
138
|
try {
|
|
127
139
|
await this.ethCheatCodes.warp(Number(timestamp), { ...opts, silent: true, resetBlockInterval: true });
|
|
128
|
-
this.logger.warn(`Warped to epoch ${epoch}
|
|
140
|
+
this.logger.warn(`Warped to epoch ${epoch}`, { offset: opts.offset, timestamp });
|
|
129
141
|
} catch (err) {
|
|
130
142
|
this.logger.warn(`Warp to epoch ${epoch} failed: ${err}`);
|
|
131
143
|
}
|
|
@@ -133,19 +145,13 @@ export class RollupCheatCodes {
|
|
|
133
145
|
}
|
|
134
146
|
|
|
135
147
|
/** Warps time in L1 until the next epoch */
|
|
136
|
-
public async advanceToNextEpoch(
|
|
137
|
-
opts: {
|
|
138
|
-
/** Optional test date provider to update with the epoch timestamp */
|
|
139
|
-
updateDateProvider?: TestDateProvider;
|
|
140
|
-
} = {},
|
|
141
|
-
) {
|
|
148
|
+
public async advanceToNextEpoch() {
|
|
142
149
|
const slot = await this.getSlot();
|
|
143
150
|
const { epochDuration, slotDuration } = await this.getConfig();
|
|
144
|
-
const slotsUntilNextEpoch = epochDuration - (slot % epochDuration) + 1n;
|
|
145
|
-
const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
|
|
151
|
+
const slotsUntilNextEpoch = epochDuration - (BigInt(slot) % epochDuration) + 1n;
|
|
152
|
+
const timeToNextEpoch = slotsUntilNextEpoch * BigInt(slotDuration);
|
|
146
153
|
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
147
154
|
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
148
|
-
...opts,
|
|
149
155
|
silent: true,
|
|
150
156
|
resetBlockInterval: true,
|
|
151
157
|
});
|
|
@@ -155,10 +161,11 @@ export class RollupCheatCodes {
|
|
|
155
161
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
156
162
|
public async advanceToNextSlot() {
|
|
157
163
|
const currentSlot = await this.getSlot();
|
|
158
|
-
const
|
|
164
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
165
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]);
|
|
159
166
|
await this.ethCheatCodes.warp(Number(timestamp), { silent: true, resetBlockInterval: true });
|
|
160
|
-
this.logger.warn(`Advanced to slot ${
|
|
161
|
-
return [timestamp,
|
|
167
|
+
this.logger.warn(`Advanced to slot ${nextSlot}`);
|
|
168
|
+
return [timestamp, nextSlot];
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
/**
|
|
@@ -167,42 +174,42 @@ export class RollupCheatCodes {
|
|
|
167
174
|
*/
|
|
168
175
|
public async advanceSlots(howMany: number) {
|
|
169
176
|
const l1Timestamp = (await this.client.getBlock()).timestamp;
|
|
170
|
-
const slotDuration = await this.rollup.read.getSlotDuration();
|
|
171
|
-
const timeToWarp = BigInt(howMany) * slotDuration;
|
|
177
|
+
const slotDuration = Number(await this.rollup.read.getSlotDuration());
|
|
178
|
+
const timeToWarp = BigInt(howMany) * BigInt(slotDuration);
|
|
172
179
|
await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, { silent: true, resetBlockInterval: true });
|
|
173
180
|
const [slot, epoch] = await Promise.all([this.getSlot(), this.getEpoch()]);
|
|
174
181
|
this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
/**
|
|
178
|
-
* Marks the specified
|
|
179
|
-
* @param
|
|
185
|
+
* Marks the specified checkpoint (or latest if none) as proven
|
|
186
|
+
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
180
187
|
*/
|
|
181
|
-
public markAsProven(
|
|
188
|
+
public markAsProven(maybeCheckpointNumber?: CheckpointNumber) {
|
|
182
189
|
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
183
190
|
const tipsBefore = await this.getTips();
|
|
184
191
|
const { pending, proven } = tipsBefore;
|
|
185
192
|
|
|
186
|
-
let
|
|
187
|
-
if (
|
|
188
|
-
|
|
193
|
+
let checkpointNumber = maybeCheckpointNumber;
|
|
194
|
+
if (checkpointNumber === undefined || checkpointNumber > pending) {
|
|
195
|
+
checkpointNumber = pending;
|
|
189
196
|
}
|
|
190
|
-
if (
|
|
191
|
-
this.logger.debug(`
|
|
197
|
+
if (checkpointNumber <= proven) {
|
|
198
|
+
this.logger.debug(`Checkpoint ${checkpointNumber} is already proven`);
|
|
192
199
|
return;
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
// @note @LHerskind this is heavily dependent on the storage layout and size of values
|
|
196
203
|
// The rollupStore is a struct and if the size of elements or the struct changes, this can break
|
|
197
|
-
const
|
|
204
|
+
const provenCheckpointNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
|
|
198
205
|
|
|
199
206
|
// Need to pack it as a single 32 byte word
|
|
200
|
-
const newValue = (BigInt(tipsBefore.pending) << 128n) | BigInt(
|
|
201
|
-
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address),
|
|
207
|
+
const newValue = (BigInt(tipsBefore.pending) << 128n) | BigInt(checkpointNumber);
|
|
208
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provenCheckpointNumberSlot, newValue);
|
|
202
209
|
|
|
203
210
|
const tipsAfter = await this.getTips();
|
|
204
211
|
if (tipsAfter.pending < tipsAfter.proven) {
|
|
205
|
-
throw new Error('Overwrote pending tip to a
|
|
212
|
+
throw new Error('Overwrote pending tip to a checkpoint in the past');
|
|
206
213
|
}
|
|
207
214
|
|
|
208
215
|
this.logger.info(
|
|
@@ -211,6 +218,56 @@ export class RollupCheatCodes {
|
|
|
211
218
|
});
|
|
212
219
|
}
|
|
213
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Overrides the inProgress field of the Inbox contract state
|
|
223
|
+
* @param howMuch - How many checkpoints to move it forward
|
|
224
|
+
*/
|
|
225
|
+
public advanceInboxInProgress(howMuch: number | bigint): Promise<bigint> {
|
|
226
|
+
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
227
|
+
// Storage slot 2 contains the InboxState struct
|
|
228
|
+
const inboxStateSlot = 2n;
|
|
229
|
+
|
|
230
|
+
// Get inbox and its current state values
|
|
231
|
+
const inboxAddress = await this.rollup.read.getInbox();
|
|
232
|
+
const currentStateValue = await this.ethCheatCodes.load(EthAddress.fromString(inboxAddress), inboxStateSlot);
|
|
233
|
+
|
|
234
|
+
// Extract current values from the packed storage slot
|
|
235
|
+
// Storage layout: rollingHash (128 bits) | totalMessagesInserted (64 bits) | inProgress (64 bits)
|
|
236
|
+
const currentRollingHash = currentStateValue & ((1n << 128n) - 1n);
|
|
237
|
+
const currentTotalMessages = (currentStateValue >> 128n) & ((1n << 64n) - 1n);
|
|
238
|
+
const currentInProgress = currentStateValue >> 192n;
|
|
239
|
+
const newInProgress = currentInProgress + BigInt(howMuch);
|
|
240
|
+
|
|
241
|
+
// Pack new values: rollingHash (low 128 bits) | totalMessages (middle 64 bits) | inProgress (high 64 bits)
|
|
242
|
+
const newValue = (BigInt(newInProgress) << 192n) | (currentTotalMessages << 128n) | currentRollingHash;
|
|
243
|
+
|
|
244
|
+
await this.ethCheatCodes.store(EthAddress.fromString(inboxAddress), inboxStateSlot, newValue, {
|
|
245
|
+
silent: true,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
this.logger.warn(`Inbox inProgress advanced from ${currentInProgress} to ${newInProgress}`, {
|
|
249
|
+
inbox: inboxAddress,
|
|
250
|
+
oldValue: '0x' + currentStateValue.toString(16),
|
|
251
|
+
newValue: '0x' + newValue.toString(16),
|
|
252
|
+
rollingHash: currentRollingHash,
|
|
253
|
+
totalMessages: currentTotalMessages,
|
|
254
|
+
oldInProgress: currentInProgress,
|
|
255
|
+
newInProgress,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
return newInProgress;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
public insertOutbox(epoch: EpochNumber, outHash: bigint) {
|
|
263
|
+
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
264
|
+
const outboxAddress = await this.rollup.read.getOutbox();
|
|
265
|
+
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch);
|
|
266
|
+
await this.ethCheatCodes.store(EthAddress.fromString(outboxAddress), epochRootSlot, outHash);
|
|
267
|
+
this.logger.warn(`Advanced outbox to epoch ${epoch} with out hash ${outHash}`);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
214
271
|
/**
|
|
215
272
|
* Executes an action impersonated as the owner of the Rollup contract.
|
|
216
273
|
* @param action - The action to execute
|
package/src/test/start_anvil.ts
CHANGED
|
@@ -15,6 +15,9 @@ export async function startAnvil(
|
|
|
15
15
|
log?: boolean;
|
|
16
16
|
captureMethodCalls?: boolean;
|
|
17
17
|
accounts?: number;
|
|
18
|
+
chainId?: number;
|
|
19
|
+
/** The hardfork to use - note: @viem/anvil types are out of date but 'cancun' and 'latest' work */
|
|
20
|
+
hardfork?: string;
|
|
18
21
|
} = {},
|
|
19
22
|
): Promise<{ anvil: Anvil; methodCalls?: string[]; rpcUrl: string; stop: () => Promise<void> }> {
|
|
20
23
|
const anvilBinary = resolve(dirname(fileURLToPath(import.meta.url)), '../../', 'scripts/anvil_kill_wrapper.sh');
|
|
@@ -30,11 +33,12 @@ export async function startAnvil(
|
|
|
30
33
|
const anvil = createAnvil({
|
|
31
34
|
anvilBinary,
|
|
32
35
|
host: '127.0.0.1',
|
|
33
|
-
port: opts.port ?? 8545,
|
|
36
|
+
port: opts.port ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : 8545),
|
|
34
37
|
blockTime: opts.l1BlockTime,
|
|
35
38
|
stopTimeout: 1000,
|
|
36
39
|
accounts: opts.accounts ?? 20,
|
|
37
40
|
gasLimit: 45_000_000n,
|
|
41
|
+
chainId: opts.chainId ?? 31337,
|
|
38
42
|
});
|
|
39
43
|
|
|
40
44
|
// Listen to the anvil output to get the port.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
2
3
|
import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
|
|
3
4
|
import { TestERC20Abi as StakingAssetAbi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
4
5
|
|
|
@@ -6,7 +7,7 @@ import { type GetContractReturnType, type PrivateKeyAccount, getContract } from
|
|
|
6
7
|
|
|
7
8
|
import { extractProposalIdFromLogs } from '../contracts/governance.js';
|
|
8
9
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
9
|
-
import {
|
|
10
|
+
import { createL1TxUtils } from '../l1_tx_utils/index.js';
|
|
10
11
|
import type { ExtendedViemWalletClient, ViemPublicClient } from '../types.js';
|
|
11
12
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
12
13
|
|
|
@@ -21,7 +22,7 @@ export async function executeGovernanceProposal(
|
|
|
21
22
|
) {
|
|
22
23
|
const proposal = await governance.read.getProposal([proposalId]);
|
|
23
24
|
|
|
24
|
-
const l1TxUtils =
|
|
25
|
+
const l1TxUtils = createL1TxUtils(l1Client);
|
|
25
26
|
|
|
26
27
|
const waitL1Block = async () => {
|
|
27
28
|
await l1TxUtils.sendAndMonitorTransaction({
|
|
@@ -30,7 +31,7 @@ export async function executeGovernanceProposal(
|
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const cheatCodes = new EthCheatCodes(rpcUrls, logger);
|
|
34
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), logger);
|
|
34
35
|
|
|
35
36
|
const timeToActive = proposal.creation + proposal.config.votingDelay;
|
|
36
37
|
logger.info(`Warping to ${timeToActive + 1n}`);
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
Client,
|
|
6
6
|
FallbackTransport,
|
|
7
7
|
GetContractReturnType,
|
|
8
|
+
Hex,
|
|
8
9
|
HttpTransport,
|
|
9
10
|
PublicActions,
|
|
10
11
|
PublicClient,
|
|
@@ -16,6 +17,67 @@ import type {
|
|
|
16
17
|
/** Type for a viem public client */
|
|
17
18
|
export type ViemPublicClient = PublicClient<FallbackTransport<HttpTransport[]>, Chain>;
|
|
18
19
|
|
|
20
|
+
export type PublicRpcDebugSchema = [
|
|
21
|
+
{
|
|
22
|
+
Method: 'debug_traceTransaction';
|
|
23
|
+
Parameters: [txHash: `0x${string}`, options: { tracer: 'callTracer' }];
|
|
24
|
+
ReturnType: DebugCallTrace;
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
Method: 'trace_transaction';
|
|
28
|
+
Parameters: [txHash: `0x${string}`];
|
|
29
|
+
ReturnType: TraceTransactionResponse[];
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** Return type for a debug_traceTransaction call */
|
|
34
|
+
export type DebugCallTrace = {
|
|
35
|
+
from: Hex;
|
|
36
|
+
to?: Hex;
|
|
37
|
+
type: string;
|
|
38
|
+
input?: Hex;
|
|
39
|
+
output?: Hex;
|
|
40
|
+
gas?: Hex;
|
|
41
|
+
gasUsed?: Hex;
|
|
42
|
+
value?: Hex;
|
|
43
|
+
error?: string;
|
|
44
|
+
calls?: DebugCallTrace[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Action object for a trace_transaction call */
|
|
48
|
+
export type TraceAction = {
|
|
49
|
+
from: Hex;
|
|
50
|
+
to?: Hex;
|
|
51
|
+
callType: string;
|
|
52
|
+
gas?: Hex;
|
|
53
|
+
input?: Hex;
|
|
54
|
+
value?: Hex;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Result object for a trace_transaction call */
|
|
58
|
+
export type TraceResult = {
|
|
59
|
+
gasUsed?: Hex;
|
|
60
|
+
output?: Hex;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Return type for a single trace in trace_transaction response */
|
|
64
|
+
export type TraceTransactionResponse = {
|
|
65
|
+
action: TraceAction;
|
|
66
|
+
result?: TraceResult;
|
|
67
|
+
error?: string;
|
|
68
|
+
subtraces: number;
|
|
69
|
+
traceAddress: number[];
|
|
70
|
+
type: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** Type for a viem public client with support for debug methods */
|
|
74
|
+
export type ViemPublicDebugClient = PublicClient<
|
|
75
|
+
FallbackTransport<HttpTransport[]>,
|
|
76
|
+
Chain,
|
|
77
|
+
undefined,
|
|
78
|
+
[...PublicRpcSchema, ...PublicRpcDebugSchema]
|
|
79
|
+
>;
|
|
80
|
+
|
|
19
81
|
export type ExtendedViemWalletClient = Client<
|
|
20
82
|
FallbackTransport<readonly HttpTransport[]>,
|
|
21
83
|
Chain,
|
package/src/utils.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
type Abi,
|
|
7
|
+
type AbiItem,
|
|
7
8
|
BaseError,
|
|
8
9
|
type ContractEventName,
|
|
9
10
|
ContractFunctionRevertedError,
|
|
10
11
|
type DecodeEventLogReturnType,
|
|
12
|
+
type FormattedTransaction,
|
|
11
13
|
type Hex,
|
|
12
14
|
type Log,
|
|
13
15
|
decodeErrorResult,
|
|
14
16
|
decodeEventLog,
|
|
15
17
|
} from 'viem';
|
|
18
|
+
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
16
19
|
|
|
17
20
|
export interface L2Claim {
|
|
18
21
|
claimSecret: Fr;
|
|
@@ -92,6 +95,57 @@ export function prettyLogViemErrorMsg(err: any) {
|
|
|
92
95
|
return err?.message ?? err;
|
|
93
96
|
}
|
|
94
97
|
|
|
98
|
+
export function mergeAbis(abis: Abi[]): Abi {
|
|
99
|
+
let merged: Abi = [];
|
|
100
|
+
const seen = new Set<string>();
|
|
101
|
+
|
|
102
|
+
for (const abi of abis) {
|
|
103
|
+
for (const item of abi) {
|
|
104
|
+
const key = getAbiItemKey(item);
|
|
105
|
+
if (!seen.has(key)) {
|
|
106
|
+
seen.add(key);
|
|
107
|
+
merged = [...merged, item];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return merged;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getAbiItemKey(item: AbiItem): string {
|
|
116
|
+
if (item.type === 'function') {
|
|
117
|
+
const signature = formatAbiItem(item);
|
|
118
|
+
const outputs = formatAbiParams(item.outputs);
|
|
119
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
120
|
+
return `function:${signature}:${outputs}:${stateMutability}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (item.type === 'event') {
|
|
124
|
+
const signature = formatAbiItem(item);
|
|
125
|
+
const indexed = (item.inputs ?? []).map(input => ((input as { indexed?: boolean }).indexed ? '1' : '0')).join('');
|
|
126
|
+
const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
|
|
127
|
+
return `event:${signature}:${indexed}:${anonymous}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (item.type === 'error') {
|
|
131
|
+
const signature = formatAbiItem(item);
|
|
132
|
+
return `error:${signature}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (item.type === 'constructor') {
|
|
136
|
+
const inputs = formatAbiParams(item.inputs);
|
|
137
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
138
|
+
return `constructor::${inputs}:${stateMutability}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (item.type === 'fallback' || item.type === 'receive') {
|
|
142
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
143
|
+
return `${item.type}:::${stateMutability}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return 'unknown';
|
|
147
|
+
}
|
|
148
|
+
|
|
95
149
|
function getNestedErrorData(error: unknown): string | undefined {
|
|
96
150
|
// If nothing, bail
|
|
97
151
|
if (!error) {
|
|
@@ -233,3 +287,31 @@ export function tryGetCustomErrorName(err: any) {
|
|
|
233
287
|
return undefined;
|
|
234
288
|
}
|
|
235
289
|
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Type guard to check if a transaction is a blob transaction (EIP-4844).
|
|
293
|
+
* Blob transactions have maxFeePerBlobGas and blobVersionedHashes fields.
|
|
294
|
+
*/
|
|
295
|
+
export function isBlobTransaction(tx: FormattedTransaction): tx is FormattedTransaction & {
|
|
296
|
+
maxFeePerBlobGas: bigint;
|
|
297
|
+
blobVersionedHashes: readonly Hex[];
|
|
298
|
+
} {
|
|
299
|
+
return (
|
|
300
|
+
'maxFeePerBlobGas' in tx &&
|
|
301
|
+
tx.maxFeePerBlobGas !== undefined &&
|
|
302
|
+
'blobVersionedHashes' in tx &&
|
|
303
|
+
tx.blobVersionedHashes !== undefined
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Calculates a percentile from an array of bigints
|
|
309
|
+
*/
|
|
310
|
+
export function calculatePercentile(values: bigint[], percentile: number): bigint {
|
|
311
|
+
if (values.length === 0) {
|
|
312
|
+
return 0n;
|
|
313
|
+
}
|
|
314
|
+
const sorted = [...values].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
315
|
+
const index = Math.ceil((sorted.length - 1) * (percentile / 100));
|
|
316
|
+
return sorted[index];
|
|
317
|
+
}
|