Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/test_fixtures/abis/RaindexV6.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "raindex"
version = "0.1.13"
version = "0.1.14"

[profile.default]
src = 'src'
Expand Down
9 changes: 7 additions & 2 deletions src/concrete/raindex/RaindexV6.sol
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,15 @@ contract RaindexV6 is IRaindexV6, IMetaV1_2, ReentrancyGuard, Multicall, Raindex
}

/// @dev Runs the post tasks for an order mutation (`addOrder4` / `removeOrder3`)
/// with a context of the order hash and the caller.
/// with a context of the order hash, the caller, and the counterparty. Order
/// mutations have no counterparty so it is always the zero address.
function _doOrderPost(bytes32 orderHash, TaskV2[] calldata post) internal {
LibRaindex.doPost(
LibBytes32Matrix.matrixFrom(LibBytes32Array.arrayFrom(orderHash, bytes32(uint256(uint160(msg.sender))))),
LibBytes32Matrix.matrixFrom(
LibBytes32Array.arrayFrom(
orderHash, bytes32(uint256(uint160(msg.sender))), bytes32(uint256(uint160(address(0))))
)
),
post
);
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/generated/0_1_14/RaindexV6.pointers.sol

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions src/generated/0_1_14/RaindexV6SubParser.pointers.sol

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/generated/0_1_14/RouteProcessor4.pointers.sol

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/generated/GenericPoolRaindexV6ArbOrderTaker.pointers.sol

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/generated/GenericPoolRaindexV6FlashBorrower.pointers.sol

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/generated/RaindexV6.pointers.sol

Large diffs are not rendered by default.

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions test/concrete/raindex/RaindexV6.addOrder.entask.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,26 @@ contract RaindexV6AddOrderEnactTest is RaindexV6ExternalRealTest {

checkAddOrder(alice, config, evals, 0, 0);
}

/// order-counterparty() in an addOrder post-action must return address(0)
/// (no counterparty in an add-order context) rather than panicking with an
/// array OOB access. Fixes #2619.
/// forge-config: default.fuzz.runs = 10
function testAddOrderCounterpartyIsZeroAddress(address alice, OrderConfigV4 memory config) external {
LibTestAddOrder.conformConfig(config, iInterpreter, iStore);

string memory usingWordsFrom = string.concat("using-words-from ", address(iSubParser).toHexString(), "\n");

bytes[] memory evals = new bytes[](1);
evals[0] = bytes(
string.concat(
usingWordsFrom,
":ensure(equal-to(order-counterparty() ",
address(0).toHexString(),
") \"order-counterparty zero\");"
)
);

checkAddOrder(alice, config, evals, 0, 0);
}
}
24 changes: 22 additions & 2 deletions test/concrete/raindex/RaindexV6.removeOrder.entask.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ contract RaindexV6RemoveOrderEnactTest is RaindexV6ExternalRealTest {
assert(iRaindex.orderExists(order.hash()));
}

/// The post tasks of a live order removal run with a context of the
/// raindex contract, the order hash, the order owner, and the
/// counterparty. An order removal has no counterparty so
/// `order-counterparty()` is always the zero address.
/// forge-config: default.fuzz.runs = 100
function testRemoveOrderContext(address alice, OrderConfigV4 memory config) external {
// Need this conform here so that the order doesn't get mutated and
Expand All @@ -188,7 +192,7 @@ contract RaindexV6RemoveOrderEnactTest is RaindexV6ExternalRealTest {
OrderV4 memory order = OrderV4(alice, config.evaluable, config.validInputs, config.validOutputs, config.nonce);
bytes32 orderHash = order.hash();

bytes[] memory evals = new bytes[](3);
bytes[] memory evals = new bytes[](4);
evals[0] = bytes(
string.concat(
usingWordsFrom, ":ensure(equal-to(raindex() ", address(iRaindex).toHexString(), ") \"raindex\");"
Expand All @@ -204,7 +208,23 @@ contract RaindexV6RemoveOrderEnactTest is RaindexV6ExternalRealTest {
usingWordsFrom, ":ensure(equal-to(order-owner() ", address(alice).toHexString(), ") \"order-owner\");"
)
);
evals[3] = bytes(
string.concat(
usingWordsFrom,
":ensure(equal-to(order-counterparty() ",
address(0).toHexString(),
") \"order-counterparty zero\");"
)
);

checkRemoveOrder(alice, config, evals, 0, 0, false);
// The order must be live for the removal to run the post tasks, so
// add it first without any tasks.
vm.startPrank(alice);
bool added = iRaindex.addOrder4(config, new TaskV2[](0));
assert(added);

bool stateChanged = iRaindex.removeOrder3(order, evalsToActions(evals));
vm.stopPrank();
assert(stateChanged);
}
}
76 changes: 76 additions & 0 deletions test/lib/deploy/LibRaindexDeployTaggedConstants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,34 @@ import {
BYTECODE_HASH as GENERIC_POOL_FB_HASH_0_1_13,
RUNTIME_CODE as GENERIC_POOL_FB_RUNTIME_0_1_13
} from "../../../src/generated/0_1_13/GenericPoolRaindexV6FlashBorrower.pointers.sol";
import {
BYTECODE_HASH as RAINDEX_HASH_0_1_14,
RUNTIME_CODE as RAINDEX_RUNTIME_0_1_14,
DEPLOYED_ADDRESS as RAINDEX_ADDR_0_1_14,
CREATION_CODE as RAINDEX_CREATION_0_1_14
} from "../../../src/generated/0_1_14/RaindexV6.pointers.sol";
import {
BYTECODE_HASH as SUB_PARSER_HASH_0_1_14,
RUNTIME_CODE as SUB_PARSER_RUNTIME_0_1_14,
DEPLOYED_ADDRESS as SUB_PARSER_ADDR_0_1_14,
CREATION_CODE as SUB_PARSER_CREATION_0_1_14
} from "../../../src/generated/0_1_14/RaindexV6SubParser.pointers.sol";
import {
BYTECODE_HASH as ROUTE_PROCESSOR_HASH_0_1_14,
RUNTIME_CODE as ROUTE_PROCESSOR_RUNTIME_0_1_14
} from "../../../src/generated/0_1_14/RouteProcessor4.pointers.sol";
import {
BYTECODE_HASH as GENERIC_POOL_ARB_HASH_0_1_14,
RUNTIME_CODE as GENERIC_POOL_ARB_RUNTIME_0_1_14
} from "../../../src/generated/0_1_14/GenericPoolRaindexV6ArbOrderTaker.pointers.sol";
import {
BYTECODE_HASH as RP_ARB_HASH_0_1_14,
RUNTIME_CODE as RP_ARB_RUNTIME_0_1_14
} from "../../../src/generated/0_1_14/RouteProcessorRaindexV6ArbOrderTaker.pointers.sol";
import {
BYTECODE_HASH as GENERIC_POOL_FB_HASH_0_1_14,
RUNTIME_CODE as GENERIC_POOL_FB_RUNTIME_0_1_14
} from "../../../src/generated/0_1_14/GenericPoolRaindexV6FlashBorrower.pointers.sol";

/// @title LibRaindexDeployTaggedConstantsTest
/// @notice Each frozen per-tag pointer snapshot under `src/generated/<tag>/`
Expand Down Expand Up @@ -773,4 +801,52 @@ contract LibRaindexDeployTaggedConstantsTest is Test {
function testGenericPoolRaindexV6FlashBorrower_0_1_13_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(GENERIC_POOL_FB_RUNTIME_0_1_13), GENERIC_POOL_FB_HASH_0_1_13);
}

/// keccak256(RUNTIME_CODE) == BYTECODE_HASH for RaindexV6 0.1.14 - the pin is internally consistent.
function testRaindexV6_0_1_14_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(RAINDEX_RUNTIME_0_1_14), RAINDEX_HASH_0_1_14);
}

/// Zoltu-deploying the frozen CREATION_CODE for RaindexV6 0.1.14 reproduces its recorded address + codehash.
function testRaindexV6_0_1_14_CreationDeploysToPinnedAddress() external {
LibRainDeploy.etchZoltuFactory(vm);
address deployed = LibRainDeploy.deployZoltu(RAINDEX_CREATION_0_1_14);
assertEq(deployed, RAINDEX_ADDR_0_1_14);
assertEq(deployed.codehash, RAINDEX_HASH_0_1_14);
assertEq(keccak256(deployed.code), RAINDEX_HASH_0_1_14);
}

/// keccak256(RUNTIME_CODE) == BYTECODE_HASH for RaindexV6SubParser 0.1.14 - the pin is internally consistent.
function testRaindexV6SubParser_0_1_14_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(SUB_PARSER_RUNTIME_0_1_14), SUB_PARSER_HASH_0_1_14);
}

/// Zoltu-deploying the frozen CREATION_CODE for RaindexV6SubParser 0.1.14 reproduces its recorded address + codehash.
function testRaindexV6SubParser_0_1_14_CreationDeploysToPinnedAddress() external {
LibRainDeploy.etchZoltuFactory(vm);
address deployed = LibRainDeploy.deployZoltu(SUB_PARSER_CREATION_0_1_14);
assertEq(deployed, SUB_PARSER_ADDR_0_1_14);
assertEq(deployed.codehash, SUB_PARSER_HASH_0_1_14);
assertEq(keccak256(deployed.code), SUB_PARSER_HASH_0_1_14);
}

/// keccak256(RUNTIME_CODE) == BYTECODE_HASH for RouteProcessor4 0.1.14 - the pin is internally consistent.
function testRouteProcessor4_0_1_14_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(ROUTE_PROCESSOR_RUNTIME_0_1_14), ROUTE_PROCESSOR_HASH_0_1_14);
}

/// keccak256(RUNTIME_CODE) == BYTECODE_HASH for GenericPoolRaindexV6ArbOrderTaker 0.1.14 - the pin is internally consistent.
function testGenericPoolRaindexV6ArbOrderTaker_0_1_14_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(GENERIC_POOL_ARB_RUNTIME_0_1_14), GENERIC_POOL_ARB_HASH_0_1_14);
}

/// keccak256(RUNTIME_CODE) == BYTECODE_HASH for RouteProcessorRaindexV6ArbOrderTaker 0.1.14 - the pin is internally consistent.
function testRouteProcessorRaindexV6ArbOrderTaker_0_1_14_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(RP_ARB_RUNTIME_0_1_14), RP_ARB_HASH_0_1_14);
}

/// keccak256(RUNTIME_CODE) == BYTECODE_HASH for GenericPoolRaindexV6FlashBorrower 0.1.14 - the pin is internally consistent.
function testGenericPoolRaindexV6FlashBorrower_0_1_14_RuntimeHashesToBytecodeHash() external pure {
assertEq(keccak256(GENERIC_POOL_FB_RUNTIME_0_1_14), GENERIC_POOL_FB_HASH_0_1_14);
}
}
Loading