@aztec/ethereum 0.0.1-commit.b655e406 → 0.0.1-commit.d3ec352c
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 +1 -1
- package/dest/config.d.ts +7 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +13 -7
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +6 -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 +5 -4
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +8 -2
- 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 +1 -1
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- 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 +16 -16
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.d.ts +5 -4
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +8 -2
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +1 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/index.d.ts +1 -1
- package/dest/contracts/multicall.d.ts +2 -2
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/registry.d.ts +1 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/rollup.d.ts +55 -64
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +76 -67
- 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 +7 -6
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +3 -3
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_l1_contracts.d.ts +455 -8
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +51 -33
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/l1_artifacts.d.ts +2020 -860
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +3 -3
- package/dest/l1_reader.d.ts +1 -1
- package/dest/l1_tx_utils/config.d.ts +3 -3
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +13 -4
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/factory.d.ts +1 -1
- package/dest/l1_tx_utils/index.d.ts +1 -1
- package/dest/l1_tx_utils/interfaces.d.ts +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -2
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +1 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +16 -16
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +3 -4
- package/dest/l1_tx_utils/signer.d.ts +1 -1
- 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 +1 -1
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +5 -3
- package/dest/test/chain_monitor.d.ts +26 -23
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +32 -34
- package/dest/test/delayed_tx_utils.d.ts +1 -1
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.d.ts +8 -12
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +8 -2
- 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 -1
- package/dest/test/rollup_cheat_codes.d.ts +13 -12
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +38 -36
- package/dest/test/start_anvil.d.ts +2 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +2 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/types.d.ts +1 -1
- package/dest/utils.d.ts +1 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/package.json +10 -9
- package/src/config.ts +16 -8
- package/src/contracts/empire_base.ts +6 -5
- package/src/contracts/empire_slashing_proposer.ts +11 -5
- package/src/contracts/governance_proposer.ts +11 -5
- package/src/contracts/rollup.ts +81 -80
- package/src/contracts/tally_slashing_proposer.ts +8 -7
- package/src/deploy_l1_contracts.ts +55 -35
- package/src/l1_tx_utils/config.ts +9 -6
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +3 -4
- package/src/queries.ts +6 -3
- package/src/test/chain_monitor.ts +48 -47
- package/src/test/eth_cheat_codes.ts +7 -1
- package/src/test/rollup_cheat_codes.ts +41 -40
- package/src/test/start_anvil.ts +2 -0
package/src/queries.ts
CHANGED
|
@@ -33,7 +33,8 @@ export async function getL1ContractsConfig(
|
|
|
33
33
|
aztecSlotDuration,
|
|
34
34
|
aztecProofSubmissionEpochs,
|
|
35
35
|
aztecTargetCommitteeSize,
|
|
36
|
-
|
|
36
|
+
lagInEpochsForValidatorSet,
|
|
37
|
+
lagInEpochsForRandao,
|
|
37
38
|
activationThreshold,
|
|
38
39
|
ejectionThreshold,
|
|
39
40
|
localEjectionThreshold,
|
|
@@ -59,7 +60,8 @@ export async function getL1ContractsConfig(
|
|
|
59
60
|
rollup.getSlotDuration(),
|
|
60
61
|
rollup.getProofSubmissionEpochs(),
|
|
61
62
|
rollup.getTargetCommitteeSize(),
|
|
62
|
-
rollup.
|
|
63
|
+
rollup.getLagInEpochsForValidatorSet(),
|
|
64
|
+
rollup.getLagInEpochsForRandao(),
|
|
63
65
|
rollup.getActivationThreshold(),
|
|
64
66
|
rollup.getEjectionThreshold(),
|
|
65
67
|
rollup.getLocalEjectionThreshold(),
|
|
@@ -87,7 +89,8 @@ export async function getL1ContractsConfig(
|
|
|
87
89
|
aztecSlotDuration: Number(aztecSlotDuration),
|
|
88
90
|
aztecProofSubmissionEpochs: Number(aztecProofSubmissionEpochs),
|
|
89
91
|
aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
|
|
90
|
-
|
|
92
|
+
lagInEpochsForValidatorSet: Number(lagInEpochsForValidatorSet),
|
|
93
|
+
lagInEpochsForRandao: Number(lagInEpochsForRandao),
|
|
91
94
|
governanceProposerQuorum: Number(governanceProposerQuorum),
|
|
92
95
|
governanceProposerRoundSize: Number(governanceProposerRoundSize),
|
|
93
96
|
activationThreshold,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InboxContract, type RollupContract } from '@aztec/ethereum/contracts';
|
|
2
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
@@ -10,11 +11,13 @@ import type { ViemClient } from '../types.js';
|
|
|
10
11
|
|
|
11
12
|
export type ChainMonitorEventMap = {
|
|
12
13
|
'l1-block': [{ l1BlockNumber: number; timestamp: bigint }];
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
checkpoint: [
|
|
15
|
+
{ checkpointNumber: CheckpointNumber; l1BlockNumber: number; l2SlotNumber: SlotNumber; timestamp: bigint },
|
|
16
|
+
];
|
|
17
|
+
'checkpoint-proven': [{ provenCheckpointNumber: CheckpointNumber; l1BlockNumber: number; timestamp: bigint }];
|
|
15
18
|
'l2-messages': [{ totalL2Messages: number; l1BlockNumber: number }];
|
|
16
|
-
'l2-epoch': [{ l2EpochNumber:
|
|
17
|
-
'l2-slot': [{ l2SlotNumber:
|
|
19
|
+
'l2-epoch': [{ l2EpochNumber: EpochNumber; timestamp: bigint; committee: EthAddress[] | undefined }];
|
|
20
|
+
'l2-slot': [{ l2SlotNumber: SlotNumber; timestamp: bigint }];
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
/** Utility class that polls the chain on quick intervals and logs new L1 blocks, L2 blocks, and L2 proofs. */
|
|
@@ -27,20 +30,20 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
27
30
|
|
|
28
31
|
/** Current L1 block number */
|
|
29
32
|
public l1BlockNumber!: number;
|
|
30
|
-
/** Current
|
|
31
|
-
public
|
|
32
|
-
/** Current
|
|
33
|
-
public
|
|
34
|
-
/** L1 timestamp for the current
|
|
35
|
-
public
|
|
36
|
-
/** L1 timestamp for the proven
|
|
37
|
-
public
|
|
33
|
+
/** Current checkpoint number */
|
|
34
|
+
public checkpointNumber!: CheckpointNumber;
|
|
35
|
+
/** Current proven checkpoint number */
|
|
36
|
+
public provenCheckpointNumber!: CheckpointNumber;
|
|
37
|
+
/** L1 timestamp for the current checkpoint */
|
|
38
|
+
public checkpointTimestamp!: bigint;
|
|
39
|
+
/** L1 timestamp for the proven checkpoint */
|
|
40
|
+
public provenCheckpointTimestamp!: bigint;
|
|
38
41
|
/** Total number of L2 messages pushed into the Inbox */
|
|
39
42
|
public totalL2Messages: number = 0;
|
|
40
43
|
/** Current L2 epoch number */
|
|
41
|
-
public l2EpochNumber!:
|
|
44
|
+
public l2EpochNumber!: EpochNumber;
|
|
42
45
|
/** Current L2 slot number */
|
|
43
|
-
public l2SlotNumber!:
|
|
46
|
+
public l2SlotNumber!: SlotNumber;
|
|
44
47
|
|
|
45
48
|
constructor(
|
|
46
49
|
private readonly rollup: RollupContract,
|
|
@@ -114,28 +117,28 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
114
117
|
this.emit('l1-block', { l1BlockNumber: newL1BlockNumber, timestamp });
|
|
115
118
|
let msg = `L1 block ${newL1BlockNumber} mined at ${timestampString}`;
|
|
116
119
|
|
|
117
|
-
const
|
|
118
|
-
if (this.
|
|
119
|
-
const epochNumber = await this.rollup.
|
|
120
|
-
msg += ` with new
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
this.emit('
|
|
124
|
-
|
|
120
|
+
const newCheckpointNumber = await this.rollup.getCheckpointNumber();
|
|
121
|
+
if (this.checkpointNumber !== newCheckpointNumber) {
|
|
122
|
+
const epochNumber = await this.rollup.getEpochNumberForCheckpoint(newCheckpointNumber);
|
|
123
|
+
msg += ` with new checkpoint ${newCheckpointNumber} for epoch ${epochNumber}`;
|
|
124
|
+
this.checkpointNumber = newCheckpointNumber;
|
|
125
|
+
this.checkpointTimestamp = timestamp;
|
|
126
|
+
this.emit('checkpoint', {
|
|
127
|
+
checkpointNumber: newCheckpointNumber,
|
|
125
128
|
l1BlockNumber: newL1BlockNumber,
|
|
126
|
-
l2SlotNumber
|
|
129
|
+
l2SlotNumber,
|
|
127
130
|
timestamp,
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
const
|
|
132
|
-
if (this.
|
|
133
|
-
const epochNumber = await this.rollup.
|
|
134
|
-
msg += ` with proof up to
|
|
135
|
-
this.
|
|
136
|
-
this.
|
|
137
|
-
this.emit('
|
|
138
|
-
|
|
134
|
+
const newProvenCheckpointNumber = await this.rollup.getProvenCheckpointNumber();
|
|
135
|
+
if (this.provenCheckpointNumber !== newProvenCheckpointNumber) {
|
|
136
|
+
const epochNumber = await this.rollup.getEpochNumberForCheckpoint(newProvenCheckpointNumber);
|
|
137
|
+
msg += ` with proof up to checkpoint ${newProvenCheckpointNumber} for epoch ${epochNumber}`;
|
|
138
|
+
this.provenCheckpointNumber = newProvenCheckpointNumber;
|
|
139
|
+
this.provenCheckpointTimestamp = timestamp;
|
|
140
|
+
this.emit('checkpoint-proven', {
|
|
141
|
+
provenCheckpointNumber: newProvenCheckpointNumber,
|
|
139
142
|
l1BlockNumber: newL1BlockNumber,
|
|
140
143
|
timestamp,
|
|
141
144
|
});
|
|
@@ -153,13 +156,13 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
153
156
|
if (l2Epoch !== this.l2EpochNumber) {
|
|
154
157
|
this.l2EpochNumber = l2Epoch;
|
|
155
158
|
committee = (await this.rollup.getCurrentEpochCommittee())?.map(addr => EthAddress.fromString(addr));
|
|
156
|
-
this.emit('l2-epoch', { l2EpochNumber:
|
|
159
|
+
this.emit('l2-epoch', { l2EpochNumber: l2Epoch, timestamp, committee });
|
|
157
160
|
msg += ` starting new epoch ${this.l2EpochNumber} `;
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
if (l2SlotNumber !== this.l2SlotNumber) {
|
|
161
164
|
this.l2SlotNumber = l2SlotNumber;
|
|
162
|
-
this.emit('l2-slot', { l2SlotNumber
|
|
165
|
+
this.emit('l2-slot', { l2SlotNumber, timestamp });
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
this.logger.info(msg, {
|
|
@@ -168,8 +171,8 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
168
171
|
l1BlockNumber: this.l1BlockNumber,
|
|
169
172
|
l2SlotNumber,
|
|
170
173
|
l2Epoch,
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
checkpointNumber: this.checkpointNumber,
|
|
175
|
+
provenCheckpointNumber: this.provenCheckpointNumber,
|
|
173
176
|
totalL2Messages: this.totalL2Messages,
|
|
174
177
|
committee,
|
|
175
178
|
});
|
|
@@ -177,14 +180,13 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
177
180
|
return this;
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
public waitUntilL2Slot(slot:
|
|
181
|
-
|
|
182
|
-
if (this.l2SlotNumber >= targetSlot) {
|
|
183
|
+
public waitUntilL2Slot(slot: SlotNumber): Promise<void> {
|
|
184
|
+
if (this.l2SlotNumber >= slot) {
|
|
183
185
|
return Promise.resolve();
|
|
184
186
|
}
|
|
185
187
|
return new Promise(resolve => {
|
|
186
|
-
const listener = (data: { l2SlotNumber:
|
|
187
|
-
if (data.l2SlotNumber >=
|
|
188
|
+
const listener = (data: { l2SlotNumber: SlotNumber; timestamp: bigint }) => {
|
|
189
|
+
if (data.l2SlotNumber >= slot) {
|
|
188
190
|
this.off('l2-slot', listener);
|
|
189
191
|
resolve();
|
|
190
192
|
}
|
|
@@ -225,19 +227,18 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
225
227
|
});
|
|
226
228
|
}
|
|
227
229
|
|
|
228
|
-
public
|
|
229
|
-
|
|
230
|
-
if (this.l2BlockNumber >= targetBlock) {
|
|
230
|
+
public waitUntilCheckpoint(checkpointNumber: CheckpointNumber): Promise<void> {
|
|
231
|
+
if (this.checkpointNumber >= checkpointNumber) {
|
|
231
232
|
return Promise.resolve();
|
|
232
233
|
}
|
|
233
234
|
return new Promise(resolve => {
|
|
234
|
-
const listener = (data: {
|
|
235
|
-
if (data.
|
|
236
|
-
this.off('
|
|
235
|
+
const listener = (data: { checkpointNumber: CheckpointNumber; timestamp: bigint }) => {
|
|
236
|
+
if (data.checkpointNumber >= checkpointNumber) {
|
|
237
|
+
this.off('checkpoint', listener);
|
|
237
238
|
resolve();
|
|
238
239
|
}
|
|
239
240
|
};
|
|
240
|
-
this.on('
|
|
241
|
+
this.on('checkpoint', listener);
|
|
241
242
|
});
|
|
242
243
|
}
|
|
243
244
|
}
|
|
@@ -6,7 +6,8 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
6
6
|
import { pluralize } from '@aztec/foundation/string';
|
|
7
7
|
import type { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
8
8
|
|
|
9
|
-
import { type Hex, type Transaction, createPublicClient, fallback, hexToNumber, http } from 'viem';
|
|
9
|
+
import { type Chain, type Hex, type Transaction, createPublicClient, fallback, hexToNumber, http } from 'viem';
|
|
10
|
+
import { foundry } from 'viem/chains';
|
|
10
11
|
|
|
11
12
|
import type { ViemPublicClient } from '../types.js';
|
|
12
13
|
|
|
@@ -28,9 +29,14 @@ export class EthCheatCodes {
|
|
|
28
29
|
* The logger to use for the eth cheatcodes
|
|
29
30
|
*/
|
|
30
31
|
public logger = createLogger('ethereum:cheat_codes'),
|
|
32
|
+
/**
|
|
33
|
+
* The chain configuration provided to Anvil
|
|
34
|
+
*/
|
|
35
|
+
public chain: Chain = foundry,
|
|
31
36
|
) {
|
|
32
37
|
this.publicClient = createPublicClient({
|
|
33
38
|
transport: fallback(this.rpcUrls.map(url => http(url))),
|
|
39
|
+
chain: chain,
|
|
34
40
|
});
|
|
35
41
|
}
|
|
36
42
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RollupContract, type ViemPublicClient } from '@aztec/ethereum';
|
|
2
2
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
+
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -14,7 +15,6 @@ import {
|
|
|
14
15
|
hexToBigInt,
|
|
15
16
|
http,
|
|
16
17
|
} from 'viem';
|
|
17
|
-
import { foundry } from 'viem/chains';
|
|
18
18
|
|
|
19
19
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
20
20
|
|
|
@@ -30,7 +30,7 @@ export class RollupCheatCodes {
|
|
|
30
30
|
addresses: Pick<L1ContractAddresses, 'rollupAddress'>,
|
|
31
31
|
) {
|
|
32
32
|
this.client = createPublicClient({
|
|
33
|
-
chain:
|
|
33
|
+
chain: ethCheatCodes.chain,
|
|
34
34
|
transport: fallback(ethCheatCodes.rpcUrls.map(url => http(url))),
|
|
35
35
|
});
|
|
36
36
|
this.rollup = getContract({
|
|
@@ -50,15 +50,15 @@ export class RollupCheatCodes {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** Returns the current slot */
|
|
53
|
-
public async getSlot() {
|
|
53
|
+
public async getSlot(): Promise<SlotNumber> {
|
|
54
54
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
55
|
-
return await this.rollup.read.getSlotAt([ts]);
|
|
55
|
+
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([ts]));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/** Returns the current epoch */
|
|
59
|
-
public async getEpoch() {
|
|
59
|
+
public async getEpoch(): Promise<EpochNumber> {
|
|
60
60
|
const slotNumber = await this.getSlot();
|
|
61
|
-
return await this.rollup.read.getEpochAtSlot([slotNumber]);
|
|
61
|
+
return EpochNumber.fromBigInt(await this.rollup.read.getEpochAtSlot([BigInt(slotNumber)]));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -66,13 +66,13 @@ export class RollupCheatCodes {
|
|
|
66
66
|
* @returns The pending and proven chain tips
|
|
67
67
|
*/
|
|
68
68
|
public async getTips(): Promise<{
|
|
69
|
-
/** The pending chain tip */ pending:
|
|
70
|
-
/** The proven chain tip */ proven:
|
|
69
|
+
/** The pending chain tip */ pending: CheckpointNumber;
|
|
70
|
+
/** The proven chain tip */ proven: CheckpointNumber;
|
|
71
71
|
}> {
|
|
72
|
-
const
|
|
72
|
+
const { pending, proven } = await this.rollup.read.getTips();
|
|
73
73
|
return {
|
|
74
|
-
pending:
|
|
75
|
-
proven:
|
|
74
|
+
pending: CheckpointNumber.fromBigInt(pending),
|
|
75
|
+
proven: CheckpointNumber.fromBigInt(proven),
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -81,16 +81,16 @@ export class RollupCheatCodes {
|
|
|
81
81
|
*/
|
|
82
82
|
public async debugRollup() {
|
|
83
83
|
const rollup = new RollupContract(this.client, this.rollup.address);
|
|
84
|
-
const pendingNum = await rollup.
|
|
85
|
-
const provenNum = await rollup.
|
|
84
|
+
const pendingNum = await rollup.getCheckpointNumber();
|
|
85
|
+
const provenNum = await rollup.getProvenCheckpointNumber();
|
|
86
86
|
const validators = await rollup.getAttesters();
|
|
87
87
|
const committee = await rollup.getCurrentEpochCommittee();
|
|
88
88
|
const archive = await rollup.archive();
|
|
89
89
|
const slot = await this.getSlot();
|
|
90
90
|
const epochNum = await rollup.getEpochNumberForSlotNumber(slot);
|
|
91
91
|
|
|
92
|
-
this.logger.info(`Pending
|
|
93
|
-
this.logger.info(`Proven
|
|
92
|
+
this.logger.info(`Pending checkpoint num: ${pendingNum}`);
|
|
93
|
+
this.logger.info(`Proven checkpoint num: ${provenNum}`);
|
|
94
94
|
this.logger.info(`Validators: ${validators.map(v => v.toString()).join(', ')}`);
|
|
95
95
|
this.logger.info(`Committee: ${committee?.map(v => v.toString()).join(', ')}`);
|
|
96
96
|
this.logger.info(`Archive: ${archive}`);
|
|
@@ -101,13 +101,13 @@ export class RollupCheatCodes {
|
|
|
101
101
|
/** Fetches the epoch and slot duration config from the rollup contract */
|
|
102
102
|
public async getConfig(): Promise<{
|
|
103
103
|
/** Epoch duration */ epochDuration: bigint;
|
|
104
|
-
/** Slot duration */ slotDuration:
|
|
104
|
+
/** Slot duration */ slotDuration: number;
|
|
105
105
|
}> {
|
|
106
106
|
const [epochDuration, slotDuration] = await Promise.all([
|
|
107
107
|
this.rollup.read.getEpochDuration(),
|
|
108
108
|
this.rollup.read.getSlotDuration(),
|
|
109
109
|
]);
|
|
110
|
-
return { epochDuration, slotDuration };
|
|
110
|
+
return { epochDuration, slotDuration: Number(slotDuration) };
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -116,15 +116,15 @@ export class RollupCheatCodes {
|
|
|
116
116
|
* @param opts - Options
|
|
117
117
|
*/
|
|
118
118
|
public async advanceToEpoch(
|
|
119
|
-
epoch:
|
|
119
|
+
epoch: EpochNumber,
|
|
120
120
|
opts: {
|
|
121
121
|
/** Offset in seconds */
|
|
122
122
|
offset?: number;
|
|
123
123
|
} = {},
|
|
124
124
|
) {
|
|
125
125
|
const { epochDuration: slotsInEpoch } = await this.getConfig();
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const slotNumber = SlotNumber(epoch * Number(slotsInEpoch));
|
|
127
|
+
const timestamp = (await this.rollup.read.getTimestampForSlot([BigInt(slotNumber)])) + BigInt(opts.offset ?? 0);
|
|
128
128
|
try {
|
|
129
129
|
await this.ethCheatCodes.warp(Number(timestamp), { ...opts, silent: true, resetBlockInterval: true });
|
|
130
130
|
this.logger.warn(`Warped to epoch ${epoch}`);
|
|
@@ -138,8 +138,8 @@ export class RollupCheatCodes {
|
|
|
138
138
|
public async advanceToNextEpoch() {
|
|
139
139
|
const slot = await this.getSlot();
|
|
140
140
|
const { epochDuration, slotDuration } = await this.getConfig();
|
|
141
|
-
const slotsUntilNextEpoch = epochDuration - (slot % epochDuration) + 1n;
|
|
142
|
-
const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
|
|
141
|
+
const slotsUntilNextEpoch = epochDuration - (BigInt(slot) % epochDuration) + 1n;
|
|
142
|
+
const timeToNextEpoch = slotsUntilNextEpoch * BigInt(slotDuration);
|
|
143
143
|
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
144
144
|
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
145
145
|
silent: true,
|
|
@@ -151,10 +151,11 @@ export class RollupCheatCodes {
|
|
|
151
151
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
152
152
|
public async advanceToNextSlot() {
|
|
153
153
|
const currentSlot = await this.getSlot();
|
|
154
|
-
const
|
|
154
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
155
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]);
|
|
155
156
|
await this.ethCheatCodes.warp(Number(timestamp), { silent: true, resetBlockInterval: true });
|
|
156
|
-
this.logger.warn(`Advanced to slot ${
|
|
157
|
-
return [timestamp,
|
|
157
|
+
this.logger.warn(`Advanced to slot ${nextSlot}`);
|
|
158
|
+
return [timestamp, nextSlot];
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
/**
|
|
@@ -163,42 +164,42 @@ export class RollupCheatCodes {
|
|
|
163
164
|
*/
|
|
164
165
|
public async advanceSlots(howMany: number) {
|
|
165
166
|
const l1Timestamp = (await this.client.getBlock()).timestamp;
|
|
166
|
-
const slotDuration = await this.rollup.read.getSlotDuration();
|
|
167
|
-
const timeToWarp = BigInt(howMany) * slotDuration;
|
|
167
|
+
const slotDuration = Number(await this.rollup.read.getSlotDuration());
|
|
168
|
+
const timeToWarp = BigInt(howMany) * BigInt(slotDuration);
|
|
168
169
|
await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, { silent: true, resetBlockInterval: true });
|
|
169
170
|
const [slot, epoch] = await Promise.all([this.getSlot(), this.getEpoch()]);
|
|
170
171
|
this.logger.warn(`Advanced ${howMany} slots up to slot ${slot} in epoch ${epoch}`);
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
/**
|
|
174
|
-
* Marks the specified
|
|
175
|
-
* @param
|
|
175
|
+
* Marks the specified checkpoint (or latest if none) as proven
|
|
176
|
+
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
176
177
|
*/
|
|
177
|
-
public markAsProven(
|
|
178
|
+
public markAsProven(maybeCheckpointNumber?: number | bigint) {
|
|
178
179
|
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
|
179
180
|
const tipsBefore = await this.getTips();
|
|
180
181
|
const { pending, proven } = tipsBefore;
|
|
181
182
|
|
|
182
|
-
let
|
|
183
|
-
if (
|
|
184
|
-
|
|
183
|
+
let checkpointNumber = maybeCheckpointNumber;
|
|
184
|
+
if (checkpointNumber === undefined || checkpointNumber > pending) {
|
|
185
|
+
checkpointNumber = pending;
|
|
185
186
|
}
|
|
186
|
-
if (
|
|
187
|
-
this.logger.debug(`
|
|
187
|
+
if (checkpointNumber <= proven) {
|
|
188
|
+
this.logger.debug(`Checkpoint ${checkpointNumber} is already proven`);
|
|
188
189
|
return;
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
// @note @LHerskind this is heavily dependent on the storage layout and size of values
|
|
192
193
|
// The rollupStore is a struct and if the size of elements or the struct changes, this can break
|
|
193
|
-
const
|
|
194
|
+
const provenCheckpointNumberSlot = hexToBigInt(RollupContract.stfStorageSlot);
|
|
194
195
|
|
|
195
196
|
// 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),
|
|
197
|
+
const newValue = (BigInt(tipsBefore.pending) << 128n) | BigInt(checkpointNumber);
|
|
198
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provenCheckpointNumberSlot, newValue);
|
|
198
199
|
|
|
199
200
|
const tipsAfter = await this.getTips();
|
|
200
201
|
if (tipsAfter.pending < tipsAfter.proven) {
|
|
201
|
-
throw new Error('Overwrote pending tip to a
|
|
202
|
+
throw new Error('Overwrote pending tip to a checkpoint in the past');
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
this.logger.info(
|
|
@@ -209,7 +210,7 @@ export class RollupCheatCodes {
|
|
|
209
210
|
|
|
210
211
|
/**
|
|
211
212
|
* Overrides the inProgress field of the Inbox contract state
|
|
212
|
-
* @param howMuch - How many
|
|
213
|
+
* @param howMuch - How many checkpoints to move it forward
|
|
213
214
|
*/
|
|
214
215
|
public advanceInboxInProgress(howMuch: number | bigint): Promise<bigint> {
|
|
215
216
|
return this.ethCheatCodes.execWithPausedAnvil(async () => {
|
package/src/test/start_anvil.ts
CHANGED
|
@@ -15,6 +15,7 @@ export async function startAnvil(
|
|
|
15
15
|
log?: boolean;
|
|
16
16
|
captureMethodCalls?: boolean;
|
|
17
17
|
accounts?: number;
|
|
18
|
+
chainId?: number;
|
|
18
19
|
} = {},
|
|
19
20
|
): Promise<{ anvil: Anvil; methodCalls?: string[]; rpcUrl: string; stop: () => Promise<void> }> {
|
|
20
21
|
const anvilBinary = resolve(dirname(fileURLToPath(import.meta.url)), '../../', 'scripts/anvil_kill_wrapper.sh');
|
|
@@ -35,6 +36,7 @@ export async function startAnvil(
|
|
|
35
36
|
stopTimeout: 1000,
|
|
36
37
|
accounts: opts.accounts ?? 20,
|
|
37
38
|
gasLimit: 45_000_000n,
|
|
39
|
+
chainId: opts.chainId ?? 31337,
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
// Listen to the anvil output to get the port.
|