Skip to content

Commit

Permalink
update metas and fn selectors for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Dec 7, 2023
1 parent 6b8dbf3 commit 6426819
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 38 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/fn-selectors.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 8 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};

Expand All @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion src/concrete/GenericPoolOrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/concrete/GenericPoolOrderBookV3FlashBorrower.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/concrete/OrderBook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 21 additions & 7 deletions test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand Down
12 changes: 9 additions & 3 deletions test/util/abstract/ArbTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)));
}

Expand Down
11 changes: 8 additions & 3 deletions test/util/abstract/OrderBookExternalMockTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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))));

Expand Down
28 changes: 22 additions & 6 deletions test/util/abstract/OrderBookExternalRealTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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(
Expand All @@ -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)))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)));
}

Expand Down

0 comments on commit 6426819

Please sign in to comment.