From ea1f7553417e14fbe6a1c151b7e3a3d2abcfc8cf Mon Sep 17 00:00:00 2001 From: Jack Chuma Date: Mon, 30 Dec 2024 11:05:27 -0500 Subject: [PATCH] add ts filler validation against selected L2 block timestamp --- services/ts-filler/src/prover/prover.service.ts | 7 ++++++- services/ts-filler/src/rewards/monitor.service.ts | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/ts-filler/src/prover/prover.service.ts b/services/ts-filler/src/prover/prover.service.ts index 5936d88..7784e36 100644 --- a/services/ts-filler/src/prover/prover.service.ts +++ b/services/ts-filler/src/prover/prover.service.ts @@ -54,7 +54,8 @@ export default class ProverService { } async generateProofWithL2Block( - requestHash: Address + requestHash: Address, + timestampCutoff = 0 ): Promise<{ proof: ProofType; l2Block: Block }> { let beaconData: GetBeaconRootAndL2TimestampReturnType | undefined; let l1BlockNumber: bigint | undefined; @@ -86,6 +87,10 @@ export default class ProverService { await this.chainService.getL2Block(l1BlockNumber); const l2Slot = this.deriveRIP7755VerifierStorageSlot(requestHash); + if (timestampCutoff > l2Block.timestamp) { + throw new Error("L2 block timestamp is too old"); + } + const storageProofOpts = { l1BlockNumber, l2Block, diff --git a/services/ts-filler/src/rewards/monitor.service.ts b/services/ts-filler/src/rewards/monitor.service.ts index ecabc5d..de6b5f6 100644 --- a/services/ts-filler/src/rewards/monitor.service.ts +++ b/services/ts-filler/src/rewards/monitor.service.ts @@ -72,7 +72,8 @@ export default class RewardMonitorService { const { requestHash, sender, receiver, payload, attributes } = job; const { proof, l2Block } = await proverService.generateProofWithL2Block( - requestHash + requestHash, + job.claimAvailableAt ); const attributesClass = new Attributes(attributes); attributesClass.removeFulfiller();