From 8c9bd82f7d336631c94ceed7f1ec895ff9057564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deividas=20Kar=C5=BEinauskas?= Date: Wed, 25 Sep 2024 19:17:43 +0300 Subject: [PATCH] Fix Keystone Solidity issues (#14565) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove forge from mock contract * Remove console and fix MaliciousRevertingReceiver for coverage 🤔 --- .../v0.8/keystone/test/KeystoneForwarder_ReportTest.t.sol | 1 - .../v0.8/keystone/test/mocks/MaliciousRevertingReceiver.sol | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/contracts/src/v0.8/keystone/test/KeystoneForwarder_ReportTest.t.sol b/contracts/src/v0.8/keystone/test/KeystoneForwarder_ReportTest.t.sol index 7751aa40a66..c6dc7fca538 100644 --- a/contracts/src/v0.8/keystone/test/KeystoneForwarder_ReportTest.t.sol +++ b/contracts/src/v0.8/keystone/test/KeystoneForwarder_ReportTest.t.sol @@ -6,7 +6,6 @@ import {IRouter} from "../interfaces/IRouter.sol"; import {MaliciousReportReceiver} from "./mocks/MaliciousReportReceiver.sol"; import {MaliciousRevertingReceiver} from "./mocks/MaliciousRevertingReceiver.sol"; import {KeystoneForwarder} from "../KeystoneForwarder.sol"; -import {console} from "forge-std/console.sol"; contract KeystoneForwarder_ReportTest is BaseTest { event MessageReceived(bytes metadata, bytes[] mercuryReports); diff --git a/contracts/src/v0.8/keystone/test/mocks/MaliciousRevertingReceiver.sol b/contracts/src/v0.8/keystone/test/mocks/MaliciousRevertingReceiver.sol index 3efb5d89ccd..d128b4a751e 100644 --- a/contracts/src/v0.8/keystone/test/mocks/MaliciousRevertingReceiver.sol +++ b/contracts/src/v0.8/keystone/test/mocks/MaliciousRevertingReceiver.sol @@ -3,11 +3,10 @@ pragma solidity 0.8.24; import {IERC165} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC165.sol"; import {IReceiver} from "../../interfaces/IReceiver.sol"; -import {Test} from "forge-std/Test.sol"; /// A malicious receiver that uses max allowed for ERC165 checks and consumes all gas in `onReport()` /// Causes parent Forwarder contract to revert if it doesn't handle gas tracking accurately -contract MaliciousRevertingReceiver is IReceiver, IERC165, Test { +contract MaliciousRevertingReceiver is IReceiver, IERC165 { function onReport(bytes calldata, bytes calldata) external view override { // consumes about 63/64 of all gas available uint256 targetGasRemaining = 200; @@ -16,8 +15,7 @@ contract MaliciousRevertingReceiver is IReceiver, IERC165, Test { function supportsInterface(bytes4 interfaceId) public pure override returns (bool) { // Consume up to the maximum amount of gas that can be consumed in this check - // This loop consumes roughly 29_000 gas - for (uint256 i = 0; i < 670; i++) {} + for (uint256 i = 0; i < 500; i++) {} return interfaceId == type(IReceiver).interfaceId || interfaceId == type(IERC165).interfaceId; }