Skip to content

Commit 993806c

Browse files
authored
fix: Handle prunes when computing current base fees (#19234)
In [this failed run](http://ci.aztec-labs.com/b0c735d3bf1a0925) of `e2e_cross_chain_messaging l1_to_l2` we see a `Rollup__UnavailableTempCheckpointLog` that's coming from `computeCurrentBaseFees`. This was caused by trying to send a tx while a prune was happening. This adds retries to `getPendingCheckpoint` so it tries getting the latest checkpoint again if it fails because the checkpoint number it's trying to fetch has been pruned out.
2 parents c42de61 + fe94779 commit 993806c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/bra
22
import { memoize } from '@aztec/foundation/decorators';
33
import { EthAddress } from '@aztec/foundation/eth-address';
44
import type { ViemSignature } from '@aztec/foundation/eth-signature';
5+
import { makeBackoff, retry } from '@aztec/foundation/retry';
56
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
67
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
78

@@ -420,6 +421,21 @@ export class RollupContract {
420421
return this.rollup.read.getCheckpoint([BigInt(checkpointNumber)]);
421422
}
422423

424+
/** Returns the pending checkpoint from the rollup contract */
425+
getPendingCheckpoint() {
426+
// We retry because of race conditions during prunes: we may get a pending checkpoint number which is immediately
427+
// reorged out due to a prune happening, causing the subsequent getCheckpoint call to fail. So we try again in that case.
428+
return retry(
429+
async () => {
430+
const pendingCheckpointNumber = await this.getCheckpointNumber();
431+
const pendingCheckpoint = await this.getCheckpoint(pendingCheckpointNumber);
432+
return pendingCheckpoint;
433+
},
434+
'getting pending checkpoint',
435+
makeBackoff([0.5, 0.5, 0.5]),
436+
);
437+
}
438+
423439
async getTips(): Promise<{ pending: CheckpointNumber; proven: CheckpointNumber }> {
424440
const { pending, proven } = await this.rollup.read.getTips();
425441
return {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class GlobalVariableBuilder implements GlobalVariableBuilderInterface {
6969
// we need to fetch the last block written, and estimate the earliest timestamp for the next block.
7070
// The timestamp of that last block will act as a lower bound for the next block.
7171

72-
const lastBlock = await this.rollupContract.getCheckpoint(await this.rollupContract.getCheckpointNumber());
72+
const lastBlock = await this.rollupContract.getPendingCheckpoint();
7373
const earliestTimestamp = await this.rollupContract.getTimestampForSlot(
7474
SlotNumber.fromBigInt(lastBlock.slotNumber + 1n),
7575
);

0 commit comments

Comments
 (0)