diff --git a/.github/workflows/fn-selectors.yaml b/.github/workflows/fn-selectors.yaml new file mode 100644 index 000000000..3e8efa34a --- /dev/null +++ b/.github/workflows/fn-selectors.yaml @@ -0,0 +1,30 @@ +name: Upload function selectors + +on: [push] + +env: + FOUNDRY_PROFILE: ci + +jobs: + check: + strategy: + fail-fast: true + + name: Upload function selectors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Install deps + run: forge install --shallow + + - name: Upload function selectors + run: forge selectors up --all + id: selectors diff --git a/flake.lock b/flake.lock index 48e298e3f..b38c4342b 100644 --- a/flake.lock +++ b/flake.lock @@ -56,17 +56,17 @@ }, "nixpkgs": { "locked": { - "lastModified": 1687807295, - "narHash": "sha256-7TUD0p0m4mZpIi1O+Cyk5NCqpJUnhv/CJOAuHOndjao=", + "lastModified": 1699343069, + "narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "6b3d1b1cf13f407fef5e634b224d575eb7211975", + "rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", "repo": "nixpkgs", + "rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d", "type": "github" } }, @@ -107,16 +107,17 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1687893383, - "narHash": "sha256-KkW04SK0vuC4mfod5j+MJSEzff0Ik9WR7CzaT04XIlc=", + "lastModified": 1700476138, + "narHash": "sha256-cpKb/QMQQgoV4xiEI/TSEW48v/8MxvGA9Q9BK75DnH4=", "owner": "rainprotocol", "repo": "rain.cli", - "rev": "aec8fa01d7c5e5c0f42199309edbd53fe32d5b05", + "rev": "6a912680be6d967fd6114aafab793ebe8503d27b", "type": "github" }, "original": { "owner": "rainprotocol", "repo": "rain.cli", + "rev": "6a912680be6d967fd6114aafab793ebe8503d27b", "type": "github" } }, diff --git a/flake.nix b/flake.nix index dbf811b33..957790f0b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,8 @@ description = "Flake for development workflows."; inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - rain.url = "github:rainprotocol/rain.cli"; + nixpkgs.url = "github:nixos/nixpkgs/ec750fd01963ab6b20ee1f0cb488754e8036d89d"; + rain.url = "github:rainprotocol/rain.cli/6a912680be6d967fd6114aafab793ebe8503d27b"; flake-utils.url = "github:numtide/flake-utils"; }; @@ -26,6 +26,7 @@ ''; build-meta = pkgs.writeShellScriptBin "build-meta" ('' set -x; + mkdir -p meta; forge build --force; '' + pkgs.lib.concatStrings (map build-single-meta concrete-contracts)); diff --git a/src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol b/src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol index 73e700840..8ae3e077e 100644 --- a/src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol +++ b/src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol @@ -6,7 +6,7 @@ import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.so import {SafeERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {Address} from "lib/openzeppelin-contracts/contracts/utils/Address.sol"; -bytes32 constant CALLER_META_HASH = bytes32(0xa519e069ba4e0d8fdcd8feb0a65292ee147333ffe032fa8341e427db6d78ed1c); +bytes32 constant CALLER_META_HASH = bytes32(0xe1d075e6f17f6706d942759ec359deb7f354ab4ac55e58eda2870c0ab3a89fa5); contract GenericPoolOrderBookV3ArbOrderTaker is OrderBookV3ArbOrderTaker { using SafeERC20 for IERC20; diff --git a/src/concrete/GenericPoolOrderBookV3FlashBorrower.sol b/src/concrete/GenericPoolOrderBookV3FlashBorrower.sol index ea62e9cc3..3ce2eea61 100644 --- a/src/concrete/GenericPoolOrderBookV3FlashBorrower.sol +++ b/src/concrete/GenericPoolOrderBookV3FlashBorrower.sol @@ -9,7 +9,7 @@ import "src/abstract/OrderBookV3FlashBorrower.sol"; /// @dev Metadata hash for `DeployerDiscoverableMetaV1`. /// - ABI for GenericPoolOrderBookV3FlashBorrower /// - Interpreter caller metadata V1 for GenericPoolOrderBookV3FlashBorrower -bytes32 constant CALLER_META_HASH = bytes32(0x5307fcdf3fa283e1e7d5d58baaa516cdefb10aba9eb23211d9cfb11afd6e4b4c); +bytes32 constant CALLER_META_HASH = bytes32(0x52cdec296c4ecb0b2452c9e314df50e1b5d52fef03927934b7426ff6f150f0fe); /// @title GenericPoolOrderBookV3FlashBorrower /// Implements the OrderBookV3FlashBorrower interface for a external liquidity diff --git a/src/concrete/OrderBook.sol b/src/concrete/OrderBook.sol index 36768c18e..e33f1aecc 100644 --- a/src/concrete/OrderBook.sol +++ b/src/concrete/OrderBook.sol @@ -155,7 +155,7 @@ uint256 constant CONTEXT_VAULT_IO_BALANCE_DIFF = 4; uint256 constant CONTEXT_VAULT_IO_ROWS = 5; /// @dev Hash of the caller contract metadata for construction. -bytes32 constant CALLER_META_HASH = bytes32(0x2b317d8d308f0a16f5782cbec6cbc8de1cec7b337a90bd9ca8f1a38112f675c5); +bytes32 constant CALLER_META_HASH = bytes32(0x4383dd3c5a557f161038940161f880963e1d4a31e8f2da771427b891956ad831); /// All information resulting from an order calculation that allows for vault IO /// to be calculated and applied, then the handle IO entrypoint to be dispatched. diff --git a/src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol b/src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol index 332de0454..d277b2be8 100644 --- a/src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol +++ b/src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol @@ -8,7 +8,7 @@ import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.so import {SafeERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {Address} from "lib/openzeppelin-contracts/contracts/utils/Address.sol"; -bytes32 constant CALLER_META_HASH = bytes32(0x6b0cdd85f2332f483d4cf2ad85c9538af7c47632abd119a748d313b3681f8932); +bytes32 constant CALLER_META_HASH = bytes32(0xb5923e408032e4f76298ae26c496091f2d8f16a7c968bbd5ee83bf90b5aca00e); contract RouteProcessorOrderBookV3ArbOrderTaker is OrderBookV3ArbOrderTaker { using SafeERC20 for IERC20; diff --git a/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol b/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol index 4b088e914..3388be4d8 100644 --- a/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol +++ b/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol @@ -2,18 +2,32 @@ pragma solidity =0.8.19; import {ArbTest, ArbTestConstructorConfig} from "test/util/abstract/ArbTest.sol"; -import "lib/openzeppelin-contracts/contracts/proxy/Clones.sol"; -import "test/util/lib/LibTestConstants.sol"; -import "test/util/lib/LibGenericPoolOrderBookV3FlashBorrowerConstants.sol"; +import {GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_META_PATH} from + "test/util/lib/LibGenericPoolOrderBookV3FlashBorrowerConstants.sol"; -import "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol"; -import "src/interface/unstable/IOrderBookV3.sol"; +import { + GenericPoolOrderBookV3FlashBorrower, + DeployerDiscoverableMetaV3ConstructionConfig, + CALLER_META_HASH as GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_CALLER_META_HASH, + MinimumOutput, + ICloneableV2, + OrderBookV3FlashBorrowerConfigV2 +} from "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol"; +import { + OrderV2, + TakeOrderConfigV2, + EvaluableConfigV3, + TakeOrdersConfigV2, + IExpressionDeployerV3 +} from "src/interface/unstable/IOrderBookV3.sol"; contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest { function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) { - (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = - buildConstructorConfig(GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_META_PATH); + (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = buildConstructorConfig( + GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_META_PATH, + GENERIC_POOL_ORDER_BOOK_V3_FLASH_BORROWER_CALLER_META_HASH + ); return ArbTestConstructorConfig(deployer, address(new GenericPoolOrderBookV3FlashBorrower(config))); } diff --git a/test/util/abstract/ArbTest.sol b/test/util/abstract/ArbTest.sol index 765d7c807..46a3986b8 100644 --- a/test/util/abstract/ArbTest.sol +++ b/test/util/abstract/ArbTest.sol @@ -44,7 +44,7 @@ abstract contract ArbTest is Test { iOrderBook = new FlashLendingMockOrderBook(); } - function buildConstructorConfig(string memory metaPath) + function buildConstructorConfig(string memory metaPath, bytes32 expectedHash) internal returns (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) { @@ -58,8 +58,14 @@ abstract contract ArbTest is Test { abi.encode(address(0), address(0), address(0), "0000") ); bytes memory meta = vm.readFileBinary(metaPath); - console2.log("ArbTest meta hash:"); - console2.logBytes32(keccak256(meta)); + bytes32 metaHash = keccak256(meta); + if (metaHash != expectedHash) { + console2.log("ArbTest meta hash:", metaPath); + console2.logBytes32(metaHash); + console2.log("expected ArbTest meta hash:"); + console2.logBytes32(expectedHash); + revert("ArbTest: invalid meta hash"); + } config = DeployerDiscoverableMetaV3ConstructionConfig(deployer, meta); } diff --git a/test/util/abstract/GenericPoolOrderBookV3ArbOrderTakerTest.sol b/test/util/abstract/GenericPoolOrderBookV3ArbOrderTakerTest.sol index 1bacedc89..272336b7f 100644 --- a/test/util/abstract/GenericPoolOrderBookV3ArbOrderTakerTest.sol +++ b/test/util/abstract/GenericPoolOrderBookV3ArbOrderTakerTest.sol @@ -5,7 +5,8 @@ import {ArbTest, ArbTestConstructorConfig} from "./ArbTest.sol"; import { GenericPoolOrderBookV3ArbOrderTaker, DeployerDiscoverableMetaV3ConstructionConfig, - OrderBookV3ArbOrderTakerConfigV1 + OrderBookV3ArbOrderTakerConfigV1, + CALLER_META_HASH as GENERIC_POOL_ORDER_BOOK_V3_ARB_ORDER_TAKER_CALLER_META_HASH } from "src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol"; import { OrderV2, @@ -20,8 +21,10 @@ import {GENERIC_POOL_ORDER_BOOK_V3_ARB_ORDER_TAKER_META_PATH} from contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest { function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) { - (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = - buildConstructorConfig(GENERIC_POOL_ORDER_BOOK_V3_ARB_ORDER_TAKER_META_PATH); + (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = buildConstructorConfig( + GENERIC_POOL_ORDER_BOOK_V3_ARB_ORDER_TAKER_META_PATH, + GENERIC_POOL_ORDER_BOOK_V3_ARB_ORDER_TAKER_CALLER_META_HASH + ); return ArbTestConstructorConfig(deployer, address(new GenericPoolOrderBookV3ArbOrderTaker(config))); } diff --git a/test/util/abstract/OrderBookExternalMockTest.sol b/test/util/abstract/OrderBookExternalMockTest.sol index 85f11f5c6..e8108b4b6 100644 --- a/test/util/abstract/OrderBookExternalMockTest.sol +++ b/test/util/abstract/OrderBookExternalMockTest.sol @@ -16,7 +16,7 @@ import {IInterpreterStoreV1} from "rain.interpreter/src/interface/IInterpreterSt import {IOrderBookV3, OrderConfigV2, OrderV2} from "src/interface/unstable/IOrderBookV3.sol"; import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {LibOrder} from "src/lib/LibOrder.sol"; -import {OrderBook} from "src/concrete/OrderBook.sol"; +import {OrderBook, CALLER_META_HASH as ORDERBOOK_CALLER_META_HASH} from "src/concrete/OrderBook.sol"; import {DeployerDiscoverableMetaV3ConstructionConfig} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV3.sol"; @@ -54,8 +54,13 @@ abstract contract OrderBookExternalMockTest is Test, IMetaV1, IOrderBookV3Stub { abi.encode(iInterpreter, iStore, address(0), "00020000") ); bytes memory meta = vm.readFileBinary(ORDER_BOOK_META_PATH); - console2.log("OrderBookExternalMockTest meta hash:"); - console2.logBytes(abi.encodePacked(keccak256(meta))); + bytes32 metaHash = keccak256(meta); + if (metaHash != ORDERBOOK_CALLER_META_HASH) { + console2.log("OrderBookExternalMockTest orderbook meta hash:"); + console2.logBytes(abi.encodePacked(metaHash)); + console2.log("expected OrderBookExternalMockTest orderbook meta hash:"); + console2.logBytes(abi.encodePacked(ORDERBOOK_CALLER_META_HASH)); + } iOrderbook = IOrderBookV3(address(new OrderBook(DeployerDiscoverableMetaV3ConstructionConfig(address(iDeployer), meta)))); diff --git a/test/util/abstract/OrderBookExternalRealTest.sol b/test/util/abstract/OrderBookExternalRealTest.sol index ac7486453..ebc3c50d6 100644 --- a/test/util/abstract/OrderBookExternalRealTest.sol +++ b/test/util/abstract/OrderBookExternalRealTest.sol @@ -6,7 +6,8 @@ import {RainterpreterNPE2} from "rain.interpreter/src/concrete/RainterpreterNPE2 import {RainterpreterStoreNPE2} from "rain.interpreter/src/concrete/RainterpreterStoreNPE2.sol"; import { RainterpreterExpressionDeployerNPE2, - RainterpreterExpressionDeployerNPE2ConstructionConfig + RainterpreterExpressionDeployerNPE2ConstructionConfig, + CONSTRUCTION_META_HASH as DEPLOYER_CALLER_META_HASH } from "rain.interpreter/src/concrete/RainterpreterExpressionDeployerNPE2.sol"; import {LibAllStandardOpsNP} from "rain.interpreter/src/lib/op/LibAllStandardOpsNP.sol"; import {REVERTING_MOCK_BYTECODE} from "test/util/lib/LibTestConstants.sol"; @@ -16,7 +17,12 @@ import {IInterpreterV2} from "rain.interpreter/src/interface/unstable/IInterpret import {IInterpreterStoreV1} from "rain.interpreter/src/interface/IInterpreterStoreV1.sol"; import {IExpressionDeployerV3} from "rain.interpreter/src/interface/unstable/IExpressionDeployerV3.sol"; import {IOrderBookV3} from "src/interface/unstable/IOrderBookV3.sol"; -import {OrderBook, IERC20, DeployerDiscoverableMetaV3ConstructionConfig} from "src/concrete/OrderBook.sol"; +import { + OrderBook, + IERC20, + DeployerDiscoverableMetaV3ConstructionConfig, + CALLER_META_HASH as ORDERBOOK_CALLER_META_HASH +} from "src/concrete/OrderBook.sol"; import {IERC1820Registry} from "rain.erc1820/interface/IERC1820Registry.sol"; import {IERC1820_REGISTRY} from "rain.erc1820/lib/LibIERC1820.sol"; import {IParserV1} from "rain.interpreter/src/interface/IParserV1.sol"; @@ -49,8 +55,13 @@ abstract contract OrderBookExternalRealTest is Test, IOrderBookV3Stub { address(IERC1820_REGISTRY), abi.encodeWithSelector(IERC1820Registry.setInterfaceImplementer.selector), "" ); bytes memory deployerMeta = vm.readFileBinary(DEPLOYER_META_PATH); - console2.log("current deployer meta hash:"); - console2.logBytes32(keccak256(deployerMeta)); + bytes32 deployerMetaHash = keccak256(deployerMeta); + if (deployerMetaHash != DEPLOYER_CALLER_META_HASH) { + console2.log("deployer meta hash:"); + console2.logBytes32(deployerMetaHash); + console2.log("expected deployer meta hash:"); + console2.logBytes32(DEPLOYER_CALLER_META_HASH); + } iDeployer = IExpressionDeployerV3( address( new RainterpreterExpressionDeployerNPE2( @@ -61,8 +72,13 @@ abstract contract OrderBookExternalRealTest is Test, IOrderBookV3Stub { ) ); bytes memory orderbookMeta = vm.readFileBinary(ORDER_BOOK_META_PATH); - console2.log("orderbook meta hash:"); - console2.logBytes(abi.encodePacked(keccak256(orderbookMeta))); + bytes32 orderbookMetaHash = keccak256(orderbookMeta); + if (orderbookMetaHash != ORDERBOOK_CALLER_META_HASH) { + console2.log("orderbook meta hash:"); + console2.logBytes(abi.encodePacked(orderbookMetaHash)); + console2.log("expected orderbook meta hash:"); + console2.logBytes(abi.encodePacked(ORDERBOOK_CALLER_META_HASH)); + } iOrderbook = IOrderBookV3( address(new OrderBook(DeployerDiscoverableMetaV3ConstructionConfig(address(iDeployer), orderbookMeta))) ); diff --git a/test/util/abstract/RouteProcessorOrderBookV3ArbOrderTakerTest.sol b/test/util/abstract/RouteProcessorOrderBookV3ArbOrderTakerTest.sol index 3eaacf4ec..8c0330958 100644 --- a/test/util/abstract/RouteProcessorOrderBookV3ArbOrderTakerTest.sol +++ b/test/util/abstract/RouteProcessorOrderBookV3ArbOrderTakerTest.sol @@ -5,7 +5,8 @@ import {ArbTest, ArbTestConstructorConfig} from "./ArbTest.sol"; import { RouteProcessorOrderBookV3ArbOrderTaker, DeployerDiscoverableMetaV3ConstructionConfig, - OrderBookV3ArbOrderTakerConfigV1 + OrderBookV3ArbOrderTakerConfigV1, + CALLER_META_HASH as ROUTE_PROCESSOR_ORDER_BOOK_V3_ARB_ORDER_TAKER_CALLER_META_HASH } from "src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol"; import { OrderV2, @@ -20,8 +21,10 @@ import {ROUTE_PROCESSOR_ORDER_BOOK_V3_ARB_ORDER_TAKER_META_PATH} from contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest { function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) { - (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = - buildConstructorConfig(ROUTE_PROCESSOR_ORDER_BOOK_V3_ARB_ORDER_TAKER_META_PATH); + (address deployer, DeployerDiscoverableMetaV3ConstructionConfig memory config) = buildConstructorConfig( + ROUTE_PROCESSOR_ORDER_BOOK_V3_ARB_ORDER_TAKER_META_PATH, + ROUTE_PROCESSOR_ORDER_BOOK_V3_ARB_ORDER_TAKER_CALLER_META_HASH + ); return ArbTestConstructorConfig(deployer, address(new RouteProcessorOrderBookV3ArbOrderTaker(config))); }