From 595cd5a5eca8dabed23e5a90068566c506656a55 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Fri, 23 Aug 2024 21:43:32 -0400 Subject: [PATCH] fix: timestamp invariant to reject old/stale certs - update to use reference block # --- src/bridge/SequencerInbox.sol | 5 ++++- test/foundry/SequencerInbox.t.sol | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index d8191778..ae785964 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -481,7 +481,10 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox // Verify that the certificate is less than 2 epochs old from the L1 reference block number // This is to prevent timing attacks where the sequencer could submit an expired or close to expired // certificate which could impact liveness of full nodes as well as the safety of the bridge - if ((cert.blobVerificationProof.batchMetadata.confirmationBlockNumber + 64) < block.number) { + if ( + (cert.blobVerificationProof.batchMetadata.batchHeader.referenceBlockNumber + 64) < + block.number + ) { revert ExpiredEigenDACert( block.number, cert.blobVerificationProof.batchMetadata.confirmationBlockNumber + 64 diff --git a/test/foundry/SequencerInbox.t.sol b/test/foundry/SequencerInbox.t.sol index 9559c666..cdbd5959 100644 --- a/test/foundry/SequencerInbox.t.sol +++ b/test/foundry/SequencerInbox.t.sol @@ -593,13 +593,11 @@ contract SequencerInboxTest is Test { cert.blobVerificationProof.batchMetadata.batchHeader.referenceBlockNumber = 0; - bytes memory data = bytes.concat(hex"ed", abi.encode(cert)); - uint256 subMessageCount = bridge.sequencerReportedSubMessageCount(); uint256 sequenceNumber = bridge.sequencerMessageCount(); uint256 delayedMessagesRead = bridge.delayedMessageCount(); - vm.roll(10000000); + vm.roll(65); vm.prank(tx.origin); vm.expectRevert(); @@ -613,7 +611,7 @@ contract SequencerInboxTest is Test { ); } - function testAddSequencerL2BatchFromEigenDA() public { + function testAddSequencerL2BatchFromEigenDA() public { DummyEigenDABlobVerifier rollupManagerImpl = new DummyEigenDABlobVerifier(); (SequencerInbox seqInbox, Bridge bridge) = deployRollup(false); // update the dummyEigenDAServiceManager to use the holesky serviceManager contract @@ -659,7 +657,6 @@ contract SequencerInboxTest is Test { ); } - // TODO: put these in jsons later // create illegal commitment BN254.G1Point illegalCommitment =