diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20f54492..9b4e2877 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,12 +66,7 @@ jobs: with: version: ${{ matrix.toolchain }} - run: forge --version - - run: | - if [ "${{ matrix.toolchain }}" = "stable" ]; then - forge test -vvv --no-match-path "test/Config.t.sol" - else - forge test -vvv - fi + - run: forge test -vvv fmt: runs-on: ubuntu-latest diff --git a/foundry.toml b/foundry.toml index b68bd546..376654da 100644 --- a/foundry.toml +++ b/foundry.toml @@ -9,11 +9,14 @@ ignored_error_codes = [3860] [rpc_endpoints] # The RPC URLs are modified versions of the default for testing initialization. -mainnet = "https://eth.merkle.io" # Different API key. +mainnet = "https://reth-ethereum.ithaca.xyz/rpc" optimism_sepolia = "https://sepolia.optimism.io/" # Adds a trailing slash. arbitrum_one_sepolia = "https://sepolia-rollup.arbitrum.io/rpc/" # Adds a trailing slash. needs_undefined_env_var = "${UNDEFINED_RPC_URL_PLACEHOLDER}" +[lint] +lint_on_build = false + [fmt] # These are all the `forge fmt` defaults. line_length = 120 diff --git a/src/StdAssertions.sol b/src/StdAssertions.sol index 4248170d..45418f2c 100644 --- a/src/StdAssertions.sol +++ b/src/StdAssertions.sol @@ -572,11 +572,7 @@ abstract contract StdAssertions { vm.assertApproxEqAbs(left, right, maxDelta); } - function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string memory err) - internal - pure - virtual - { + function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string memory err) internal pure virtual { vm.assertApproxEqAbs(left, right, maxDelta, err); } @@ -626,7 +622,11 @@ abstract contract StdAssertions { uint256 left, uint256 right, uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100% - ) internal pure virtual { + ) + internal + pure + virtual + { vm.assertApproxEqRel(left, right, maxPercentDelta); } @@ -635,7 +635,11 @@ abstract contract StdAssertions { uint256 right, uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100% string memory err - ) internal pure virtual { + ) + internal + pure + virtual + { vm.assertApproxEqRel(left, right, maxPercentDelta, err); } @@ -644,7 +648,11 @@ abstract contract StdAssertions { uint256 right, uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100% uint256 decimals - ) internal pure virtual { + ) + internal + pure + virtual + { vm.assertApproxEqRelDecimal(left, right, maxPercentDelta, decimals); } @@ -667,7 +675,11 @@ abstract contract StdAssertions { int256 right, uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100% string memory err - ) internal pure virtual { + ) + internal + pure + virtual + { vm.assertApproxEqRel(left, right, maxPercentDelta, err); } @@ -676,7 +688,11 @@ abstract contract StdAssertions { int256 right, uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100% uint256 decimals - ) internal pure virtual { + ) + internal + pure + virtual + { vm.assertApproxEqRelDecimal(left, right, maxPercentDelta, decimals); } diff --git a/src/StdCheats.sol b/src/StdCheats.sol index 9f360dec..b6e4b446 100644 --- a/src/StdCheats.sol +++ b/src/StdCheats.sol @@ -326,7 +326,7 @@ abstract contract StdCheatsSafe { vm.assume(addr < address(0x1) || addr > address(0xff)); // forgefmt: disable-start - if (chainId == 10 || chainId == 420) { + if (chainId == 10 || chainId == 420 || chainId == 11155420) { // https://github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.go#L6-L21 vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800)); } else if (chainId == 42161 || chainId == 421613) { diff --git a/src/StdConfig.sol b/src/StdConfig.sol index 506ac34a..161e3171 100644 --- a/src/StdConfig.sol +++ b/src/StdConfig.sol @@ -105,8 +105,9 @@ contract StdConfig { // Cache the configure rpc endpoint for that chain. // Falls back to `[rpc_endpoints]`. Panics if no rpc endpoint is configured. - try vm.parseTomlString(content, string.concat("$.", chain_key, ".endpoint_url")) returns (string memory url) - { + try vm.parseTomlString(content, string.concat("$.", chain_key, ".endpoint_url")) returns ( + string memory url + ) { _rpcOf[chainId] = vm.resolveEnv(url); } catch { _rpcOf[chainId] = vm.resolveEnv(vm.rpcUrl(chain_key)); @@ -126,7 +127,7 @@ contract StdConfig { revert AlreadyInitialized(key); } } - } catch {} // Section does not exist, ignore. + } catch {} } } } diff --git a/src/StdJson.sol b/src/StdJson.sol index 2a033c03..193f89a6 100644 --- a/src/StdJson.sol +++ b/src/StdJson.sol @@ -197,10 +197,7 @@ library stdJson { return vm.serializeBool(jsonKey, key, value); } - function serialize(string memory jsonKey, string memory key, bool[] memory value) - internal - returns (string memory) - { + function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory) { return vm.serializeBool(jsonKey, key, value); } @@ -259,10 +256,7 @@ library stdJson { return vm.serializeBytes(jsonKey, key, value); } - function serialize(string memory jsonKey, string memory key, string memory value) - internal - returns (string memory) - { + function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory) { return vm.serializeString(jsonKey, key, value); } diff --git a/src/StdToml.sol b/src/StdToml.sol index 7ad3be2f..7ea92e26 100644 --- a/src/StdToml.sol +++ b/src/StdToml.sol @@ -197,10 +197,7 @@ library stdToml { return vm.serializeBool(jsonKey, key, value); } - function serialize(string memory jsonKey, string memory key, bool[] memory value) - internal - returns (string memory) - { + function serialize(string memory jsonKey, string memory key, bool[] memory value) internal returns (string memory) { return vm.serializeBool(jsonKey, key, value); } @@ -259,10 +256,7 @@ library stdToml { return vm.serializeBytes(jsonKey, key, value); } - function serialize(string memory jsonKey, string memory key, string memory value) - internal - returns (string memory) - { + function serialize(string memory jsonKey, string memory key, string memory value) internal returns (string memory) { return vm.serializeString(jsonKey, key, value); } diff --git a/src/Vm.sol b/src/Vm.sol index c028bc80..20f91a14 100644 --- a/src/Vm.sol +++ b/src/Vm.sol @@ -372,10 +372,12 @@ interface VmSafe { /// Derive a private key from a provided mnemonic string (or mnemonic file path) in the specified language /// at `{derivationPath}{index}`. - function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language) - external - pure - returns (uint256 privateKey); + function deriveKey( + string calldata mnemonic, + string calldata derivationPath, + uint32 index, + string calldata language + ) external pure returns (uint256 privateKey); /// Derives secp256r1 public key from the provided `privateKey`. function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY); @@ -871,10 +873,7 @@ interface VmSafe { function getDeployment(string calldata contractName) external view returns (address deployedAddress); /// Returns the most recent deployment for the given contract on `chainId` - function getDeployment(string calldata contractName, uint64 chainId) - external - view - returns (address deployedAddress); + function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress); /// Returns all deployments for the given contract on `chainId` /// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber. @@ -981,10 +980,7 @@ interface VmSafe { function parseJsonAddress(string calldata json, string calldata key) external pure returns (address); /// Parses a string of JSON data at `key` and coerces it to `address[]`. - function parseJsonAddressArray(string calldata json, string calldata key) - external - pure - returns (address[] memory); + function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory); /// Parses a string of JSON data at `key` and coerces it to `bool`. function parseJsonBool(string calldata json, string calldata key) external pure returns (bool); @@ -999,10 +995,7 @@ interface VmSafe { function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32); /// Parses a string of JSON data at `key` and coerces it to `bytes32[]`. - function parseJsonBytes32Array(string calldata json, string calldata key) - external - pure - returns (bytes32[] memory); + function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory); /// Parses a string of JSON data at `key` and coerces it to `bytes[]`. function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory); @@ -1029,10 +1022,7 @@ interface VmSafe { returns (bytes memory); /// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`. - function parseJsonType(string calldata json, string calldata typeDescription) - external - pure - returns (bytes memory); + function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`. function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) @@ -1399,9 +1389,7 @@ interface VmSafe { /// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`. /// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100% /// Includes error message into revert string on failure. - function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) - external - pure; + function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error) external pure; /// Asserts that two `uint256` values are equal, formatting them with decimals in failure message. function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure; @@ -1800,10 +1788,7 @@ interface VmSafe { function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address); /// Parses a string of TOML data at `key` and coerces it to `address[]`. - function parseTomlAddressArray(string calldata toml, string calldata key) - external - pure - returns (address[] memory); + function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory); /// Parses a string of TOML data at `key` and coerces it to `bool`. function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool); @@ -1818,10 +1803,7 @@ interface VmSafe { function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32); /// Parses a string of TOML data at `key` and coerces it to `bytes32[]`. - function parseTomlBytes32Array(string calldata toml, string calldata key) - external - pure - returns (bytes32[] memory); + function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory); /// Parses a string of TOML data at `key` and coerces it to `bytes[]`. function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory); @@ -1848,10 +1830,7 @@ interface VmSafe { returns (bytes memory); /// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`. - function parseTomlType(string calldata toml, string calldata typeDescription) - external - pure - returns (bytes memory); + function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory); /// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`. function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) @@ -1888,10 +1867,7 @@ interface VmSafe { function bound(int256 current, int256 min, int256 max) external view returns (int256); /// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer. - function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) - external - pure - returns (address); + function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer) external pure returns (address); /// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer. function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address); @@ -2138,8 +2114,7 @@ interface Vm is VmSafe { function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; /// Reverts a call to an address with a specific `msg.value`, with specified revert data. - function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) - external; + function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external; /// Reverts a call to an address with specified revert data. /// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`. @@ -2385,8 +2360,13 @@ interface Vm is VmSafe { /// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.). /// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). - function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) - external; + function expectEmitAnonymous( + bool checkTopic0, + bool checkTopic1, + bool checkTopic2, + bool checkTopic3, + bool checkData + ) external; /// Same as the previous method, but also checks supplied address against emitting contract. function expectEmitAnonymous( @@ -2412,8 +2392,7 @@ interface Vm is VmSafe { function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; /// Same as the previous method, but also checks supplied address against emitting contract. - function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) - external; + function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter) external; /// Prepare an expected log with all topic and data checks enabled. /// Call this function, then emit an event, then call a function. Internally after the call, we check if diff --git a/src/interfaces/IERC7540.sol b/src/interfaces/IERC7540.sol index 91a38ca3..9b3ca08b 100644 --- a/src/interfaces/IERC7540.sol +++ b/src/interfaces/IERC7540.sol @@ -64,10 +64,7 @@ interface IERC7540Deposit is IERC7540Operator { * - MUST NOT show any variations depending on the caller. * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. */ - function pendingDepositRequest(uint256 requestId, address controller) - external - view - returns (uint256 pendingAssets); + function pendingDepositRequest(uint256 requestId, address controller) external view returns (uint256 pendingAssets); /** * @dev Returns the amount of requested assets in Claimable state for the controller to deposit or mint. @@ -127,10 +124,7 @@ interface IERC7540Redeem is IERC7540Operator { * - MUST NOT show any variations depending on the caller. * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. */ - function pendingRedeemRequest(uint256 requestId, address controller) - external - view - returns (uint256 pendingShares); + function pendingRedeemRequest(uint256 requestId, address controller) external view returns (uint256 pendingShares); /** * @dev Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw. diff --git a/src/interfaces/IMulticall3.sol b/src/interfaces/IMulticall3.sol index 0d031b71..3b79851b 100644 --- a/src/interfaces/IMulticall3.sol +++ b/src/interfaces/IMulticall3.sol @@ -27,10 +27,7 @@ interface IMulticall3 { bytes returnData; } - function aggregate(Call[] calldata calls) - external - payable - returns (uint256 blockNumber, bytes[] memory returnData); + function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData); function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData); diff --git a/test/StdChains.t.sol b/test/StdChains.t.sol index 9522b37d..0394d180 100644 --- a/test/StdChains.t.sol +++ b/test/StdChains.t.sol @@ -24,7 +24,7 @@ contract StdChainsMock is Test { contract StdChainsTest is Test { function test_ChainRpcInitialization() public { // RPCs specified in `foundry.toml` should be updated. - assertEq(getChain(1).rpcUrl, "https://eth.merkle.io"); + assertEq(getChain(1).rpcUrl, "https://reth-ethereum.ithaca.xyz/rpc"); assertEq(getChain("optimism_sepolia").rpcUrl, "https://sepolia.optimism.io/"); assertEq(getChain("arbitrum_one_sepolia").rpcUrl, "https://sepolia-rollup.arbitrum.io/rpc/"); @@ -36,7 +36,7 @@ contract StdChainsTest is Test { // Cannot override RPCs defined in `foundry.toml` vm.setEnv("MAINNET_RPC_URL", "myoverride2"); - assertEq(getChain("mainnet").rpcUrl, "https://eth.merkle.io"); + assertEq(getChain("mainnet").rpcUrl, "https://reth-ethereum.ithaca.xyz/rpc"); // Other RPCs should remain unchanged. assertEq(getChain(31337).rpcUrl, "http://127.0.0.1:8545"); diff --git a/test/StdStorage.t.sol b/test/StdStorage.t.sol index 46604f86..d59465b5 100644 --- a/test/StdStorage.t.sol +++ b/test/StdStorage.t.sol @@ -58,9 +58,8 @@ contract StdStorageTest is Test { } function test_StorageDeepMap() public { - uint256 slot = stdstore.target(address(test)).sig(test.deep_map.selector).with_key(address(this)).with_key( - address(this) - ).find(); + uint256 slot = stdstore.target(address(test)).sig(test.deep_map.selector).with_key(address(this)) + .with_key(address(this)).find(); assertEq(uint256(keccak256(abi.encode(address(this), keccak256(abi.encode(address(this), uint256(5)))))), slot); } @@ -74,7 +73,9 @@ contract StdStorageTest is Test { uint256 slot = stdstore.target(address(test)).sig(test.deep_map_struct.selector).with_key(address(this)) .with_key(address(this)).depth(0).find(); assertEq( - bytes32(uint256(keccak256(abi.encode(address(this), keccak256(abi.encode(address(this), uint256(6)))))) + 0), + bytes32( + uint256(keccak256(abi.encode(address(this), keccak256(abi.encode(address(this), uint256(6)))))) + 0 + ), bytes32(slot) ); } @@ -83,24 +84,24 @@ contract StdStorageTest is Test { uint256 slot = stdstore.target(address(test)).sig(test.deep_map_struct.selector).with_key(address(this)) .with_key(address(this)).depth(1).find(); assertEq( - bytes32(uint256(keccak256(abi.encode(address(this), keccak256(abi.encode(address(this), uint256(6)))))) + 1), + bytes32( + uint256(keccak256(abi.encode(address(this), keccak256(abi.encode(address(this), uint256(6)))))) + 1 + ), bytes32(slot) ); } function test_StorageCheckedWriteDeepMapStructA() public { - stdstore.target(address(test)).sig(test.deep_map_struct.selector).with_key(address(this)).with_key( - address(this) - ).depth(0).checked_write(100); + stdstore.target(address(test)).sig(test.deep_map_struct.selector).with_key(address(this)) + .with_key(address(this)).depth(0).checked_write(100); (uint256 a, uint256 b) = test.deep_map_struct(address(this), address(this)); assertEq(100, a); assertEq(0, b); } function test_StorageCheckedWriteDeepMapStructB() public { - stdstore.target(address(test)).sig(test.deep_map_struct.selector).with_key(address(this)).with_key( - address(this) - ).depth(1).checked_write(100); + stdstore.target(address(test)).sig(test.deep_map_struct.selector).with_key(address(this)) + .with_key(address(this)).depth(1).checked_write(100); (uint256 a, uint256 b) = test.deep_map_struct(address(this), address(this)); assertEq(0, a); assertEq(100, b); @@ -192,9 +193,8 @@ contract StdStorageTest is Test { uint256 full = test.map_packed(address(1337)); // keep upper 128, set lower 128 to 1337 full = (full & (uint256((1 << 128) - 1) << 128)) | 1337; - stdstore.target(address(test)).sig(test.map_packed.selector).with_key(address(uint160(1337))).checked_write( - full - ); + stdstore.target(address(test)).sig(test.map_packed.selector).with_key(address(uint160(1337))) + .checked_write(full); assertEq(1337, test.read_struct_lower(address(1337))); } @@ -290,9 +290,9 @@ contract StdStorageTest is Test { // clear left bits, then clear right bits and realign uint256 expectedValToRead = (val << leftBits) >> (leftBits + rightBits); - uint256 readVal = stdstore.target(address(test)).enable_packed_slots().sig( - "getRandomPacked(uint8,uint8[],uint8)" - ).with_calldata(abi.encode(shifts, shiftSizes, elemToGet)).read_uint(); + uint256 readVal = stdstore.target(address(test)).enable_packed_slots() + .sig("getRandomPacked(uint8,uint8[],uint8)").with_calldata(abi.encode(shifts, shiftSizes, elemToGet)) + .read_uint(); assertEq(readVal, expectedValToRead); } @@ -330,16 +330,14 @@ contract StdStorageTest is Test { // Pack all values into the slot. for (uint256 i = 0; i < nvars; i++) { - stdstore.enable_packed_slots().target(address(test)).sig("getRandomPacked(uint256,uint256)").with_key( - sizes[i] - ).with_key(offsets[i]).checked_write(vals[i]); + stdstore.enable_packed_slots().target(address(test)).sig("getRandomPacked(uint256,uint256)") + .with_key(sizes[i]).with_key(offsets[i]).checked_write(vals[i]); } // Verify the read data matches. for (uint256 i = 0; i < nvars; i++) { - uint256 readVal = stdstore.enable_packed_slots().target(address(test)).sig( - "getRandomPacked(uint256,uint256)" - ).with_key(sizes[i]).with_key(offsets[i]).read_uint(); + uint256 readVal = stdstore.enable_packed_slots().target(address(test)) + .sig("getRandomPacked(uint256,uint256)").with_key(sizes[i]).with_key(offsets[i]).read_uint(); uint256 retVal = test.getRandomPacked(sizes[i], offsets[i]);