@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891
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 +10 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +13 -3
- package/dest/config.d.ts +24 -68
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +67 -380
- 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 +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +208 -123
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +807 -188
- 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 +9 -7
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +11 -4
- 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 +7608 -2048
- 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 +5 -1
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +12 -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 +43 -7
- 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 +18 -8
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +75 -46
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +19 -30
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +63 -167
- 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 +47 -25
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +66 -38
- package/dest/test/eth_cheat_codes.d.ts +11 -3
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +11 -3
- 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 +17 -13
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +62 -38
- package/dest/test/start_anvil.d.ts +18 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +129 -28
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/test/upgrade_utils.js +2 -2
- 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 +80 -12
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +34 -16
- package/src/client.ts +10 -2
- package/src/config.ts +86 -460
- 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/registry.ts +31 -1
- package/src/contracts/rollup.ts +485 -162
- package/src/contracts/tally_slashing_proposer.ts +15 -8
- 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 +21 -1
- package/src/l1_tx_utils/config.ts +52 -11
- 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 +84 -36
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +77 -213
- 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 +110 -51
- package/src/test/eth_cheat_codes.ts +9 -3
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +63 -43
- package/src/test/start_anvil.ts +156 -27
- package/src/test/upgrade_utils.ts +2 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +100 -15
- 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 -1473
- 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 -1849
- 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,5 +1,7 @@
|
|
|
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
7
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -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,
|
|
@@ -50,15 +51,24 @@ export class RollupCheatCodes {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/** Returns the current slot */
|
|
53
|
-
public async getSlot() {
|
|
54
|
+
public async getSlot(): Promise<SlotNumber> {
|
|
54
55
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
55
|
-
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));
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
/** Returns the current epoch */
|
|
59
|
-
public async getEpoch() {
|
|
69
|
+
public async getEpoch(): Promise<EpochNumber> {
|
|
60
70
|
const slotNumber = await this.getSlot();
|
|
61
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
71
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
/**
|
|
@@ -66,13 +76,13 @@ export class RollupCheatCodes {
|
|
|
66
76
|
* @returns The pending and proven chain tips
|
|
67
77
|
*/
|
|
68
78
|
public async getTips(): Promise<{
|
|
69
|
-
/** The pending chain tip */ pending:
|
|
70
|
-
/** The proven chain tip */ proven:
|
|
79
|
+
/** The pending chain tip */ pending: CheckpointNumber;
|
|
80
|
+
/** The proven chain tip */ proven: CheckpointNumber;
|
|
71
81
|
}> {
|
|
72
|
-
const
|
|
82
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
73
83
|
return {
|
|
74
|
-
pending:
|
|
75
|
-
proven:
|
|
84
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
85
|
+
proven: CheckpointNumber.fromBigInt(proven),
|
|
76
86
|
};
|
|
77
87
|
}
|
|
78
88
|
|
|
@@ -81,16 +91,16 @@ export class RollupCheatCodes {
|
|
|
81
91
|
*/
|
|
82
92
|
public async debugRollup() {
|
|
83
93
|
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
84
|
-
const pendingNum = await rollup.
|
|
85
|
-
const provenNum = await rollup.
|
|
94
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
95
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
86
96
|
const validators = await rollup.getAttesters();
|
|
87
97
|
const committee = await rollup.getCurrentEpochCommittee();
|
|
88
98
|
const archive = await rollup.archive();
|
|
89
99
|
const slot = await this.getSlot();
|
|
90
100
|
const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
|
|
91
101
|
|
|
92
|
-
this.logger.info(`Pending
|
|
93
|
-
this.logger.info(`Proven
|
|
102
|
+
this.logger.info(`Pending checkpoint num: ${pendingNum}`);
|
|
103
|
+
this.logger.info(`Proven checkpoint num: ${provenNum}`);
|
|
94
104
|
this.logger.info(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
95
105
|
this.logger.info(`Committee: ${committee?.map(v => v.toString()).join(', ')}`);
|
|
96
106
|
this.logger.info(`Archive: ${archive}`);
|
|
@@ -101,13 +111,13 @@ export class RollupCheatCodes {
|
|
|
101
111
|
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
102
112
|
public async getConfig(): Promise<{
|
|
103
113
|
/** Epoch duration */ epochDuration: bigint;
|
|
104
|
-
/** Slot duration */ slotDuration:
|
|
114
|
+
/** Slot duration */ slotDuration: number;
|
|
105
115
|
}> {
|
|
106
116
|
const [epochDuration, slotDuration] = await Promise.all([
|
|
107
117
|
this.rollup.read.getEpochDuration(),
|
|
108
118
|
this.rollup.read.getSlotDuration(),
|
|
109
119
|
]);
|
|
110
|
-
return { epochDuration, slotDuration };
|
|
120
|
+
return { epochDuration, slotDuration: Number(slotDuration) };
|
|
111
121
|
}
|
|
112
122
|
|
|
113
123
|
/**
|
|
@@ -116,18 +126,18 @@ export class RollupCheatCodes {
|
|
|
116
126
|
* @param opts - Options
|
|
117
127
|
*/
|
|
118
128
|
public async advanceToEpoch(
|
|
119
|
-
epoch:
|
|
129
|
+
epoch: EpochNumber,
|
|
120
130
|
opts: {
|
|
121
131
|
/** Offset in seconds */
|
|
122
132
|
offset?: number;
|
|
123
133
|
} = {},
|
|
124
134
|
) {
|
|
125
135
|
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
126
|
-
const
|
|
127
|
-
|
|
136
|
+
const slotNumber = SlotNumber(Number(epoch) * Number(slotsInEpoch));
|
|
137
|
+
const timestamp = (await this.rollup.read.getTimestampForSlot([BigInt(slotNumber)])) + BigInt(opts.offset ?? 0);
|
|
128
138
|
try {
|
|
129
139
|
await this.ethCheatCodes.warp(Number(timestamp), { ...opts, silent: true, resetBlockInterval: true });
|
|
130
|
-
this.logger.warn(`Warped to epoch ${epoch}
|
|
140
|
+
this.logger.warn(`Warped to epoch ${epoch}`, { offset: opts.offset, timestamp });
|
|
131
141
|
} catch (err) {
|
|
132
142
|
this.logger.warn(`Warp to epoch ${epoch} failed: ${err}`);
|
|
133
143
|
}
|
|
@@ -138,8 +148,8 @@ export class RollupCheatCodes {
|
|
|
138
148
|
public async advanceToNextEpoch() {
|
|
139
149
|
const slot = await this.getSlot();
|
|
140
150
|
const { epochDuration, slotDuration } = await this.getConfig();
|
|
141
|
-
const slotsUntilNextEpoch = epochDuration - (slot % epochDuration) + 1n;
|
|
142
|
-
const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
|
|
151
|
+
const slotsUntilNextEpoch = epochDuration - (BigInt(slot) % epochDuration) + 1n;
|
|
152
|
+
const timeToNextEpoch = slotsUntilNextEpoch * BigInt(slotDuration);
|
|
143
153
|
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
144
154
|
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
145
155
|
silent: true,
|
|
@@ -151,10 +161,11 @@ export class RollupCheatCodes {
|
|
|
151
161
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
152
162
|
public async advanceToNextSlot() {
|
|
153
163
|
const currentSlot = await this.getSlot();
|
|
154
|
-
const
|
|
164
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
165
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]);
|
|
155
166
|
await this.ethCheatCodes.warp(Number(timestamp), { silent: true, resetBlockInterval: true });
|
|
156
|
-
this.logger.warn(`Advanced to slot ${
|
|
157
|
-
return [timestamp,
|
|
167
|
+
this.logger.warn(`Advanced to slot ${nextSlot}`);
|
|
168
|
+
return [timestamp, nextSlot];
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
/**
|
|
@@ -163,42 +174,42 @@ export class RollupCheatCodes {
|
|
|
163
174
|
*/
|
|
164
175
|
public async advanceSlots(howMany: number) {
|
|
165
176
|
const l1Timestamp = (await this.client.getBlock()).timestamp;
|
|
166
|
-
const slotDuration = await this.rollup.read.getSlotDuration();
|
|
167
|
-
const timeToWarp = BigInt(howMany) * slotDuration;
|
|
177
|
+
const slotDuration = Number(await this.rollup.read.getSlotDuration());
|
|
178
|
+
const timeToWarp = BigInt(howMany) * BigInt(slotDuration);
|
|
168
179
|
await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, { silent: true, resetBlockInterval: true });
|
|
169
180
|
const [slot, epoch] = await Promise.all([this.getSlot(), this.getEpoch()]);
|
|
170
181
|
this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
|
|
171
182
|
}
|
|
172
183
|
|
|
173
184
|
/**
|
|
174
|
-
* Marks the specified
|
|
175
|
-
* @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)
|
|
176
187
|
*/
|
|
177
|
-
public markAsProven(
|
|
188
|
+
public markAsProven(maybeCheckpointNumber?: CheckpointNumber) {
|
|
178
189
|
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
179
190
|
const tipsBefore = await this.getTips();
|
|
180
191
|
const { pending, proven } = tipsBefore;
|
|
181
192
|
|
|
182
|
-
let
|
|
183
|
-
if (
|
|
184
|
-
|
|
193
|
+
let checkpointNumber = maybeCheckpointNumber;
|
|
194
|
+
if (checkpointNumber === undefined || checkpointNumber > pending) {
|
|
195
|
+
checkpointNumber = pending;
|
|
185
196
|
}
|
|
186
|
-
if (
|
|
187
|
-
this.logger.debug(`
|
|
197
|
+
if (checkpointNumber <= proven) {
|
|
198
|
+
this.logger.debug(`Checkpoint ${checkpointNumber} is already proven`);
|
|
188
199
|
return;
|
|
189
200
|
}
|
|
190
201
|
|
|
191
202
|
// @note @LHerskind this is heavily dependent on the storage layout and size of values
|
|
192
203
|
// The rollupStore is a struct and if the size of elements or the struct changes, this can break
|
|
193
|
-
const
|
|
204
|
+
const provenCheckpointNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
|
|
194
205
|
|
|
195
206
|
// Need to pack it as a single 32 byte word
|
|
196
|
-
const newValue = (BigInt(tipsBefore.pending) << 128n) | BigInt(
|
|
197
|
-
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);
|
|
198
209
|
|
|
199
210
|
const tipsAfter = await this.getTips();
|
|
200
211
|
if (tipsAfter.pending < tipsAfter.proven) {
|
|
201
|
-
throw new Error('Overwrote pending tip to a
|
|
212
|
+
throw new Error('Overwrote pending tip to a checkpoint in the past');
|
|
202
213
|
}
|
|
203
214
|
|
|
204
215
|
this.logger.info(
|
|
@@ -209,7 +220,7 @@ export class RollupCheatCodes {
|
|
|
209
220
|
|
|
210
221
|
/**
|
|
211
222
|
* Overrides the inProgress field of the Inbox contract state
|
|
212
|
-
* @param howMuch - How many
|
|
223
|
+
* @param howMuch - How many checkpoints to move it forward
|
|
213
224
|
*/
|
|
214
225
|
public advanceInboxInProgress(howMuch: number | bigint): Promise<bigint> {
|
|
215
226
|
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
@@ -248,6 +259,15 @@ export class RollupCheatCodes {
|
|
|
248
259
|
});
|
|
249
260
|
}
|
|
250
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
|
+
|
|
251
271
|
/**
|
|
252
272
|
* Executes an action impersonated as the owner of the Rollup contract.
|
|
253
273
|
* @param action - The action to execute
|
package/src/test/start_anvil.ts
CHANGED
|
@@ -2,9 +2,17 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
3
3
|
import { fileURLToPath } from '@aztec/foundation/url';
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type ChildProcess, spawn } from 'child_process';
|
|
6
6
|
import { dirname, resolve } from 'path';
|
|
7
7
|
|
|
8
|
+
/** Minimal interface matching the @viem/anvil Anvil shape used by callers. */
|
|
9
|
+
export interface Anvil {
|
|
10
|
+
readonly port: number;
|
|
11
|
+
readonly host: string;
|
|
12
|
+
readonly status: 'listening' | 'idle';
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* Ensures there's a running Anvil instance and returns the RPC URL.
|
|
10
18
|
*/
|
|
@@ -15,53 +23,174 @@ export async function startAnvil(
|
|
|
15
23
|
log?: boolean;
|
|
16
24
|
captureMethodCalls?: boolean;
|
|
17
25
|
accounts?: number;
|
|
26
|
+
chainId?: number;
|
|
27
|
+
/** The hardfork to use (e.g. 'cancun', 'latest'). */
|
|
28
|
+
hardfork?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Number of slots per epoch used by anvil to compute the 'finalized' and 'safe' block tags.
|
|
31
|
+
* Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
|
|
32
|
+
* Defaults to 1 so the finalized block advances immediately, making tests that check
|
|
33
|
+
* L1-finality-based logic work without needing hundreds of mined blocks.
|
|
34
|
+
*/
|
|
35
|
+
slotsInAnEpoch?: number;
|
|
18
36
|
} = {},
|
|
19
37
|
): Promise<{ anvil: Anvil; methodCalls?: string[]; rpcUrl: string; stop: () => Promise<void> }> {
|
|
20
38
|
const anvilBinary = resolve(dirname(fileURLToPath(import.meta.url)), '../../', 'scripts/anvil_kill_wrapper.sh');
|
|
21
39
|
const logger = opts.log ? createLogger('ethereum:anvil') : undefined;
|
|
22
40
|
const methodCalls = opts.captureMethodCalls ? ([] as string[]) : undefined;
|
|
23
41
|
|
|
24
|
-
let
|
|
42
|
+
let detectedPort: number | undefined;
|
|
25
43
|
|
|
26
|
-
// Start anvil.
|
|
27
|
-
// We go via a wrapper script to ensure if the parent dies, anvil dies.
|
|
28
44
|
const anvil = await retry(
|
|
29
45
|
async () => {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
host
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
accounts
|
|
37
|
-
|
|
46
|
+
const port = opts.port ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : 8545);
|
|
47
|
+
const args: string[] = [
|
|
48
|
+
'--host',
|
|
49
|
+
'127.0.0.1',
|
|
50
|
+
'--port',
|
|
51
|
+
String(port),
|
|
52
|
+
'--accounts',
|
|
53
|
+
String(opts.accounts ?? 20),
|
|
54
|
+
'--gas-limit',
|
|
55
|
+
String(45_000_000),
|
|
56
|
+
'--chain-id',
|
|
57
|
+
String(opts.chainId ?? 31337),
|
|
58
|
+
];
|
|
59
|
+
if (opts.l1BlockTime !== undefined) {
|
|
60
|
+
args.push('--block-time', String(opts.l1BlockTime));
|
|
61
|
+
}
|
|
62
|
+
if (opts.hardfork !== undefined) {
|
|
63
|
+
args.push('--hardfork', opts.hardfork);
|
|
64
|
+
}
|
|
65
|
+
args.push('--slots-in-an-epoch', String(opts.slotsInAnEpoch ?? 1));
|
|
66
|
+
|
|
67
|
+
const child = spawn(anvilBinary, args, {
|
|
68
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
69
|
+
env: { ...process.env, RAYON_NUM_THREADS: '1' },
|
|
38
70
|
});
|
|
39
71
|
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
72
|
+
// Wait for "Listening on" or an early exit.
|
|
73
|
+
await new Promise<void>((resolve, reject) => {
|
|
74
|
+
let stderr = '';
|
|
75
|
+
|
|
76
|
+
const onStdout = (data: Buffer) => {
|
|
77
|
+
const text = data.toString();
|
|
78
|
+
logger?.debug(text.trim());
|
|
79
|
+
methodCalls?.push(...(text.match(/eth_[^\s]+/g) || []));
|
|
43
80
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
if (detectedPort === undefined && text.includes('Listening on')) {
|
|
82
|
+
const match = text.match(/Listening on ([^:]+):(\d+)/);
|
|
83
|
+
if (match) {
|
|
84
|
+
detectedPort = parseInt(match[2]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (detectedPort !== undefined) {
|
|
88
|
+
child.stdout?.removeListener('data', onStdout);
|
|
89
|
+
child.stderr?.removeListener('data', onStderr);
|
|
90
|
+
child.removeListener('close', onClose);
|
|
91
|
+
resolve();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const onStderr = (data: Buffer) => {
|
|
96
|
+
stderr += data.toString();
|
|
97
|
+
logger?.debug(data.toString().trim());
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const onClose = (code: number | null) => {
|
|
101
|
+
child.stdout?.removeListener('data', onStdout);
|
|
102
|
+
child.stderr?.removeListener('data', onStderr);
|
|
103
|
+
reject(new Error(`Anvil exited with code ${code} before listening. stderr: ${stderr}`));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
child.stdout?.on('data', onStdout);
|
|
107
|
+
child.stderr?.on('data', onStderr);
|
|
108
|
+
child.once('close', onClose);
|
|
48
109
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
110
|
+
|
|
111
|
+
// Continue piping for logging / method-call capture after startup.
|
|
112
|
+
if (logger || opts.captureMethodCalls) {
|
|
113
|
+
child.stdout?.on('data', (data: Buffer) => {
|
|
114
|
+
const text = data.toString();
|
|
115
|
+
logger?.debug(text.trim());
|
|
116
|
+
methodCalls?.push(...(text.match(/eth_[^\s]+/g) || []));
|
|
117
|
+
});
|
|
118
|
+
child.stderr?.on('data', (data: Buffer) => {
|
|
119
|
+
logger?.debug(data.toString().trim());
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
// Consume streams so the child process doesn't block on full pipe buffers.
|
|
123
|
+
child.stdout?.resume();
|
|
124
|
+
child.stderr?.resume();
|
|
52
125
|
}
|
|
53
126
|
|
|
54
|
-
return
|
|
127
|
+
return child;
|
|
55
128
|
},
|
|
56
129
|
'Start anvil',
|
|
57
130
|
makeBackoff([5, 5, 5]),
|
|
58
131
|
);
|
|
59
132
|
|
|
60
|
-
if (!
|
|
133
|
+
if (!detectedPort) {
|
|
61
134
|
throw new Error('Failed to start anvil');
|
|
62
135
|
}
|
|
63
136
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
137
|
+
const port = detectedPort;
|
|
138
|
+
let status: 'listening' | 'idle' = 'listening';
|
|
139
|
+
|
|
140
|
+
anvil.once('close', () => {
|
|
141
|
+
status = 'idle';
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const stop = async () => {
|
|
145
|
+
if (status === 'idle') {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
await killChild(anvil);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const anvilObj: Anvil = {
|
|
152
|
+
port,
|
|
153
|
+
host: '127.0.0.1',
|
|
154
|
+
get status() {
|
|
155
|
+
return status;
|
|
156
|
+
},
|
|
157
|
+
stop,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return { anvil: anvilObj, methodCalls, stop, rpcUrl: `http://127.0.0.1:${port}` };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Send SIGTERM, wait up to 5 s, then SIGKILL. All timers are always cleared. */
|
|
164
|
+
function killChild(child: ChildProcess): Promise<void> {
|
|
165
|
+
return new Promise<void>(resolve => {
|
|
166
|
+
if (child.exitCode !== null || child.killed) {
|
|
167
|
+
child.stdout?.destroy();
|
|
168
|
+
child.stderr?.destroy();
|
|
169
|
+
resolve();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let killTimer: NodeJS.Timeout | undefined;
|
|
174
|
+
|
|
175
|
+
const onClose = () => {
|
|
176
|
+
if (killTimer !== undefined) {
|
|
177
|
+
clearTimeout(killTimer);
|
|
178
|
+
}
|
|
179
|
+
// Destroy stdio streams so their PipeWrap handles don't keep the event loop alive.
|
|
180
|
+
child.stdout?.destroy();
|
|
181
|
+
child.stderr?.destroy();
|
|
182
|
+
resolve();
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
child.once('close', onClose);
|
|
186
|
+
child.kill('SIGTERM');
|
|
187
|
+
|
|
188
|
+
killTimer = setTimeout(() => {
|
|
189
|
+
killTimer = undefined;
|
|
190
|
+
child.kill('SIGKILL');
|
|
191
|
+
}, 5000);
|
|
192
|
+
|
|
193
|
+
// Ensure the timer does not prevent Node from exiting.
|
|
194
|
+
killTimer.unref();
|
|
195
|
+
});
|
|
67
196
|
}
|
|
@@ -7,7 +7,7 @@ import { type GetContractReturnType, type PrivateKeyAccount, getContract } from
|
|
|
7
7
|
|
|
8
8
|
import { extractProposalIdFromLogs } from '../contracts/governance.js';
|
|
9
9
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
10
|
-
import {
|
|
10
|
+
import { createL1TxUtils } from '../l1_tx_utils/index.js';
|
|
11
11
|
import type { ExtendedViemWalletClient, ViemPublicClient } from '../types.js';
|
|
12
12
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ export async function executeGovernanceProposal(
|
|
|
22
22
|
) {
|
|
23
23
|
const proposal = await governance.read.getProposal([proposalId]);
|
|
24
24
|
|
|
25
|
-
const l1TxUtils =
|
|
25
|
+
const l1TxUtils = createL1TxUtils(l1Client);
|
|
26
26
|
|
|
27
27
|
const waitL1Block = async () => {
|
|
28
28
|
await l1TxUtils.sendAndMonitorTransaction({
|
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,
|