diff --git a/packages/evm/contracts/adapters/BlockHashAdapter.sol b/packages/evm/contracts/adapters/BlockHashAdapter.sol index bdf65b50..173a5a8b 100644 --- a/packages/evm/contracts/adapters/BlockHashAdapter.sol +++ b/packages/evm/contracts/adapters/BlockHashAdapter.sol @@ -12,21 +12,14 @@ abstract contract BlockHashAdapter is IBlockHashAdapter, Adapter { function proveAncestralBlockHashes(uint256 chainId, bytes[] memory blockHeaders) external { for (uint256 i = 0; i < blockHeaders.length; i++) { RLPReader.RLPItem memory blockHeaderRLP = RLPReader.toRlpItem(blockHeaders[i]); - if (!blockHeaderRLP.isList()) revert InvalidBlockHeaderRLP(); - RLPReader.RLPItem[] memory blockHeaderContent = blockHeaderRLP.toList(); - // A block header should have between 15 and 17 elements (baseFee and withdrawalsRoot have been added later) - if (blockHeaderContent.length < 15 || blockHeaderContent.length > 17) - revert InvalidBlockHeaderLength(blockHeaderContent.length); - bytes32 blockParent = bytes32(blockHeaderContent[0].toUint()); uint256 blockNumber = uint256(blockHeaderContent[8].toUint()); bytes32 blockHash = keccak256(blockHeaders[i]); bytes32 storedBlockHash = getHash(chainId, blockNumber); - if (blockHash != storedBlockHash) revert ConflictingBlockHeader(blockNumber, blockHash, storedBlockHash); _storeHash(chainId, blockNumber - 1, blockParent); diff --git a/packages/evm/contracts/interfaces/IAdapter.sol b/packages/evm/contracts/interfaces/IAdapter.sol index 72498484..72b9c7f2 100644 --- a/packages/evm/contracts/interfaces/IAdapter.sol +++ b/packages/evm/contracts/interfaces/IAdapter.sol @@ -6,7 +6,6 @@ pragma solidity ^0.8.0; */ interface IAdapter { error ConflictingBlockHeader(uint256 blockNumber, bytes32 blockHash, bytes32 storedBlockHash); - error InvalidBlockHeaderLength(uint256 length); error InvalidBlockHeaderRLP(); /** diff --git a/packages/evm/test/adapters/02_Adapter.spec.ts b/packages/evm/test/adapters/02_Adapter.spec.ts index ed60d30c..8b9f9987 100644 --- a/packages/evm/test/adapters/02_Adapter.spec.ts +++ b/packages/evm/test/adapters/02_Adapter.spec.ts @@ -113,25 +113,5 @@ describe("Adapter", function () { "InvalidBlockHeaderRLP", ) }) - - it("Reverts if block proof doesn't match valid block header lengths", async function () { - const { adapter, blocks } = await setup() - const blockHeaderContents = RLP.decode(blockRLP(blocks[0])) - const blockHeaderTooShortContents = blockHeaderContents.slice(0, 14) - const blockHeaderTooShort = RLP.encode(blockHeaderTooShortContents) - - // Block header RLP contains too few elements - await expect(adapter.proveAncestralBlockHashes(CHAIN_ID, [blockHeaderTooShort])) - .to.revertedWithCustomError(adapter, "InvalidBlockHeaderLength") - .withArgs(blockHeaderTooShortContents.length) - - const blockHeaderTooLongContents = blockHeaderContents.concat([adapter.address, adapter.address]) - const blockHeaderTooLong = RLP.encode(blockHeaderTooLongContents) - - // Block header RLP contains too many elements - await expect(adapter.proveAncestralBlockHashes(CHAIN_ID, [blockHeaderTooLong])) - .to.revertedWithCustomError(adapter, "InvalidBlockHeaderLength") - .withArgs(blockHeaderTooLongContents.length) - }) }) })