From ca4a6e6f2fbb57401568cb69bd86e3cec8a41a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keszey=20D=C3=A1niel?= Date: Fri, 19 Jul 2024 10:38:05 +0200 Subject: [PATCH] fix or uncomment not relevant tests --- packages/protocol/contracts/L1/TaikoL1.sol | 68 +++++++++++----------- packages/protocol/test/L1/TaikoL1.t.sol | 28 ++++----- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index 688dc223267f..75981bce97fe 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -129,44 +129,46 @@ contract TaikoL1 is EssentialContract, TaikoEvents, TaikoErrors { // Check that the tx length is non-zero and within the supported range require(_block.txListByteSize <= config.blockMaxTxListBytes, "invalid txlist size"); - // Also since we dont write into storage this check is hard to do here + the - // parentBlock.l1StateBlockNumber too for the preconfs (checking the 4 epoch window) - // I just guess, but also during proving we can see if this condition is - // fulfilled OR not, and then resulting in an empty block (+slashing of the - // proposer/preconfer) ? - TaikoData.Block storage parentBlock = state.blocks[(state.numBlocks - 1)]; - - require(_block.parentMetaHash == parentBlock.metaHash, "invalid parentMetaHash"); - require(_block.parentBlockHash == parentBlock.blockHash, "invalid parentHash"); - - // Verify the passed in L1 state block number. - // We only allow the L1 block to be 4 epochs old. - // The other constraint is that the L1 block number needs to be larger than or equal the one - // in the previous L2 block. - - if ( - _block.l1StateBlockNumber + 128 < block.number - || _block.l1StateBlockNumber >= block.number - || _block.l1StateBlockNumber < parentBlock.l1StateBlockNumber - ) { - revert L1_INVALID_L1_STATE_BLOCK(); - } - - // Verify the passed in timestamp. - // We only allow the timestamp to be 4 epochs old. - // The other constraint is that the timestamp needs to be larger than or equal the one - // in the previous L2 block. - if ( - _block.timestamp + 128 * 12 < block.timestamp || _block.timestamp > block.timestamp - || _block.timestamp < parentBlock.timestamp - ) { - revert L1_INVALID_TIMESTAMP(); - } + /* NOT NEEDED ! Commenting out. When PR approved, i'll delete also. */ + // // Also since we dont write into storage this check is hard to do here + the + // // parentBlock.l1StateBlockNumber too for the preconfs (checking the 4 epoch window) + // // I just guess, but also during proving we can see if this condition is + // // fulfilled OR not, and then resulting in an empty block (+slashing of the + // // proposer/preconfer) ? + // TaikoData.Block storage parentBlock = state.blocks[(state.numBlocks - 1)]; + + // require(_block.parentMetaHash == parentBlock.metaHash, "invalid parentMetaHash"); + // require(_block.parentBlockHash == parentBlock.blockHash, "invalid parentHash"); + + // // Verify the passed in L1 state block number. + // // We only allow the L1 block to be 4 epochs old. + // // The other constraint is that the L1 block number needs to be larger than or equal the one + // // in the previous L2 block. + + // if ( + // _block.l1StateBlockNumber + 128 < block.number + // || _block.l1StateBlockNumber >= block.number + // || _block.l1StateBlockNumber < parentBlock.l1StateBlockNumber + // ) { + // revert L1_INVALID_L1_STATE_BLOCK(); + // } + + // // Verify the passed in timestamp. + // // We only allow the timestamp to be 4 epochs old. + // // The other constraint is that the timestamp needs to be larger than or equal the one + // // in the previous L2 block. + // if ( + // _block.timestamp + 128 * 12 < block.timestamp || _block.timestamp > block.timestamp + // || _block.timestamp < parentBlock.timestamp + // ) { + // revert L1_INVALID_TIMESTAMP(); + // } emit BlockProposed({ blockId: _block.l2BlockNumber, meta: _block }); } // These will be unknown in the smart contract + // NOT NEEDED ! Commenting out. When PR approved, i'll delete also. // Maybe possible to extract with ChainProver, but not directly from here. // function getBlock(uint64 blockId) {} // function getLastVerifiedBlockId() {} diff --git a/packages/protocol/test/L1/TaikoL1.t.sol b/packages/protocol/test/L1/TaikoL1.t.sol index 79942ad05044..a0e4b38d3ee7 100644 --- a/packages/protocol/test/L1/TaikoL1.t.sol +++ b/packages/protocol/test/L1/TaikoL1.t.sol @@ -88,23 +88,25 @@ contract TaikoL1Test is TaikoL1TestBase { } } - function test_L1_propose_block_outside_the_4_epoch_window() external { - giveEthAndTko(Alice, 100 ether, 100 ether); + // This test does not fail anymore, because proposing is possible but validating of the preconf window violation will be done + // So for now, not needed ! Commenting out. When PR approved, i'll delete also. + // function test_L1_propose_block_outside_the_4_epoch_window() external { + // giveEthAndTko(Alice, 100 ether, 100 ether); - TaikoData.BlockMetadata memory meta; + // TaikoData.BlockMetadata memory meta; - vm.roll(block.number + 1); - vm.warp(block.timestamp + 12); + // vm.roll(block.number + 1); + // vm.warp(block.timestamp + 12); - bytes32 parentMetaHash; - bytes32 parentBlockHash = GENESIS_BLOCK_HASH; - // Create metadata and propose the block 129 blocks later only - meta = createBlockMetaData(Alice, 1, 1, true, parentMetaHash, parentBlockHash); - vm.roll(block.number + 129); - vm.warp(block.timestamp + 129 * 12); + // bytes32 parentMetaHash; + // bytes32 parentBlockHash = GENESIS_BLOCK_HASH; + // // Create metadata and propose the block 129 blocks later only + // meta = createBlockMetaData(Alice, 1, 1, true, parentMetaHash, parentBlockHash); + // vm.roll(block.number + 129); + // vm.warp(block.timestamp + 129 * 12); - proposeBlock(Alice, meta, TaikoErrors.L1_INVALID_L1_STATE_BLOCK.selector); - } + // proposeBlock(Alice, meta, TaikoErrors.L1_INVALID_L1_STATE_BLOCK.selector); + // } function test_print_genesis_hash() external pure { console2.logBytes32(keccak256("GENESIS_BLOCK_HASH"));