From c2aaa37d924e44ee89f2172adbeef753a1f03526 Mon Sep 17 00:00:00 2001 From: Geoffrey Hayes Date: Wed, 11 Sep 2024 17:14:49 -0700 Subject: [PATCH 1/3] TStore for Transients This patch bumps us up to 0.8.27 and cancun and starts using `tstore` and `tload` for transient reads and writes. Note: we still clear values mostly to ensure that post-nested calls the script will see 0 instead of the nested's own value. Note: I have not taken a stab at understanding `ALLOW_CALLBACKS` and how that should function. Patches: * Try to build allow callbacks to ensure it still works as expected, though it can't be observed now. --- foundry.toml | 4 +- script/DeployCodeJarFactory.s.sol | 2 +- script/DeployQuarkWalletFactory.s.sol | 2 +- src/codejar/foundry.toml | 4 +- src/codejar/src/CodeJar.sol | 2 +- src/codejar/src/CodeJarFactory.sol | 2 +- src/quark-core-scripts/foundry.toml | 4 +- .../src/ConditionalMulticall.sol | 2 +- src/quark-core-scripts/src/Ethcall.sol | 2 +- src/quark-core-scripts/src/Multicall.sol | 2 +- src/quark-core-scripts/src/Paycall.sol | 2 +- src/quark-core-scripts/src/Quotecall.sol | 2 +- .../src/UniswapFlashLoan.sol | 2 +- .../src/UniswapFlashSwapExactOut.sol | 2 +- .../src/lib/ConditionalChecker.sol | 2 +- .../src/lib/UniswapFactoryAddress.sol | 2 +- .../uniswap_v3_periphery/PoolAddress.sol | 2 +- src/quark-core/foundry.toml | 4 +- src/quark-core/src/QuarkNonceManager.sol | 2 +- src/quark-core/src/QuarkScript.sol | 21 ++++---- src/quark-core/src/QuarkWallet.sol | 32 +++++------ src/quark-core/src/QuarkWalletStandalone.sol | 2 +- .../src/interfaces/IHasSignerExecutor.sol | 2 +- .../src/interfaces/IQuarkWallet.sol | 2 +- .../src/periphery/BatchExecutor.sol | 2 +- src/quark-factory/foundry.toml | 4 +- src/quark-factory/src/QuarkFactory.sol | 2 +- src/quark-proxy/foundry.toml | 4 +- src/quark-proxy/src/QuarkMinimalProxy.sol | 2 +- .../src/QuarkWalletProxyFactory.sol | 2 +- test/ReplayableTransactions.t.sol | 2 +- test/codejar/CodeJar.t.sol | 2 +- test/lib/AllowCallbacks.sol | 34 ++++++++---- test/lib/CallbackFromCounter.sol | 2 +- test/lib/CallcodeReentrancy.sol | 2 +- test/lib/CancelOtherScript.sol | 2 +- test/lib/ConstructorReverter.sol | 2 +- test/lib/Counter.sol | 2 +- test/lib/CounterScript.sol | 2 +- test/lib/DeFiScripts.sol | 2 +- test/lib/EIP1271Signer.sol | 2 +- test/lib/EmptyCode.sol | 2 +- test/lib/EvilReceiver.sol | 2 +- test/lib/ExecuteOnBehalf.sol | 2 +- test/lib/ExecuteOtherOperation.sol | 2 +- test/lib/ExecuteWithRequirements.sol | 2 +- test/lib/GetMessageDetails.sol | 2 +- test/lib/Incrementer.sol | 2 +- test/lib/Logger.sol | 2 +- test/lib/MaxCounterScript.sol | 2 +- test/lib/Mememe.sol | 2 +- test/lib/Noncer.sol | 2 +- test/lib/Permit2Helper.sol | 2 +- test/lib/PrecompileCaller.sol | 2 +- test/lib/QuarkOperationHelper.sol | 2 +- test/lib/RecurringPurchase.sol | 2 +- test/lib/Redeployer.sol | 2 +- test/lib/ReentrantTransfer.sol | 2 +- test/lib/Reverts.sol | 2 +- test/lib/SignatureHelper.sol | 2 +- test/lib/TickCounter.sol | 2 +- test/lib/Transfer.sol | 2 +- test/lib/VictimERC777.sol | 2 +- test/lib/Wacky.sol | 2 +- test/lib/YulHelper.sol | 2 +- .../ConditionalMulticall.t.sol | 2 +- test/quark-core-scripts/Ethcall.t.sol | 2 +- test/quark-core-scripts/Multicall.t.sol | 2 +- test/quark-core-scripts/Paycall.t.sol | 2 +- test/quark-core-scripts/Quotecall.t.sol | 2 +- .../quark-core-scripts/UniswapFlashLoan.t.sol | 2 +- .../UniswapFlashSwapExactOut.t.sol | 2 +- test/quark-core-scripts/interfaces/IComet.sol | 2 +- .../interfaces/ISwapRouter.sol | 2 +- test/quark-core/Callbacks.t.sol | 54 ++++++++++++++----- test/quark-core/EIP1271.t.sol | 2 +- test/quark-core/EIP712.t.sol | 2 +- test/quark-core/Executor.t.sol | 2 +- test/quark-core/Noncer.t.sol | 2 +- test/quark-core/QuarkNonceManager.t.sol | 2 +- test/quark-core/QuarkWallet.t.sol | 2 +- test/quark-core/Reverts.t.sol | 2 +- test/quark-core/isValidSignature.t.sol | 2 +- test/quark-core/periphery/BatchExecutor.t.sol | 2 +- test/quark-factory/QuarkFactory.t.sol | 2 +- test/quark-proxy/QuarkMinimalProxy.t.sol | 2 +- .../quark-proxy/QuarkWalletProxyFactory.t.sol | 2 +- 87 files changed, 176 insertions(+), 143 deletions(-) diff --git a/foundry.toml b/foundry.toml index b18fae7d..9cd9f8aa 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,6 +1,6 @@ [profile.default] -solc = "0.8.23" -evm_version = "paris" +solc = "0.8.27" +evm_version = "cancun" libs = [ "./lib" ] diff --git a/script/DeployCodeJarFactory.s.sol b/script/DeployCodeJarFactory.s.sol index 8059e462..0b6c9cdf 100644 --- a/script/DeployCodeJarFactory.s.sol +++ b/script/DeployCodeJarFactory.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Script.sol"; import "forge-std/console.sol"; diff --git a/script/DeployQuarkWalletFactory.s.sol b/script/DeployQuarkWalletFactory.s.sol index a8769733..56f3f342 100644 --- a/script/DeployQuarkWalletFactory.s.sol +++ b/script/DeployQuarkWalletFactory.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Script.sol"; import "forge-std/console.sol"; diff --git a/src/codejar/foundry.toml b/src/codejar/foundry.toml index 663d458c..04443a55 100644 --- a/src/codejar/foundry.toml +++ b/src/codejar/foundry.toml @@ -1,6 +1,6 @@ [profile.default] -solc = "0.8.23" -evm_version = "paris" +solc = "0.8.27" +evm_version = "cancun" libs = [ "../../lib" ] diff --git a/src/codejar/src/CodeJar.sol b/src/codejar/src/CodeJar.sol index 6866311e..fb8441c1 100644 --- a/src/codejar/src/CodeJar.sol +++ b/src/codejar/src/CodeJar.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; /** * @title Code Jar diff --git a/src/codejar/src/CodeJarFactory.sol b/src/codejar/src/CodeJarFactory.sol index cedd54f8..91abf544 100644 --- a/src/codejar/src/CodeJarFactory.sol +++ b/src/codejar/src/CodeJarFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {CodeJar} from "codejar/src/CodeJar.sol"; diff --git a/src/quark-core-scripts/foundry.toml b/src/quark-core-scripts/foundry.toml index 455503d4..5d8adf3f 100644 --- a/src/quark-core-scripts/foundry.toml +++ b/src/quark-core-scripts/foundry.toml @@ -1,6 +1,6 @@ [profile.default] -solc = "0.8.23" -evm_version = "paris" +solc = "0.8.27" +evm_version = "cancun" libs = [ "../../lib" ] diff --git a/src/quark-core-scripts/src/ConditionalMulticall.sol b/src/quark-core-scripts/src/ConditionalMulticall.sol index fa8ab848..612e6062 100644 --- a/src/quark-core-scripts/src/ConditionalMulticall.sol +++ b/src/quark-core-scripts/src/ConditionalMulticall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core-scripts/src/lib/ConditionalChecker.sol"; diff --git a/src/quark-core-scripts/src/Ethcall.sol b/src/quark-core-scripts/src/Ethcall.sol index 77402537..017e7a68 100644 --- a/src/quark-core-scripts/src/Ethcall.sol +++ b/src/quark-core-scripts/src/Ethcall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; /** * @title Ethcall Core Script diff --git a/src/quark-core-scripts/src/Multicall.sol b/src/quark-core-scripts/src/Multicall.sol index b7759381..479ef7ae 100644 --- a/src/quark-core-scripts/src/Multicall.sol +++ b/src/quark-core-scripts/src/Multicall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; /** * @title Multicall Core Script diff --git a/src/quark-core-scripts/src/Paycall.sol b/src/quark-core-scripts/src/Paycall.sol index aebd4ff0..01112d09 100644 --- a/src/quark-core-scripts/src/Paycall.sol +++ b/src/quark-core-scripts/src/Paycall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core-scripts/src/vendor/chainlink/AggregatorV3Interface.sol"; import "openzeppelin/token/ERC20/utils/SafeERC20.sol"; diff --git a/src/quark-core-scripts/src/Quotecall.sol b/src/quark-core-scripts/src/Quotecall.sol index b980b882..ce292ddb 100644 --- a/src/quark-core-scripts/src/Quotecall.sol +++ b/src/quark-core-scripts/src/Quotecall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core-scripts/src/vendor/chainlink/AggregatorV3Interface.sol"; import "openzeppelin/token/ERC20/utils/SafeERC20.sol"; diff --git a/src/quark-core-scripts/src/UniswapFlashLoan.sol b/src/quark-core-scripts/src/UniswapFlashLoan.sol index 5025d7a8..817b9281 100644 --- a/src/quark-core-scripts/src/UniswapFlashLoan.sol +++ b/src/quark-core-scripts/src/UniswapFlashLoan.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "openzeppelin/token/ERC20/utils/SafeERC20.sol"; import "v3-core/contracts/interfaces/IUniswapV3Pool.sol"; diff --git a/src/quark-core-scripts/src/UniswapFlashSwapExactOut.sol b/src/quark-core-scripts/src/UniswapFlashSwapExactOut.sol index b65aaf7d..2c256a97 100644 --- a/src/quark-core-scripts/src/UniswapFlashSwapExactOut.sol +++ b/src/quark-core-scripts/src/UniswapFlashSwapExactOut.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "openzeppelin/token/ERC20/utils/SafeERC20.sol"; import "v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol"; diff --git a/src/quark-core-scripts/src/lib/ConditionalChecker.sol b/src/quark-core-scripts/src/lib/ConditionalChecker.sol index b8d92b36..1a0ceee0 100644 --- a/src/quark-core-scripts/src/lib/ConditionalChecker.sol +++ b/src/quark-core-scripts/src/lib/ConditionalChecker.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; library ConditionalChecker { enum CheckType { diff --git a/src/quark-core-scripts/src/lib/UniswapFactoryAddress.sol b/src/quark-core-scripts/src/lib/UniswapFactoryAddress.sol index 82d6b7b2..d154a4b7 100644 --- a/src/quark-core-scripts/src/lib/UniswapFactoryAddress.sol +++ b/src/quark-core-scripts/src/lib/UniswapFactoryAddress.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; library UniswapFactoryAddress { // Reference: https://docs.uniswap.org/contracts/v3/reference/deployments diff --git a/src/quark-core-scripts/src/vendor/uniswap_v3_periphery/PoolAddress.sol b/src/quark-core-scripts/src/vendor/uniswap_v3_periphery/PoolAddress.sol index 73eb80aa..1e3435af 100644 --- a/src/quark-core-scripts/src/vendor/uniswap_v3_periphery/PoolAddress.sol +++ b/src/quark-core-scripts/src/vendor/uniswap_v3_periphery/PoolAddress.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.23; +pragma solidity 0.8.27; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { diff --git a/src/quark-core/foundry.toml b/src/quark-core/foundry.toml index 7fd17720..09a39c63 100644 --- a/src/quark-core/foundry.toml +++ b/src/quark-core/foundry.toml @@ -1,6 +1,6 @@ [profile.default] -solc = "0.8.23" -evm_version = "paris" +solc = "0.8.27" +evm_version = "cancun" libs = [ "../../lib" ] diff --git a/src/quark-core/src/QuarkNonceManager.sol b/src/quark-core/src/QuarkNonceManager.sol index 4bc71851..5f4d938d 100644 --- a/src/quark-core/src/QuarkNonceManager.sol +++ b/src/quark-core/src/QuarkNonceManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {IQuarkWallet} from "quark-core/src/interfaces/IQuarkWallet.sol"; diff --git a/src/quark-core/src/QuarkScript.sol b/src/quark-core/src/QuarkScript.sol index 7a1537a2..4be68f17 100644 --- a/src/quark-core/src/QuarkScript.sol +++ b/src/quark-core/src/QuarkScript.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {QuarkWallet, QuarkWalletMetadata, IHasSignerExecutor, IQuarkWallet} from "quark-core/src/QuarkWallet.sol"; import {QuarkNonceManager, QuarkNonceManagerMetadata} from "quark-core/src/QuarkNonceManager.sol"; @@ -23,21 +23,20 @@ abstract contract QuarkScript { modifier nonReentrant() { bytes32 slot = REENTRANCY_FLAG_SLOT; bytes32 flag; - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 assembly { - flag := sload(slot) + flag := tload(slot) } if (flag == bytes32(uint256(1))) { revert ReentrantCall(); } assembly { - sstore(slot, 1) + tstore(slot, 1) } _; assembly { - sstore(slot, 0) + tstore(slot, 0) } } @@ -78,17 +77,15 @@ abstract contract QuarkScript { bytes32 callbackSlot = QuarkWalletMetadata.CALLBACK_SLOT; bytes32 activeScriptSlot = QuarkWalletMetadata.ACTIVE_SCRIPT_SLOT; assembly { - // TODO: Move to TLOAD/TSTORE after updating Solidity version to >=0.8.24 - let activeScript := sload(activeScriptSlot) - sstore(callbackSlot, activeScript) + let activeScript := tload(activeScriptSlot) + tstore(callbackSlot, activeScript) } } function clearCallback() internal { bytes32 callbackSlot = QuarkWalletMetadata.CALLBACK_SLOT; assembly { - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(callbackSlot, 0) + tstore(callbackSlot, 0) } } @@ -141,7 +138,7 @@ abstract contract QuarkScript { bytes32 activeNonceSlot = QuarkWalletMetadata.ACTIVE_NONCE_SLOT; bytes32 value; assembly { - value := sload(activeNonceSlot) + value := tload(activeNonceSlot) } return value; @@ -152,7 +149,7 @@ abstract contract QuarkScript { bytes32 activeSubmissionTokenSlot = QuarkWalletMetadata.ACTIVE_SUBMISSION_TOKEN_SLOT; bytes32 value; assembly { - value := sload(activeSubmissionTokenSlot) + value := tload(activeSubmissionTokenSlot) } return value; } diff --git a/src/quark-core/src/QuarkWallet.sol b/src/quark-core/src/QuarkWallet.sol index 85134866..9af81514 100644 --- a/src/quark-core/src/QuarkWallet.sol +++ b/src/quark-core/src/QuarkWallet.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {ECDSA} from "openzeppelin/utils/cryptography/ECDSA.sol"; import {IERC1271} from "openzeppelin/interfaces/IERC1271.sol"; @@ -482,31 +482,28 @@ contract QuarkWallet is IERC1271 { assembly { // TODO: TSTORE the callback slot to 0 - // Store the active script - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(activeScriptSlot, scriptAddress) + // Transiently store the active script + tstore(activeScriptSlot, scriptAddress) - // Store the active nonce - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(activeNonceSlot, nonce) + // Transiently store the active nonce + tstore(activeNonceSlot, nonce) - // Store the active submission token - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(activeSubmissionTokenSlot, submissionToken) + // Transiently store the active submission token + tstore(activeSubmissionTokenSlot, submissionToken) // Note: CALLCODE is used to set the QuarkWallet as the `msg.sender` success := callcode(gas(), scriptAddress, /* value */ 0, add(scriptCalldata, 0x20), scriptCalldataLen, 0x0, 0) returnSize := returndatasize() - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(activeScriptSlot, 0) + // Transiently clear the active script + tstore(activeScriptSlot, 0) - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(activeNonceSlot, 0) + // Transiently clear the active nonce + tstore(activeNonceSlot, 0) - // TODO: Move to TSTORE after updating Solidity version to >=0.8.24 - sstore(activeSubmissionTokenSlot, 0) + // Transiently clear the active submission token + tstore(activeSubmissionTokenSlot, 0) } bytes memory returnData = new bytes(returnSize); @@ -531,8 +528,7 @@ contract QuarkWallet is IERC1271 { bytes32 callbackSlot = CALLBACK_SLOT; address callback; assembly { - // TODO: Move to TLOAD after updating Solidity version to >=0.8.24 - callback := sload(callbackSlot) + callback := tload(callbackSlot) } if (callback != address(0)) { (bool success, bytes memory result) = callback.delegatecall(data); diff --git a/src/quark-core/src/QuarkWalletStandalone.sol b/src/quark-core/src/QuarkWalletStandalone.sol index ff9be9f4..e48bdfd1 100644 --- a/src/quark-core/src/QuarkWalletStandalone.sol +++ b/src/quark-core/src/QuarkWalletStandalone.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {CodeJar} from "codejar/src/CodeJar.sol"; diff --git a/src/quark-core/src/interfaces/IHasSignerExecutor.sol b/src/quark-core/src/interfaces/IHasSignerExecutor.sol index 0b3fbc23..c4e6165d 100644 --- a/src/quark-core/src/interfaces/IHasSignerExecutor.sol +++ b/src/quark-core/src/interfaces/IHasSignerExecutor.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; /** * @title Has Signer and Executor interface diff --git a/src/quark-core/src/interfaces/IQuarkWallet.sol b/src/quark-core/src/interfaces/IQuarkWallet.sol index 6566f65f..7758f951 100644 --- a/src/quark-core/src/interfaces/IQuarkWallet.sol +++ b/src/quark-core/src/interfaces/IQuarkWallet.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; /** * @title Quark Wallet interface diff --git a/src/quark-core/src/periphery/BatchExecutor.sol b/src/quark-core/src/periphery/BatchExecutor.sol index 78d1de5c..07a5ceb9 100644 --- a/src/quark-core/src/periphery/BatchExecutor.sol +++ b/src/quark-core/src/periphery/BatchExecutor.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {QuarkWallet} from "quark-core/src/QuarkWallet.sol"; diff --git a/src/quark-factory/foundry.toml b/src/quark-factory/foundry.toml index f64bc2f7..a9abd330 100644 --- a/src/quark-factory/foundry.toml +++ b/src/quark-factory/foundry.toml @@ -1,6 +1,6 @@ [profile.default] -solc = "0.8.23" -evm_version = "paris" +solc = "0.8.27" +evm_version = "cancun" libs = [ "../../lib" ] diff --git a/src/quark-factory/src/QuarkFactory.sol b/src/quark-factory/src/QuarkFactory.sol index 257f5539..9eefcbb3 100644 --- a/src/quark-factory/src/QuarkFactory.sol +++ b/src/quark-factory/src/QuarkFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {CodeJar} from "codejar/src/CodeJar.sol"; import {QuarkWallet} from "quark-core/src/QuarkWallet.sol"; diff --git a/src/quark-proxy/foundry.toml b/src/quark-proxy/foundry.toml index 5317ab6a..15c1aff9 100644 --- a/src/quark-proxy/foundry.toml +++ b/src/quark-proxy/foundry.toml @@ -1,6 +1,6 @@ [profile.default] -solc = "0.8.23" -evm_version = "paris" +solc = "0.8.27" +evm_version = "cancun" libs = [ "../../lib" ] diff --git a/src/quark-proxy/src/QuarkMinimalProxy.sol b/src/quark-proxy/src/QuarkMinimalProxy.sol index 7371a407..e1e89888 100644 --- a/src/quark-proxy/src/QuarkMinimalProxy.sol +++ b/src/quark-proxy/src/QuarkMinimalProxy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {IHasSignerExecutor} from "quark-core/src/interfaces/IHasSignerExecutor.sol"; diff --git a/src/quark-proxy/src/QuarkWalletProxyFactory.sol b/src/quark-proxy/src/QuarkWalletProxyFactory.sol index 66eadcf4..415da743 100644 --- a/src/quark-proxy/src/QuarkWalletProxyFactory.sol +++ b/src/quark-proxy/src/QuarkWalletProxyFactory.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {QuarkWallet, QuarkWalletMetadata} from "quark-core/src/QuarkWallet.sol"; diff --git a/test/ReplayableTransactions.t.sol b/test/ReplayableTransactions.t.sol index aca2e57e..450919dd 100644 --- a/test/ReplayableTransactions.t.sol +++ b/test/ReplayableTransactions.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/codejar/CodeJar.t.sol b/test/codejar/CodeJar.t.sol index 802dc91b..486dc9a6 100644 --- a/test/codejar/CodeJar.t.sol +++ b/test/codejar/CodeJar.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/lib/AllowCallbacks.sol b/test/lib/AllowCallbacks.sol index 7fe91c70..50a707b4 100644 --- a/test/lib/AllowCallbacks.sol +++ b/test/lib/AllowCallbacks.sol @@ -1,24 +1,36 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkScript.sol"; import "quark-core/src/QuarkWallet.sol"; -contract AllowCallbacks is QuarkScript { - function run(address callbackAddress) public { - QuarkWallet self = QuarkWallet(payable(address(this))); - bytes32 CALLBACK_SLOT = self.CALLBACK_SLOT(); - bytes32 data = bytes32(uint256(uint160(callbackAddress))); - assembly { - sstore(CALLBACK_SLOT, data) - } +interface IComeback { + function request() external returns (uint256); +} + +contract Comebacker { + function comeback() public returns (uint256) { + return IComeback(msg.sender).request() + 1; } +} - function allowCallbackFun() public { +contract AllowCallbacks is QuarkScript { + function run() public returns (uint256) { allowCallback(); + return new Comebacker().comeback() * 2; } - function clearCallbackFun() public { + function runAllowThenClear() public returns (uint256) { + allowCallback(); clearCallback(); + return new Comebacker().comeback() * 2; + } + + function runWithoutAllow() public returns (uint256) { + return new Comebacker().comeback() * 2; + } + + function request() external view returns (uint256) { + return 100 + getActiveReplayCount(); } } diff --git a/test/lib/CallbackFromCounter.sol b/test/lib/CallbackFromCounter.sol index 731bfdac..b81275ed 100644 --- a/test/lib/CallbackFromCounter.sol +++ b/test/lib/CallbackFromCounter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "test/lib/Counter.sol"; import "quark-core/src/QuarkScript.sol"; diff --git a/test/lib/CallcodeReentrancy.sol b/test/lib/CallcodeReentrancy.sol index 594718c3..93468649 100644 --- a/test/lib/CallcodeReentrancy.sol +++ b/test/lib/CallcodeReentrancy.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/console.sol"; diff --git a/test/lib/CancelOtherScript.sol b/test/lib/CancelOtherScript.sol index 9e09967a..d9e62ec0 100644 --- a/test/lib/CancelOtherScript.sol +++ b/test/lib/CancelOtherScript.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkWallet.sol"; import "quark-core/src/QuarkScript.sol"; diff --git a/test/lib/ConstructorReverter.sol b/test/lib/ConstructorReverter.sol index 9ed871b2..651856a8 100644 --- a/test/lib/ConstructorReverter.sol +++ b/test/lib/ConstructorReverter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract ConstructorReverter { error Test(uint256); diff --git a/test/lib/Counter.sol b/test/lib/Counter.sol index 65a47172..d9b02cb9 100644 --- a/test/lib/Counter.sol +++ b/test/lib/Counter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; interface HasCallback { function callback() external payable; diff --git a/test/lib/CounterScript.sol b/test/lib/CounterScript.sol index 773b1433..deca9d4f 100644 --- a/test/lib/CounterScript.sol +++ b/test/lib/CounterScript.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "test/lib/Counter.sol"; diff --git a/test/lib/DeFiScripts.sol b/test/lib/DeFiScripts.sol index 3e1fd1e6..6ef396d9 100644 --- a/test/lib/DeFiScripts.sol +++ b/test/lib/DeFiScripts.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol"; diff --git a/test/lib/EIP1271Signer.sol b/test/lib/EIP1271Signer.sol index c8290e58..d416d5ce 100644 --- a/test/lib/EIP1271Signer.sol +++ b/test/lib/EIP1271Signer.sol @@ -1,4 +1,4 @@ -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract EIP1271Signer { bytes4 internal constant EIP_1271_MAGIC_VALUE = 0x1626ba7e; diff --git a/test/lib/EmptyCode.sol b/test/lib/EmptyCode.sol index c27562ca..c84624c0 100644 --- a/test/lib/EmptyCode.sol +++ b/test/lib/EmptyCode.sol @@ -1,4 +1,4 @@ -pragma solidity "0.8.23"; +pragma solidity "0.8.27"; contract EmptyCode { // NOTE: force the solidity compiler to produce empty code when this is deployed diff --git a/test/lib/EvilReceiver.sol b/test/lib/EvilReceiver.sol index 65b488e1..24d4cc1b 100644 --- a/test/lib/EvilReceiver.sol +++ b/test/lib/EvilReceiver.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkWallet.sol"; import "quark-core/src/QuarkScript.sol"; diff --git a/test/lib/ExecuteOnBehalf.sol b/test/lib/ExecuteOnBehalf.sol index bfec2cc7..1b1baa61 100644 --- a/test/lib/ExecuteOnBehalf.sol +++ b/test/lib/ExecuteOnBehalf.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkWallet.sol"; diff --git a/test/lib/ExecuteOtherOperation.sol b/test/lib/ExecuteOtherOperation.sol index 62fcf96c..6e853230 100644 --- a/test/lib/ExecuteOtherOperation.sol +++ b/test/lib/ExecuteOtherOperation.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkWallet.sol"; import "quark-core/src/QuarkScript.sol"; diff --git a/test/lib/ExecuteWithRequirements.sol b/test/lib/ExecuteWithRequirements.sol index 2047bed3..ed5465f9 100644 --- a/test/lib/ExecuteWithRequirements.sol +++ b/test/lib/ExecuteWithRequirements.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkWallet.sol"; import "quark-core/src/QuarkNonceManager.sol"; diff --git a/test/lib/GetMessageDetails.sol b/test/lib/GetMessageDetails.sol index baf483ba..10412d26 100644 --- a/test/lib/GetMessageDetails.sol +++ b/test/lib/GetMessageDetails.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract GetMessageDetails { function getMsgSenderAndValue() external payable returns (address, uint256) { diff --git a/test/lib/Incrementer.sol b/test/lib/Incrementer.sol index ba8a2ba4..7bd62340 100644 --- a/test/lib/Incrementer.sol +++ b/test/lib/Incrementer.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "test/lib/Counter.sol"; diff --git a/test/lib/Logger.sol b/test/lib/Logger.sol index 7522ec48..02f8cb90 100644 --- a/test/lib/Logger.sol +++ b/test/lib/Logger.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract Logger { event Ping(uint256); diff --git a/test/lib/MaxCounterScript.sol b/test/lib/MaxCounterScript.sol index 59a8f9ba..ff31ae3d 100644 --- a/test/lib/MaxCounterScript.sol +++ b/test/lib/MaxCounterScript.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "quark-core/src/QuarkScript.sol"; import "test/lib/Counter.sol"; diff --git a/test/lib/Mememe.sol b/test/lib/Mememe.sol index 50afd81a..a42e9c7f 100644 --- a/test/lib/Mememe.sol +++ b/test/lib/Mememe.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract Mememe { address public immutable me; diff --git a/test/lib/Noncer.sol b/test/lib/Noncer.sol index 51afaaad..fb8c1feb 100644 --- a/test/lib/Noncer.sol +++ b/test/lib/Noncer.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {QuarkScript} from "quark-core/src/QuarkScript.sol"; import {QuarkWallet} from "quark-core/src/QuarkWallet.sol"; diff --git a/test/lib/Permit2Helper.sol b/test/lib/Permit2Helper.sol index ac3f88d2..9fb952de 100644 --- a/test/lib/Permit2Helper.sol +++ b/test/lib/Permit2Helper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; interface Permit2 { function permit(address owner, Permit2Helper.PermitSingle memory permitSingle, bytes calldata signature) external; diff --git a/test/lib/PrecompileCaller.sol b/test/lib/PrecompileCaller.sol index d386ef37..7b755c1c 100644 --- a/test/lib/PrecompileCaller.sol +++ b/test/lib/PrecompileCaller.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract PrecompileCaller { // 0x01 diff --git a/test/lib/QuarkOperationHelper.sol b/test/lib/QuarkOperationHelper.sol index dfa4c586..6e2bbf26 100644 --- a/test/lib/QuarkOperationHelper.sol +++ b/test/lib/QuarkOperationHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "quark-core/src/QuarkWallet.sol"; diff --git a/test/lib/RecurringPurchase.sol b/test/lib/RecurringPurchase.sol index 8d2cd9df..591cdde5 100644 --- a/test/lib/RecurringPurchase.sol +++ b/test/lib/RecurringPurchase.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol"; diff --git a/test/lib/Redeployer.sol b/test/lib/Redeployer.sol index 06ef26cc..fde64e80 100644 --- a/test/lib/Redeployer.sol +++ b/test/lib/Redeployer.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; interface CodeJar { function saveCode(bytes memory code) external returns (address); diff --git a/test/lib/ReentrantTransfer.sol b/test/lib/ReentrantTransfer.sol index 011abaf2..af5908fa 100644 --- a/test/lib/ReentrantTransfer.sol +++ b/test/lib/ReentrantTransfer.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol"; diff --git a/test/lib/Reverts.sol b/test/lib/Reverts.sol index 0cebf8c6..2b097fd1 100644 --- a/test/lib/Reverts.sol +++ b/test/lib/Reverts.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {CodeJar} from "codejar/src/CodeJar.sol"; diff --git a/test/lib/SignatureHelper.sol b/test/lib/SignatureHelper.sol index 9a7f27b3..070e426e 100644 --- a/test/lib/SignatureHelper.sol +++ b/test/lib/SignatureHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "quark-core/src/QuarkWallet.sol"; diff --git a/test/lib/TickCounter.sol b/test/lib/TickCounter.sol index 2c307690..a86b0a87 100644 --- a/test/lib/TickCounter.sol +++ b/test/lib/TickCounter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract TickCounter { uint256 public immutable base; diff --git a/test/lib/Transfer.sol b/test/lib/Transfer.sol index 157ad062..f3146c70 100644 --- a/test/lib/Transfer.sol +++ b/test/lib/Transfer.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol"; diff --git a/test/lib/VictimERC777.sol b/test/lib/VictimERC777.sol index c2622266..a3cb131c 100644 --- a/test/lib/VictimERC777.sol +++ b/test/lib/VictimERC777.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "openzeppelin/token/ERC777/ERC777.sol"; import "openzeppelin/token/ERC20/ERC20.sol"; diff --git a/test/lib/Wacky.sol b/test/lib/Wacky.sol index 86423272..87c89a57 100644 --- a/test/lib/Wacky.sol +++ b/test/lib/Wacky.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; contract WackyBeacon { bytes public code; diff --git a/test/lib/YulHelper.sol b/test/lib/YulHelper.sol index 6c912f53..39626a34 100644 --- a/test/lib/YulHelper.sol +++ b/test/lib/YulHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; diff --git a/test/quark-core-scripts/ConditionalMulticall.t.sol b/test/quark-core-scripts/ConditionalMulticall.t.sol index e9087936..59aa206c 100644 --- a/test/quark-core-scripts/ConditionalMulticall.t.sol +++ b/test/quark-core-scripts/ConditionalMulticall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/Ethcall.t.sol b/test/quark-core-scripts/Ethcall.t.sol index 66e15d48..53fa6d01 100644 --- a/test/quark-core-scripts/Ethcall.t.sol +++ b/test/quark-core-scripts/Ethcall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/Multicall.t.sol b/test/quark-core-scripts/Multicall.t.sol index ac4e0b17..3218a7cd 100644 --- a/test/quark-core-scripts/Multicall.t.sol +++ b/test/quark-core-scripts/Multicall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/Paycall.t.sol b/test/quark-core-scripts/Paycall.t.sol index c15a4f0b..2276c4fc 100644 --- a/test/quark-core-scripts/Paycall.t.sol +++ b/test/quark-core-scripts/Paycall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/Quotecall.t.sol b/test/quark-core-scripts/Quotecall.t.sol index 4f80fb4c..4f87e0f4 100644 --- a/test/quark-core-scripts/Quotecall.t.sol +++ b/test/quark-core-scripts/Quotecall.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/UniswapFlashLoan.t.sol b/test/quark-core-scripts/UniswapFlashLoan.t.sol index 13f13ff6..ad92a269 100644 --- a/test/quark-core-scripts/UniswapFlashLoan.t.sol +++ b/test/quark-core-scripts/UniswapFlashLoan.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/UniswapFlashSwapExactOut.t.sol b/test/quark-core-scripts/UniswapFlashSwapExactOut.t.sol index 088a8cdd..f19d7a93 100644 --- a/test/quark-core-scripts/UniswapFlashSwapExactOut.t.sol +++ b/test/quark-core-scripts/UniswapFlashSwapExactOut.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core-scripts/interfaces/IComet.sol b/test/quark-core-scripts/interfaces/IComet.sol index babfdc9c..545a4b1c 100644 --- a/test/quark-core-scripts/interfaces/IComet.sol +++ b/test/quark-core-scripts/interfaces/IComet.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; interface IComet { function getAssetInfo(uint8 i) external view returns (AssetInfo memory); diff --git a/test/quark-core-scripts/interfaces/ISwapRouter.sol b/test/quark-core-scripts/interfaces/ISwapRouter.sol index 101ccd70..5b569bcb 100644 --- a/test/quark-core-scripts/interfaces/ISwapRouter.sol +++ b/test/quark-core-scripts/interfaces/ISwapRouter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; // Router interfaces thats only used in test for swapping interface ISwapRouter { diff --git a/test/quark-core/Callbacks.t.sol b/test/quark-core/Callbacks.t.sol index 9f48206b..db73ab25 100644 --- a/test/quark-core/Callbacks.t.sol +++ b/test/quark-core/Callbacks.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/console.sol"; @@ -173,33 +173,61 @@ contract CallbacksTest is Test { assertEq(counter.number(), 2); } - function testClearCallback() public { + function testSimpleCallback() public { // gas: do not meter set-up vm.pauseGasMetering(); - bytes32 callbackSlot = aliceWallet.CALLBACK_SLOT(); bytes memory allowCallbacks = new YulHelper().getCode("AllowCallbacks.sol/AllowCallbacks.json"); (QuarkWallet.QuarkOperation memory op1, bytes32[] memory submissionTokens) = new QuarkOperationHelper() .newReplayableOpWithCalldata( - aliceWallet, allowCallbacks, abi.encodeWithSignature("allowCallbackFun()"), ScriptType.ScriptSource, 1 + aliceWallet, allowCallbacks, abi.encodeWithSignature("run()"), ScriptType.ScriptSource, 1 ); (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); - QuarkWallet.QuarkOperation memory op2 = new QuarkOperationHelper().newBasicOpWithCalldata( - aliceWallet, allowCallbacks, abi.encodeWithSignature("clearCallbackFun()"), ScriptType.ScriptSource - ); - op2.nonce = op1.nonce; - (uint8 v2, bytes32 r2, bytes32 s2) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op2); - assertEq(vm.load(address(aliceWallet), callbackSlot), bytes32(0)); + // gas: meter execute + vm.resumeGasMetering(); + bytes memory result = aliceWallet.executeQuarkOperation(op1, v1, r1, s1); + uint256 res = abi.decode(result, (uint256)); + assertEq(res, 202); + + // Can run again + result = aliceWallet.executeQuarkOperationWithSubmissionToken(op1, submissionTokens[1], v1, r1, s1); + res = abi.decode(result, (uint256)); + assertEq(res, 204); + } + + function testWithoutAllowCallback() public { + // gas: do not meter set-up + vm.pauseGasMetering(); + bytes memory allowCallbacks = new YulHelper().getCode("AllowCallbacks.sol/AllowCallbacks.json"); + + (QuarkWallet.QuarkOperation memory op1, bytes32[] memory submissionTokens) = new QuarkOperationHelper() + .newReplayableOpWithCalldata( + aliceWallet, allowCallbacks, abi.encodeWithSignature("runWithoutAllow()"), ScriptType.ScriptSource, 1 + ); + (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); // gas: meter execute vm.resumeGasMetering(); + vm.expectRevert(abi.encodeWithSelector(QuarkWallet.NoActiveCallback.selector)); aliceWallet.executeQuarkOperation(op1, v1, r1, s1); + } - assertNotEq(vm.load(address(aliceWallet), callbackSlot), bytes32(0)); + function testWithClearedCallback() public { + // gas: do not meter set-up + vm.pauseGasMetering(); + bytes memory allowCallbacks = new YulHelper().getCode("AllowCallbacks.sol/AllowCallbacks.json"); - aliceWallet.executeQuarkOperationWithSubmissionToken(op2, submissionTokens[1], v2, r2, s2); - assertEq(vm.load(address(aliceWallet), callbackSlot), bytes32(0)); + (QuarkWallet.QuarkOperation memory op1, bytes32[] memory submissionTokens) = new QuarkOperationHelper() + .newReplayableOpWithCalldata( + aliceWallet, allowCallbacks, abi.encodeWithSignature("runAllowThenClear()"), ScriptType.ScriptSource, 1 + ); + (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); + + // gas: meter execute + vm.resumeGasMetering(); + vm.expectRevert(abi.encodeWithSelector(QuarkWallet.NoActiveCallback.selector)); + aliceWallet.executeQuarkOperation(op1, v1, r1, s1); } function testRevertsOnCallbackWhenNoActiveCallback() public { diff --git a/test/quark-core/EIP1271.t.sol b/test/quark-core/EIP1271.t.sol index 5d463777..2f3cbe79 100644 --- a/test/quark-core/EIP1271.t.sol +++ b/test/quark-core/EIP1271.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/StdUtils.sol"; diff --git a/test/quark-core/EIP712.t.sol b/test/quark-core/EIP712.t.sol index b83274dd..25ace1d3 100644 --- a/test/quark-core/EIP712.t.sol +++ b/test/quark-core/EIP712.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/StdUtils.sol"; diff --git a/test/quark-core/Executor.t.sol b/test/quark-core/Executor.t.sol index 934ca616..0ecf287d 100644 --- a/test/quark-core/Executor.t.sol +++ b/test/quark-core/Executor.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/console.sol"; diff --git a/test/quark-core/Noncer.t.sol b/test/quark-core/Noncer.t.sol index 3ad9ea3d..1067df32 100644 --- a/test/quark-core/Noncer.t.sol +++ b/test/quark-core/Noncer.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core/QuarkNonceManager.t.sol b/test/quark-core/QuarkNonceManager.t.sol index 7906da8b..4115eb47 100644 --- a/test/quark-core/QuarkNonceManager.t.sol +++ b/test/quark-core/QuarkNonceManager.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core/QuarkWallet.t.sol b/test/quark-core/QuarkWallet.t.sol index 4b8aa6cf..46390c2d 100644 --- a/test/quark-core/QuarkWallet.t.sol +++ b/test/quark-core/QuarkWallet.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core/Reverts.t.sol b/test/quark-core/Reverts.t.sol index a5cdf183..58fb3a70 100644 --- a/test/quark-core/Reverts.t.sol +++ b/test/quark-core/Reverts.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-core/isValidSignature.t.sol b/test/quark-core/isValidSignature.t.sol index 748afcd0..917fc7c4 100644 --- a/test/quark-core/isValidSignature.t.sol +++ b/test/quark-core/isValidSignature.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/StdUtils.sol"; diff --git a/test/quark-core/periphery/BatchExecutor.t.sol b/test/quark-core/periphery/BatchExecutor.t.sol index 913fb85c..897548c3 100644 --- a/test/quark-core/periphery/BatchExecutor.t.sol +++ b/test/quark-core/periphery/BatchExecutor.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-factory/QuarkFactory.t.sol b/test/quark-factory/QuarkFactory.t.sol index 85fe5689..634b35fd 100644 --- a/test/quark-factory/QuarkFactory.t.sol +++ b/test/quark-factory/QuarkFactory.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/test/quark-proxy/QuarkMinimalProxy.t.sol b/test/quark-proxy/QuarkMinimalProxy.t.sol index b3e2386b..165eb0cc 100644 --- a/test/quark-proxy/QuarkMinimalProxy.t.sol +++ b/test/quark-proxy/QuarkMinimalProxy.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/console.sol"; import {Test} from "forge-std/Test.sol"; diff --git a/test/quark-proxy/QuarkWalletProxyFactory.t.sol b/test/quark-proxy/QuarkWalletProxyFactory.t.sol index 2efdc080..8ac0cfea 100644 --- a/test/quark-proxy/QuarkWalletProxyFactory.t.sol +++ b/test/quark-proxy/QuarkWalletProxyFactory.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BSD-3-Clause -pragma solidity 0.8.23; +pragma solidity 0.8.27; import "forge-std/Test.sol"; import "forge-std/console.sol"; From 2ce245adf05cb628e26f47a1efcb9970876dd5e7 Mon Sep 17 00:00:00 2001 From: Geoff Hayes Date: Thu, 12 Sep 2024 15:43:13 -0700 Subject: [PATCH 2/3] Cancel Core Script (#215) This patch simply adds a cancel core script that can be used (a) as a nop to cancel a chain, or (b) to directly call `nonceManager.cancel(nonce)` with one or more nonces. These are merely given as helpers for the end-users. --- src/quark-core-scripts/src/Cancel.sol | 41 +++++++++++++ src/quark-core/src/QuarkWallet.sol | 9 ++- ...elOtherScript.sol => CheckNonceScript.sol} | 14 +---- test/lib/QuarkOperationHelper.sol | 18 ++++-- test/quark-core/Callbacks.t.sol | 6 +- test/quark-core/Noncer.t.sol | 17 ++++-- test/quark-core/QuarkWallet.t.sol | 57 +++++++++++-------- 7 files changed, 109 insertions(+), 53 deletions(-) create mode 100644 src/quark-core-scripts/src/Cancel.sol rename test/lib/{CancelOtherScript.sol => CheckNonceScript.sol} (63%) diff --git a/src/quark-core-scripts/src/Cancel.sol b/src/quark-core-scripts/src/Cancel.sol new file mode 100644 index 00000000..c37f653b --- /dev/null +++ b/src/quark-core-scripts/src/Cancel.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BSD-3-Clause +pragma solidity 0.8.27; + +import {IQuarkWallet} from "quark-core/src/QuarkWallet.sol"; +import {QuarkNonceManager} from "quark-core/src/QuarkNonceManager.sol"; + +/** + * @title Cancel Core Script + * @notice Core transaction script that can be used to cancel quark operations. + * @author Legend Labs, Inc. + */ +contract Cancel { + /** + * @notice May cancel a script by being run as a no-op (no operation). + */ + function nop() external pure {} + + /** + * @notice Cancels a script by calling into nonce manager to cancel the script's nonce. + * @param nonce The nonce of the quark operation to cancel (exhaust) + */ + function cancel(bytes32 nonce) external { + nonceManager().cancel(nonce); + } + + /** + * @notice Cancels many scripts by calling into nonce manager to cancel each script's nonce. + * @param nonces A list of nonces of the quark operations to cancel (exhaust) + */ + function cancelMany(bytes32[] calldata nonces) external { + QuarkNonceManager manager = nonceManager(); + for (uint256 i = 0; i < nonces.length; ++i) { + bytes32 nonce = nonces[i]; + manager.cancel(nonce); + } + } + + function nonceManager() internal view returns (QuarkNonceManager) { + return QuarkNonceManager(IQuarkWallet(address(this)).nonceManager()); + } +} diff --git a/src/quark-core/src/QuarkWallet.sol b/src/quark-core/src/QuarkWallet.sol index 9af81514..50288df9 100644 --- a/src/quark-core/src/QuarkWallet.sol +++ b/src/quark-core/src/QuarkWallet.sol @@ -78,11 +78,12 @@ contract QuarkWallet is IERC1271 { } /// @notice Event emitted when a Quark script is executed by this Quark wallet - event ExecuteQuarkScript( + event QuarkExecution( address indexed executor, address indexed scriptAddress, bytes32 indexed nonce, bytes32 submissionToken, + bool isReplayable, ExecutionType executionType ); @@ -292,7 +293,9 @@ contract QuarkWallet is IERC1271 { nonceManager.submit(op.nonce, op.isReplayable, submissionToken); - emit ExecuteQuarkScript(msg.sender, op.scriptAddress, op.nonce, submissionToken, ExecutionType.Signature); + emit QuarkExecution( + msg.sender, op.scriptAddress, op.nonce, submissionToken, op.isReplayable, ExecutionType.Signature + ); return executeScriptInternal(op.scriptAddress, op.scriptCalldata, op.nonce, submissionToken); } @@ -324,7 +327,7 @@ contract QuarkWallet is IERC1271 { nonceManager.submit(nonce, false, nonce); - emit ExecuteQuarkScript(msg.sender, scriptAddress, nonce, nonce, ExecutionType.Direct); + emit QuarkExecution(msg.sender, scriptAddress, nonce, nonce, false, ExecutionType.Direct); return executeScriptInternal(scriptAddress, scriptCalldata, nonce, nonce); } diff --git a/test/lib/CancelOtherScript.sol b/test/lib/CheckNonceScript.sol similarity index 63% rename from test/lib/CancelOtherScript.sol rename to test/lib/CheckNonceScript.sol index d9e62ec0..f7b1919a 100644 --- a/test/lib/CancelOtherScript.sol +++ b/test/lib/CheckNonceScript.sol @@ -4,19 +4,7 @@ pragma solidity 0.8.27; import "quark-core/src/QuarkWallet.sol"; import "quark-core/src/QuarkScript.sol"; -contract CancelOtherScript is QuarkScript { - event Nop(); - event CancelNonce(bytes32 nonce); - - function nop() public { - emit Nop(); - } - - function run(bytes32 nonce) public { - nonceManager().cancel(nonce); - emit CancelNonce(nonce); - } - +contract CheckNonceScript is QuarkScript { function checkNonce() public view returns (bytes32) { return getActiveNonce(); } diff --git a/test/lib/QuarkOperationHelper.sol b/test/lib/QuarkOperationHelper.sol index 6e2bbf26..38babb2b 100644 --- a/test/lib/QuarkOperationHelper.sol +++ b/test/lib/QuarkOperationHelper.sol @@ -44,6 +44,16 @@ contract QuarkOperationHelper is Test { ); } + function newBasicOpWithCalldata( + QuarkWallet wallet, + bytes memory scriptSource, + bytes memory scriptCalldata, + ScriptType scriptType, + bytes32 nonce + ) public returns (QuarkWallet.QuarkOperation memory) { + return newBasicOpWithCalldata(wallet, scriptSource, scriptCalldata, new bytes[](0), scriptType, nonce); + } + function newBasicOpWithCalldata( QuarkWallet wallet, bytes memory scriptSource, @@ -144,7 +154,7 @@ contract QuarkOperationHelper is Test { returns (QuarkWallet.QuarkOperation memory) { return getCancelOperation( - wallet, semiRandomNonce(wallet), abi.encodeWithSignature("run(bytes32)", quarkOperation.nonce) + wallet, semiRandomNonce(wallet), abi.encodeWithSignature("cancel(bytes32)", quarkOperation.nonce) ); } @@ -152,10 +162,10 @@ contract QuarkOperationHelper is Test { public returns (QuarkWallet.QuarkOperation memory) { - bytes memory cancelOtherScript = new YulHelper().getCode("CancelOtherScript.sol/CancelOtherScript.json"); - address scriptAddress = wallet.codeJar().saveCode(cancelOtherScript); + bytes memory cancelScript = new YulHelper().getCode("Cancel.sol/Cancel.json"); + address scriptAddress = wallet.codeJar().saveCode(cancelScript); bytes[] memory scriptSources = new bytes[](1); - scriptSources[0] = cancelOtherScript; + scriptSources[0] = cancelScript; return QuarkWallet.QuarkOperation({ scriptAddress: scriptAddress, scriptSources: scriptSources, diff --git a/test/quark-core/Callbacks.t.sol b/test/quark-core/Callbacks.t.sol index db73ab25..2cbef133 100644 --- a/test/quark-core/Callbacks.t.sol +++ b/test/quark-core/Callbacks.t.sol @@ -201,8 +201,7 @@ contract CallbacksTest is Test { vm.pauseGasMetering(); bytes memory allowCallbacks = new YulHelper().getCode("AllowCallbacks.sol/AllowCallbacks.json"); - (QuarkWallet.QuarkOperation memory op1, bytes32[] memory submissionTokens) = new QuarkOperationHelper() - .newReplayableOpWithCalldata( + (QuarkWallet.QuarkOperation memory op1,) = new QuarkOperationHelper().newReplayableOpWithCalldata( aliceWallet, allowCallbacks, abi.encodeWithSignature("runWithoutAllow()"), ScriptType.ScriptSource, 1 ); (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); @@ -218,8 +217,7 @@ contract CallbacksTest is Test { vm.pauseGasMetering(); bytes memory allowCallbacks = new YulHelper().getCode("AllowCallbacks.sol/AllowCallbacks.json"); - (QuarkWallet.QuarkOperation memory op1, bytes32[] memory submissionTokens) = new QuarkOperationHelper() - .newReplayableOpWithCalldata( + (QuarkWallet.QuarkOperation memory op1,) = new QuarkOperationHelper().newReplayableOpWithCalldata( aliceWallet, allowCallbacks, abi.encodeWithSignature("runAllowThenClear()"), ScriptType.ScriptSource, 1 ); (uint8 v1, bytes32 r1, bytes32 s1) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op1); diff --git a/test/quark-core/Noncer.t.sol b/test/quark-core/Noncer.t.sol index 1067df32..3fd66fe0 100644 --- a/test/quark-core/Noncer.t.sol +++ b/test/quark-core/Noncer.t.sol @@ -357,21 +357,26 @@ contract NoncerTest is Test { assertEq(replayCount, 2); } - function testGetActiveReplayCountWithCancel() public { + function testGetActiveReplayCountWithNonReplaySoftCancel() public { // gas: do not meter set-up vm.pauseGasMetering(); bytes memory noncerScript = new YulHelper().getCode("Noncer.sol/Noncer.json"); + bytes memory checkNonceScript = new YulHelper().getCode("CheckNonceScript.sol/CheckNonceScript.json"); (QuarkWallet.QuarkOperation memory op, bytes32[] memory submissionTokens) = new QuarkOperationHelper() .newReplayableOpWithCalldata( aliceWallet, noncerScript, abi.encodeWithSignature("checkReplayCount()"), ScriptType.ScriptSource, 2 ); (uint8 v, bytes32 r, bytes32 s) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, op); - QuarkWallet.QuarkOperation memory cancelOp = new QuarkOperationHelper().getCancelOperation( - aliceWallet, op.nonce, abi.encodeWithSignature("checkReplayCount()") + QuarkWallet.QuarkOperation memory checkReplayCountOp = new QuarkOperationHelper().newBasicOpWithCalldata( + aliceWallet, + checkNonceScript, + abi.encodeWithSignature("checkReplayCount()"), + ScriptType.ScriptSource, + op.nonce ); - (uint8 cancelV, bytes32 cancelR, bytes32 cancelS) = - new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOp); + (uint8 checkReplayCountOpV, bytes32 checkReplayCountOpR, bytes32 checkReplayCountOpS) = + new SignatureHelper().signOp(alicePrivateKey, aliceWallet, checkReplayCountOp); // gas: meter execute vm.resumeGasMetering(); @@ -381,7 +386,7 @@ contract NoncerTest is Test { assertEq(replayCount, 0); result = aliceWallet.executeQuarkOperationWithSubmissionToken( - cancelOp, submissionTokens[1], cancelV, cancelR, cancelS + checkReplayCountOp, submissionTokens[1], checkReplayCountOpV, checkReplayCountOpR, checkReplayCountOpS ); (replayCount) = abi.decode(result, (uint256)); diff --git a/test/quark-core/QuarkWallet.t.sol b/test/quark-core/QuarkWallet.t.sol index 46390c2d..d5a967dd 100644 --- a/test/quark-core/QuarkWallet.t.sol +++ b/test/quark-core/QuarkWallet.t.sol @@ -28,7 +28,7 @@ import {Incrementer} from "test/lib/Incrementer.sol"; import {PrecompileCaller} from "test/lib/PrecompileCaller.sol"; import {MaxCounterScript} from "test/lib/MaxCounterScript.sol"; import {GetMessageDetails} from "test/lib/GetMessageDetails.sol"; -import {CancelOtherScript} from "test/lib/CancelOtherScript.sol"; +import {CheckNonceScript} from "test/lib/CheckNonceScript.sol"; contract QuarkWalletTest is Test { enum ExecutionType { @@ -37,11 +37,12 @@ contract QuarkWalletTest is Test { } event Ping(uint256); - event ExecuteQuarkScript( + event QuarkExecution( address indexed executor, address indexed scriptAddress, bytes32 indexed nonce, bytes32 submissionToken, + bool isReplayable, ExecutionType executionType ); @@ -162,14 +163,24 @@ contract QuarkWalletTest is Test { // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript( - address(this), scriptAddress, opWithScriptAddress.nonce, opWithScriptAddress.nonce, ExecutionType.Signature + emit QuarkExecution( + address(this), + scriptAddress, + opWithScriptAddress.nonce, + opWithScriptAddress.nonce, + false, + ExecutionType.Signature ); aliceWallet.executeQuarkOperation(opWithScriptAddress, v, r, s); vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript( - address(this), scriptAddress, opWithScriptSource.nonce, opWithScriptSource.nonce, ExecutionType.Signature + emit QuarkExecution( + address(this), + scriptAddress, + opWithScriptSource.nonce, + opWithScriptSource.nonce, + false, + ExecutionType.Signature ); aliceWallet.executeQuarkOperation(opWithScriptSource, v2, r2, s2); } @@ -193,22 +204,27 @@ contract QuarkWalletTest is Test { // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript( - address(this), scriptAddress, opWithScriptAddress.nonce, opWithScriptAddress.nonce, ExecutionType.Signature + emit QuarkExecution( + address(this), + scriptAddress, + opWithScriptAddress.nonce, + opWithScriptAddress.nonce, + true, + ExecutionType.Signature ); aliceWallet.executeQuarkOperation(opWithScriptAddress, v, r, s); // second execution vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript( - address(this), scriptAddress, opWithScriptAddress.nonce, submissionTokens[1], ExecutionType.Signature + emit QuarkExecution( + address(this), scriptAddress, opWithScriptAddress.nonce, submissionTokens[1], true, ExecutionType.Signature ); aliceWallet.executeQuarkOperationWithSubmissionToken(opWithScriptAddress, submissionTokens[1], v, r, s); // third execution vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript( - address(this), scriptAddress, opWithScriptAddress.nonce, submissionTokens[2], ExecutionType.Signature + emit QuarkExecution( + address(this), scriptAddress, opWithScriptAddress.nonce, submissionTokens[2], true, ExecutionType.Signature ); aliceWallet.executeQuarkOperationWithSubmissionToken(opWithScriptAddress, submissionTokens[2], v, r, s); } @@ -227,7 +243,7 @@ contract QuarkWalletTest is Test { // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript(address(aliceAccount), scriptAddress, nonce, nonce, ExecutionType.Direct); + emit QuarkExecution(address(aliceAccount), scriptAddress, nonce, nonce, false, ExecutionType.Direct); aliceWalletExecutable.executeScript(nonce, scriptAddress, call, new bytes[](0)); } @@ -251,7 +267,7 @@ contract QuarkWalletTest is Test { // gas: meter execute vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); - emit ExecuteQuarkScript(address(aliceAccount), scriptAddress, nonce, nonce, ExecutionType.Direct); + emit QuarkExecution(address(aliceAccount), scriptAddress, nonce, nonce, false, ExecutionType.Direct); aliceWalletExecutable.executeScript(nonce, scriptAddress, call, scriptSources); assertEq(counter.number(), 1); @@ -592,8 +608,6 @@ contract QuarkWalletTest is Test { (uint8 cancelV, bytes32 cancelR, bytes32 cancelS) = new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOtherOp); vm.resumeGasMetering(); - vm.expectEmit(true, true, true, true); - emit CancelOtherScript.Nop(); aliceWallet.executeQuarkOperationWithSubmissionToken( cancelOtherOp, submissionTokens[1], cancelV, cancelR, cancelS ); @@ -638,16 +652,13 @@ contract QuarkWalletTest is Test { // can cancel the replayable nonce... vm.pauseGasMetering(); - QuarkWallet.QuarkOperation memory cancelOtherOp = - new QuarkOperationHelper().cancelReplayableByNewOp(aliceWallet, op); + QuarkWallet.QuarkOperation memory cancelOp = new QuarkOperationHelper().cancelReplayableByNewOp(aliceWallet, op); (uint8 cancelV, bytes32 cancelR, bytes32 cancelS) = - new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOtherOp); + new SignatureHelper().signOp(alicePrivateKey, aliceWallet, cancelOp); vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); - emit CancelOtherScript.CancelNonce(op.nonce); - aliceWallet.executeQuarkOperationWithSubmissionToken( - cancelOtherOp, submissionTokens[1], cancelV, cancelR, cancelS - ); + emit QuarkNonceManager.NonceCanceled(address(aliceWallet), op.nonce); + aliceWallet.executeQuarkOperationWithSubmissionToken(cancelOp, submissionTokens[1], cancelV, cancelR, cancelS); // and now you can no longer replay vm.expectRevert( From 6554059686cd3caebb55a6c699ca34e535f1b07c Mon Sep 17 00:00:00 2001 From: Geoffrey Hayes Date: Thu, 12 Sep 2024 15:47:32 -0700 Subject: [PATCH 3/3] Remove comment and fix version for vendoza --- src/quark-core-scripts/src/vendor/manifest.json | 2 +- src/quark-core/src/QuarkScript.sol | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/quark-core-scripts/src/vendor/manifest.json b/src/quark-core-scripts/src/vendor/manifest.json index 40cc65e2..d32806d1 100644 --- a/src/quark-core-scripts/src/vendor/manifest.json +++ b/src/quark-core-scripts/src/vendor/manifest.json @@ -16,7 +16,7 @@ "newLines": 6, "lines": [ " // SPDX-License-Identifier: GPL-2.0-or-later", - "-pragma solidity 0.8.23;", + "-pragma solidity 0.8.27;", "+pragma solidity >=0.5.0;", " ", " /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee", diff --git a/src/quark-core/src/QuarkScript.sol b/src/quark-core/src/QuarkScript.sol index 4be68f17..772272eb 100644 --- a/src/quark-core/src/QuarkScript.sol +++ b/src/quark-core/src/QuarkScript.sol @@ -114,8 +114,6 @@ abstract contract QuarkScript { return write(keccak256(bytes(key)), value); } - // TODO: Consider adding nonce-based scoping by TLOAD'ing the nonce and using - // that to hash the key. function write(bytes32 key, bytes32 value) internal { bytes32 isolatedKey = getNonceIsolatedKey(key); assembly {