Skip to content

Commit 7d7975b

Browse files
spalladinoclaude
andcommitted
fix(ethereum): add getEffectivePendingCheckpoint to handle prune scenarios
Addresses PR #22116 review comment 3: fee predictor was using the raw pending checkpoint which could be stale when a prune is imminent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8d872f8 commit 7d7975b

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

yarn-project/ethereum/src/contracts/rollup.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,26 @@ export class RollupContract {
689689
);
690690
}
691691

692+
/** Returns the effective pending checkpoint, accounting for potential prunes.
693+
* When a prune can happen, the L1 contract uses the proven checkpoint instead of the pending one.
694+
* This mirrors the behavior of getEffectivePendingCheckpointNumber in STFLib.sol. */
695+
getEffectivePendingCheckpoint() {
696+
return retry(
697+
async () => {
698+
const timestamp = (await this.client.getBlock()).timestamp;
699+
const canPrune = await this.canPruneAtTime(timestamp);
700+
if (canPrune) {
701+
const provenCheckpointNumber = await this.getProvenCheckpointNumber();
702+
return await this.getCheckpoint(provenCheckpointNumber);
703+
}
704+
const pendingCheckpointNumber = await this.getCheckpointNumber();
705+
return await this.getCheckpoint(pendingCheckpointNumber);
706+
},
707+
'getting effective pending checkpoint',
708+
makeBackoff([0.5, 0.5, 0.5]),
709+
);
710+
}
711+
692712
async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
693713
const { pending, proven } = await this.rollup.read.getTips();
694714
return {

yarn-project/sequencer-client/src/global_variable_builder/fee_predictor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class FeePredictor {
5656
// Most of the items below are cached by the rollup contract
5757
const [lastCheckpoint, currentSlot, manaTarget, manaLimit, provingCostPerManaEth, epochDuration] =
5858
await Promise.all([
59-
this.rollupContract.getPendingCheckpoint(),
59+
this.rollupContract.getEffectivePendingCheckpoint(),
6060
this.rollupContract.getSlotNumber(),
6161
this.rollupContract.getManaTarget(),
6262
this.rollupContract.getManaLimit(),

0 commit comments

Comments
 (0)