From 42c5165204bba5fbdaba6244e6e40ce5cc219d0e Mon Sep 17 00:00:00 2001 From: Prateek Gupta Date: Thu, 6 Jun 2024 02:34:26 +0530 Subject: [PATCH] Remove transient storage and downgrade solidity version (#75) * Remove transient storage and downgrade solidity version * remove evm version --- foundry.toml | 1 - src/proposals/Proposal.sol | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/foundry.toml b/foundry.toml index c8ab2c6..41042af 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,7 +6,6 @@ auto_detect_solc = true fs_permissions = [{ access = "read", path = "./"}] optimizer = true optimizer_runs = 200 -evm_version="Cancun" [rpc_endpoints] localhost = "http://127.0.0.1:8545" diff --git a/src/proposals/Proposal.sol b/src/proposals/Proposal.sol index d6cb3e1..6a69b52 100644 --- a/src/proposals/Proposal.sol +++ b/src/proposals/Proposal.sol @@ -1,4 +1,4 @@ -pragma solidity =0.8.25; +pragma solidity ^0.8.0; import {Test} from "@forge-std/Test.sol"; import {VmSafe} from "@forge-std/Vm.sol"; @@ -205,19 +205,20 @@ abstract contract Proposal is Test, Script, IProposal { uint256 value, bytes memory data ) internal virtual { - // uses transition storage to check for duplicate actions - bytes32 actionHash = keccak256(abi.encodePacked(target, value, data)); - - uint256 found; - - assembly { - found := tload(actionHash) - } - - require(found == 0, "Duplicated action found"); + uint256 actionsLength = actions.length; + for (uint256 i = 0; i < actionsLength; i++) { + // Check if the target, arguments and value matches with other exciting actions. + bool isDuplicateTarget = actions[i].target == target; + bool isDuplicateArguments = keccak256(actions[i].arguments) == + keccak256(data); + bool isDuplicateValue = actions[i].value == value; - assembly { - tstore(actionHash, 1) + require( + !(isDuplicateTarget && + isDuplicateArguments && + isDuplicateValue), + "Duplicated action found" + ); } }