Skip to content

Commit

Permalink
chore(contracts/solve): rename call.destChainId to call.chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhalliday committed Jan 6, 2025
1 parent 2c553d9 commit 51b822d
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion contracts/bindings/admin.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions contracts/bindings/solveinbox.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions contracts/bindings/solveoutbox.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions contracts/solve/src/Solve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ library Solve {

/**
* @notice Details of a call to be executed on another chain.
* @param destChainId ID of the destination chain.
* @param value Amount of native currency to send with the call.
* @param target Address of the target contract on the destination chain.
* @param data Encoded data to be sent with the call.
* @param chainId ID of chain on which the call should be executed.
* @param value Amount of native currency to send with the call.
* @param target Address of the target contract on the destination chain.
* @param data Encoded data to be sent with the call.
*/
struct Call {
uint64 destChainId;
uint64 chainId;
address target;
uint256 value;
bytes data;
Expand Down
4 changes: 2 additions & 2 deletions contracts/solve/src/SolveInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ contract SolveInbox is OwnableRoles, ReentrancyGuard, Initializable, DeployedAt,
returns (bytes32 id)
{
if (call.target == address(0)) revert InvalidCall();
if (call.destChainId == 0) revert InvalidCall();
if (call.chainId == 0) revert InvalidCall();
if (call.data.length == 0) revert InvalidCall();
if (deposits.length == 0 && msg.value == 0) revert NoDeposits();

Expand Down Expand Up @@ -189,7 +189,7 @@ contract SolveInbox is OwnableRoles, ReentrancyGuard, Initializable, DeployedAt,
Solve.Request storage req = _requests[id];
if (req.status != Solve.Status.Accepted) revert NotAccepted();
if (xmsg.sender != _outbox) revert NotOutbox();
if (xmsg.sourceChainId != req.call.destChainId) revert WrongSourceChain();
if (xmsg.sourceChainId != req.call.chainId) revert WrongSourceChain();

// Ensure reported call hash matches requested call hash
if (callHash != _callHash(id, uint64(block.chainid), req.call)) revert WrongCallHash();
Expand Down
2 changes: 1 addition & 1 deletion contracts/solve/src/SolveOutbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ contract SolveOutbox is OwnableRoles, ReentrancyGuard, Initializable, DeployedAt
Solve.Call calldata call,
Solve.TokenPrereq[] calldata prereqs
) external payable onlyRoles(SOLVER) nonReentrant {
if (call.destChainId != block.chainid) revert WrongDestChain();
if (call.chainId != block.chainid) revert WrongDestChain();
if (!allowedCalls[call.target][bytes4(call.data)]) revert CallNotAllowed();

// If the call has already been fulfilled, revert. Else, mark fulfilled
Expand Down
2 changes: 1 addition & 1 deletion contracts/solve/test/InboxBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract InboxBase is Test {
function randCall() internal returns (Solve.Call memory) {
uint256 rand = vm.randomUint(1, 1000);
return Solve.Call({
destChainId: uint64(rand),
chainId: uint64(rand),
value: rand * 1 ether,
target: address(uint160(rand)),
data: abi.encode("data", rand)
Expand Down
4 changes: 2 additions & 2 deletions contracts/solve/test/Inbox_claim.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract SolveInbox_claim_Test is InboxBase {

// mark fulfilled
portal.mockXCall({
sourceChainId: call.destChainId,
sourceChainId: call.chainId,
sender: address(outbox),
data: abi.encodeCall(inbox.markFulfilled, (id, callHash(id, call))),
to: address(inbox)
Expand Down Expand Up @@ -163,7 +163,7 @@ contract SolveInbox_claim_Test is InboxBase {

// mark fulfilled
portal.mockXCall({
sourceChainId: call.destChainId,
sourceChainId: call.chainId,
sender: address(outbox),
data: abi.encodeCall(inbox.markFulfilled, (id, callHash(id, call))),
to: address(inbox)
Expand Down
10 changes: 5 additions & 5 deletions contracts/solve/test/Inbox_markFulfilled.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ contract SolveInbox_markFulfilled_Test is InboxBase {
// must be xcall from outbox
vm.expectRevert(SolveInbox.NotOutbox.selector);
portal.mockXCall({
sourceChainId: call.destChainId,
sourceChainId: call.chainId,
sender: address(1234), // not outbox
data: abi.encodeCall(inbox.markFulfilled, (id, callHash(id, call))),
to: address(inbox)
});

// must be xcall from call.destChainId
// must be xcall from call.chainId
vm.expectRevert(SolveInbox.WrongSourceChain.selector);
portal.mockXCall({
sourceChainId: 1234, // not call.destChainId
sourceChainId: 1234, // not call.chainId
sender: address(outbox),
data: abi.encodeCall(inbox.markFulfilled, (id, callHash(id, call))),
to: address(inbox)
Expand All @@ -47,7 +47,7 @@ contract SolveInbox_markFulfilled_Test is InboxBase {
// must have correct call hash
vm.expectRevert(SolveInbox.WrongCallHash.selector);
portal.mockXCall({
sourceChainId: call.destChainId,
sourceChainId: call.chainId,
sender: address(outbox),
data: abi.encodeCall(inbox.markFulfilled, (id, bytes32(uint256(1234)))), // not correct call hash
to: address(inbox)
Expand All @@ -72,7 +72,7 @@ contract SolveInbox_markFulfilled_Test is InboxBase {
vm.expectEmit(address(inbox));
emit ISolveInbox.Fulfilled(id, callHash(id, call), solver);
portal.mockXCall({
sourceChainId: call.destChainId,
sourceChainId: call.chainId,
sender: address(outbox),
data: abi.encodeCall(inbox.markFulfilled, (id, callHash(id, call))),
to: address(inbox)
Expand Down
8 changes: 4 additions & 4 deletions contracts/solve/test/Inbox_request.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import { InboxBase } from "./InboxBase.sol";
contract SolveInbox_request_Test is InboxBase {
/// @dev Test all revert conditions for SolveInbox.request(...)
function test_request_reverts() public prankUser {
Solve.Call memory call = Solve.Call({ destChainId: 0, value: 0, target: address(0), data: bytes("") });
Solve.Call memory call = Solve.Call({ chainId: 0, value: 0, target: address(0), data: bytes("") });
Solve.TokenDeposit[] memory deposits = new Solve.TokenDeposit[](0);

// needs call.target
vm.expectRevert(SolveInbox.InvalidCall.selector);
inbox.request(call, deposits);
call.target = address(1);

// needs destChainId
// needs chainId
vm.expectRevert(SolveInbox.InvalidCall.selector);
inbox.request(call, deposits);
call.destChainId = 1;
call.chainId = 1;

// needs data
vm.expectRevert(SolveInbox.InvalidCall.selector);
Expand Down Expand Up @@ -224,7 +224,7 @@ contract SolveInbox_request_Test is InboxBase {
assertEq(req.id, status == Solve.Status.Invalid ? bytes32(0) : id, "_assertNewRequest : req.id");
assertEq(req.from, from, "_assertNewRequest : req.from");
assertEq(req.call.target, call.target, "_assertNewRequest : req.call.target");
assertEq(req.call.destChainId, call.destChainId, "_assertNewRequest : req.call.destChainId");
assertEq(req.call.chainId, call.chainId, "_assertNewRequest : req.call.chainId");
assertEq(req.call.value, call.value, "_assertNewRequest : req.call.value");
assertEq(req.call.data, call.data, "_assertNewRequest : req.call.data");

Expand Down
8 changes: 4 additions & 4 deletions contracts/solve/test/Outbox_fulfill.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ contract SolveOutbox_fulfill_test is Test {
vm.startPrank(solver);

// only correct dest chain
vm.chainId(call.destChainId + 1);
vm.chainId(call.chainId + 1);
vm.expectRevert(SolveOutbox.WrongDestChain.selector);
outbox.fulfill(srcReqId, srcChainId, call, new Solve.TokenPrereq[](0));
vm.chainId(call.destChainId);
vm.chainId(call.chainId);

// only allowed calls
Solve.Call memory notAllowed = randCall();
Expand Down Expand Up @@ -154,7 +154,7 @@ contract SolveOutbox_fulfill_test is Test {
/// @dev Returns a call to deposit into a vault.
function vaultCall(address vault, address onBehalfOf, uint256 amount) internal view returns (Solve.Call memory) {
bytes memory data = abi.encodeCall(MockVault.deposit, (onBehalfOf, amount));
return Solve.Call({ destChainId: uint64(block.chainid), target: vault, value: 0, data: data });
return Solve.Call({ chainId: uint64(block.chainid), target: vault, value: 0, data: data });
}

/// @dev Returns expected OmniPortal.xcall Inbox.markFulfilled calldata
Expand All @@ -179,7 +179,7 @@ contract SolveOutbox_fulfill_test is Test {
function randCall() internal returns (Solve.Call memory) {
uint256 rand = vm.randomUint(1, 1000);
return Solve.Call({
destChainId: uint64(block.chainid),
chainId: uint64(block.chainid),
value: rand * 1 ether,
target: address(uint160(rand)),
data: abi.encode("data", rand)
Expand Down
8 changes: 4 additions & 4 deletions e2e/solve/devapp/deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ func requestAtInbox(ctx context.Context, app App, backend *ethbackend.Backend, a
}

call := bindings.SolveCall{
DestChainId: app.L1.ChainID,
Target: app.L1Vault,
Value: new(big.Int), // 0 native
Data: data,
ChainId: app.L1.ChainID,
Target: app.L1Vault,
Value: new(big.Int), // 0 native
Data: data,
}

for _, opt := range opts {
Expand Down
2 changes: 1 addition & 1 deletion solver/app/procdeps.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func newFulfiller(
solverAddr, outboxAddr common.Address,
) func(ctx context.Context, srcChainID uint64, req bindings.SolveRequest) error {
return func(ctx context.Context, srcChainID uint64, req bindings.SolveRequest) error {
destChainID := req.Call.DestChainId // Fulfilling happens on destination chain
destChainID := req.Call.ChainId // Fulfilling happens on destination chain
outbox, ok := outboxContracts[destChainID]
if !ok {
return errors.New("unknown chain")
Expand Down
4 changes: 2 additions & 2 deletions solver/app/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func getTarget(network netconf.ID, call bindings.SolveCall) (types.Target, error

var resp *types.Target
for _, target := range targets {
if target.ChainID() == call.DestChainId && target.Address() == call.Target {
if target.ChainID() == call.ChainId && target.Address() == call.Target {
if resp != nil {
return nil, errors.New("multiple targets found [BUG]")
}
Expand All @@ -32,7 +32,7 @@ func getTarget(network netconf.ID, call bindings.SolveCall) (types.Target, error
}

if resp == nil {
return nil, errors.New("no target found", "dest_chain_id", call.DestChainId, "target_address", call.Target)
return nil, errors.New("no target found", "chain_id", call.ChainId, "target_address", call.Target)
}

return *resp, nil
Expand Down

0 comments on commit 51b822d

Please sign in to comment.