@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.017a351
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 +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +28 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +73 -3
- package/dest/config.d.ts +70 -23
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +151 -34
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/empire_base.d.ts +25 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +20 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +59 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +131 -43
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +281 -87
- package/dest/contracts/governance_proposer.d.ts +49 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +483 -26
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +47 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +85 -0
- package/dest/contracts/index.d.ts +11 -2
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +10 -1
- 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 +136 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +264 -0
- package/dest/contracts/outbox.d.ts +64 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +113 -0
- package/dest/contracts/registry.d.ts +12 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +74 -17
- package/dest/contracts/rollup.d.ts +5526 -52
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1446 -118
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/slashing_proposer.d.ts +133 -15
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/slashing_proposer.js +293 -22
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_aztec_l1_contracts.d.ts +256 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +411 -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 +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- 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 +79270 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +151 -0
- package/dest/l1_contract_addresses.d.ts +61 -45
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +99 -76
- package/dest/l1_reader.d.ts +8 -6
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +20 -12
- package/dest/l1_tx_utils/config.d.ts +65 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +109 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +32 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +22 -0
- 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 +13 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +13 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -0
- 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 +113 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +658 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +328 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/l1_tx_utils/tx_delayer.js +223 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +30 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +162 -0
- package/dest/queries.d.ts +17 -4
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +120 -12
- package/dest/test/chain_monitor.d.ts +95 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +249 -0
- package/dest/test/eth_cheat_codes.d.ts +237 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +573 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -2
- package/dest/test/rollup_cheat_codes.d.ts +118 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +344 -0
- package/dest/test/start_anvil.d.ts +30 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +147 -24
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +25 -4
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +142 -91
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +52 -26
- package/src/account.ts +5 -0
- package/src/client.ts +107 -5
- package/src/config.ts +218 -43
- package/src/contracts/README.md +157 -0
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +66 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +343 -74
- package/src/contracts/governance_proposer.ts +128 -25
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +123 -0
- package/src/contracts/index.ts +10 -1
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +296 -0
- package/src/contracts/outbox.ts +132 -0
- package/src/contracts/registry.ts +81 -26
- package/src/contracts/rollup.ts +1246 -90
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/slashing_proposer.ts +296 -27
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +646 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_artifacts.ts +231 -0
- package/src/l1_contract_addresses.ts +121 -80
- package/src/l1_reader.ts +31 -16
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +181 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- 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 +15 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +789 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +424 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/tx_delayer.ts +303 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/l1_types.ts +6 -0
- package/src/publisher_manager.ts +203 -0
- package/src/queries.ts +149 -17
- package/src/test/chain_monitor.ts +307 -0
- package/src/test/eth_cheat_codes.ts +600 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -2
- package/src/test/rollup_cheat_codes.ts +388 -0
- package/src/test/start_anvil.ts +189 -22
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +164 -96
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/dest/test/delayed_tx_utils.d.ts +0 -8
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -21
- package/dest/test/tx_delayer.d.ts +0 -25
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/dest/test/tx_delayer.js +0 -116
- package/src/contracts/forwarder.ts +0 -132
- package/src/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
- package/src/test/delayed_tx_utils.ts +0 -24
- package/src/test/tx_delayer.ts +0 -163
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
2
|
+
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
|
+
import { type GetContractReturnType, type Hex } from 'viem';
|
|
7
|
+
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
8
|
+
/** Cheat codes for the L1 rollup contract. */
|
|
9
|
+
export declare class RollupCheatCodes {
|
|
10
|
+
private ethCheatCodes;
|
|
11
|
+
private client;
|
|
12
|
+
private rollup;
|
|
13
|
+
private logger;
|
|
14
|
+
constructor(ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>);
|
|
15
|
+
static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>, dateProvider: DateProvider): RollupCheatCodes;
|
|
16
|
+
/** Returns the current slot */
|
|
17
|
+
getSlot(): Promise<SlotNumber>;
|
|
18
|
+
/** Returns the slot number at a given timestamp. */
|
|
19
|
+
getSlotAt(timestamp: bigint): Promise<SlotNumber>;
|
|
20
|
+
/** Returns the timestamp for the start of a given slot. */
|
|
21
|
+
getTimestampForSlot(slot: SlotNumber): Promise<bigint>;
|
|
22
|
+
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */
|
|
23
|
+
getSecondsUntilSlot(slot: SlotNumber): Promise<number>;
|
|
24
|
+
/** Returns the current epoch */
|
|
25
|
+
getEpoch(): Promise<EpochNumber>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the pending and proven chain tips
|
|
28
|
+
* @returns The pending and proven chain tips
|
|
29
|
+
*/
|
|
30
|
+
getTips(): Promise<{
|
|
31
|
+
/** The pending chain tip */ pending: CheckpointNumber;
|
|
32
|
+
/** The proven chain tip */ proven: CheckpointNumber;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Logs the current state of the rollup contract.
|
|
36
|
+
*/
|
|
37
|
+
debugRollup(): Promise<void>;
|
|
38
|
+
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
39
|
+
getConfig(): Promise<{
|
|
40
|
+
/** Epoch duration */ epochDuration: bigint;
|
|
41
|
+
/** Slot duration */ slotDuration: number;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Advances time to the beginning of the given epoch
|
|
45
|
+
* @param epoch - The epoch to advance to
|
|
46
|
+
* @param opts - Options
|
|
47
|
+
*/
|
|
48
|
+
advanceToEpoch(epoch: EpochNumber, opts?: {
|
|
49
|
+
/** Offset in seconds */
|
|
50
|
+
offset?: number;
|
|
51
|
+
}): Promise<bigint>;
|
|
52
|
+
/** Warps time in L1 until the next epoch */
|
|
53
|
+
advanceToNextEpoch(): Promise<void>;
|
|
54
|
+
/** Warps time in L1 until the beginning of the next slot. */
|
|
55
|
+
advanceToNextSlot(): Promise<(bigint | SlotNumber)[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
|
|
58
|
+
* relative to the current L1 timestamp at call time and therefore races with real-time
|
|
59
|
+
* progression between query and warp, this lands at the slot regardless of latency.
|
|
60
|
+
*
|
|
61
|
+
* Throws if the requested slot is in the past relative to current L1 time (anvil cannot
|
|
62
|
+
* rewind).
|
|
63
|
+
*/
|
|
64
|
+
advanceToSlot(slot: SlotNumber): Promise<bigint>;
|
|
65
|
+
/**
|
|
66
|
+
* Warps time in L1 equivalent to however many slots.
|
|
67
|
+
* @param howMany - The number of slots to advance.
|
|
68
|
+
*/
|
|
69
|
+
advanceSlots(howMany: number): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Marks the specified checkpoint (or latest if none) as proven
|
|
72
|
+
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
73
|
+
*/
|
|
74
|
+
markAsProven(maybeCheckpointNumber?: CheckpointNumber): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Overrides the inProgress field of the Inbox contract state
|
|
77
|
+
* @param howMuch - How many checkpoints to move it forward
|
|
78
|
+
*/
|
|
79
|
+
advanceInboxInProgress(howMuch: number | bigint): Promise<bigint>;
|
|
80
|
+
insertOutbox(epoch: EpochNumber, numCheckpointsInEpoch: number, outHash: bigint): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Executes an action impersonated as the owner of the Rollup contract.
|
|
83
|
+
* @param action - The action to execute
|
|
84
|
+
*/
|
|
85
|
+
asOwner(action: (owner: Hex, rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>) => Promise<void>): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Sets up the epoch.
|
|
88
|
+
*/
|
|
89
|
+
setupEpoch(): Promise<void>;
|
|
90
|
+
/** Directly calls the L1 gas fee oracle. */
|
|
91
|
+
updateL1GasFeeOracle(): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Bumps proving cost per mana.
|
|
94
|
+
* @param bumper - Callback to calculate the new proving cost per mana based on current value.
|
|
95
|
+
*/
|
|
96
|
+
bumpProvingCostPerMana(bumper: (before: bigint) => bigint): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Directly updates proving cost per mana. Throws if the on-chain tx reverts
|
|
99
|
+
* (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
|
|
100
|
+
* @param ethValue - The new proving cost per mana in ETH
|
|
101
|
+
*/
|
|
102
|
+
setProvingCostPerMana(ethValue: bigint): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
|
|
105
|
+
* by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
|
|
106
|
+
* successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
|
|
107
|
+
* land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
|
|
108
|
+
*
|
|
109
|
+
* @note This is tightly coupled to the `FeeStore` layout in
|
|
110
|
+
* l1-contracts/src/core/libraries/rollup/FeeLib.sol:
|
|
111
|
+
* slot + 0: CompressedFeeConfig config (uint256)
|
|
112
|
+
* slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
|
|
113
|
+
* slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
|
|
114
|
+
* If the struct layout changes, update the offset below.
|
|
115
|
+
*/
|
|
116
|
+
clearProvingCostCooldown(): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwX2NoZWF0X2NvZGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9yb2xsdXBfY2hlYXRfY29kZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzlELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxXQUFXLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFHNUYsT0FBTyxLQUFLLEVBQUUsW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CACzB,KAAK,EAAE,WAAW,EAClB,IAAI,GAAE;QACJ,wBAAwB;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ,mBAYP;IAED,4CAA4C;IAC/B,kBAAkB,kBAW9B;IAED,6DAA6D;IAChD,iBAAiB,qCAO7B;IAED;;;;;;;OAOG;IACU,aAAa,CAAC,IAAI,EAAE,UAAU,mBAK1C;IAED;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,iBAOxC;IAED;;;OAGG;IACI,YAAY,CAAC,qBAAqB,CAAC,EAAE,gBAAgB,iBA+B3D;IAED;;;OAGG;IACI,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCvE;IAEM,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBASrF;IAED;;;OAGG;IACU,OAAO,CAClB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,iBAMzG;IAED;;OAEG;IACU,UAAU,kBAOtB;IAED,4CAA4C;IAC/B,oBAAoB,kBAMhC;IAED;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,iBAIrE;IAED;;;;OAIG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM,iBAiBlD;IAED;;;;;;;;;;;;OAYG;IACU,wBAAwB,kBAOpC;CACF"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
|
+
import { createPublicClient, fallback, getContract, hexToBigInt, http, keccak256 } from 'viem';
|
|
7
|
+
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
8
|
+
/** Cheat codes for the L1 rollup contract. */ export class RollupCheatCodes {
|
|
9
|
+
ethCheatCodes;
|
|
10
|
+
client;
|
|
11
|
+
rollup;
|
|
12
|
+
logger;
|
|
13
|
+
constructor(ethCheatCodes, addresses){
|
|
14
|
+
this.ethCheatCodes = ethCheatCodes;
|
|
15
|
+
this.logger = createLogger('aztecjs:cheat_codes');
|
|
16
|
+
this.client = createPublicClient({
|
|
17
|
+
chain: ethCheatCodes.chain,
|
|
18
|
+
transport: fallback(ethCheatCodes.rpcUrls.map((url)=>http(url, {
|
|
19
|
+
batch: false
|
|
20
|
+
})))
|
|
21
|
+
});
|
|
22
|
+
this.rollup = getContract({
|
|
23
|
+
abi: RollupAbi,
|
|
24
|
+
address: addresses.rollupAddress.toString(),
|
|
25
|
+
client: this.client
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
static create(rpcUrls, addresses, dateProvider) {
|
|
29
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
30
|
+
return new RollupCheatCodes(ethCheatCodes, addresses);
|
|
31
|
+
}
|
|
32
|
+
/** Returns the current slot */ async getSlot() {
|
|
33
|
+
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
34
|
+
return this.getSlotAt(ts);
|
|
35
|
+
}
|
|
36
|
+
/** Returns the slot number at a given timestamp. */ async getSlotAt(timestamp) {
|
|
37
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
38
|
+
timestamp
|
|
39
|
+
]));
|
|
40
|
+
}
|
|
41
|
+
/** Returns the timestamp for the start of a given slot. */ async getTimestampForSlot(slot) {
|
|
42
|
+
return await this.rollup.read.getTimestampForSlot([
|
|
43
|
+
BigInt(slot)
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */ async getSecondsUntilSlot(slot) {
|
|
47
|
+
const [currentTimestamp, targetTimestamp] = await Promise.all([
|
|
48
|
+
this.client.getBlock().then((b)=>BigInt(b.timestamp)),
|
|
49
|
+
this.rollup.read.getTimestampForSlot([
|
|
50
|
+
BigInt(slot)
|
|
51
|
+
])
|
|
52
|
+
]);
|
|
53
|
+
return Math.max(0, Number(targetTimestamp - currentTimestamp));
|
|
54
|
+
}
|
|
55
|
+
/** Returns the current epoch */ async getEpoch() {
|
|
56
|
+
const slotNumber = await this.getSlot();
|
|
57
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([
|
|
58
|
+
BigInt(slotNumber)
|
|
59
|
+
]));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the pending and proven chain tips
|
|
63
|
+
* @returns The pending and proven chain tips
|
|
64
|
+
*/ async getTips() {
|
|
65
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
66
|
+
return {
|
|
67
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
68
|
+
proven: CheckpointNumber.fromBigInt(proven)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Logs the current state of the rollup contract.
|
|
73
|
+
*/ async debugRollup() {
|
|
74
|
+
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
75
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
76
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
77
|
+
const validators = await rollup.getAttesters();
|
|
78
|
+
const committee = await rollup.getCurrentEpochCommittee();
|
|
79
|
+
const archive = await rollup.archive();
|
|
80
|
+
const slot = await this.getSlot();
|
|
81
|
+
const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
|
|
82
|
+
this.logger.info(`Pending checkpoint num: ${pendingNum}`);
|
|
83
|
+
this.logger.info(`Proven checkpoint num: ${provenNum}`);
|
|
84
|
+
this.logger.info(`Validators: ${validators.map((v)=>v.toString()).join(', ')}`);
|
|
85
|
+
this.logger.info(`Committee: ${committee?.map((v)=>v.toString()).join(', ')}`);
|
|
86
|
+
this.logger.info(`Archive: ${archive}`);
|
|
87
|
+
this.logger.info(`Epoch num: ${epochNum}`);
|
|
88
|
+
this.logger.info(`Slot: ${slot}`);
|
|
89
|
+
}
|
|
90
|
+
/** Fetches the epoch and slot duration config from the rollup contract */ async getConfig() {
|
|
91
|
+
const [epochDuration, slotDuration] = await Promise.all([
|
|
92
|
+
this.rollup.read.getEpochDuration(),
|
|
93
|
+
this.rollup.read.getSlotDuration()
|
|
94
|
+
]);
|
|
95
|
+
return {
|
|
96
|
+
epochDuration,
|
|
97
|
+
slotDuration: Number(slotDuration)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Advances time to the beginning of the given epoch
|
|
102
|
+
* @param epoch - The epoch to advance to
|
|
103
|
+
* @param opts - Options
|
|
104
|
+
*/ async advanceToEpoch(epoch, opts = {}) {
|
|
105
|
+
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
106
|
+
const slotNumber = SlotNumber(Number(epoch) * Number(slotsInEpoch));
|
|
107
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([
|
|
108
|
+
BigInt(slotNumber)
|
|
109
|
+
]) + BigInt(opts.offset ?? 0);
|
|
110
|
+
try {
|
|
111
|
+
await this.ethCheatCodes.warp(Number(timestamp), {
|
|
112
|
+
...opts,
|
|
113
|
+
silent: true,
|
|
114
|
+
resetBlockInterval: true
|
|
115
|
+
});
|
|
116
|
+
this.logger.warn(`Warped to epoch ${epoch}`, {
|
|
117
|
+
offset: opts.offset,
|
|
118
|
+
timestamp
|
|
119
|
+
});
|
|
120
|
+
} catch (err) {
|
|
121
|
+
this.logger.warn(`Warp to epoch ${epoch} failed: ${err}`);
|
|
122
|
+
}
|
|
123
|
+
return timestamp;
|
|
124
|
+
}
|
|
125
|
+
/** Warps time in L1 until the next epoch */ async advanceToNextEpoch() {
|
|
126
|
+
const slot = await this.getSlot();
|
|
127
|
+
const { epochDuration, slotDuration } = await this.getConfig();
|
|
128
|
+
const slotsUntilNextEpoch = epochDuration - BigInt(slot) % epochDuration + 1n;
|
|
129
|
+
const timeToNextEpoch = slotsUntilNextEpoch * BigInt(slotDuration);
|
|
130
|
+
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
131
|
+
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
132
|
+
silent: true,
|
|
133
|
+
resetBlockInterval: true
|
|
134
|
+
});
|
|
135
|
+
this.logger.warn(`Advanced to next epoch`);
|
|
136
|
+
}
|
|
137
|
+
/** Warps time in L1 until the beginning of the next slot. */ async advanceToNextSlot() {
|
|
138
|
+
const currentSlot = await this.getSlot();
|
|
139
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
140
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([
|
|
141
|
+
BigInt(nextSlot)
|
|
142
|
+
]);
|
|
143
|
+
await this.ethCheatCodes.warp(Number(timestamp), {
|
|
144
|
+
silent: true,
|
|
145
|
+
resetBlockInterval: true
|
|
146
|
+
});
|
|
147
|
+
this.logger.warn(`Advanced to slot ${nextSlot}`);
|
|
148
|
+
return [
|
|
149
|
+
timestamp,
|
|
150
|
+
nextSlot
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
|
|
155
|
+
* relative to the current L1 timestamp at call time and therefore races with real-time
|
|
156
|
+
* progression between query and warp, this lands at the slot regardless of latency.
|
|
157
|
+
*
|
|
158
|
+
* Throws if the requested slot is in the past relative to current L1 time (anvil cannot
|
|
159
|
+
* rewind).
|
|
160
|
+
*/ async advanceToSlot(slot) {
|
|
161
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([
|
|
162
|
+
BigInt(slot)
|
|
163
|
+
]);
|
|
164
|
+
await this.ethCheatCodes.warp(Number(timestamp), {
|
|
165
|
+
silent: true,
|
|
166
|
+
resetBlockInterval: true
|
|
167
|
+
});
|
|
168
|
+
this.logger.warn(`Advanced to slot ${slot}`, {
|
|
169
|
+
timestamp
|
|
170
|
+
});
|
|
171
|
+
return timestamp;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Warps time in L1 equivalent to however many slots.
|
|
175
|
+
* @param howMany - The number of slots to advance.
|
|
176
|
+
*/ async advanceSlots(howMany) {
|
|
177
|
+
const l1Timestamp = (await this.client.getBlock()).timestamp;
|
|
178
|
+
const slotDuration = Number(await this.rollup.read.getSlotDuration());
|
|
179
|
+
const timeToWarp = BigInt(howMany) * BigInt(slotDuration);
|
|
180
|
+
await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, {
|
|
181
|
+
silent: true,
|
|
182
|
+
resetBlockInterval: true
|
|
183
|
+
});
|
|
184
|
+
const [slot, epoch] = await Promise.all([
|
|
185
|
+
this.getSlot(),
|
|
186
|
+
this.getEpoch()
|
|
187
|
+
]);
|
|
188
|
+
this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Marks the specified checkpoint (or latest if none) as proven
|
|
192
|
+
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
193
|
+
*/ markAsProven(maybeCheckpointNumber) {
|
|
194
|
+
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
195
|
+
const tipsBefore = await this.getTips();
|
|
196
|
+
const { pending, proven } = tipsBefore;
|
|
197
|
+
let checkpointNumber = maybeCheckpointNumber;
|
|
198
|
+
if (checkpointNumber === undefined || checkpointNumber > pending) {
|
|
199
|
+
checkpointNumber = pending;
|
|
200
|
+
}
|
|
201
|
+
if (checkpointNumber <= proven) {
|
|
202
|
+
this.logger.debug(`Checkpoint ${checkpointNumber} is already proven`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// @note @LHerskind this is heavily dependent on the storage layout and size of values
|
|
206
|
+
// The rollupStore is a struct and if the size of elements or the struct changes, this can break
|
|
207
|
+
const provenCheckpointNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
|
|
208
|
+
// Need to pack it as a single 32 byte word
|
|
209
|
+
const newValue = BigInt(tipsBefore.pending) << 128n | BigInt(checkpointNumber);
|
|
210
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provenCheckpointNumberSlot, newValue);
|
|
211
|
+
const tipsAfter = await this.getTips();
|
|
212
|
+
if (tipsAfter.pending < tipsAfter.proven) {
|
|
213
|
+
throw new Error('Overwrote pending tip to a checkpoint in the past');
|
|
214
|
+
}
|
|
215
|
+
this.logger.info(`Proven tip moved: ${tipsBefore.proven} -> ${tipsAfter.proven}. Pending tip: ${tipsAfter.pending}.`);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Overrides the inProgress field of the Inbox contract state
|
|
220
|
+
* @param howMuch - How many checkpoints to move it forward
|
|
221
|
+
*/ advanceInboxInProgress(howMuch) {
|
|
222
|
+
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
223
|
+
// Storage slot 2 contains the InboxState struct
|
|
224
|
+
const inboxStateSlot = 2n;
|
|
225
|
+
// Get inbox and its current state values
|
|
226
|
+
const inboxAddress = await this.rollup.read.getInbox();
|
|
227
|
+
const currentStateValue = await this.ethCheatCodes.load(EthAddress.fromString(inboxAddress), inboxStateSlot);
|
|
228
|
+
// Extract current values from the packed storage slot
|
|
229
|
+
// Storage layout: rollingHash (128 bits) | totalMessagesInserted (64 bits) | inProgress (64 bits)
|
|
230
|
+
const currentRollingHash = currentStateValue & (1n << 128n) - 1n;
|
|
231
|
+
const currentTotalMessages = currentStateValue >> 128n & (1n << 64n) - 1n;
|
|
232
|
+
const currentInProgress = currentStateValue >> 192n;
|
|
233
|
+
const newInProgress = currentInProgress + BigInt(howMuch);
|
|
234
|
+
// Pack new values: rollingHash (low 128 bits) | totalMessages (middle 64 bits) | inProgress (high 64 bits)
|
|
235
|
+
const newValue = BigInt(newInProgress) << 192n | currentTotalMessages << 128n | currentRollingHash;
|
|
236
|
+
await this.ethCheatCodes.store(EthAddress.fromString(inboxAddress), inboxStateSlot, newValue, {
|
|
237
|
+
silent: true
|
|
238
|
+
});
|
|
239
|
+
this.logger.warn(`Inbox inProgress advanced from ${currentInProgress} to ${newInProgress}`, {
|
|
240
|
+
inbox: inboxAddress,
|
|
241
|
+
oldValue: '0x' + currentStateValue.toString(16),
|
|
242
|
+
newValue: '0x' + newValue.toString(16),
|
|
243
|
+
rollingHash: currentRollingHash,
|
|
244
|
+
totalMessages: currentTotalMessages,
|
|
245
|
+
oldInProgress: currentInProgress,
|
|
246
|
+
newInProgress
|
|
247
|
+
});
|
|
248
|
+
return newInProgress;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
insertOutbox(epoch, numCheckpointsInEpoch, outHash) {
|
|
252
|
+
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
253
|
+
const outboxAddress = await this.rollup.read.getOutbox();
|
|
254
|
+
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch, numCheckpointsInEpoch);
|
|
255
|
+
await this.ethCheatCodes.store(EthAddress.fromString(outboxAddress), epochRootSlot, outHash);
|
|
256
|
+
this.logger.warn(`Advanced outbox to epoch ${epoch} numCheckpointsInEpoch ${numCheckpointsInEpoch} with out hash ${outHash}`);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Executes an action impersonated as the owner of the Rollup contract.
|
|
261
|
+
* @param action - The action to execute
|
|
262
|
+
*/ async asOwner(action) {
|
|
263
|
+
const owner = await this.rollup.read.owner();
|
|
264
|
+
await this.ethCheatCodes.startImpersonating(owner);
|
|
265
|
+
await action(owner, this.rollup);
|
|
266
|
+
await this.ethCheatCodes.stopImpersonating(owner);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Sets up the epoch.
|
|
270
|
+
*/ async setupEpoch() {
|
|
271
|
+
// Doesn't need to be done as owner, but the functionality is here...
|
|
272
|
+
await this.asOwner(async (account, rollup)=>{
|
|
273
|
+
const hash = await rollup.write.setupEpoch({
|
|
274
|
+
account
|
|
275
|
+
});
|
|
276
|
+
await this.client.waitForTransactionReceipt({
|
|
277
|
+
hash
|
|
278
|
+
});
|
|
279
|
+
this.logger.warn(`Setup epoch`);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/** Directly calls the L1 gas fee oracle. */ async updateL1GasFeeOracle() {
|
|
283
|
+
await this.asOwner(async (account, rollup)=>{
|
|
284
|
+
const hash = await rollup.write.updateL1GasFeeOracle({
|
|
285
|
+
account,
|
|
286
|
+
chain: this.client.chain
|
|
287
|
+
});
|
|
288
|
+
await this.client.waitForTransactionReceipt({
|
|
289
|
+
hash
|
|
290
|
+
});
|
|
291
|
+
this.logger.warn(`Updated L1 gas fee oracle`);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Bumps proving cost per mana.
|
|
296
|
+
* @param bumper - Callback to calculate the new proving cost per mana based on current value.
|
|
297
|
+
*/ async bumpProvingCostPerMana(bumper) {
|
|
298
|
+
const currentCost = await this.rollup.read.getProvingCostPerManaInEth();
|
|
299
|
+
const newCost = bumper(currentCost);
|
|
300
|
+
await this.setProvingCostPerMana(newCost);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Directly updates proving cost per mana. Throws if the on-chain tx reverts
|
|
304
|
+
* (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
|
|
305
|
+
* @param ethValue - The new proving cost per mana in ETH
|
|
306
|
+
*/ async setProvingCostPerMana(ethValue) {
|
|
307
|
+
await this.asOwner(async (account, rollup)=>{
|
|
308
|
+
const hash = await rollup.write.setProvingCostPerMana([
|
|
309
|
+
ethValue
|
|
310
|
+
], {
|
|
311
|
+
account,
|
|
312
|
+
chain: this.client.chain,
|
|
313
|
+
gasLimit: 1000000n
|
|
314
|
+
});
|
|
315
|
+
const receipt = await this.client.waitForTransactionReceipt({
|
|
316
|
+
hash
|
|
317
|
+
});
|
|
318
|
+
if (receipt.status !== 'success') {
|
|
319
|
+
throw new Error(`setProvingCostPerMana(${ethValue}) reverted on L1 (tx ${hash}). ` + `Likely FeeLib rate-limit (30-day cooldown or 1.5x step cap); ` + `use clearProvingCostCooldown() between successive updates.`);
|
|
320
|
+
}
|
|
321
|
+
this.logger.warn(`Updated proving cost per mana to ${ethValue}`);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
|
|
326
|
+
* by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
|
|
327
|
+
* successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
|
|
328
|
+
* land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
|
|
329
|
+
*
|
|
330
|
+
* @note This is tightly coupled to the `FeeStore` layout in
|
|
331
|
+
* l1-contracts/src/core/libraries/rollup/FeeLib.sol:
|
|
332
|
+
* slot + 0: CompressedFeeConfig config (uint256)
|
|
333
|
+
* slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
|
|
334
|
+
* slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
|
|
335
|
+
* If the struct layout changes, update the offset below.
|
|
336
|
+
*/ async clearProvingCostCooldown() {
|
|
337
|
+
const feeStoreBaseSlot = hexToBigInt(keccak256(Buffer.from('aztec.fee.storage', 'utf-8')));
|
|
338
|
+
const provingCostLastUpdateSlot = feeStoreBaseSlot + 2n;
|
|
339
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provingCostLastUpdateSlot, 0n, {
|
|
340
|
+
silent: true
|
|
341
|
+
});
|
|
342
|
+
this.logger.warn(`Cleared proving-cost update cooldown`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
@@ -1,12 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
2
|
+
/** Minimal interface matching the @viem/anvil Anvil shape used by callers. */
|
|
3
|
+
export interface Anvil {
|
|
4
|
+
readonly port: number;
|
|
5
|
+
readonly host: string;
|
|
6
|
+
readonly status: 'listening' | 'idle';
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Ensures there's a running Anvil instance and returns the RPC URL.
|
|
4
11
|
*/
|
|
5
12
|
export declare function startAnvil(opts?: {
|
|
13
|
+
port?: number;
|
|
6
14
|
l1BlockTime?: number;
|
|
15
|
+
log?: boolean;
|
|
16
|
+
captureMethodCalls?: boolean;
|
|
17
|
+
accounts?: number;
|
|
18
|
+
chainId?: number;
|
|
19
|
+
/** The hardfork to use (e.g. 'cancun', 'latest'). */
|
|
20
|
+
hardfork?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Number of slots per epoch used by anvil to compute the 'finalized' and 'safe' block tags.
|
|
23
|
+
* Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
|
|
24
|
+
* Defaults to 1 so the finalized block advances immediately, making tests that check
|
|
25
|
+
* L1-finality-based logic work without needing hundreds of mined blocks.
|
|
26
|
+
*/
|
|
27
|
+
slotsInAnEpoch?: number;
|
|
28
|
+
/**
|
|
29
|
+
* If provided, the date provider will be synced to anvil's block time on every mined block.
|
|
30
|
+
* This keeps the dateProvider in lockstep with anvil's chain time, avoiding drift between
|
|
31
|
+
* the wall clock and the L1 chain when computing L1 slot timestamps.
|
|
32
|
+
*/
|
|
33
|
+
dateProvider?: TestDateProvider;
|
|
7
34
|
}): Promise<{
|
|
8
35
|
anvil: Anvil;
|
|
36
|
+
methodCalls?: string[];
|
|
9
37
|
rpcUrl: string;
|
|
10
38
|
stop: () => Promise<void>;
|
|
11
39
|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FBQztDQUM1QixHQUNMLE9BQU8sQ0FBQztJQUFFLEtBQUssRUFBRSxLQUFLLENBQUM7SUFBQyxXQUFXLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUFDLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFBQyxJQUFJLEVBQUUsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7Q0FBRSxDQUFDLENBK0g5RiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,8EAA8E;AAC9E,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IACtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,IAAI,GAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,GACL,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CA+H9F"}
|