From 1307e308a4fdc9207798f74954ee7880a2d1581d Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:05:55 +0200 Subject: [PATCH 1/8] feat: bump to solc 0.8.28 for `transient` keyword --- foundry.toml | 2 +- script/base/deploy-base.s.sol | 2 +- script/create-oev-demo-positions.s.sol | 2 +- script/deploy-atlas.s.sol | 2 +- script/deploy-demo-tokens.s.sol | 2 +- script/deploy-exec-env.s.sol | 2 +- script/deploy-fl-online-control.s.sol | 2 +- script/deploy-gas-calculator.s.sol | 2 +- script/deploy-oev-demo.s.sol | 2 +- script/deploy-solver.s.sol | 2 +- script/deploy-sorter.s.sol | 2 +- script/deploy-swap-intent-control.s.sol | 2 +- script/deploy-tx-builder.s.sol | 2 +- script/deploy-v2-reward-control.s.sol | 2 +- script/log-balances.s.sol | 2 +- script/mint-demo-tokens.s.sol | 2 +- script/set-oev-demo-signers.s.sol | 2 +- script/solver-deposit.s.sol | 2 +- src/contracts/atlas/AtlETH.sol | 2 +- src/contracts/atlas/Atlas.sol | 2 +- src/contracts/atlas/AtlasVerification.sol | 2 +- src/contracts/atlas/DAppIntegration.sol | 2 +- src/contracts/atlas/Escrow.sol | 2 +- src/contracts/atlas/Factory.sol | 2 +- src/contracts/atlas/FactoryLib.sol | 145 ++++++++++++++++++ src/contracts/atlas/GasAccounting.sol | 8 +- src/contracts/atlas/NonceManager.sol | 2 +- src/contracts/atlas/Permit69.sol | 2 +- src/contracts/atlas/SafetyLocks.sol | 2 +- src/contracts/atlas/Storage.sol | 12 +- src/contracts/common/ExecutionBase.sol | 2 +- src/contracts/common/ExecutionEnvironment.sol | 2 +- src/contracts/common/Mimic.sol | 2 +- src/contracts/dapp/ControlTemplate.sol | 2 +- src/contracts/dapp/DAppControl.sol | 2 +- .../examples/ex-post-mev-example/V2ExPost.sol | 2 +- .../examples/fastlane-online/BaseStorage.sol | 2 +- .../fastlane-online/FastLaneControl.sol | 2 +- .../fastlane-online/FastLaneOnlineErrors.sol | 2 +- .../fastlane-online/FastLaneOnlineInner.sol | 2 +- .../fastlane-online/FastLaneOnlineOuter.sol | 2 +- .../fastlane-online/FastLaneTypes.sol | 2 +- .../fastlane-online/IFastLaneOnline.sol | 2 +- .../examples/fastlane-online/OuterHelpers.sol | 2 +- .../fastlane-online/SolverGateway.sol | 2 +- src/contracts/examples/gas-filler/Filler.sol | 2 +- .../GeneralizedBackrunUserBundler.sol | 2 +- .../examples/intents-example/StateIntent.sol | 2 +- .../intents-example/SwapIntentDAppControl.sol | 2 +- .../oev-example/ChainlinkAtlasWrapper.sol | 2 +- .../oev-example/ChainlinkAtlasWrapperAlt.sol | 2 +- .../oev-example/ChainlinkDAppControl.sol | 2 +- .../oev-example/ChainlinkDAppControlAlt.sol | 2 +- .../oev-example/IChainlinkAtlasWrapper.sol | 2 +- .../oev-example/IChainlinkDAppControl.sol | 2 +- .../trebleswap/TrebleSwapDAppControl.sol | 2 +- .../v2-example-router/V2RewardDAppControl.sol | 2 +- .../examples/v2-example/V2DAppControl.sol | 2 +- src/contracts/examples/v4-example/IHooks.sol | 2 +- .../examples/v4-example/IPoolManager.sol | 2 +- .../examples/v4-example/UniV4Hook.sol | 2 +- .../examples/v4-example/V4DAppControl.sol | 2 +- .../gasCalculator/BaseGasCalculator.sol | 2 +- src/contracts/helpers/DemoLendingProtocol.sol | 2 +- src/contracts/helpers/DemoToken.sol | 2 +- src/contracts/helpers/DemoWETH.sol | 2 +- src/contracts/helpers/GovernanceBurner.sol | 2 +- src/contracts/helpers/Simulator.sol | 2 +- src/contracts/helpers/Sorter.sol | 2 +- src/contracts/helpers/TxBuilder.sol | 2 +- src/contracts/helpers/Utilities.sol | 2 +- src/contracts/interfaces/IAtlas.sol | 2 +- .../interfaces/IAtlasVerification.sol | 2 +- src/contracts/interfaces/IDAppControl.sol | 2 +- .../interfaces/IExecutionEnvironment.sol | 2 +- src/contracts/interfaces/IL2GasCalculator.sol | 2 +- src/contracts/interfaces/ISimulator.sol | 2 +- src/contracts/interfaces/ISolverContract.sol | 2 +- src/contracts/libraries/AccountingMath.sol | 2 +- src/contracts/libraries/CallBits.sol | 2 +- src/contracts/libraries/CallVerification.sol | 2 +- src/contracts/libraries/EscrowBits.sol | 2 +- src/contracts/libraries/SafeCall/SafeCall.sol | 2 +- src/contracts/libraries/SafetyBits.sol | 2 +- src/contracts/solver/SolverBase.sol | 2 +- src/contracts/solver/SolverBaseInvertBid.sol | 2 +- src/contracts/solver/src/TestSolver.sol | 2 +- src/contracts/solver/src/TestSolverExPost.sol | 2 +- src/contracts/types/AtlasConstants.sol | 2 +- src/contracts/types/AtlasErrors.sol | 2 +- src/contracts/types/AtlasEvents.sol | 2 +- src/contracts/types/ConfigTypes.sol | 2 +- src/contracts/types/DAppOperation.sol | 2 +- src/contracts/types/EscrowTypes.sol | 2 +- src/contracts/types/LockTypes.sol | 2 +- src/contracts/types/SolverOperation.sol | 2 +- src/contracts/types/UserOperation.sol | 2 +- src/contracts/types/ValidCalls.sol | 2 +- test/Accounting.t.sol | 2 +- test/AccountingMath.t.sol | 2 +- test/AtlETH.t.sol | 2 +- test/AtlasVerification.t.sol | 2 +- test/BidFinding.t.sol | 2 +- test/DAppIntegration.t.sol | 2 +- test/Escrow.t.sol | 2 +- test/ExPost.t.sol | 2 +- test/ExecutionBase.t.sol | 2 +- test/ExecutionEnvironment.t.sol | 2 +- test/FLOnline.t.sol | 2 +- test/Factory.t.sol | 2 +- test/FlashLoan.t.sol | 2 +- test/GasAccounting.t.sol | 8 +- test/MainTest.t.sol | 2 +- test/Mimic.t.sol | 2 +- test/NonceManager.t.sol | 2 +- test/OEV.t.sol | 2 +- test/OEValt.t.sol | 2 +- test/Permit69.t.sol | 2 +- test/SafetyLocks.t.sol | 12 +- test/Simulator.t.sol | 2 +- test/Sorter.t.sol | 2 +- test/Storage.t.sol | 14 +- test/Surcharge.t.sol | 2 +- test/SwapIntent.t.sol | 2 +- test/SwapIntentInvertBid.t.sol | 2 +- test/TrebleSwap.t.sol | 2 +- test/V2Helper.sol | 2 +- test/V2RewardDAppControl.t.sol | 2 +- test/base/ArbitrageTest.t.sol | 2 +- test/base/BaseTest.t.sol | 2 +- test/base/DummyDAppControl.sol | 2 +- test/base/GasSponsorDAppControl.sol | 2 +- test/base/TestAtlas.sol | 10 +- test/base/TestUtils.sol | 2 +- test/base/builders/DAppOperationBuilder.sol | 2 +- test/base/builders/SolverOperationBuilder.sol | 2 +- test/base/builders/UserOperationBuilder.sol | 2 +- test/base/interfaces/IUniswapV2Router.sol | 2 +- test/helpers/CallConfigBuilder.sol | 2 +- test/helpers/DummyDAppControlBuilder.sol | 2 +- test/libraries/CallBits.t.sol | 2 +- test/libraries/CallVerification.t.sol | 2 +- test/libraries/EscrowBits.t.sol | 2 +- test/libraries/SafetyBits.t.sol | 2 +- 144 files changed, 304 insertions(+), 179 deletions(-) create mode 100644 src/contracts/atlas/FactoryLib.sol diff --git a/foundry.toml b/foundry.toml index fdbb6ebe5..217b928a2 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,7 +5,7 @@ block_gas_limit = 300000000 gas_limit = 3000000000 gas_price = 1500000000 - solc_version = "0.8.25" + solc_version = "0.8.28" evm_version = "cancun" isolate = false gas_reports = ["Atlas", "AtlasVerification", "Simulator", "Sorter", "ExecutionEnvironment"] diff --git a/script/base/deploy-base.s.sol b/script/base/deploy-base.s.sol index fb28277fb..0b5059d45 100644 --- a/script/base/deploy-base.s.sol +++ b/script/base/deploy-base.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/create-oev-demo-positions.s.sol b/script/create-oev-demo-positions.s.sol index 283309e84..be10a6bcf 100644 --- a/script/create-oev-demo-positions.s.sol +++ b/script/create-oev-demo-positions.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-atlas.s.sol b/script/deploy-atlas.s.sol index 95c8f335c..866d20f1d 100644 --- a/script/deploy-atlas.s.sol +++ b/script/deploy-atlas.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-demo-tokens.s.sol b/script/deploy-demo-tokens.s.sol index 54afc65fa..3d24baca4 100644 --- a/script/deploy-demo-tokens.s.sol +++ b/script/deploy-demo-tokens.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-exec-env.s.sol b/script/deploy-exec-env.s.sol index 337678dcd..d603a180a 100644 --- a/script/deploy-exec-env.s.sol +++ b/script/deploy-exec-env.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-fl-online-control.s.sol b/script/deploy-fl-online-control.s.sol index 3e513931a..ac9d9998a 100644 --- a/script/deploy-fl-online-control.s.sol +++ b/script/deploy-fl-online-control.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-gas-calculator.s.sol b/script/deploy-gas-calculator.s.sol index 3866bbaf1..68b9d0f01 100644 --- a/script/deploy-gas-calculator.s.sol +++ b/script/deploy-gas-calculator.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/script/deploy-oev-demo.s.sol b/script/deploy-oev-demo.s.sol index dbe42e4ee..d48fd33ba 100644 --- a/script/deploy-oev-demo.s.sol +++ b/script/deploy-oev-demo.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-solver.s.sol b/script/deploy-solver.s.sol index 499e6b733..12ef6c13e 100644 --- a/script/deploy-solver.s.sol +++ b/script/deploy-solver.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-sorter.s.sol b/script/deploy-sorter.s.sol index 3a6f2f1f8..9d9c44c48 100644 --- a/script/deploy-sorter.s.sol +++ b/script/deploy-sorter.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-swap-intent-control.s.sol b/script/deploy-swap-intent-control.s.sol index 3eb01e615..9e3b01eff 100644 --- a/script/deploy-swap-intent-control.s.sol +++ b/script/deploy-swap-intent-control.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-tx-builder.s.sol b/script/deploy-tx-builder.s.sol index c9fb32758..fe6a977a0 100644 --- a/script/deploy-tx-builder.s.sol +++ b/script/deploy-tx-builder.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/deploy-v2-reward-control.s.sol b/script/deploy-v2-reward-control.s.sol index 46db22ea6..2f6b348eb 100644 --- a/script/deploy-v2-reward-control.s.sol +++ b/script/deploy-v2-reward-control.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/log-balances.s.sol b/script/log-balances.s.sol index a8de086b7..edbe43314 100644 --- a/script/log-balances.s.sol +++ b/script/log-balances.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/mint-demo-tokens.s.sol b/script/mint-demo-tokens.s.sol index ab8ef1c4c..b7c814c7e 100644 --- a/script/mint-demo-tokens.s.sol +++ b/script/mint-demo-tokens.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/set-oev-demo-signers.s.sol b/script/set-oev-demo-signers.s.sol index e2c8ead19..b88b19038 100644 --- a/script/set-oev-demo-signers.s.sol +++ b/script/set-oev-demo-signers.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/script/solver-deposit.s.sol b/script/solver-deposit.s.sol index 01e4ecbf6..57e10b008 100644 --- a/script/solver-deposit.s.sol +++ b/script/solver-deposit.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/src/contracts/atlas/AtlETH.sol b/src/contracts/atlas/AtlETH.sol index 2bfcdd214..60bfb9eeb 100644 --- a/src/contracts/atlas/AtlETH.sol +++ b/src/contracts/atlas/AtlETH.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { SafeCast } from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; diff --git a/src/contracts/atlas/Atlas.sol b/src/contracts/atlas/Atlas.sol index 5765c084a..6091d0b32 100644 --- a/src/contracts/atlas/Atlas.sol +++ b/src/contracts/atlas/Atlas.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { LibSort } from "solady/utils/LibSort.sol"; diff --git a/src/contracts/atlas/AtlasVerification.sol b/src/contracts/atlas/AtlasVerification.sol index 9c1b7d5cc..2bf28d6d4 100644 --- a/src/contracts/atlas/AtlasVerification.sol +++ b/src/contracts/atlas/AtlasVerification.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { EIP712 } from "openzeppelin-contracts/contracts/utils/cryptography/EIP712.sol"; import { ECDSA } from "openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol"; diff --git a/src/contracts/atlas/DAppIntegration.sol b/src/contracts/atlas/DAppIntegration.sol index 1ffc0c8e5..447a1c863 100644 --- a/src/contracts/atlas/DAppIntegration.sol +++ b/src/contracts/atlas/DAppIntegration.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IDAppControl } from "../interfaces/IDAppControl.sol"; import { IAtlas } from "../interfaces/IAtlas.sol"; diff --git a/src/contracts/atlas/Escrow.sol b/src/contracts/atlas/Escrow.sol index 713fe336c..2d68b88f6 100644 --- a/src/contracts/atlas/Escrow.sol +++ b/src/contracts/atlas/Escrow.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { AtlETH } from "./AtlETH.sol"; import { IExecutionEnvironment } from "../interfaces/IExecutionEnvironment.sol"; diff --git a/src/contracts/atlas/Factory.sol b/src/contracts/atlas/Factory.sol index 57a5fcd2c..181563e2c 100644 --- a/src/contracts/atlas/Factory.sol +++ b/src/contracts/atlas/Factory.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IDAppControl } from "../interfaces/IDAppControl.sol"; import { Mimic } from "../common/Mimic.sol"; diff --git a/src/contracts/atlas/FactoryLib.sol b/src/contracts/atlas/FactoryLib.sol new file mode 100644 index 000000000..9ca878bbc --- /dev/null +++ b/src/contracts/atlas/FactoryLib.sol @@ -0,0 +1,145 @@ +//SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.28; + +import { Mimic } from "../common/Mimic.sol"; +import { AtlasEvents } from "../types/AtlasEvents.sol"; + +// NOTE: Do not call these functions directly. This contract should only ever be delegatecalled by the Atlas contract. + +contract FactoryLib { + address public immutable EXECUTION_ENV_TEMPLATE; + + /// @notice Initializes a new Factory contract instance by setting the immutable salt for deterministic deployment + /// of Execution Environments and storing the execution template address. + /// @dev The Execution Environment Template must be separately deployed using the same calculated salt. + /// @param executionTemplate Address of the pre-deployed execution template contract for creating Execution + /// Environment instances. + constructor(address executionTemplate) { + EXECUTION_ENV_TEMPLATE = executionTemplate; + } + + /// @notice Deploys a new execution environment or retrieves the address of an existing one based on the DApp + /// control, user, and configuration. + /// @dev Uses the `create2` opcode for deterministic deployment, allowing the calculation of the execution + /// environment's address before deployment. The deployment uses a combination of the DAppControl address, user + /// address, call configuration, and a unique salt to ensure the uniqueness and predictability of the environment's + /// address. + /// @param user The address of the user for whom the execution environment is being set. + /// @param control The address of the DAppControl contract providing the operational context. + /// @param callConfig CallConfig settings of the DAppControl contract. + /// @return executionEnvironment The address of the newly created or already existing execution environment. + function getOrCreateExecutionEnvironment( + address user, + address control, + uint32 callConfig, + bytes32 salt + ) + public + returns (address executionEnvironment) + { + bytes memory _creationCode = _getMimicCreationCode({ user: user, control: control, callConfig: callConfig }); + + executionEnvironment = address( + uint160( + uint256( + keccak256( + abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(abi.encodePacked(_creationCode))) + ) + ) + ) + ); + + if (executionEnvironment.code.length == 0) { + assembly { + executionEnvironment := create2(0, add(_creationCode, 32), mload(_creationCode), salt) + } + emit AtlasEvents.ExecutionEnvironmentCreated(user, executionEnvironment); + } + } + + /// @notice Generates the address of a user's execution environment affected by deprecated callConfig changes in the + /// DAppControl. + /// @dev Calculates the deterministic address of the execution environment based on the user, control, + /// callConfig, and controlCodeHash, ensuring consistency across changes in callConfig. + /// @param user The address of the user for whom the execution environment's address is being generated. + /// @param control The address of the DAppControl contract associated with the execution environment. + /// @param callConfig The configuration flags defining the behavior of the execution environment. + /// @return executionEnvironment The address of the user's execution environment. + function getExecutionEnvironmentCustom( + address user, + address control, + uint32 callConfig, + bytes32 salt + ) + public + view + returns (address executionEnvironment) + { + bytes memory _creationCode = _getMimicCreationCode({ user: user, control: control, callConfig: callConfig }); + + executionEnvironment = address( + uint160( + uint256( + keccak256( + abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(abi.encodePacked(_creationCode))) + ) + ) + ) + ); + } + + /// @notice Generates the creation code for the execution environment contract. + /// @param control The address of the DAppControl contract associated with the execution environment. + /// @param callConfig The configuration flags defining the behavior of the execution environment. + /// @param user The address of the user for whom the execution environment is being created, contributing to the + /// uniqueness of the creation code. + /// @return creationCode The bytecode representing the creation code of the execution environment contract. + function _getMimicCreationCode( + address user, + address control, + uint32 callConfig + ) + internal + view + returns (bytes memory creationCode) + { + address _executionLib = EXECUTION_ENV_TEMPLATE; + // NOTE: Changing compiler settings or solidity versions can break this. + creationCode = type(Mimic).creationCode; + + assembly { + // Insert the ExecutionEnvironment "Lib" address, into the AAAA placeholder in the creation code. + mstore( + add(creationCode, 79), + or( + and(mload(add(creationCode, 79)), not(shl(96, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))), + shl(96, _executionLib) + ) + ) + + // Insert the user address into the BBBB placeholder in the creation code. + mstore( + add(creationCode, 111), + or( + and(mload(add(creationCode, 111)), not(shl(96, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))), + shl(96, user) + ) + ) + + // Insert the control address into the CCCC placeholder in the creation code. + mstore( + add(creationCode, 132), + or( + and(mload(add(creationCode, 132)), not(shl(96, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))), + shl(96, control) + ) + ) + + // Insert the callConfig into the 2222 placeholder in the creation code. + mstore( + add(creationCode, 153), + or(and(mload(add(creationCode, 153)), not(shl(224, 0xFFFFFFFF))), shl(224, callConfig)) + ) + } + } +} diff --git a/src/contracts/atlas/GasAccounting.sol b/src/contracts/atlas/GasAccounting.sol index ce79b62af..474e6442c 100644 --- a/src/contracts/atlas/GasAccounting.sol +++ b/src/contracts/atlas/GasAccounting.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { SafeCast } from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol"; @@ -46,7 +46,7 @@ abstract contract GasAccounting is SafetyLocks { uint256 _rawClaims = (FIXED_GAS_OFFSET + gasMarker) * tx.gasprice; // Set any withdraws or deposits - _setClaims(_rawClaims.withSurcharge(BUNDLER_SURCHARGE_RATE)); + claims = _rawClaims.withSurcharge(BUNDLER_SURCHARGE_RATE); // Atlas surcharge is based on the raw claims value. _setFees(_rawClaims.getSurcharge(ATLAS_SURCHARGE_RATE)); @@ -105,7 +105,7 @@ abstract contract GasAccounting is SafetyLocks { } function _deficit() internal view returns (uint256) { - return claims() + withdrawals() + fees() - writeoffs(); + return claims + withdrawals() + fees() - writeoffs(); } /// @notice Allows a solver to settle any outstanding ETH owed, either to repay gas used by their solverOp or to @@ -346,7 +346,7 @@ abstract contract GasAccounting is SafetyLocks { adjustedWithdrawals = withdrawals(); adjustedDeposits = deposits(); - adjustedClaims = claims(); + adjustedClaims = claims; adjustedWriteoffs = writeoffs(); uint256 _fees = fees(); diff --git a/src/contracts/atlas/NonceManager.sol b/src/contracts/atlas/NonceManager.sol index 19fa27956..3f1b9a38c 100644 --- a/src/contracts/atlas/NonceManager.sol +++ b/src/contracts/atlas/NonceManager.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { AtlasConstants } from "../types/AtlasConstants.sol"; diff --git a/src/contracts/atlas/Permit69.sol b/src/contracts/atlas/Permit69.sol index 84ba2e599..096d7630c 100644 --- a/src/contracts/atlas/Permit69.sol +++ b/src/contracts/atlas/Permit69.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/atlas/SafetyLocks.sol b/src/contracts/atlas/SafetyLocks.sol index 6d7ec03f2..87f274eea 100644 --- a/src/contracts/atlas/SafetyLocks.sol +++ b/src/contracts/atlas/SafetyLocks.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { Storage } from "./Storage.sol"; import { CallBits } from "../libraries/CallBits.sol"; diff --git a/src/contracts/atlas/Storage.sol b/src/contracts/atlas/Storage.sol index 0359dc2f9..2d2120554 100644 --- a/src/contracts/atlas/Storage.sol +++ b/src/contracts/atlas/Storage.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/EscrowTypes.sol"; import "../types/LockTypes.sol"; @@ -36,7 +36,7 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { bytes32 private constant _T_SOLVER_LOCK_SLOT = keccak256("ATLAS_SOLVER_LOCK"); bytes32 private constant _T_SOLVER_TO_SLOT = keccak256("ATLAS_SOLVER_TO"); - bytes32 private constant _T_CLAIMS_SLOT = keccak256("ATLAS_CLAIMS"); + uint256 public transient claims; bytes32 private constant _T_FEES_SLOT = keccak256("ATLAS_FEES"); bytes32 private constant _T_WRITEOFFS_SLOT = keccak256("ATLAS_WRITEOFFS"); bytes32 private constant _T_WITHDRAWALS_SLOT = keccak256("ATLAS_WITHDRAWALS"); @@ -155,10 +155,6 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { // Transient Internal Getters // // ---------------------------------------------------- // - function claims() internal view returns (uint256) { - return uint256(_tload(_T_CLAIMS_SLOT)); - } - function fees() internal view returns (uint256) { return uint256(_tload(_T_FEES_SLOT)); } @@ -252,10 +248,6 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { _tstore(_T_SOLVER_TO_SLOT, bytes32(uint256(uint160(newSolverTo)))); } - function _setClaims(uint256 newClaims) internal { - _tstore(_T_CLAIMS_SLOT, bytes32(newClaims)); - } - function _setFees(uint256 newFees) internal { _tstore(_T_FEES_SLOT, bytes32(newFees)); } diff --git a/src/contracts/common/ExecutionBase.sol b/src/contracts/common/ExecutionBase.sol index 4bdeddec1..a1383ae9e 100644 --- a/src/contracts/common/ExecutionBase.sol +++ b/src/contracts/common/ExecutionBase.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/common/ExecutionEnvironment.sol b/src/contracts/common/ExecutionEnvironment.sol index 42945ad01..84fb2fc03 100644 --- a/src/contracts/common/ExecutionEnvironment.sol +++ b/src/contracts/common/ExecutionEnvironment.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/common/Mimic.sol b/src/contracts/common/Mimic.sol index a88446bc9..ad7f4a718 100644 --- a/src/contracts/common/Mimic.sol +++ b/src/contracts/common/Mimic.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; contract Mimic { /* diff --git a/src/contracts/dapp/ControlTemplate.sol b/src/contracts/dapp/ControlTemplate.sol index b510f7f1d..3663f915e 100644 --- a/src/contracts/dapp/ControlTemplate.sol +++ b/src/contracts/dapp/ControlTemplate.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/SolverOperation.sol"; import "../types/UserOperation.sol"; diff --git a/src/contracts/dapp/DAppControl.sol b/src/contracts/dapp/DAppControl.sol index 03c4d977e..8340bd7f4 100644 --- a/src/contracts/dapp/DAppControl.sol +++ b/src/contracts/dapp/DAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { DAppControlTemplate } from "./ControlTemplate.sol"; import { ExecutionBase } from "../common/ExecutionBase.sol"; diff --git a/src/contracts/examples/ex-post-mev-example/V2ExPost.sol b/src/contracts/examples/ex-post-mev-example/V2ExPost.sol index 7c90b9140..66b71792a 100644 --- a/src/contracts/examples/ex-post-mev-example/V2ExPost.sol +++ b/src/contracts/examples/ex-post-mev-example/V2ExPost.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/fastlane-online/BaseStorage.sol b/src/contracts/examples/fastlane-online/BaseStorage.sol index ca2514a3d..457b564a5 100644 --- a/src/contracts/examples/fastlane-online/BaseStorage.sol +++ b/src/contracts/examples/fastlane-online/BaseStorage.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../../types/SolverOperation.sol"; diff --git a/src/contracts/examples/fastlane-online/FastLaneControl.sol b/src/contracts/examples/fastlane-online/FastLaneControl.sol index 9b0388c95..183e6c350 100644 --- a/src/contracts/examples/fastlane-online/FastLaneControl.sol +++ b/src/contracts/examples/fastlane-online/FastLaneControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/fastlane-online/FastLaneOnlineErrors.sol b/src/contracts/examples/fastlane-online/FastLaneOnlineErrors.sol index 603cdff3a..436bb994a 100644 --- a/src/contracts/examples/fastlane-online/FastLaneOnlineErrors.sol +++ b/src/contracts/examples/fastlane-online/FastLaneOnlineErrors.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; contract FastLaneOnlineErrors { // FastLaneControl.sol diff --git a/src/contracts/examples/fastlane-online/FastLaneOnlineInner.sol b/src/contracts/examples/fastlane-online/FastLaneOnlineInner.sol index 492085440..b49f1f55d 100644 --- a/src/contracts/examples/fastlane-online/FastLaneOnlineInner.sol +++ b/src/contracts/examples/fastlane-online/FastLaneOnlineInner.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/fastlane-online/FastLaneOnlineOuter.sol b/src/contracts/examples/fastlane-online/FastLaneOnlineOuter.sol index b4a9efe4f..fb4f10f65 100644 --- a/src/contracts/examples/fastlane-online/FastLaneOnlineOuter.sol +++ b/src/contracts/examples/fastlane-online/FastLaneOnlineOuter.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/fastlane-online/FastLaneTypes.sol b/src/contracts/examples/fastlane-online/FastLaneTypes.sol index 13e4270f8..786e6a7e3 100644 --- a/src/contracts/examples/fastlane-online/FastLaneTypes.sol +++ b/src/contracts/examples/fastlane-online/FastLaneTypes.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // External representation of the swap intent struct SwapIntent { diff --git a/src/contracts/examples/fastlane-online/IFastLaneOnline.sol b/src/contracts/examples/fastlane-online/IFastLaneOnline.sol index c61c79508..df5d056d5 100644 --- a/src/contracts/examples/fastlane-online/IFastLaneOnline.sol +++ b/src/contracts/examples/fastlane-online/IFastLaneOnline.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../../types/UserOperation.sol"; import "../../types/SolverOperation.sol"; diff --git a/src/contracts/examples/fastlane-online/OuterHelpers.sol b/src/contracts/examples/fastlane-online/OuterHelpers.sol index 4a0544d40..976674c2f 100644 --- a/src/contracts/examples/fastlane-online/OuterHelpers.sol +++ b/src/contracts/examples/fastlane-online/OuterHelpers.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/fastlane-online/SolverGateway.sol b/src/contracts/examples/fastlane-online/SolverGateway.sol index 26e3ed80c..0e106b7b1 100644 --- a/src/contracts/examples/fastlane-online/SolverGateway.sol +++ b/src/contracts/examples/fastlane-online/SolverGateway.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/gas-filler/Filler.sol b/src/contracts/examples/gas-filler/Filler.sol index 904c11476..29f042c33 100644 --- a/src/contracts/examples/gas-filler/Filler.sol +++ b/src/contracts/examples/gas-filler/Filler.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/generalized-backrun/GeneralizedBackrunUserBundler.sol b/src/contracts/examples/generalized-backrun/GeneralizedBackrunUserBundler.sol index 22aa7620c..643fe0bea 100644 --- a/src/contracts/examples/generalized-backrun/GeneralizedBackrunUserBundler.sol +++ b/src/contracts/examples/generalized-backrun/GeneralizedBackrunUserBundler.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/intents-example/StateIntent.sol b/src/contracts/examples/intents-example/StateIntent.sol index 3083ca379..bc3984d81 100644 --- a/src/contracts/examples/intents-example/StateIntent.sol +++ b/src/contracts/examples/intents-example/StateIntent.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Atlas Base Imports import { IExecutionEnvironment } from "../../interfaces/IExecutionEnvironment.sol"; diff --git a/src/contracts/examples/intents-example/SwapIntentDAppControl.sol b/src/contracts/examples/intents-example/SwapIntentDAppControl.sol index 8250a32e0..fd98fd9fa 100644 --- a/src/contracts/examples/intents-example/SwapIntentDAppControl.sol +++ b/src/contracts/examples/intents-example/SwapIntentDAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/oev-example/ChainlinkAtlasWrapper.sol b/src/contracts/examples/oev-example/ChainlinkAtlasWrapper.sol index d00f82af8..daf3d5dd7 100644 --- a/src/contracts/examples/oev-example/ChainlinkAtlasWrapper.sol +++ b/src/contracts/examples/oev-example/ChainlinkAtlasWrapper.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; import { SafeERC20, IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/src/contracts/examples/oev-example/ChainlinkAtlasWrapperAlt.sol b/src/contracts/examples/oev-example/ChainlinkAtlasWrapperAlt.sol index 47cefee0d..ed3842065 100644 --- a/src/contracts/examples/oev-example/ChainlinkAtlasWrapperAlt.sol +++ b/src/contracts/examples/oev-example/ChainlinkAtlasWrapperAlt.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; import { SafeERC20, IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; diff --git a/src/contracts/examples/oev-example/ChainlinkDAppControl.sol b/src/contracts/examples/oev-example/ChainlinkDAppControl.sol index 18883ed99..fc6d7ef2b 100644 --- a/src/contracts/examples/oev-example/ChainlinkDAppControl.sol +++ b/src/contracts/examples/oev-example/ChainlinkDAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { ECDSA } from "openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol"; import { CallConfig } from "../../types/ConfigTypes.sol"; diff --git a/src/contracts/examples/oev-example/ChainlinkDAppControlAlt.sol b/src/contracts/examples/oev-example/ChainlinkDAppControlAlt.sol index 611e32bdc..53b699ad5 100644 --- a/src/contracts/examples/oev-example/ChainlinkDAppControlAlt.sol +++ b/src/contracts/examples/oev-example/ChainlinkDAppControlAlt.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { CallConfig } from "../../types/ConfigTypes.sol"; import "../../types/UserOperation.sol"; diff --git a/src/contracts/examples/oev-example/IChainlinkAtlasWrapper.sol b/src/contracts/examples/oev-example/IChainlinkAtlasWrapper.sol index a45b6e7b8..01fa7d141 100644 --- a/src/contracts/examples/oev-example/IChainlinkAtlasWrapper.sol +++ b/src/contracts/examples/oev-example/IChainlinkAtlasWrapper.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IChainlinkDAppControl } from "./IChainlinkDAppControl.sol"; diff --git a/src/contracts/examples/oev-example/IChainlinkDAppControl.sol b/src/contracts/examples/oev-example/IChainlinkDAppControl.sol index 3c0ff8944..663a77518 100644 --- a/src/contracts/examples/oev-example/IChainlinkDAppControl.sol +++ b/src/contracts/examples/oev-example/IChainlinkDAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; interface IChainlinkDAppControl { function verifyTransmitSigners( diff --git a/src/contracts/examples/trebleswap/TrebleSwapDAppControl.sol b/src/contracts/examples/trebleswap/TrebleSwapDAppControl.sol index 413a54af9..865b3c2ba 100644 --- a/src/contracts/examples/trebleswap/TrebleSwapDAppControl.sol +++ b/src/contracts/examples/trebleswap/TrebleSwapDAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/examples/v2-example-router/V2RewardDAppControl.sol b/src/contracts/examples/v2-example-router/V2RewardDAppControl.sol index 45a73d5d9..667e27b65 100644 --- a/src/contracts/examples/v2-example-router/V2RewardDAppControl.sol +++ b/src/contracts/examples/v2-example-router/V2RewardDAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/v2-example/V2DAppControl.sol b/src/contracts/examples/v2-example/V2DAppControl.sol index de6e2f9f6..591c68648 100644 --- a/src/contracts/examples/v2-example/V2DAppControl.sol +++ b/src/contracts/examples/v2-example/V2DAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/examples/v4-example/IHooks.sol b/src/contracts/examples/v4-example/IHooks.sol index 3f4fa5caf..03d33c679 100644 --- a/src/contracts/examples/v4-example/IHooks.sol +++ b/src/contracts/examples/v4-example/IHooks.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IPoolManager } from "./IPoolManager.sol"; diff --git a/src/contracts/examples/v4-example/IPoolManager.sol b/src/contracts/examples/v4-example/IPoolManager.sol index a2e49b34e..e9e022eba 100644 --- a/src/contracts/examples/v4-example/IPoolManager.sol +++ b/src/contracts/examples/v4-example/IPoolManager.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IHooks } from "./IHooks.sol"; diff --git a/src/contracts/examples/v4-example/UniV4Hook.sol b/src/contracts/examples/v4-example/UniV4Hook.sol index 490622e5b..7922c3745 100644 --- a/src/contracts/examples/v4-example/UniV4Hook.sol +++ b/src/contracts/examples/v4-example/UniV4Hook.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // V4 Imports import { IPoolManager } from "./IPoolManager.sol"; diff --git a/src/contracts/examples/v4-example/V4DAppControl.sol b/src/contracts/examples/v4-example/V4DAppControl.sol index 093defc0d..3eb4d198f 100644 --- a/src/contracts/examples/v4-example/V4DAppControl.sol +++ b/src/contracts/examples/v4-example/V4DAppControl.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Base Imports import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/gasCalculator/BaseGasCalculator.sol b/src/contracts/gasCalculator/BaseGasCalculator.sol index 97e404a66..ff9b73208 100644 --- a/src/contracts/gasCalculator/BaseGasCalculator.sol +++ b/src/contracts/gasCalculator/BaseGasCalculator.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IL2GasCalculator } from "src/contracts/interfaces/IL2GasCalculator.sol"; diff --git a/src/contracts/helpers/DemoLendingProtocol.sol b/src/contracts/helpers/DemoLendingProtocol.sol index ebe66343b..3a6ba24f3 100644 --- a/src/contracts/helpers/DemoLendingProtocol.sol +++ b/src/contracts/helpers/DemoLendingProtocol.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeERC20, IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; diff --git a/src/contracts/helpers/DemoToken.sol b/src/contracts/helpers/DemoToken.sol index c2e7a93d6..375783aa6 100644 --- a/src/contracts/helpers/DemoToken.sol +++ b/src/contracts/helpers/DemoToken.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { ERC20 } from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; diff --git a/src/contracts/helpers/DemoWETH.sol b/src/contracts/helpers/DemoWETH.sol index 3824bd5ea..2b9c0f15d 100644 --- a/src/contracts/helpers/DemoWETH.sol +++ b/src/contracts/helpers/DemoWETH.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { WETH } from "solady/tokens/WETH.sol"; import { Ownable } from "openzeppelin-contracts/contracts/access/Ownable.sol"; diff --git a/src/contracts/helpers/GovernanceBurner.sol b/src/contracts/helpers/GovernanceBurner.sol index fdad5a2f0..325784c09 100644 --- a/src/contracts/helpers/GovernanceBurner.sol +++ b/src/contracts/helpers/GovernanceBurner.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IDAppControl } from "../interfaces/IDAppControl.sol"; diff --git a/src/contracts/helpers/Simulator.sol b/src/contracts/helpers/Simulator.sol index 2385b8477..5ac2653d7 100644 --- a/src/contracts/helpers/Simulator.sol +++ b/src/contracts/helpers/Simulator.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; diff --git a/src/contracts/helpers/Sorter.sol b/src/contracts/helpers/Sorter.sol index b4a0fd924..43b0a9df2 100644 --- a/src/contracts/helpers/Sorter.sol +++ b/src/contracts/helpers/Sorter.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IAtlas } from "../interfaces/IAtlas.sol"; import { IDAppControl } from "../interfaces/IDAppControl.sol"; diff --git a/src/contracts/helpers/TxBuilder.sol b/src/contracts/helpers/TxBuilder.sol index dea57c90b..2d95b81fb 100644 --- a/src/contracts/helpers/TxBuilder.sol +++ b/src/contracts/helpers/TxBuilder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IDAppControl } from "../interfaces/IDAppControl.sol"; import { IAtlas } from "../interfaces/IAtlas.sol"; diff --git a/src/contracts/helpers/Utilities.sol b/src/contracts/helpers/Utilities.sol index a04978ff7..01cb6adca 100644 --- a/src/contracts/helpers/Utilities.sol +++ b/src/contracts/helpers/Utilities.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Script.sol"; import "forge-std/Test.sol"; diff --git a/src/contracts/interfaces/IAtlas.sol b/src/contracts/interfaces/IAtlas.sol index b518a0016..d66ce2adb 100644 --- a/src/contracts/interfaces/IAtlas.sol +++ b/src/contracts/interfaces/IAtlas.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/SolverOperation.sol"; import "../types/UserOperation.sol"; diff --git a/src/contracts/interfaces/IAtlasVerification.sol b/src/contracts/interfaces/IAtlasVerification.sol index ed4f050f5..f8af0fa31 100644 --- a/src/contracts/interfaces/IAtlasVerification.sol +++ b/src/contracts/interfaces/IAtlasVerification.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/UserOperation.sol"; import "../types/ConfigTypes.sol"; diff --git a/src/contracts/interfaces/IDAppControl.sol b/src/contracts/interfaces/IDAppControl.sol index e3be1417f..20625d463 100644 --- a/src/contracts/interfaces/IDAppControl.sol +++ b/src/contracts/interfaces/IDAppControl.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/UserOperation.sol"; import "../types/SolverOperation.sol"; diff --git a/src/contracts/interfaces/IExecutionEnvironment.sol b/src/contracts/interfaces/IExecutionEnvironment.sol index 9dcdee96a..af0c7e040 100644 --- a/src/contracts/interfaces/IExecutionEnvironment.sol +++ b/src/contracts/interfaces/IExecutionEnvironment.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/SolverOperation.sol"; import "../types/UserOperation.sol"; diff --git a/src/contracts/interfaces/IL2GasCalculator.sol b/src/contracts/interfaces/IL2GasCalculator.sol index 387aab8e8..41fd7c364 100644 --- a/src/contracts/interfaces/IL2GasCalculator.sol +++ b/src/contracts/interfaces/IL2GasCalculator.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; interface IL2GasCalculator { /// @notice Calculate the cost of calldata in ETH on a L2 with a different fee structure than mainnet diff --git a/src/contracts/interfaces/ISimulator.sol b/src/contracts/interfaces/ISimulator.sol index f1d3bb8ce..ae2148744 100644 --- a/src/contracts/interfaces/ISimulator.sol +++ b/src/contracts/interfaces/ISimulator.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/SolverOperation.sol"; import "../types/UserOperation.sol"; diff --git a/src/contracts/interfaces/ISolverContract.sol b/src/contracts/interfaces/ISolverContract.sol index b055a0415..e0a87a968 100644 --- a/src/contracts/interfaces/ISolverContract.sol +++ b/src/contracts/interfaces/ISolverContract.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/SolverOperation.sol"; diff --git a/src/contracts/libraries/AccountingMath.sol b/src/contracts/libraries/AccountingMath.sol index 5706f1ddf..43a941c47 100644 --- a/src/contracts/libraries/AccountingMath.sol +++ b/src/contracts/libraries/AccountingMath.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; library AccountingMath { uint256 internal constant _MAX_BUNDLER_REFUND_RATE = 8_000_000; // out of 10_000_000 = 80% diff --git a/src/contracts/libraries/CallBits.sol b/src/contracts/libraries/CallBits.sol index f5c1d0a6e..53abaa446 100644 --- a/src/contracts/libraries/CallBits.sol +++ b/src/contracts/libraries/CallBits.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IDAppControl } from "../interfaces/IDAppControl.sol"; diff --git a/src/contracts/libraries/CallVerification.sol b/src/contracts/libraries/CallVerification.sol index ba4f4829e..4eab4c580 100644 --- a/src/contracts/libraries/CallVerification.sol +++ b/src/contracts/libraries/CallVerification.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/SolverOperation.sol"; import "../types/UserOperation.sol"; diff --git a/src/contracts/libraries/EscrowBits.sol b/src/contracts/libraries/EscrowBits.sol index d8c19356c..aa5eb28f6 100644 --- a/src/contracts/libraries/EscrowBits.sol +++ b/src/contracts/libraries/EscrowBits.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/EscrowTypes.sol"; diff --git a/src/contracts/libraries/SafeCall/SafeCall.sol b/src/contracts/libraries/SafeCall/SafeCall.sol index db83111d1..02ca156fc 100644 --- a/src/contracts/libraries/SafeCall/SafeCall.sol +++ b/src/contracts/libraries/SafeCall/SafeCall.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; /// @title SafeCall /// @author FastLane Labs diff --git a/src/contracts/libraries/SafetyBits.sol b/src/contracts/libraries/SafetyBits.sol index c9fe77717..e912807e9 100644 --- a/src/contracts/libraries/SafetyBits.sol +++ b/src/contracts/libraries/SafetyBits.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../types/LockTypes.sol"; diff --git a/src/contracts/solver/SolverBase.sol b/src/contracts/solver/SolverBase.sol index ca57036cd..ea9553bc1 100644 --- a/src/contracts/solver/SolverBase.sol +++ b/src/contracts/solver/SolverBase.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/solver/SolverBaseInvertBid.sol b/src/contracts/solver/SolverBaseInvertBid.sol index 328ffc169..8963df9f7 100644 --- a/src/contracts/solver/SolverBaseInvertBid.sol +++ b/src/contracts/solver/SolverBaseInvertBid.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/solver/src/TestSolver.sol b/src/contracts/solver/src/TestSolver.sol index 445ac3bea..5f5441a5a 100644 --- a/src/contracts/solver/src/TestSolver.sol +++ b/src/contracts/solver/src/TestSolver.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SolverBase } from "../../solver/SolverBase.sol"; diff --git a/src/contracts/solver/src/TestSolverExPost.sol b/src/contracts/solver/src/TestSolverExPost.sol index 0cdf88cc5..74dbbbe9e 100644 --- a/src/contracts/solver/src/TestSolverExPost.sol +++ b/src/contracts/solver/src/TestSolverExPost.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/src/contracts/types/AtlasConstants.sol b/src/contracts/types/AtlasConstants.sol index 25fa70fb7..dbe575056 100644 --- a/src/contracts/types/AtlasConstants.sol +++ b/src/contracts/types/AtlasConstants.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "./ValidCalls.sol"; diff --git a/src/contracts/types/AtlasErrors.sol b/src/contracts/types/AtlasErrors.sol index 582c14e89..606f7239f 100644 --- a/src/contracts/types/AtlasErrors.sol +++ b/src/contracts/types/AtlasErrors.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "./ValidCalls.sol"; diff --git a/src/contracts/types/AtlasEvents.sol b/src/contracts/types/AtlasEvents.sol index d53e93e9b..8bd9383d7 100644 --- a/src/contracts/types/AtlasEvents.sol +++ b/src/contracts/types/AtlasEvents.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; contract AtlasEvents { // Metacall diff --git a/src/contracts/types/ConfigTypes.sol b/src/contracts/types/ConfigTypes.sol index 39605bce9..f68e327b5 100644 --- a/src/contracts/types/ConfigTypes.sol +++ b/src/contracts/types/ConfigTypes.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; struct DAppConfig { address to; // Address of the DAppControl contract diff --git a/src/contracts/types/DAppOperation.sol b/src/contracts/types/DAppOperation.sol index 897563d16..82a3b1d1c 100644 --- a/src/contracts/types/DAppOperation.sol +++ b/src/contracts/types/DAppOperation.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; bytes32 constant DAPP_TYPEHASH = keccak256( "DAppOperation(address from,address to,uint256 nonce,uint256 deadline,address control,address bundler,bytes32 userOpHash,bytes32 callChainHash)" diff --git a/src/contracts/types/EscrowTypes.sol b/src/contracts/types/EscrowTypes.sol index 7568cb582..c5e8f393c 100644 --- a/src/contracts/types/EscrowTypes.sol +++ b/src/contracts/types/EscrowTypes.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // bonded = total - unbonding struct EscrowAccountBalance { diff --git a/src/contracts/types/LockTypes.sol b/src/contracts/types/LockTypes.sol index f5831ff6d..938b7199b 100644 --- a/src/contracts/types/LockTypes.sol +++ b/src/contracts/types/LockTypes.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; struct Context { bytes32 userOpHash; // not packed diff --git a/src/contracts/types/SolverOperation.sol b/src/contracts/types/SolverOperation.sol index ffd9392e6..d58c73952 100644 --- a/src/contracts/types/SolverOperation.sol +++ b/src/contracts/types/SolverOperation.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; bytes32 constant SOLVER_TYPEHASH = keccak256( "SolverOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256 deadline,address solver,address control,bytes32 userOpHash,address bidToken,uint256 bidAmount,bytes data)" diff --git a/src/contracts/types/UserOperation.sol b/src/contracts/types/UserOperation.sol index de80f5c20..3a6d06600 100644 --- a/src/contracts/types/UserOperation.sol +++ b/src/contracts/types/UserOperation.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; // Default UserOperation typehash bytes32 constant USER_TYPEHASH_DEFAULT = keccak256( diff --git a/src/contracts/types/ValidCalls.sol b/src/contracts/types/ValidCalls.sol index 43a996434..0831a98a2 100644 --- a/src/contracts/types/ValidCalls.sol +++ b/src/contracts/types/ValidCalls.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; /// @title ValidCallsResult /// @notice Enum for ValidCallsResult diff --git a/test/Accounting.t.sol b/test/Accounting.t.sol index 0ca3c5042..1006d6047 100644 --- a/test/Accounting.t.sol +++ b/test/Accounting.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/AccountingMath.t.sol b/test/AccountingMath.t.sol index 2db24f74a..1a380ca6c 100644 --- a/test/AccountingMath.t.sol +++ b/test/AccountingMath.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import "../src/contracts/libraries/AccountingMath.sol"; diff --git a/test/AtlETH.t.sol b/test/AtlETH.t.sol index 76bc505b8..9c8a8aee6 100644 --- a/test/AtlETH.t.sol +++ b/test/AtlETH.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/AtlasVerification.t.sol b/test/AtlasVerification.t.sol index c703cafc7..093098e1c 100644 --- a/test/AtlasVerification.t.sol +++ b/test/AtlasVerification.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/BidFinding.t.sol b/test/BidFinding.t.sol index c30d339e5..c31e30bc7 100644 --- a/test/BidFinding.t.sol +++ b/test/BidFinding.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import { LibSort } from "solady/utils/LibSort.sol"; diff --git a/test/DAppIntegration.t.sol b/test/DAppIntegration.t.sol index 6f64b0bab..33b6533bb 100644 --- a/test/DAppIntegration.t.sol +++ b/test/DAppIntegration.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/Escrow.t.sol b/test/Escrow.t.sol index f31c292d6..cbde8b2e1 100644 --- a/test/Escrow.t.sol +++ b/test/Escrow.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/ExPost.t.sol b/test/ExPost.t.sol index 1fce2d00b..78f5add99 100644 --- a/test/ExPost.t.sol +++ b/test/ExPost.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/ExecutionBase.t.sol b/test/ExecutionBase.t.sol index 9a9debdc7..b30d6d542 100644 --- a/test/ExecutionBase.t.sol +++ b/test/ExecutionBase.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/ExecutionEnvironment.t.sol b/test/ExecutionEnvironment.t.sol index aa94f361b..e7bac6f64 100644 --- a/test/ExecutionEnvironment.t.sol +++ b/test/ExecutionEnvironment.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import { BaseTest } from "./base/BaseTest.t.sol"; diff --git a/test/FLOnline.t.sol b/test/FLOnline.t.sol index 4f43cf480..c8f9ab6e9 100644 --- a/test/FLOnline.t.sol +++ b/test/FLOnline.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/test/Factory.t.sol b/test/Factory.t.sol index 1552ae90e..80235982b 100644 --- a/test/Factory.t.sol +++ b/test/Factory.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/FlashLoan.t.sol b/test/FlashLoan.t.sol index a313d2abd..578741fd2 100644 --- a/test/FlashLoan.t.sol +++ b/test/FlashLoan.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/GasAccounting.t.sol b/test/GasAccounting.t.sol index 6c7cbcbc6..eb312230b 100644 --- a/test/GasAccounting.t.sol +++ b/test/GasAccounting.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; @@ -661,7 +661,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { vm.prank(executionEnvironment); mockGasAccounting.contribute{ value: 10 ether }(); - assertEq(mockGasAccounting.getClaims(), 10 ether, "Claims should be set to 10 ether"); + assertEq(mockGasAccounting.claims(), 10 ether, "Claims should be set to 10 ether"); assertEq(address(mockGasAccounting).balance, 10 ether, "mockGasAccounting should have 10 ether"); } @@ -1040,7 +1040,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { (uint256 claimsPaidToBundler, uint256 netGasSurcharge) = mockGasAccounting.settle(ctx); // Check final balances and perform assertions - uint256 finalClaims = mockGasAccounting.getClaims(); + uint256 finalClaims = mockGasAccounting.claims(); uint256 finalBonded = mockGasAccounting.balanceOfBonded(solverOneEOA); uint256 finalUnbonding = mockGasAccounting.balanceOfUnbonding(solverOneEOA); { @@ -1086,7 +1086,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { assertTrue(claimsPaidToBundler > 0, "Claims paid to bundler should be non-zero"); assertTrue(netGasSurcharge > 0, "Net gas surcharge should be non-zero"); assertLe( - mockGasAccounting.getClaims(), + mockGasAccounting.claims(), 3 ether, "Final claims should be less than or equal to initial claims plus deposits" ); diff --git a/test/MainTest.t.sol b/test/MainTest.t.sol index 6883c3a85..788b8ab9b 100644 --- a/test/MainTest.t.sol +++ b/test/MainTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/test/Mimic.t.sol b/test/Mimic.t.sol index f1a2445c9..c676dc6a7 100644 --- a/test/Mimic.t.sol +++ b/test/Mimic.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import { Mimic } from "../src/contracts/common/Mimic.sol"; diff --git a/test/NonceManager.t.sol b/test/NonceManager.t.sol index 083648fd6..76b60b175 100644 --- a/test/NonceManager.t.sol +++ b/test/NonceManager.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/OEV.t.sol b/test/OEV.t.sol index 0ad596d7d..267d966e4 100644 --- a/test/OEV.t.sol +++ b/test/OEV.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/OEValt.t.sol b/test/OEValt.t.sol index fc8ffa4a2..a836e5c1d 100644 --- a/test/OEValt.t.sol +++ b/test/OEValt.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/Permit69.t.sol b/test/Permit69.t.sol index af195d3e6..0d95172f5 100644 --- a/test/Permit69.t.sol +++ b/test/Permit69.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/SafetyLocks.t.sol b/test/SafetyLocks.t.sol index 80df01533..57347165b 100644 --- a/test/SafetyLocks.t.sol +++ b/test/SafetyLocks.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; @@ -57,7 +57,7 @@ contract MockSafetyLocks is SafetyLocks { } function setClaims(uint256 _claims) external { - _setClaims(_claims); + claims = _claims; } function setWithdrawals(uint256 _withdrawals) external { @@ -90,10 +90,6 @@ contract MockSafetyLocks is SafetyLocks { // View functions - function getClaims() external view returns (uint256) { - return claims(); - } - function getFees() external view returns (uint256) { return fees(); } @@ -158,7 +154,7 @@ contract SafetyLocksTest is Test { safetyLocks.setClaims(newClaims); - uint256 claims = safetyLocks.getClaims(); + uint256 claims = safetyLocks.claims(); assertEq(claims, newClaims); } @@ -245,7 +241,7 @@ contract SafetyLocksTest is Test { safetyLocks.setSolverLock(0x456); (address activeEnv, uint32 callConfig, uint8 phase) = safetyLocks.lock(); - uint256 claims = safetyLocks.getClaims(); + uint256 claims = safetyLocks.claims(); uint256 withdrawals = safetyLocks.getWithdrawals(); uint256 deposits = safetyLocks.getDeposits(); uint256 fees = safetyLocks.getFees(); diff --git a/test/Simulator.t.sol b/test/Simulator.t.sol index 61cae787e..1a842a92c 100644 --- a/test/Simulator.t.sol +++ b/test/Simulator.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/Sorter.t.sol b/test/Sorter.t.sol index 7f2224504..d24d52dd0 100644 --- a/test/Sorter.t.sol +++ b/test/Sorter.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { BaseTest } from "./base/BaseTest.t.sol"; diff --git a/test/Storage.t.sol b/test/Storage.t.sol index 242c04dc2..154d70f21 100644 --- a/test/Storage.t.sol +++ b/test/Storage.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; @@ -228,13 +228,13 @@ contract StorageTest is BaseTest { } function test_storage_transient_claims() public { - assertEq(atlas.getClaims(), 0, "claims should start at 0"); + assertEq(atlas.claims(), 0, "claims should start at 0"); atlas.setClaims(100); - assertEq(atlas.getClaims(), 100, "claims should be 100"); + assertEq(atlas.claims(), 100, "claims should be 100"); atlas.clearTransientStorage(); - assertEq(atlas.getClaims(), 0, "claims should be 0 again"); + assertEq(atlas.claims(), 0, "claims should be 0 again"); } function test_storage_transient_fees() public { @@ -420,7 +420,7 @@ contract MockStorage is Storage { _setLock(address(0), 0, 0); _setSolverLock(0); _setSolverTo(address(0)); - _setClaims(0); + claims = 0; _setFees(0); _setWriteoffs(0); _setWithdrawals(0); @@ -429,10 +429,6 @@ contract MockStorage is Storage { // View functions - function getClaims() external view returns (uint256) { - return claims(); - } - function getFees() external view returns (uint256) { return fees(); } diff --git a/test/Surcharge.t.sol b/test/Surcharge.t.sol index 53ea362fe..7ee7b2749 100644 --- a/test/Surcharge.t.sol +++ b/test/Surcharge.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import { BaseTest } from "./base/BaseTest.t.sol"; diff --git a/test/SwapIntent.t.sol b/test/SwapIntent.t.sol index 37f16b513..5ae6b8ce2 100644 --- a/test/SwapIntent.t.sol +++ b/test/SwapIntent.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/SwapIntentInvertBid.t.sol b/test/SwapIntentInvertBid.t.sol index 5ab8aadf2..4af3f86fd 100644 --- a/test/SwapIntentInvertBid.t.sol +++ b/test/SwapIntentInvertBid.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; diff --git a/test/TrebleSwap.t.sol b/test/TrebleSwap.t.sol index 79eac047f..e118e588b 100644 --- a/test/TrebleSwap.t.sol +++ b/test/TrebleSwap.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/V2Helper.sol b/test/V2Helper.sol index 18088422a..ed14f6c75 100644 --- a/test/V2Helper.sol +++ b/test/V2Helper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { TxBuilder } from "../src/contracts/helpers/TxBuilder.sol"; diff --git a/test/V2RewardDAppControl.t.sol b/test/V2RewardDAppControl.t.sol index 4a6776273..d20e697ef 100644 --- a/test/V2RewardDAppControl.t.sol +++ b/test/V2RewardDAppControl.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/base/ArbitrageTest.t.sol b/test/base/ArbitrageTest.t.sol index eda8080e9..2d7234a8b 100644 --- a/test/base/ArbitrageTest.t.sol +++ b/test/base/ArbitrageTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/base/BaseTest.t.sol b/test/base/BaseTest.t.sol index 07c0fcf02..ebec10978 100644 --- a/test/base/BaseTest.t.sol +++ b/test/base/BaseTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/base/DummyDAppControl.sol b/test/base/DummyDAppControl.sol index 99def7930..8d5dbc439 100644 --- a/test/base/DummyDAppControl.sol +++ b/test/base/DummyDAppControl.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { DAppControl } from "../../src/contracts/dapp/DAppControl.sol"; diff --git a/test/base/GasSponsorDAppControl.sol b/test/base/GasSponsorDAppControl.sol index c9de344cd..d6d676fbb 100644 --- a/test/base/GasSponsorDAppControl.sol +++ b/test/base/GasSponsorDAppControl.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { DAppControl } from "../../src/contracts/dapp/DAppControl.sol"; import { IAtlas } from "../../src/contracts/interfaces/IAtlas.sol"; diff --git a/test/base/TestAtlas.sol b/test/base/TestAtlas.sol index 8d9fe9bb2..828ea6762 100644 --- a/test/base/TestAtlas.sol +++ b/test/base/TestAtlas.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "../../src/contracts/atlas/Atlas.sol"; @@ -35,7 +35,7 @@ contract TestAtlas is Atlas { _setLock(address(0), 0, 0); _setSolverLock(0); _setSolverTo(address(0)); - _setClaims(0); + claims = 0; _setFees(0); _setWriteoffs(0); _setWithdrawals(0); @@ -59,7 +59,7 @@ contract TestAtlas is Atlas { } function setClaims(uint256 newClaims) public { - _setClaims(newClaims); + claims = newClaims; } function setFees(uint256 newFees) public { @@ -80,10 +80,6 @@ contract TestAtlas is Atlas { // View functions - function getClaims() external view returns (uint256) { - return claims(); - } - function getFees() external view returns (uint256) { return fees(); } diff --git a/test/base/TestUtils.sol b/test/base/TestUtils.sol index 4b6cae7ca..a3e942694 100644 --- a/test/base/TestUtils.sol +++ b/test/base/TestUtils.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { IDAppControl } from "../../src/contracts/interfaces/IDAppControl.sol"; import { Mimic } from "../../src/contracts/common/Mimic.sol"; diff --git a/test/base/builders/DAppOperationBuilder.sol b/test/base/builders/DAppOperationBuilder.sol index 76cb6c8f4..4d45d6f94 100644 --- a/test/base/builders/DAppOperationBuilder.sol +++ b/test/base/builders/DAppOperationBuilder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/base/builders/SolverOperationBuilder.sol b/test/base/builders/SolverOperationBuilder.sol index 9b3e9e53d..4130bb452 100644 --- a/test/base/builders/SolverOperationBuilder.sol +++ b/test/base/builders/SolverOperationBuilder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/base/builders/UserOperationBuilder.sol b/test/base/builders/UserOperationBuilder.sol index 126892e08..791642190 100644 --- a/test/base/builders/UserOperationBuilder.sol +++ b/test/base/builders/UserOperationBuilder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/base/interfaces/IUniswapV2Router.sol b/test/base/interfaces/IUniswapV2Router.sol index aa198cf3c..3d45d23c2 100644 --- a/test/base/interfaces/IUniswapV2Router.sol +++ b/test/base/interfaces/IUniswapV2Router.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; interface IUniswapV2Router01 { function factory() external pure returns (address); diff --git a/test/helpers/CallConfigBuilder.sol b/test/helpers/CallConfigBuilder.sol index 82800d46c..97dbc2a94 100644 --- a/test/helpers/CallConfigBuilder.sol +++ b/test/helpers/CallConfigBuilder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { CallConfig } from "../../src/contracts/types/ConfigTypes.sol"; diff --git a/test/helpers/DummyDAppControlBuilder.sol b/test/helpers/DummyDAppControlBuilder.sol index 5ef97d908..b86cf0037 100644 --- a/test/helpers/DummyDAppControlBuilder.sol +++ b/test/helpers/DummyDAppControlBuilder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { DummyDAppControl } from "../base/DummyDAppControl.sol"; import { CallConfig } from "../../src/contracts/types/ConfigTypes.sol"; diff --git a/test/libraries/CallBits.t.sol b/test/libraries/CallBits.t.sol index 0c5d6f5fd..7d217a22e 100644 --- a/test/libraries/CallBits.t.sol +++ b/test/libraries/CallBits.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/libraries/CallVerification.t.sol b/test/libraries/CallVerification.t.sol index a5c7aa404..1861ee266 100644 --- a/test/libraries/CallVerification.t.sol +++ b/test/libraries/CallVerification.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/libraries/EscrowBits.t.sol b/test/libraries/EscrowBits.t.sol index ff5f829e1..254cef218 100644 --- a/test/libraries/EscrowBits.t.sol +++ b/test/libraries/EscrowBits.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; diff --git a/test/libraries/SafetyBits.t.sol b/test/libraries/SafetyBits.t.sol index d9f4c06f7..1ec221353 100644 --- a/test/libraries/SafetyBits.t.sol +++ b/test/libraries/SafetyBits.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity 0.8.25; +pragma solidity 0.8.28; import "forge-std/Test.sol"; From c37e7a82fa88b2ebaefdd4948e75a91768e1f18d Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Sat, 19 Oct 2024 10:54:40 +0200 Subject: [PATCH 2/8] rm: FactoryLib file from different PR --- src/contracts/atlas/FactoryLib.sol | 145 ----------------------------- 1 file changed, 145 deletions(-) delete mode 100644 src/contracts/atlas/FactoryLib.sol diff --git a/src/contracts/atlas/FactoryLib.sol b/src/contracts/atlas/FactoryLib.sol deleted file mode 100644 index 9ca878bbc..000000000 --- a/src/contracts/atlas/FactoryLib.sol +++ /dev/null @@ -1,145 +0,0 @@ -//SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.28; - -import { Mimic } from "../common/Mimic.sol"; -import { AtlasEvents } from "../types/AtlasEvents.sol"; - -// NOTE: Do not call these functions directly. This contract should only ever be delegatecalled by the Atlas contract. - -contract FactoryLib { - address public immutable EXECUTION_ENV_TEMPLATE; - - /// @notice Initializes a new Factory contract instance by setting the immutable salt for deterministic deployment - /// of Execution Environments and storing the execution template address. - /// @dev The Execution Environment Template must be separately deployed using the same calculated salt. - /// @param executionTemplate Address of the pre-deployed execution template contract for creating Execution - /// Environment instances. - constructor(address executionTemplate) { - EXECUTION_ENV_TEMPLATE = executionTemplate; - } - - /// @notice Deploys a new execution environment or retrieves the address of an existing one based on the DApp - /// control, user, and configuration. - /// @dev Uses the `create2` opcode for deterministic deployment, allowing the calculation of the execution - /// environment's address before deployment. The deployment uses a combination of the DAppControl address, user - /// address, call configuration, and a unique salt to ensure the uniqueness and predictability of the environment's - /// address. - /// @param user The address of the user for whom the execution environment is being set. - /// @param control The address of the DAppControl contract providing the operational context. - /// @param callConfig CallConfig settings of the DAppControl contract. - /// @return executionEnvironment The address of the newly created or already existing execution environment. - function getOrCreateExecutionEnvironment( - address user, - address control, - uint32 callConfig, - bytes32 salt - ) - public - returns (address executionEnvironment) - { - bytes memory _creationCode = _getMimicCreationCode({ user: user, control: control, callConfig: callConfig }); - - executionEnvironment = address( - uint160( - uint256( - keccak256( - abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(abi.encodePacked(_creationCode))) - ) - ) - ) - ); - - if (executionEnvironment.code.length == 0) { - assembly { - executionEnvironment := create2(0, add(_creationCode, 32), mload(_creationCode), salt) - } - emit AtlasEvents.ExecutionEnvironmentCreated(user, executionEnvironment); - } - } - - /// @notice Generates the address of a user's execution environment affected by deprecated callConfig changes in the - /// DAppControl. - /// @dev Calculates the deterministic address of the execution environment based on the user, control, - /// callConfig, and controlCodeHash, ensuring consistency across changes in callConfig. - /// @param user The address of the user for whom the execution environment's address is being generated. - /// @param control The address of the DAppControl contract associated with the execution environment. - /// @param callConfig The configuration flags defining the behavior of the execution environment. - /// @return executionEnvironment The address of the user's execution environment. - function getExecutionEnvironmentCustom( - address user, - address control, - uint32 callConfig, - bytes32 salt - ) - public - view - returns (address executionEnvironment) - { - bytes memory _creationCode = _getMimicCreationCode({ user: user, control: control, callConfig: callConfig }); - - executionEnvironment = address( - uint160( - uint256( - keccak256( - abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(abi.encodePacked(_creationCode))) - ) - ) - ) - ); - } - - /// @notice Generates the creation code for the execution environment contract. - /// @param control The address of the DAppControl contract associated with the execution environment. - /// @param callConfig The configuration flags defining the behavior of the execution environment. - /// @param user The address of the user for whom the execution environment is being created, contributing to the - /// uniqueness of the creation code. - /// @return creationCode The bytecode representing the creation code of the execution environment contract. - function _getMimicCreationCode( - address user, - address control, - uint32 callConfig - ) - internal - view - returns (bytes memory creationCode) - { - address _executionLib = EXECUTION_ENV_TEMPLATE; - // NOTE: Changing compiler settings or solidity versions can break this. - creationCode = type(Mimic).creationCode; - - assembly { - // Insert the ExecutionEnvironment "Lib" address, into the AAAA placeholder in the creation code. - mstore( - add(creationCode, 79), - or( - and(mload(add(creationCode, 79)), not(shl(96, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))), - shl(96, _executionLib) - ) - ) - - // Insert the user address into the BBBB placeholder in the creation code. - mstore( - add(creationCode, 111), - or( - and(mload(add(creationCode, 111)), not(shl(96, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))), - shl(96, user) - ) - ) - - // Insert the control address into the CCCC placeholder in the creation code. - mstore( - add(creationCode, 132), - or( - and(mload(add(creationCode, 132)), not(shl(96, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))), - shl(96, control) - ) - ) - - // Insert the callConfig into the 2222 placeholder in the creation code. - mstore( - add(creationCode, 153), - or(and(mload(add(creationCode, 153)), not(shl(224, 0xFFFFFFFF))), shl(224, callConfig)) - ) - } - } -} From fdcdba516a44e583a3b99383630b3019a7062262 Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Sat, 19 Oct 2024 10:55:36 +0200 Subject: [PATCH 3/8] refactor: `transient` keyword for Accounting vars --- src/contracts/atlas/GasAccounting.sol | 48 +++++++++++----------- src/contracts/atlas/Storage.sol | 52 +++--------------------- test/GasAccounting.t.sol | 58 +++++++++++++-------------- test/SafetyLocks.t.sol | 50 ++++++++--------------- test/Storage.t.sol | 51 ++++++++--------------- test/base/TestAtlas.sol | 35 +++++----------- 6 files changed, 100 insertions(+), 194 deletions(-) diff --git a/src/contracts/atlas/GasAccounting.sol b/src/contracts/atlas/GasAccounting.sol index 474e6442c..2c734d7e4 100644 --- a/src/contracts/atlas/GasAccounting.sol +++ b/src/contracts/atlas/GasAccounting.sol @@ -49,13 +49,13 @@ abstract contract GasAccounting is SafetyLocks { claims = _rawClaims.withSurcharge(BUNDLER_SURCHARGE_RATE); // Atlas surcharge is based on the raw claims value. - _setFees(_rawClaims.getSurcharge(ATLAS_SURCHARGE_RATE)); - _setDeposits(msg.value); - _setSolverSurcharge(0); + fees = _rawClaims.getSurcharge(ATLAS_SURCHARGE_RATE); + deposits = msg.value; - // Explicitly set writeoffs and withdrawals to 0 in case multiple metacalls in single tx. - _setWriteoffs(0); - _setWithdrawals(0); + // Explicitly set other transient vars to 0 in case multiple metacalls in single tx. + writeoffs = 0; + withdrawals = 0; + solverSurcharge = 0; // Explicitly clear solverLock and solverTo in case multiple metacalls in single tx. _setSolverLock(0); @@ -100,12 +100,12 @@ abstract contract GasAccounting is SafetyLocks { /// @return uint256 The current shortfall amount, or 0 if there is no shortfall. function shortfall() external view returns (uint256) { uint256 _currentDeficit = _deficit(); - uint256 _deposits = deposits(); + uint256 _deposits = deposits; return (_currentDeficit > _deposits) ? (_currentDeficit - _deposits) : 0; } function _deficit() internal view returns (uint256) { - return claims + withdrawals() + fees() - writeoffs(); + return claims + withdrawals + fees - writeoffs; } /// @notice Allows a solver to settle any outstanding ETH owed, either to repay gas used by their solverOp or to @@ -137,12 +137,12 @@ abstract contract GasAccounting is SafetyLocks { if (maxApprovedGasSpend > _bondedBalance) maxApprovedGasSpend = _bondedBalance; uint256 _deductions = _deficit(); - uint256 _additions = deposits() + msg.value; + uint256 _additions = deposits + msg.value; // Add msg.value to solver's deposits // NOTE: Surplus deposits are credited back to the Solver during settlement. // NOTE: This function is called inside the solver try/catch and will be undone if solver fails. - if (msg.value > 0) _setDeposits(_additions); + if (msg.value > 0) deposits = _additions; // CASE: Callback verified but insufficient balance if (_deductions > _additions + maxApprovedGasSpend) { @@ -165,7 +165,7 @@ abstract contract GasAccounting is SafetyLocks { /// @notice Internal function to handle ETH contribution, increasing deposits if a non-zero value is sent. function _contribute() internal { - if (msg.value != 0) _setDeposits(deposits() + msg.value); + if (msg.value != 0) deposits += msg.value; } /// @notice Borrows ETH from the contract, transferring the specified amount to the caller if available. @@ -178,7 +178,7 @@ abstract contract GasAccounting is SafetyLocks { if (amount == 0) return true; if (address(this).balance < amount) return false; - _setWithdrawals(withdrawals() + amount); + withdrawals += amount; return true; } @@ -221,7 +221,7 @@ abstract contract GasAccounting is SafetyLocks { s_balanceOf[owner].unbonding = 0; _aData.bonded = 0; - _setWriteoffs(writeoffs() + deficit); + writeoffs += deficit; amount -= deficit; // Set amount equal to total to accurately track the changing bondedTotalSupply } else { // The unbonding balance is sufficient to cover the remaining amount owed. Draw everything from the @@ -242,7 +242,7 @@ abstract contract GasAccounting is SafetyLocks { S_accessData[owner] = _aData; S_bondedTotalSupply -= amount; - _setDeposits(deposits() + amount); + deposits += amount; } /// @notice Increases the owner's bonded balance by the specified amount. @@ -264,7 +264,7 @@ abstract contract GasAccounting is SafetyLocks { // Persist changes in the _aData memory struct back to storage S_accessData[owner] = _aData; - _setWithdrawals(withdrawals() + amount); + withdrawals += amount; } /// @notice Accounts for the gas cost of a failed SolverOperation, either by increasing writeoffs (if the bundler is @@ -293,7 +293,7 @@ abstract contract GasAccounting is SafetyLocks { if (result.bundlersFault()) { // CASE: Solver is not responsible for the failure of their operation, so we blame the bundler // and reduce the total amount refunded to the bundler - _setWriteoffs(writeoffs() + _gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE)); + writeoffs += _gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); } else { // CASE: Solver failed, so we calculate what they owe. uint256 _gasUsedWithSurcharges = _gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); @@ -308,13 +308,13 @@ abstract contract GasAccounting is SafetyLocks { // so that in the event of no successful solvers, any `_assign()`ed surcharges can be attributed to an // increase in Atlas' cumulative surcharge. if (_surchargesOnly > _assignDeficit) { - _setSolverSurcharge(solverSurcharge() + (_surchargesOnly - _assignDeficit)); + solverSurcharge += (_surchargesOnly - _assignDeficit); } } } function _writeOffBidFindGasCost(uint256 gasUsed) internal { - _setWriteoffs(writeoffs() + gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE)); + writeoffs += gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); } /// @param ctx Context struct containing relevant context information for the Atlas auction. @@ -344,11 +344,11 @@ abstract contract GasAccounting is SafetyLocks { { uint256 _surcharge = S_cumulativeSurcharge; - adjustedWithdrawals = withdrawals(); - adjustedDeposits = deposits(); + adjustedWithdrawals = withdrawals; + adjustedDeposits = deposits; adjustedClaims = claims; - adjustedWriteoffs = writeoffs(); - uint256 _fees = fees(); + adjustedWriteoffs = writeoffs; + uint256 _fees = fees; uint256 _gasLeft = gasleft(); // Hold this constant for the calculations @@ -368,7 +368,7 @@ abstract contract GasAccounting is SafetyLocks { S_cumulativeSurcharge = _surcharge + netAtlasGasSurcharge; } else { // If no successful solvers, only collect partial surcharges from solver's fault failures (if any) - uint256 _solverSurcharge = solverSurcharge(); + uint256 _solverSurcharge = solverSurcharge; if (_solverSurcharge > 0) { netAtlasGasSurcharge = _solverSurcharge.getPortionFromTotalSurcharge({ targetSurchargeRate: ATLAS_SURCHARGE_RATE, @@ -533,6 +533,6 @@ abstract contract GasAccounting is SafetyLocks { /// correct. /// @return True if the balance is reconciled, false otherwise. function _isBalanceReconciled() internal view returns (bool) { - return deposits() >= _deficit(); + return deposits >= _deficit(); } } diff --git a/src/contracts/atlas/Storage.sol b/src/contracts/atlas/Storage.sol index 2d2120554..326d1f23d 100644 --- a/src/contracts/atlas/Storage.sol +++ b/src/contracts/atlas/Storage.sol @@ -37,11 +37,11 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { bytes32 private constant _T_SOLVER_TO_SLOT = keccak256("ATLAS_SOLVER_TO"); uint256 public transient claims; - bytes32 private constant _T_FEES_SLOT = keccak256("ATLAS_FEES"); - bytes32 private constant _T_WRITEOFFS_SLOT = keccak256("ATLAS_WRITEOFFS"); - bytes32 private constant _T_WITHDRAWALS_SLOT = keccak256("ATLAS_WITHDRAWALS"); - bytes32 private constant _T_DEPOSITS_SLOT = keccak256("ATLAS_DEPOSITS"); - bytes32 private constant _T_SOLVER_SURCHARGE_SLOT = keccak256("ATLAS_SOLVER_SURCHARGE"); + uint256 public transient fees; + uint256 public transient writeoffs; + uint256 public transient withdrawals; + uint256 public transient deposits; + uint256 public transient solverSurcharge; // total surcharge collected from failed solverOps due to solver fault. // AtlETH storage uint256 internal S_totalSupply; @@ -155,26 +155,6 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { // Transient Internal Getters // // ---------------------------------------------------- // - function fees() internal view returns (uint256) { - return uint256(_tload(_T_FEES_SLOT)); - } - - function writeoffs() internal view returns (uint256) { - return uint256(_tload(_T_WRITEOFFS_SLOT)); - } - - function withdrawals() internal view returns (uint256) { - return uint256(_tload(_T_WITHDRAWALS_SLOT)); - } - - function deposits() internal view returns (uint256) { - return uint256(_tload(_T_DEPOSITS_SLOT)); - } - - function solverSurcharge() internal view returns (uint256) { - return uint256(_tload(_T_SOLVER_SURCHARGE_SLOT)); - } - function _lock() internal view returns (address activeEnvironment, uint32 callConfig, uint8 phase) { bytes32 _lockData = _tload(_T_LOCK_SLOT); activeEnvironment = address(uint160(uint256(_lockData >> 40))); @@ -248,28 +228,6 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { _tstore(_T_SOLVER_TO_SLOT, bytes32(uint256(uint160(newSolverTo)))); } - function _setFees(uint256 newFees) internal { - _tstore(_T_FEES_SLOT, bytes32(newFees)); - } - - function _setWriteoffs(uint256 newWriteoffs) internal { - _tstore(_T_WRITEOFFS_SLOT, bytes32(newWriteoffs)); - } - - function _setWithdrawals(uint256 newWithdrawals) internal { - _tstore(_T_WITHDRAWALS_SLOT, bytes32(newWithdrawals)); - } - - function _setDeposits(uint256 newDeposits) internal { - _tstore(_T_DEPOSITS_SLOT, bytes32(newDeposits)); - } - - // NOTE: Only captures surcharges for failed solver Ops where - // solver is at fault - function _setSolverSurcharge(uint256 newSurcharge) internal { - _tstore(_T_SOLVER_SURCHARGE_SLOT, bytes32(newSurcharge)); - } - // ------------------------------------------------------ // // Transient Storage Helpers // // ------------------------------------------------------ // diff --git a/test/GasAccounting.t.sol b/test/GasAccounting.t.sol index eb312230b..47c7b6177 100644 --- a/test/GasAccounting.t.sol +++ b/test/GasAccounting.t.sol @@ -315,7 +315,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { // Verify the balances after contribution assertEq(address(mockGasAccounting).balance, contributeValue); - assertEq(mockGasAccounting.getDeposits(), contributeValue); + assertEq(mockGasAccounting.deposits(), contributeValue); } function test_multipleContributes() public { @@ -334,7 +334,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { // Verify the balances after the first contribution assertEq(address(mockGasAccounting).balance, firstContributeValue); - assertEq(mockGasAccounting.getDeposits(), firstContributeValue); + assertEq(mockGasAccounting.deposits(), firstContributeValue); // Perform the second valid contribute call vm.prank(executionEnvironment); @@ -342,7 +342,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { // Verify the balances after the second contribution assertEq(address(mockGasAccounting).balance, totalContributeValue); - assertEq(mockGasAccounting.getDeposits(), totalContributeValue); + assertEq(mockGasAccounting.deposits(), totalContributeValue); } function test_contribute_withZeroValue() public { @@ -358,7 +358,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { // Verify the balances after the contribution is zero assertEq(address(mockGasAccounting).balance, contributeValue); - assertEq(mockGasAccounting.getDeposits(), contributeValue); + assertEq(mockGasAccounting.deposits(), contributeValue); } function test_borrow_preOpsPhase() public { @@ -373,7 +373,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { assertEq( solverOneEOA.balance, borrowedAmount, "Execution environment balance should be equal to borrowed amount" ); - assertEq(borrowedAmount, mockGasAccounting.getWithdrawals(), "Withdrawals should be equal to borrowed amount"); + assertEq(borrowedAmount, mockGasAccounting.withdrawals(), "Withdrawals should be equal to borrowed amount"); } function test_borrow_userOperationPhase() public { @@ -390,7 +390,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { borrowedAmount, "Execution environment balance should be equal to borrowed amount" ); - assertEq(borrowedAmount, mockGasAccounting.getWithdrawals(), "Withdrawals should be equal to borrowed amount"); + assertEq(borrowedAmount, mockGasAccounting.withdrawals(), "Withdrawals should be equal to borrowed amount"); } function test_borrow_preSolverPhase() public { @@ -407,7 +407,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { borrowedAmount, "Execution environment balance should be equal to borrowed amount" ); - assertEq(borrowedAmount, mockGasAccounting.getWithdrawals(), "Withdrawals should be equal to borrowed amount"); + assertEq(borrowedAmount, mockGasAccounting.withdrawals(), "Withdrawals should be equal to borrowed amount"); } function test_borrow_solverOperationPhase() public { @@ -423,12 +423,12 @@ contract GasAccountingTest is AtlasConstants, BaseTest { borrowedAmount, "Execution environment balance should be equal to borrowed amount" ); - assertEq(borrowedAmount, mockGasAccounting.getWithdrawals(), "Withdrawals should be equal to borrowed amount"); + assertEq(borrowedAmount, mockGasAccounting.withdrawals(), "Withdrawals should be equal to borrowed amount"); } function test_borrow_postSolverPhase_reverts() public { uint256 borrowedAmount = 1e18; - uint256 withdrawalsBefore = mockGasAccounting.getWithdrawals(); + uint256 withdrawalsBefore = mockGasAccounting.withdrawals(); fundContract(borrowedAmount); mockGasAccounting.setLock(executionEnvironment, 0, uint8(ExecutionPhase.PostSolver)); @@ -437,12 +437,12 @@ contract GasAccountingTest is AtlasConstants, BaseTest { mockGasAccounting.borrow(borrowedAmount); assertEq(executionEnvironment.balance, 0, "Execution environment balance should remain zero"); - assertEq(withdrawalsBefore, mockGasAccounting.getWithdrawals(), "Withdrawals should remain unchanged"); + assertEq(withdrawalsBefore, mockGasAccounting.withdrawals(), "Withdrawals should remain unchanged"); } function test_borrow_allocateValuePhase_reverts() public { uint256 borrowedAmount = 1e18; - uint256 withdrawalsBefore = mockGasAccounting.getWithdrawals(); + uint256 withdrawalsBefore = mockGasAccounting.withdrawals(); fundContract(borrowedAmount); mockGasAccounting.setLock(executionEnvironment, 0, uint8(ExecutionPhase.AllocateValue)); @@ -451,12 +451,12 @@ contract GasAccountingTest is AtlasConstants, BaseTest { mockGasAccounting.borrow(borrowedAmount); assertEq(executionEnvironment.balance, 0, "Execution environment balance should remain zero"); - assertEq(withdrawalsBefore, mockGasAccounting.getWithdrawals(), "Withdrawals should remain unchanged"); + assertEq(withdrawalsBefore, mockGasAccounting.withdrawals(), "Withdrawals should remain unchanged"); } function test_borrow_postOpsPhase_reverts() public { uint256 borrowedAmount = 1e18; - uint256 withdrawalsBefore = mockGasAccounting.getWithdrawals(); + uint256 withdrawalsBefore = mockGasAccounting.withdrawals(); fundContract(borrowedAmount); mockGasAccounting.setLock(executionEnvironment, 0, uint8(ExecutionPhase.PostOps)); @@ -465,7 +465,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { mockGasAccounting.borrow(borrowedAmount); assertEq(executionEnvironment.balance, 0, "Execution environment balance should remain zero"); - assertEq(withdrawalsBefore, mockGasAccounting.getWithdrawals(), "Withdrawals should remain unchanged"); + assertEq(withdrawalsBefore, mockGasAccounting.withdrawals(), "Withdrawals should remain unchanged"); } function test_multipleBorrows() public { @@ -529,7 +529,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { "Final contract balance should be initial balance minus total borrowed amount" ); assertEq( - totalBorrowAmount, mockGasAccounting.getWithdrawals(), "Withdrawals should equal total borrowed amount" + totalBorrowAmount, mockGasAccounting.withdrawals(), "Withdrawals should equal total borrowed amount" ); } @@ -735,7 +735,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { assertEq(currentSolver, solverOneEOA, "Current solver should match execution environment"); // Verify that deposits did not increase - assertEq(mockGasAccounting.getDeposits(), initialClaims, "Deposits should remain unchanged"); + assertEq(mockGasAccounting.deposits(), initialClaims, "Deposits should remain unchanged"); } function test_reconcileWithETH() public { @@ -762,7 +762,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { assertEq(currentSolver, solverOneEOA, "Current solver should match execution environment"); // Verify that deposits increased by the reconciled amount - assertEq(mockGasAccounting.getDeposits(), initialClaims, "Deposits should match the amount sent as msg.value"); + assertEq(mockGasAccounting.deposits(), initialClaims, "Deposits should match the amount sent as msg.value"); } function test_assign_zeroAmount() public { @@ -784,7 +784,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { // Get initial values uint256 bondedTotalSupplyBefore = mockGasAccounting.bondedTotalSupply(); - uint256 depositsBefore = mockGasAccounting.getDeposits(); + uint256 depositsBefore = mockGasAccounting.deposits(); uint256 deficit = mockGasAccounting.assign(solverOp.from, assignedAmount, assignedAmount, true); assertEq(deficit, 0, "Deficit should be 0"); @@ -793,7 +793,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { assertEq(lastAccessedBlock, uint32(block.number)); uint256 bondedTotalSupplyAfter = mockGasAccounting.bondedTotalSupply(); - uint256 depositsAfter = mockGasAccounting.getDeposits(); + uint256 depositsAfter = mockGasAccounting.deposits(); assertEq(bondedTotalSupplyAfter, bondedTotalSupplyBefore - assignedAmount); assertEq(depositsAfter, depositsBefore + assignedAmount); @@ -809,7 +809,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { mockGasAccounting.increaseBondedBalance(solverOp.from, bondedAmount); // Set bonded balance to 500 uint256 bondedTotalSupplyBefore = mockGasAccounting.bondedTotalSupply(); - uint256 depositsBefore = mockGasAccounting.getDeposits(); + uint256 depositsBefore = mockGasAccounting.deposits(); // Call the assign function and capture the deficit uint256 deficit = mockGasAccounting.assign(solverOp.from, assignedAmount, assignedAmount, true); @@ -825,7 +825,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { bondedTotalSupplyBefore - assignedAmount, "Bonded total supply mismatch" ); - assertEq(mockGasAccounting.getDeposits(), depositsBefore + assignedAmount, "Deposits mismatch"); + assertEq(mockGasAccounting.deposits(), depositsBefore + assignedAmount, "Deposits mismatch"); // Retrieve and check the updated balances (uint112 bonded, uint112 unbonding) = mockGasAccounting._balanceOf(solverOp.from); @@ -843,13 +843,13 @@ contract GasAccountingTest is AtlasConstants, BaseTest { mockGasAccounting.increaseBondedBalance(solverOp.from, bondedAmount); uint256 bondedTotalSupplyBefore = mockGasAccounting.bondedTotalSupply(); - uint256 depositsBefore = mockGasAccounting.getDeposits(); + uint256 depositsBefore = mockGasAccounting.deposits(); uint256 deficit = mockGasAccounting.assign(solverOp.from, assignedAmount, assignedAmount, true); assertEq(deficit, assignedAmount - (unbondingAmount + bondedAmount)); (, uint32 lastAccessedBlock,,,) = mockGasAccounting.accessData(solverOp.from); assertEq(lastAccessedBlock, uint32(block.number)); assertEq(mockGasAccounting.bondedTotalSupply(), bondedTotalSupplyBefore - (unbondingAmount + bondedAmount)); - assertEq(mockGasAccounting.getDeposits(), depositsBefore + (unbondingAmount + bondedAmount)); + assertEq(mockGasAccounting.deposits(), depositsBefore + (unbondingAmount + bondedAmount)); (uint112 bonded, uint112 unbonding) = mockGasAccounting._balanceOf(solverOp.from); assertEq(unbonding, 0); assertEq(bonded, 0); @@ -912,14 +912,14 @@ contract GasAccountingTest is AtlasConstants, BaseTest { mockGasAccounting.increaseBondedBalance(solverOp.from, bondedAmount); uint256 bondedTotalSupplyBefore = mockGasAccounting.bondedTotalSupply(); - uint256 depositsBefore = mockGasAccounting.getDeposits(); + uint256 depositsBefore = mockGasAccounting.deposits(); (uint112 unbondingBefore,) = mockGasAccounting._balanceOf(solverOp.from); vm.expectRevert(AtlasErrors.ValueTooLarge.selector); mockGasAccounting.assign(solverOp.from, assignedAmount, assignedAmount, true); // Check assign reverted with overflow, and accounting values did not change assertEq(mockGasAccounting.bondedTotalSupply(), bondedTotalSupplyBefore); - assertEq(mockGasAccounting.getDeposits(), depositsBefore); + assertEq(mockGasAccounting.deposits(), depositsBefore); (uint112 unbonding,) = mockGasAccounting._balanceOf(solverOp.from); assertEq(unbonding, unbondingBefore); } @@ -929,7 +929,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { uint256 lastAccessedBlock; uint256 bondedTotalSupplyBefore = mockGasAccounting.bondedTotalSupply(); - uint256 withdrawalsBefore = mockGasAccounting.getWithdrawals(); + uint256 withdrawalsBefore = mockGasAccounting.withdrawals(); (uint112 bondedBefore,,,,) = mockGasAccounting.accessData(solverOp.from); (, lastAccessedBlock,,,) = mockGasAccounting.accessData(solverOp.from); assertEq(lastAccessedBlock, 0); @@ -942,7 +942,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { assertEq(lastAccessedBlock, uint32(block.number)); assertEq(mockGasAccounting.bondedTotalSupply(), bondedTotalSupplyBefore + creditedAmount); assertEq(bondedAfter, bondedBefore + uint112(creditedAmount)); - assertEq(mockGasAccounting.getWithdrawals(), withdrawalsBefore + creditedAmount); + assertEq(mockGasAccounting.withdrawals(), withdrawalsBefore + creditedAmount); // Testing uint112 boundary values for casting from uint256 to uint112 in _credit() uint256 overflowAmount = uint256(type(uint112).max) + 1; @@ -954,7 +954,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { // Setup solverOp.data = ""; uint256 gasWaterMark = gasleft() + 5000; - uint256 initialWriteoffs = mockGasAccounting.getWriteoffs(); + uint256 initialWriteoffs = mockGasAccounting.writeoffs(); // Simulate solver not responsible for failure uint256 result = EscrowBits._NO_REFUND; @@ -971,7 +971,7 @@ contract GasAccountingTest is AtlasConstants, BaseTest { uint256 expectedWriteoffs = initialWriteoffs + AccountingMath.withSurcharges(gasUsed, DEFAULT_ATLAS_SURCHARGE_RATE, DEFAULT_BUNDLER_SURCHARGE_RATE); // Verify writeoffs have increased assertApproxEqRel( - mockGasAccounting.getWriteoffs(), + mockGasAccounting.writeoffs(), expectedWriteoffs, 1e15, // 0.1% margin for error "Writeoffs should be approximately equal to expected value" diff --git a/test/SafetyLocks.t.sol b/test/SafetyLocks.t.sol index 57347165b..de65cbbc9 100644 --- a/test/SafetyLocks.t.sol +++ b/test/SafetyLocks.t.sol @@ -60,20 +60,20 @@ contract MockSafetyLocks is SafetyLocks { claims = _claims; } - function setWithdrawals(uint256 _withdrawals) external { - _setWithdrawals(_withdrawals); + function setFees(uint256 newFees) public { + fees = newFees; } - function setDeposits(uint256 _deposits) external { - _setDeposits(_deposits); + function setWriteoffs(uint256 newWriteoffs) public { + writeoffs = newWriteoffs; } - function setFees(uint256 _fees) external { - _setFees(_fees); + function setWithdrawals(uint256 newWithdrawals) public { + withdrawals = newWithdrawals; } - function setWriteoffs(uint256 _writeoffs) external { - _setWriteoffs(_writeoffs); + function setDeposits(uint256 newDeposits) public { + deposits = newDeposits; } function setSolverLock(uint256 newSolverLock) external { @@ -87,24 +87,6 @@ contract MockSafetyLocks is SafetyLocks { function solverTo() external view returns (address) { return _solverTo(); } - - // View functions - - function getFees() external view returns (uint256) { - return fees(); - } - - function getWriteoffs() external view returns (uint256) { - return writeoffs(); - } - - function getWithdrawals() external view returns (uint256) { - return withdrawals(); - } - - function getDeposits() external view returns (uint256) { - return deposits(); - } } contract SafetyLocksTest is Test { @@ -163,7 +145,7 @@ contract SafetyLocksTest is Test { safetyLocks.setWithdrawals(newWithdrawals); - uint256 withdrawals = safetyLocks.getWithdrawals(); + uint256 withdrawals = safetyLocks.withdrawals(); assertEq(withdrawals, newWithdrawals); } @@ -172,7 +154,7 @@ contract SafetyLocksTest is Test { safetyLocks.setDeposits(newDeposits); - uint256 deposits = safetyLocks.getDeposits(); + uint256 deposits = safetyLocks.deposits(); assertEq(deposits, newDeposits); } @@ -181,7 +163,7 @@ contract SafetyLocksTest is Test { safetyLocks.setFees(newFees); - uint256 fees = safetyLocks.getFees(); + uint256 fees = safetyLocks.fees(); assertEq(fees, newFees); } @@ -190,7 +172,7 @@ contract SafetyLocksTest is Test { safetyLocks.setWriteoffs(newWriteoffs); - uint256 writeoffs = safetyLocks.getWriteoffs(); + uint256 writeoffs = safetyLocks.writeoffs(); assertEq(writeoffs, newWriteoffs); } @@ -242,10 +224,10 @@ contract SafetyLocksTest is Test { (address activeEnv, uint32 callConfig, uint8 phase) = safetyLocks.lock(); uint256 claims = safetyLocks.claims(); - uint256 withdrawals = safetyLocks.getWithdrawals(); - uint256 deposits = safetyLocks.getDeposits(); - uint256 fees = safetyLocks.getFees(); - uint256 writeoffs = safetyLocks.getWriteoffs(); + uint256 withdrawals = safetyLocks.withdrawals(); + uint256 deposits = safetyLocks.deposits(); + uint256 fees = safetyLocks.fees(); + uint256 writeoffs = safetyLocks.writeoffs(); (address solverTo,,) = safetyLocks.solverLockData(); assertEq(safetyLocks.isUnlocked(), false); diff --git a/test/Storage.t.sol b/test/Storage.t.sol index 154d70f21..eaca89d1c 100644 --- a/test/Storage.t.sol +++ b/test/Storage.t.sol @@ -238,43 +238,43 @@ contract StorageTest is BaseTest { } function test_storage_transient_fees() public { - assertEq(atlas.getFees(), 0, "fees should start at 0"); + assertEq(atlas.fees(), 0, "fees should start at 0"); atlas.setFees(100); - assertEq(atlas.getFees(), 100, "fees should be 100"); + assertEq(atlas.fees(), 100, "fees should be 100"); atlas.clearTransientStorage(); - assertEq(atlas.getFees(), 0, "fees should be 0 again"); + assertEq(atlas.fees(), 0, "fees should be 0 again"); } function test_storage_transient_writeoffs() public { - assertEq(atlas.getWriteoffs(), 0, "writeoffs should start at 0"); + assertEq(atlas.writeoffs(), 0, "writeoffs should start at 0"); atlas.setWriteoffs(100); - assertEq(atlas.getWriteoffs(), 100, "writeoffs should be 100"); + assertEq(atlas.writeoffs(), 100, "writeoffs should be 100"); atlas.clearTransientStorage(); - assertEq(atlas.getWriteoffs(), 0, "writeoffs should be 0 again"); + assertEq(atlas.writeoffs(), 0, "writeoffs should be 0 again"); } function test_storage_transient_withdrawals() public { - assertEq(atlas.getWithdrawals(), 0, "withdrawals should start at 0"); + assertEq(atlas.withdrawals(), 0, "withdrawals should start at 0"); atlas.setWithdrawals(100); - assertEq(atlas.getWithdrawals(), 100, "withdrawals should be 100"); + assertEq(atlas.withdrawals(), 100, "withdrawals should be 100"); atlas.clearTransientStorage(); - assertEq(atlas.getWithdrawals(), 0, "withdrawals should be 0 again"); + assertEq(atlas.withdrawals(), 0, "withdrawals should be 0 again"); } function test_storage_transient_deposits() public { - assertEq(atlas.getDeposits(), 0, "deposits should start at 0"); + assertEq(atlas.deposits(), 0, "deposits should start at 0"); atlas.setDeposits(100); - assertEq(atlas.getDeposits(), 100, "deposits should be 100"); + assertEq(atlas.deposits(), 100, "deposits should be 100"); atlas.clearTransientStorage(); - assertEq(atlas.getDeposits(), 0, "deposits should be 0 again"); + assertEq(atlas.deposits(), 0, "deposits should be 0 again"); } function test_storage_transient_solverTo() public { @@ -421,27 +421,10 @@ contract MockStorage is Storage { _setSolverLock(0); _setSolverTo(address(0)); claims = 0; - _setFees(0); - _setWriteoffs(0); - _setWithdrawals(0); - _setDeposits(0); - } - - // View functions - - function getFees() external view returns (uint256) { - return fees(); - } - - function getWriteoffs() external view returns (uint256) { - return writeoffs(); - } - - function getWithdrawals() external view returns (uint256) { - return withdrawals(); - } - - function getDeposits() external view returns (uint256) { - return deposits(); + fees = 0; + writeoffs = 0; + withdrawals = 0; + deposits = 0; + solverSurcharge = 0; } } diff --git a/test/base/TestAtlas.sol b/test/base/TestAtlas.sol index 828ea6762..679eb476c 100644 --- a/test/base/TestAtlas.sol +++ b/test/base/TestAtlas.sol @@ -36,10 +36,11 @@ contract TestAtlas is Atlas { _setSolverLock(0); _setSolverTo(address(0)); claims = 0; - _setFees(0); - _setWriteoffs(0); - _setWithdrawals(0); - _setDeposits(0); + fees = 0; + writeoffs = 0; + withdrawals = 0; + deposits = 0; + solverSurcharge = 0; } function setLock(address activeEnvironment, uint32 callConfig, uint8 phase) public { @@ -63,36 +64,18 @@ contract TestAtlas is Atlas { } function setFees(uint256 newFees) public { - _setFees(newFees); + fees = newFees; } function setWriteoffs(uint256 newWriteoffs) public { - _setWriteoffs(newWriteoffs); + writeoffs = newWriteoffs; } function setWithdrawals(uint256 newWithdrawals) public { - _setWithdrawals(newWithdrawals); + withdrawals = newWithdrawals; } function setDeposits(uint256 newDeposits) public { - _setDeposits(newDeposits); - } - - // View functions - - function getFees() external view returns (uint256) { - return fees(); - } - - function getWriteoffs() external view returns (uint256) { - return writeoffs(); - } - - function getWithdrawals() external view returns (uint256) { - return withdrawals(); - } - - function getDeposits() external view returns (uint256) { - return deposits(); + deposits = newDeposits; } } From 0950125cfd03e6ce8ed9040f8159162c7a3e3eed Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Sat, 19 Oct 2024 15:41:38 +0200 Subject: [PATCH 4/8] refactor: make transient vars internal + `t_` prefixed --- src/contracts/atlas/Escrow.sol | 4 +- src/contracts/atlas/GasAccounting.sol | 62 +++++++++++++-------------- src/contracts/atlas/Storage.sol | 31 +++++--------- test/GasAccounting.t.sol | 2 +- test/SafetyLocks.t.sol | 44 ++++++++++++++----- test/Storage.t.sol | 20 ++++----- test/base/TestAtlas.sol | 52 +++++++++++++++------- 7 files changed, 123 insertions(+), 92 deletions(-) diff --git a/src/contracts/atlas/Escrow.sol b/src/contracts/atlas/Escrow.sol index 2d68b88f6..3bcd5da45 100644 --- a/src/contracts/atlas/Escrow.sol +++ b/src/contracts/atlas/Escrow.sol @@ -573,8 +573,8 @@ abstract contract Escrow is AtlETH { bool _success; // Set the solver lock and solver address at the beginning to ensure reliability - _setSolverLock(uint256(uint160(solverOp.from))); - _setSolverTo(solverOp.solver); + t_solverLock = uint256(uint160(solverOp.from)); + t_solverTo = solverOp.solver; // ------------------------------------- // // Pre-Solver Call // diff --git a/src/contracts/atlas/GasAccounting.sol b/src/contracts/atlas/GasAccounting.sol index 2c734d7e4..43e0c7ece 100644 --- a/src/contracts/atlas/GasAccounting.sol +++ b/src/contracts/atlas/GasAccounting.sol @@ -46,20 +46,18 @@ abstract contract GasAccounting is SafetyLocks { uint256 _rawClaims = (FIXED_GAS_OFFSET + gasMarker) * tx.gasprice; // Set any withdraws or deposits - claims = _rawClaims.withSurcharge(BUNDLER_SURCHARGE_RATE); + t_claims = _rawClaims.withSurcharge(BUNDLER_SURCHARGE_RATE); // Atlas surcharge is based on the raw claims value. - fees = _rawClaims.getSurcharge(ATLAS_SURCHARGE_RATE); - deposits = msg.value; + t_fees = _rawClaims.getSurcharge(ATLAS_SURCHARGE_RATE); + t_deposits = msg.value; // Explicitly set other transient vars to 0 in case multiple metacalls in single tx. - writeoffs = 0; - withdrawals = 0; - solverSurcharge = 0; - - // Explicitly clear solverLock and solverTo in case multiple metacalls in single tx. - _setSolverLock(0); - _setSolverTo(address(0)); + t_writeoffs = 0; + t_withdrawals = 0; + t_solverSurcharge = 0; + t_solverLock = 0; + t_solverTo = address(0); // The Lock slot is cleared at the end of the metacall, so no need to zero again here. } @@ -100,12 +98,12 @@ abstract contract GasAccounting is SafetyLocks { /// @return uint256 The current shortfall amount, or 0 if there is no shortfall. function shortfall() external view returns (uint256) { uint256 _currentDeficit = _deficit(); - uint256 _deposits = deposits; + uint256 _deposits = t_deposits; return (_currentDeficit > _deposits) ? (_currentDeficit - _deposits) : 0; } function _deficit() internal view returns (uint256) { - return claims + withdrawals + fees - writeoffs; + return t_claims + t_withdrawals + t_fees - t_writeoffs; } /// @notice Allows a solver to settle any outstanding ETH owed, either to repay gas used by their solverOp or to @@ -128,7 +126,7 @@ abstract contract GasAccounting is SafetyLocks { // calls directly to the solver contract in this phase, the solver should be careful to not call malicious // contracts which may call reconcile() on their behalf, with an excessive maxApprovedGasSpend. if (_phase() != uint8(ExecutionPhase.SolverOperation)) revert WrongPhase(); - if (msg.sender != _solverTo()) revert InvalidAccess(); + if (msg.sender != t_solverTo) revert InvalidAccess(); (address _currentSolver, bool _calledBack, bool _fulfilled) = _solverLockData(); uint256 _bondedBalance = uint256(S_accessData[_currentSolver].bonded); @@ -137,12 +135,12 @@ abstract contract GasAccounting is SafetyLocks { if (maxApprovedGasSpend > _bondedBalance) maxApprovedGasSpend = _bondedBalance; uint256 _deductions = _deficit(); - uint256 _additions = deposits + msg.value; + uint256 _additions = t_deposits + msg.value; // Add msg.value to solver's deposits // NOTE: Surplus deposits are credited back to the Solver during settlement. // NOTE: This function is called inside the solver try/catch and will be undone if solver fails. - if (msg.value > 0) deposits = _additions; + if (msg.value > 0) t_deposits = _additions; // CASE: Callback verified but insufficient balance if (_deductions > _additions + maxApprovedGasSpend) { @@ -151,21 +149,21 @@ abstract contract GasAccounting is SafetyLocks { // but it does treat any msg.value as a deposit and allows for either the solver to call back with a // higher maxApprovedGasSpend or to have their deficit covered by a contribute during the postSolverOp // hook. - _setSolverLock(uint256(uint160(_currentSolver)) | _SOLVER_CALLED_BACK_MASK); + t_solverLock = (uint256(uint160(_currentSolver)) | _SOLVER_CALLED_BACK_MASK); } return _deductions - _additions; } // CASE: Callback verified and solver duty fulfilled if (!_fulfilled) { - _setSolverLock(uint256(uint160(_currentSolver)) | _SOLVER_CALLED_BACK_MASK | _SOLVER_FULFILLED_MASK); + t_solverLock = (uint256(uint160(_currentSolver)) | _SOLVER_CALLED_BACK_MASK | _SOLVER_FULFILLED_MASK); } return 0; } /// @notice Internal function to handle ETH contribution, increasing deposits if a non-zero value is sent. function _contribute() internal { - if (msg.value != 0) deposits += msg.value; + if (msg.value != 0) t_deposits += msg.value; } /// @notice Borrows ETH from the contract, transferring the specified amount to the caller if available. @@ -178,7 +176,7 @@ abstract contract GasAccounting is SafetyLocks { if (amount == 0) return true; if (address(this).balance < amount) return false; - withdrawals += amount; + t_withdrawals += amount; return true; } @@ -221,7 +219,7 @@ abstract contract GasAccounting is SafetyLocks { s_balanceOf[owner].unbonding = 0; _aData.bonded = 0; - writeoffs += deficit; + t_writeoffs += deficit; amount -= deficit; // Set amount equal to total to accurately track the changing bondedTotalSupply } else { // The unbonding balance is sufficient to cover the remaining amount owed. Draw everything from the @@ -242,7 +240,7 @@ abstract contract GasAccounting is SafetyLocks { S_accessData[owner] = _aData; S_bondedTotalSupply -= amount; - deposits += amount; + t_deposits += amount; } /// @notice Increases the owner's bonded balance by the specified amount. @@ -264,7 +262,7 @@ abstract contract GasAccounting is SafetyLocks { // Persist changes in the _aData memory struct back to storage S_accessData[owner] = _aData; - withdrawals += amount; + t_withdrawals += amount; } /// @notice Accounts for the gas cost of a failed SolverOperation, either by increasing writeoffs (if the bundler is @@ -293,7 +291,7 @@ abstract contract GasAccounting is SafetyLocks { if (result.bundlersFault()) { // CASE: Solver is not responsible for the failure of their operation, so we blame the bundler // and reduce the total amount refunded to the bundler - writeoffs += _gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); + t_writeoffs += _gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); } else { // CASE: Solver failed, so we calculate what they owe. uint256 _gasUsedWithSurcharges = _gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); @@ -308,13 +306,13 @@ abstract contract GasAccounting is SafetyLocks { // so that in the event of no successful solvers, any `_assign()`ed surcharges can be attributed to an // increase in Atlas' cumulative surcharge. if (_surchargesOnly > _assignDeficit) { - solverSurcharge += (_surchargesOnly - _assignDeficit); + t_solverSurcharge += (_surchargesOnly - _assignDeficit); } } } function _writeOffBidFindGasCost(uint256 gasUsed) internal { - writeoffs += gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); + t_writeoffs += gasUsed.withSurcharges(ATLAS_SURCHARGE_RATE, BUNDLER_SURCHARGE_RATE); } /// @param ctx Context struct containing relevant context information for the Atlas auction. @@ -344,11 +342,11 @@ abstract contract GasAccounting is SafetyLocks { { uint256 _surcharge = S_cumulativeSurcharge; - adjustedWithdrawals = withdrawals; - adjustedDeposits = deposits; - adjustedClaims = claims; - adjustedWriteoffs = writeoffs; - uint256 _fees = fees; + adjustedWithdrawals = t_withdrawals; + adjustedDeposits = t_deposits; + adjustedClaims = t_claims; + adjustedWriteoffs = t_writeoffs; + uint256 _fees = t_fees; uint256 _gasLeft = gasleft(); // Hold this constant for the calculations @@ -368,7 +366,7 @@ abstract contract GasAccounting is SafetyLocks { S_cumulativeSurcharge = _surcharge + netAtlasGasSurcharge; } else { // If no successful solvers, only collect partial surcharges from solver's fault failures (if any) - uint256 _solverSurcharge = solverSurcharge; + uint256 _solverSurcharge = t_solverSurcharge; if (_solverSurcharge > 0) { netAtlasGasSurcharge = _solverSurcharge.getPortionFromTotalSurcharge({ targetSurchargeRate: ATLAS_SURCHARGE_RATE, @@ -533,6 +531,6 @@ abstract contract GasAccounting is SafetyLocks { /// correct. /// @return True if the balance is reconciled, false otherwise. function _isBalanceReconciled() internal view returns (bool) { - return deposits >= _deficit(); + return t_deposits >= _deficit(); } } diff --git a/src/contracts/atlas/Storage.sol b/src/contracts/atlas/Storage.sol index 326d1f23d..d74838c60 100644 --- a/src/contracts/atlas/Storage.sol +++ b/src/contracts/atlas/Storage.sol @@ -33,15 +33,16 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { // Transient storage slots bytes32 private constant _T_LOCK_SLOT = keccak256("ATLAS_LOCK"); - bytes32 private constant _T_SOLVER_LOCK_SLOT = keccak256("ATLAS_SOLVER_LOCK"); - bytes32 private constant _T_SOLVER_TO_SLOT = keccak256("ATLAS_SOLVER_TO"); + + uint256 internal transient t_solverLock; + address internal transient t_solverTo; // current solverOp.solver contract address - uint256 public transient claims; - uint256 public transient fees; - uint256 public transient writeoffs; - uint256 public transient withdrawals; - uint256 public transient deposits; - uint256 public transient solverSurcharge; // total surcharge collected from failed solverOps due to solver fault. + uint256 internal transient t_claims; + uint256 internal transient t_fees; + uint256 internal transient t_writeoffs; + uint256 internal transient t_withdrawals; + uint256 internal transient t_deposits; + uint256 internal transient t_solverSurcharge; // total surcharge collected from failed solverOps due to solver fault. // AtlETH storage uint256 internal S_totalSupply; @@ -182,16 +183,12 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { /// @return calledBack Boolean indicating whether the solver has called back via `reconcile`. /// @return fulfilled Boolean indicating whether the solver's outstanding debt has been repaid via `reconcile`. function _solverLockData() internal view returns (address currentSolver, bool calledBack, bool fulfilled) { - uint256 _solverLock = uint256(_tload(_T_SOLVER_LOCK_SLOT)); + uint256 _solverLock = t_solverLock; currentSolver = address(uint160(_solverLock)); calledBack = _solverLock & _SOLVER_CALLED_BACK_MASK != 0; fulfilled = _solverLock & _SOLVER_FULFILLED_MASK != 0; } - function _solverTo() internal view returns (address) { - return address(uint160(uint256(_tload(_T_SOLVER_TO_SLOT)))); - } - function _isUnlocked() internal view returns (bool) { return _tload(_T_LOCK_SLOT) == bytes32(_UNLOCKED); } @@ -220,14 +217,6 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { _tstore(_T_LOCK_SLOT, (_tload(_T_LOCK_SLOT) & _LOCK_PHASE_MASK) | bytes32(uint256(newPhase))); } - function _setSolverLock(uint256 newSolverLock) internal { - _tstore(_T_SOLVER_LOCK_SLOT, bytes32(newSolverLock)); - } - - function _setSolverTo(address newSolverTo) internal { - _tstore(_T_SOLVER_TO_SLOT, bytes32(uint256(uint160(newSolverTo)))); - } - // ------------------------------------------------------ // // Transient Storage Helpers // // ------------------------------------------------------ // diff --git a/test/GasAccounting.t.sol b/test/GasAccounting.t.sol index 47c7b6177..430471dcf 100644 --- a/test/GasAccounting.t.sol +++ b/test/GasAccounting.t.sol @@ -116,7 +116,7 @@ contract MockGasAccounting is TestAtlas, BaseTest { } function setSolverLock(address _solverFrom) external { - _setSolverLock(uint256(uint160(_solverFrom))); + t_solverLock = (uint256(uint160(_solverFrom))); } function _balanceOf(address account) external view returns (uint112, uint112) { diff --git a/test/SafetyLocks.t.sol b/test/SafetyLocks.t.sol index de65cbbc9..c4d1bd4fc 100644 --- a/test/SafetyLocks.t.sol +++ b/test/SafetyLocks.t.sol @@ -56,36 +56,58 @@ contract MockSafetyLocks is SafetyLocks { _setLockPhase(newPhase); } - function setClaims(uint256 _claims) external { - claims = _claims; + function setSolverLock(uint256 newSolverLock) public { + t_solverLock = newSolverLock; + } + + function setSolverTo(address newSolverTo) public { + t_solverTo = newSolverTo; + } + + function setClaims(uint256 newClaims) public { + t_claims = newClaims; } function setFees(uint256 newFees) public { - fees = newFees; + t_fees = newFees; } function setWriteoffs(uint256 newWriteoffs) public { - writeoffs = newWriteoffs; + t_writeoffs = newWriteoffs; } function setWithdrawals(uint256 newWithdrawals) public { - withdrawals = newWithdrawals; + t_withdrawals = newWithdrawals; } function setDeposits(uint256 newDeposits) public { - deposits = newDeposits; + t_deposits = newDeposits; + } + + // Transient Var View Functions + + function claims() external view returns (uint256) { + return t_claims; + } + + function fees() external view returns (uint256) { + return t_fees; + } + + function writeoffs() external view returns (uint256) { + return t_writeoffs; } - function setSolverLock(uint256 newSolverLock) external { - _setSolverLock(newSolverLock); + function withdrawals() external view returns (uint256) { + return t_withdrawals; } - function setSolverTo(address newSolverTo) external { - _setSolverTo(newSolverTo); + function deposits() external view returns (uint256) { + return t_deposits; } function solverTo() external view returns (address) { - return _solverTo(); + return t_solverTo; } } diff --git a/test/Storage.t.sol b/test/Storage.t.sol index eaca89d1c..7852ae2a4 100644 --- a/test/Storage.t.sol +++ b/test/Storage.t.sol @@ -391,11 +391,11 @@ contract MockStorage is Storage { // For internal view functions without external versions function solverTo() public view returns (address) { - return _solverTo(); + return t_solverTo; } function setSolverTo(address newSolverTo) public { - _setSolverTo(newSolverTo); + t_solverTo = newSolverTo; } function activeEnvironment() public view returns (address) { @@ -418,13 +418,13 @@ contract MockStorage is Storage { // To clear all transient storage vars function clearTransientStorage() public { _setLock(address(0), 0, 0); - _setSolverLock(0); - _setSolverTo(address(0)); - claims = 0; - fees = 0; - writeoffs = 0; - withdrawals = 0; - deposits = 0; - solverSurcharge = 0; + t_solverLock = 0; + t_solverTo = address(0); + t_claims = 0; + t_fees = 0; + t_writeoffs = 0; + t_withdrawals = 0; + t_deposits = 0; + t_solverSurcharge = 0; } } diff --git a/test/base/TestAtlas.sol b/test/base/TestAtlas.sol index 679eb476c..3ee904489 100644 --- a/test/base/TestAtlas.sol +++ b/test/base/TestAtlas.sol @@ -33,14 +33,14 @@ contract TestAtlas is Atlas { function clearTransientStorage() public { _setLock(address(0), 0, 0); - _setSolverLock(0); - _setSolverTo(address(0)); - claims = 0; - fees = 0; - writeoffs = 0; - withdrawals = 0; - deposits = 0; - solverSurcharge = 0; + t_solverLock = 0; + t_solverTo = address(0); + t_claims = 0; + t_fees = 0; + t_writeoffs = 0; + t_withdrawals = 0; + t_deposits = 0; + t_solverSurcharge = 0; } function setLock(address activeEnvironment, uint32 callConfig, uint8 phase) public { @@ -52,30 +52,52 @@ contract TestAtlas is Atlas { } function setSolverLock(uint256 newSolverLock) public { - _setSolverLock(newSolverLock); + t_solverLock = newSolverLock; } function setSolverTo(address newSolverTo) public { - _setSolverTo(newSolverTo); + t_solverTo = newSolverTo; } function setClaims(uint256 newClaims) public { - claims = newClaims; + t_claims = newClaims; } function setFees(uint256 newFees) public { - fees = newFees; + t_fees = newFees; } function setWriteoffs(uint256 newWriteoffs) public { - writeoffs = newWriteoffs; + t_writeoffs = newWriteoffs; } function setWithdrawals(uint256 newWithdrawals) public { - withdrawals = newWithdrawals; + t_withdrawals = newWithdrawals; } function setDeposits(uint256 newDeposits) public { - deposits = newDeposits; + t_deposits = newDeposits; + } + + // Transient Var View Functions + + function claims() external view returns (uint256) { + return t_claims; + } + + function fees() external view returns (uint256) { + return t_fees; + } + + function writeoffs() external view returns (uint256) { + return t_writeoffs; + } + + function withdrawals() external view returns (uint256) { + return t_withdrawals; + } + + function deposits() external view returns (uint256) { + return t_deposits; } } From a90b1adcafa63adf8d7697f2e609e414c1bd0c99 Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:02:31 +0200 Subject: [PATCH 5/8] refactor: convert lock slot to `transient` syntax --- src/contracts/atlas/Storage.sol | 49 ++++++++------------------ src/contracts/types/AtlasConstants.sol | 2 +- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/contracts/atlas/Storage.sol b/src/contracts/atlas/Storage.sol index d74838c60..baca20ae2 100644 --- a/src/contracts/atlas/Storage.sol +++ b/src/contracts/atlas/Storage.sol @@ -32,17 +32,17 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { uint256 public constant FIXED_GAS_OFFSET = AccountingMath._FIXED_GAS_OFFSET; // Transient storage slots - bytes32 private constant _T_LOCK_SLOT = keccak256("ATLAS_LOCK"); - + uint256 internal transient t_lock; // contains activeAddress, callConfig, and phase uint256 internal transient t_solverLock; address internal transient t_solverTo; // current solverOp.solver contract address + // solverSurcharge = total surcharge collected from failed solverOps due to solver fault. + uint256 internal transient t_solverSurcharge; uint256 internal transient t_claims; uint256 internal transient t_fees; uint256 internal transient t_writeoffs; uint256 internal transient t_withdrawals; uint256 internal transient t_deposits; - uint256 internal transient t_solverSurcharge; // total surcharge collected from failed solverOps due to solver fault. // AtlETH storage uint256 internal S_totalSupply; @@ -157,25 +157,25 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { // ---------------------------------------------------- // function _lock() internal view returns (address activeEnvironment, uint32 callConfig, uint8 phase) { - bytes32 _lockData = _tload(_T_LOCK_SLOT); - activeEnvironment = address(uint160(uint256(_lockData >> 40))); - callConfig = uint32(uint256(_lockData >> 8)); - phase = uint8(uint256(_lockData)); + uint256 _lockData = t_lock; + activeEnvironment = address(uint160(_lockData >> 40)); + callConfig = uint32(_lockData >> 8); + phase = uint8(_lockData); } function _activeEnvironment() internal view returns (address) { // right shift 40 bits to remove the callConfig and phase, only activeEnvironment remains - return address(uint160(uint256(_tload(_T_LOCK_SLOT) >> 40))); + return address(uint160(t_lock >> 40)); } function _activeCallConfig() internal view returns (uint32) { // right shift 8 bits to remove the phase, cast to uint32 to remove the activeEnvironment - return uint32(uint256(_tload(_T_LOCK_SLOT) >> 8)); + return uint32(t_lock >> 8); } function _phase() internal view returns (uint8) { // right-most 8 bits of Lock are the phase - return uint8(uint256(_tload(_T_LOCK_SLOT))); + return uint8(t_lock); } /// @notice Returns information about the current state of the solver lock. @@ -190,7 +190,7 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { } function _isUnlocked() internal view returns (bool) { - return _tload(_T_LOCK_SLOT) == bytes32(_UNLOCKED); + return t_lock == _UNLOCKED; } // ---------------------------------------------------- // @@ -201,36 +201,15 @@ contract Storage is AtlasEvents, AtlasErrors, AtlasConstants { // Pack the lock slot from the right: // [ 56 bits ][ 160 bits ][ 32 bits ][ 8 bits ] // [ unused bits ][ activeEnvironment ][ callConfig ][ phase ] - _tstore( - _T_LOCK_SLOT, - bytes32(uint256(uint160(activeEnvironment))) << 40 | bytes32(uint256(callConfig)) << 8 - | bytes32(uint256(phase)) - ); + t_lock = uint256(uint160(activeEnvironment)) << 40 | uint256(callConfig) << 8 | uint256(phase); } function _releaseLock() internal { - _tstore(_T_LOCK_SLOT, bytes32(_UNLOCKED)); + t_lock = _UNLOCKED; } // Sets the Lock phase without changing the activeEnvironment or callConfig. function _setLockPhase(uint8 newPhase) internal { - _tstore(_T_LOCK_SLOT, (_tload(_T_LOCK_SLOT) & _LOCK_PHASE_MASK) | bytes32(uint256(newPhase))); - } - - // ------------------------------------------------------ // - // Transient Storage Helpers // - // ------------------------------------------------------ // - - function _tstore(bytes32 slot, bytes32 value) internal { - assembly { - tstore(slot, value) - } - } - - function _tload(bytes32 slot) internal view returns (bytes32 value) { - assembly { - value := tload(slot) - } - return value; + t_lock = (t_lock & _LOCK_PHASE_MASK) | uint256(newPhase); } } diff --git a/src/contracts/types/AtlasConstants.sol b/src/contracts/types/AtlasConstants.sol index dbe575056..79edb0c25 100644 --- a/src/contracts/types/AtlasConstants.sol +++ b/src/contracts/types/AtlasConstants.sol @@ -37,7 +37,7 @@ contract AtlasConstants { uint256 internal constant _SOLVER_FULFILLED_MASK = 1 << 162; // Used to set Lock phase without changing the activeEnvironment or callConfig. - bytes32 internal constant _LOCK_PHASE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00; + uint256 internal constant _LOCK_PHASE_MASK = uint256(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00); // ValidCalls error threshold before which the metacall reverts, and after which it returns gracefully to store // nonces as used. From a8030e2ac8dcafd77cac94da6493fa57b4c835df Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Sat, 19 Oct 2024 16:28:35 +0200 Subject: [PATCH 6/8] chore: remove unused constants --- src/contracts/types/AtlasConstants.sol | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/contracts/types/AtlasConstants.sol b/src/contracts/types/AtlasConstants.sol index 79edb0c25..b8cf43d07 100644 --- a/src/contracts/types/AtlasConstants.sol +++ b/src/contracts/types/AtlasConstants.sol @@ -18,6 +18,7 @@ contract AtlasConstants { // Atlas constants used in `_bidFindingIteration()` uint256 internal constant _BITS_FOR_INDEX = 16; + uint256 internal constant _FIRST_16_BITS_TRUE_MASK = uint256(0xFFFF); // Escrow constants uint256 internal constant _VALIDATION_GAS_LIMIT = 500_000; @@ -47,16 +48,5 @@ contract AtlasConstants { // ATLAS VERIFICATION CONSTANTS // // ------------------------------------------------------- // - uint256 internal constant _FULL_BITMAP = _FIRST_240_BITS_TRUE_MASK; - uint256 internal constant _NONCES_PER_BITMAP = 240; uint8 internal constant _MAX_SOLVERS = type(uint8).max - 1; - - // ------------------------------------------------------- // - // SHARED CONSTANTS // - // ------------------------------------------------------- // - - uint256 internal constant _FIRST_240_BITS_TRUE_MASK = - uint256(0x0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); - uint256 internal constant _FIRST_16_BITS_TRUE_MASK = uint256(0xFFFF); - uint256 internal constant _FIRST_4_BITS_TRUE_MASK = uint256(0xF); } From 148049f573e0a30edf8a0ecf08f738a2fe1d7350 Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:24:19 +0200 Subject: [PATCH 7/8] chore: bump Solidity version to `0.8.28` --- src/contracts/atlas/FactoryLib.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/atlas/FactoryLib.sol b/src/contracts/atlas/FactoryLib.sol index 0cf9495a5..a6b74e3d1 100644 --- a/src/contracts/atlas/FactoryLib.sol +++ b/src/contracts/atlas/FactoryLib.sol @@ -1,5 +1,5 @@ //SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.25; +pragma solidity 0.8.28; import { Mimic } from "../common/Mimic.sol"; import { AtlasEvents } from "../types/AtlasEvents.sol"; From 776fb93f789fdc648cc836c34b6ff15427516ed1 Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Mon, 21 Oct 2024 21:25:47 +0200 Subject: [PATCH 8/8] ci: disable lint check as pre-req for test check --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8deface8..0aed06e90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: echo "✅ Passed" >> $GITHUB_STEP_SUMMARY tests: - needs: ["lint", "build"] + needs: ["build"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2