From 8d0369cad3f8129a9609e19dc361dc2d10a5ce00 Mon Sep 17 00:00:00 2001 From: Francois Hardrouyere Date: Wed, 4 Sep 2024 09:49:58 +0200 Subject: [PATCH] lint --- contracts/src/EventImporter.sol | 11 +++-------- contracts/src/RLPUtils.sol | 6 +++++- contracts/test/MerklePatricia.t.sol | 4 ++-- contracts/test/RLPUtilsTests.t.sol | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/contracts/src/EventImporter.sol b/contracts/src/EventImporter.sol index 470064b..435e0e0 100644 --- a/contracts/src/EventImporter.sol +++ b/contracts/src/EventImporter.sol @@ -5,14 +5,12 @@ pragma solidity 0.8.18; -import {EVMLog, EVMEventInfo, EVMReceipt, IEventImporter} from "./IEventImporter.sol"; +import {EVMLog, EVMEventInfo, IEventImporter} from "./IEventImporter.sol"; import {WarpBlockHash, IWarpMessenger} from "@subnet-evm/contracts/interfaces/IWarpMessenger.sol"; import {MerklePatricia, StorageValue} from "@solidity-merkle-trees/MerklePatricia.sol"; import {RLPReader} from "@solidity-merkle-trees/trie/ethereum/RLPReader.sol"; import {RLPUtils} from "./RLPUtils.sol"; -import "forge-std/Test.sol"; - /** * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. * DO NOT USE THIS CODE IN PRODUCTION. @@ -23,7 +21,7 @@ import "forge-std/Test.sol"; * Uses the Warp precompile to authenticate the block hash of the block including the events to be imported. * Inheriting contracts must implement the _onEventImport function to handle event imports. */ -abstract contract EventImporter is IEventImporter, Test { +abstract contract EventImporter is IEventImporter { using RLPReader for bytes; using RLPReader for RLPReader.RLPItem; @@ -57,10 +55,7 @@ abstract contract EventImporter is IEventImporter, Test { // TODO it is more expensive to do that because of the memory allocation // but Solidity function inlining is not easy to predict. TxLogIndex[] memory txLogIndexes = new TxLogIndex[](1); - txLogIndexes[0] = TxLogIndex({ - txIndex: txIndex, - logIndex: logIndex - }); + txLogIndexes[0] = TxLogIndex({txIndex: txIndex, logIndex: logIndex}); importEvents(bytes32(0), blockHeader, receiptProof, txLogIndexes); } diff --git a/contracts/src/RLPUtils.sol b/contracts/src/RLPUtils.sol index f94cbd3..529a0de 100644 --- a/contracts/src/RLPUtils.sol +++ b/contracts/src/RLPUtils.sol @@ -71,7 +71,11 @@ library RLPUtils { return evmLog; } - function decodeLogFast(RLPReader.RLPItem memory encodedReceipt, uint256 logIndex) internal pure returns (EVMLog memory) { + function decodeLogFast(RLPReader.RLPItem memory encodedReceipt, uint256 logIndex) + internal + pure + returns (EVMLog memory) + { RLPReader.RLPItem[] memory receiptItems = encodedReceipt.toList(); RLPReader.RLPItem[] memory logs = receiptItems[3].toList(); if (logIndex >= logs.length) { diff --git a/contracts/test/MerklePatricia.t.sol b/contracts/test/MerklePatricia.t.sol index 8c664dc..3b17a24 100644 --- a/contracts/test/MerklePatricia.t.sol +++ b/contracts/test/MerklePatricia.t.sol @@ -5,13 +5,13 @@ pragma solidity 0.8.18; -import "forge-std/Test.sol"; +import {Test} from "forge-std/Test.sol"; import {MerklePatricia, StorageValue} from "@solidity-merkle-trees/MerklePatricia.sol"; import {RLPUtils} from "src/RLPUtils.sol"; contract MerklePatriciaTest is Test { - function testVerify() public { + function testVerify() public pure { bytes32 receiptsRoot = 0x7149d37617782b645919054a607d47ffc590e8c8827c616e792b22caf8fb527f; bytes[] memory receiptProof = new bytes[](3); receiptProof[0] = diff --git a/contracts/test/RLPUtilsTests.t.sol b/contracts/test/RLPUtilsTests.t.sol index f4d3504..ba4fba3 100644 --- a/contracts/test/RLPUtilsTests.t.sol +++ b/contracts/test/RLPUtilsTests.t.sol @@ -50,10 +50,10 @@ contract PriceFeedImporterTest is Test { } } - bytes receipt_bytes = hex"f905a40183162ae9b9010000000000000000000000000000000000000000000000000000000100000000000000100000000000000000000000000000000000000200000000000000000000000000000000000000000001002000000000000001000000000000000000000000000000020000000000000000000800000000000000000000000000000001000000000000000000000000000000000000000480000000000000000000400000000000001000000000000200000000000000000008000008000000000000000000000000000000000000000000000000004010000000000000000000000020000000000000000000000000000000000000000000000000000000000001000000f90499f9035c94154bab1fc1d87ff641eed0e9bc0f8a50d880d2b6f842a0f6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451a0000000000000000000000000000000000000000000000000000000000002be00b90300000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000e5b37dc608c73852f9c0f56e30f8d74d89b51c5500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000002c00000000000000000000000f4fc72042f23c3a2b6da6ebfecf0b6e30001538902000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000600bc7bda0000000000000000000000000000000000000000000000000000000600bc8b1c4000000000000000000000000000000000000000000000000000000600c0b0c17000000000000000000000000000000000000000000000000000000600d9b39e5000000000000000000000000000000000000000000000000000000600f2e28c6000000000000000000000000000000000000000000000000000000600f9c1e30000000000000000000000000000000000000000000000000000000600f9c1e3000000000000000000000000000000000000000000000000000000060105dd20a8000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000000000000000000000000000000006013c1415ba000000000000000000000000000000000000000000000000000006014367c00800000000000000000000000000000000000000000000000000000601bf96ddf600000000000000000000000000000000000000000000000000000601bf96ddf6000000000000000000000000000000000000000000000000000006023b6e36e00000000000000000000000000000000000000000000000000000000000000010010f0d0e0c040903080a000b0607020500000000000000000000000000000000f89b94154bab1fc1d87ff641eed0e9bc0f8a50d880d2b6f863a00109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271a0000000000000000000000000000000000000000000000000000000000002be00a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000066452e8df89b94154bab1fc1d87ff641eed0e9bc0f8a50d880d2b6f863a00559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5fa0000000000000000000000000000000000000000000000000000006010e05e000a0000000000000000000000000000000000000000000000000000000000002be00a00000000000000000000000000000000000000000000000000000000066452e8d"; - function testDecodeReceipt() public { - EVMReceipt memory receipt = RLPUtils.decodeReceipt(receipt_bytes.toRlpItem()); + bytes memory receiptBytes = hex"f905a40183162ae9b9010000000000000000000000000000000000000000000000000000000100000000000000100000000000000000000000000000000000000200000000000000000000000000000000000000000001002000000000000001000000000000000000000000000000020000000000000000000800000000000000000000000000000001000000000000000000000000000000000000000480000000000000000000400000000000001000000000000200000000000000000008000008000000000000000000000000000000000000000000000000004010000000000000000000000020000000000000000000000000000000000000000000000000000000000001000000f90499f9035c94154bab1fc1d87ff641eed0e9bc0f8a50d880d2b6f842a0f6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451a0000000000000000000000000000000000000000000000000000000000002be00b90300000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000e5b37dc608c73852f9c0f56e30f8d74d89b51c5500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000002c00000000000000000000000f4fc72042f23c3a2b6da6ebfecf0b6e30001538902000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000600bc7bda0000000000000000000000000000000000000000000000000000000600bc8b1c4000000000000000000000000000000000000000000000000000000600c0b0c17000000000000000000000000000000000000000000000000000000600d9b39e5000000000000000000000000000000000000000000000000000000600f2e28c6000000000000000000000000000000000000000000000000000000600f9c1e30000000000000000000000000000000000000000000000000000000600f9c1e3000000000000000000000000000000000000000000000000000000060105dd20a8000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000000000000000000000000000000006010e05e000000000000000000000000000000000000000000000000000000006013c1415ba000000000000000000000000000000000000000000000000000006014367c00800000000000000000000000000000000000000000000000000000601bf96ddf600000000000000000000000000000000000000000000000000000601bf96ddf6000000000000000000000000000000000000000000000000000006023b6e36e00000000000000000000000000000000000000000000000000000000000000010010f0d0e0c040903080a000b0607020500000000000000000000000000000000f89b94154bab1fc1d87ff641eed0e9bc0f8a50d880d2b6f863a00109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271a0000000000000000000000000000000000000000000000000000000000002be00a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000066452e8df89b94154bab1fc1d87ff641eed0e9bc0f8a50d880d2b6f863a00559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5fa0000000000000000000000000000000000000000000000000000006010e05e000a0000000000000000000000000000000000000000000000000000000000002be00a00000000000000000000000000000000000000000000000000000000066452e8d"; + + EVMReceipt memory receipt = RLPUtils.decodeReceipt(receiptBytes.toRlpItem()); assertEq(receipt.txType, 0); assertEq(receipt.postStateOrStatus, hex"01"); assertEq(receipt.cumulativeGasUsed, 1452777);