Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz committed Sep 4, 2024
1 parent 1b05066 commit 8d0369c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
11 changes: 3 additions & 8 deletions contracts/src/EventImporter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 5 additions & 1 deletion contracts/src/RLPUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/MerklePatricia.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/RLPUtilsTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8d0369c

Please sign in to comment.