diff --git a/packages/evm/contracts/adapters/Spectre/SpectreAdapter.sol b/packages/evm/contracts/adapters/Spectre/SpectreAdapter.sol index 3e3da00a..a1aadb12 100644 --- a/packages/evm/contracts/adapters/Spectre/SpectreAdapter.sol +++ b/packages/evm/contracts/adapters/Spectre/SpectreAdapter.sol @@ -70,7 +70,7 @@ contract SpectreAdapter is AccessControl, BlockHashAdapter { ); if (!parsedReceipt.isValid) revert ErrorParseReceipt(); - if (bytes32(parsedReceipt.topics[0]) != MESSAGE_DISPATCHED_EVENT_SIG) revert InvalidEventSignature(); + if (parsedReceipt.topics[0] != MESSAGE_DISPATCHED_EVENT_SIG) revert InvalidEventSignature(); if (parsedReceipt.eventSource != SOURCE_YAHO) revert InvalidEventSource(); uint256 messageId = uint256(parsedReceipt.topics[1]); diff --git a/packages/evm/contracts/adapters/Spectre/lib/Merkle.sol b/packages/evm/contracts/adapters/Spectre/lib/Merkle.sol index 109fcde2..1cd649ed 100644 --- a/packages/evm/contracts/adapters/Spectre/lib/Merkle.sol +++ b/packages/evm/contracts/adapters/Spectre/lib/Merkle.sol @@ -56,8 +56,6 @@ library Merkle { index = concatGindices(receiptGindexes); } else if (lcSlot - txSlot > SLOTS_PER_HISTORICAL_ROOT) { revert("txSlot lags by >8192 blocks. Not supported."); - } else { - revert("txSlot can't be greater than lightclient slot"); } bytes32 computedRoot = restoreMerkleRoot(receiptsRootBranch, receiptsRoot, calculateIndex(index)); @@ -75,9 +73,6 @@ library Merkle { } function bitLength(uint256 number) internal pure returns (uint256) { - if (number == 0) { - return 0; - } uint256 length = 0; while (number > 0) { length++; @@ -87,16 +82,7 @@ library Merkle { } function calculateArrayGindex(uint256 elementIndex) internal pure returns (uint256) { - uint256 gindex = 1; - uint256 depth = 0; - while ((1 << depth) < SLOTS_PER_HISTORICAL_ROOT) { - depth++; - } - - for (uint256 d = 0; d < depth; d++) { - gindex = (gindex << 1) | ((elementIndex >> (depth - d - 1)) & 1); - } - return gindex; + return SLOTS_PER_HISTORICAL_ROOT + (elementIndex % SLOTS_PER_HISTORICAL_ROOT); } function calculateIndex(uint256 gindex) internal pure returns (uint256 index) { diff --git a/packages/evm/contracts/adapters/Spectre/lib/Receipt.sol b/packages/evm/contracts/adapters/Spectre/lib/Receipt.sol index 4c6153d7..b0030db7 100644 --- a/packages/evm/contracts/adapters/Spectre/lib/Receipt.sol +++ b/packages/evm/contracts/adapters/Spectre/lib/Receipt.sol @@ -52,7 +52,7 @@ library Receipt { // memory pointer to the RLP Receipt uint256 memPtr; assembly { - memPtr := add(value, add(0x20, mul(0x01, offset))) + memPtr := add(value, add(0x20, offset)) } // read Receipt as a list of RLPItem