Skip to content
Merged
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
11 changes: 11 additions & 0 deletions Errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@
| `OnlyOffChain()` | `0x9cbfe066` |
| `SimulationFailed()` | `0x2fbab3ac` |

## protocol/switchboard/CCTPSwitchboard.sol

| Error | Signature |
| ------------------------------- | ------------ |
| `RemoteExecutionNotFound()` | `0xbd506972` |
| `PrevBatchDigestHashMismatch()` | `0xc9864e9d` |
| `NotAttested()` | `0x99efb890` |
| `NotExecuted()` | `0xec84b1da` |
| `InvalidSender()` | `0xddb5de5e` |
| `OnlyMessageTransmitter()` | `0x935ac89c` |

## protocol/switchboard/FastSwitchboard.sol

| Error | Signature |
Expand Down
16 changes: 16 additions & 0 deletions EventTopics.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@
| `TriggerFeesSet` | `(triggerFees: uint256)` | `0x7df3967b7c8727af5ac0ee9825d88aafeb899d769bc428b91f8967fa0b623084` |
| `TriggerSucceeded` | `(triggerId: bytes32)` | `0x92d20fbcbf31370b8218e10ed00c5aad0e689022da30a08905ba5ced053219eb` |

## ICCTPSwitchboard

| Event | Arguments | Topic |
| ----- | --------- | ----- |

## CCTPSwitchboard

| Event | Arguments | Topic |
| ---------------------------- | ----------------------------------------- | -------------------------------------------------------------------- |
| `Attested` | `(payloadId_: bytes32, watcher: address)` | `0x3d83c7bc55c269e0bc853ddc0d7b9fca30216ecc43779acb4e36b7e0ad1c71e4` |
| `OwnershipHandoverCanceled` | `(pendingOwner: address)` | `0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92` |
| `OwnershipHandoverRequested` | `(pendingOwner: address)` | `0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d` |
| `OwnershipTransferred` | `(oldOwner: address, newOwner: address)` | `0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0` |
| `RoleGranted` | `(role: bytes32, grantee: address)` | `0x2ae6a113c0ed5b78a53413ffbb7679881f11145ccfba4fb92e863dfcd5a1d2f3` |
| `RoleRevoked` | `(role: bytes32, revokee: address)` | `0x155aaafb6329a2098580462df33ec4b7441b19729b9601c5fc17ae1cf99a8a52` |

## FastSwitchboard

| Event | Arguments | Topic |
Expand Down
60 changes: 48 additions & 12 deletions FunctionSignatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,19 @@

## SocketBatcher

| Function | Signature |
| ---------------------------- | ------------ |
| `attestAndExecute` | `0x66c7748a` |
| `cancelOwnershipHandover` | `0x54d1f13d` |
| `completeOwnershipHandover` | `0xf04e283e` |
| `owner` | `0x8da5cb5b` |
| `ownershipHandoverExpiresAt` | `0xfee81cf4` |
| `renounceOwnership` | `0x715018a6` |
| `requestOwnershipHandover` | `0x25692962` |
| `rescueFunds` | `0x6ccae054` |
| `socket__` | `0xc6a261d2` |
| `transferOwnership` | `0xf2fde38b` |
| Function | Signature |
| ------------------------------ | ------------ |
| `attestAndExecute` | `0x66c7748a` |
| `attestCCTPAndProveAndExecute` | `0x6c5fd05f` |
| `cancelOwnershipHandover` | `0x54d1f13d` |
| `completeOwnershipHandover` | `0xf04e283e` |
| `owner` | `0x8da5cb5b` |
| `ownershipHandoverExpiresAt` | `0xfee81cf4` |
| `renounceOwnership` | `0x715018a6` |
| `requestOwnershipHandover` | `0x25692962` |
| `rescueFunds` | `0x6ccae054` |
| `socket__` | `0xc6a261d2` |
| `transferOwnership` | `0xf2fde38b` |

## SocketFeeManager

Expand Down Expand Up @@ -472,6 +473,41 @@
| `watcherMultiCall` | `0x8021e82b` |
| `watcher__` | `0x300bb063` |

## CCTPSwitchboard

| Function | Signature |
| -------------------------------- | ------------ |
| `addRemoteEndpoint` | `0x7d396da5` |
| `allowPacket` | `0x21e9ec80` |
| `allowPayload` | `0x31c23f66` |
| `attest` | `0x63671b60` |
| `attestVerifyAndProveExecutions` | `0x3e9e97e2` |
| `cancelOwnershipHandover` | `0x54d1f13d` |
| `chainSlug` | `0xb349ba65` |
| `chainSlugToRemoteEndpoint` | `0xa4500424` |
| `completeOwnershipHandover` | `0xf04e283e` |
| `domainToRemoteEndpoint` | `0xc24964fe` |
| `grantRole` | `0x2f2ff15d` |
| `handleReceiveMessage` | `0x96abeb70` |
| `hasRole` | `0x91d14854` |
| `isAttested` | `0xc13c2396` |
| `isRemoteExecuted` | `0x0cd97747` |
| `isSyncedOut` | `0x5ae5dfd6` |
| `messageTransmitter` | `0x7b04c181` |
| `owner` | `0x8da5cb5b` |
| `ownershipHandoverExpiresAt` | `0xfee81cf4` |
| `proveRemoteExecutions` | `0xc36f2ca2` |
| `registerSwitchboard` | `0x74f5b1fc` |
| `remoteExecutedDigests` | `0xecbf77d9` |
| `renounceOwnership` | `0x715018a6` |
| `requestOwnershipHandover` | `0x25692962` |
| `rescueFunds` | `0x6ccae054` |
| `revokeRole` | `0xd547741f` |
| `socket__` | `0xc6a261d2` |
| `syncOut` | `0x69a60ff0` |
| `transferOwnership` | `0xf2fde38b` |
| `verifyAttestations` | `0x6f30514c` |

## FastSwitchboard

| Function | Signature |
Expand Down
4 changes: 4 additions & 0 deletions contracts/evmx/interfaces/IAppGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ interface IAppGateway {
bytes32 contractId_,
uint32 chainSlug_
) external view returns (address forwarderAddress);

/// @notice get the switchboard type
/// @return sbType The switchboard type
function sbType() external view returns (bytes32);
}
35 changes: 34 additions & 1 deletion contracts/protocol/SocketBatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import "solady/auth/Ownable.sol";
import "./interfaces/ISocket.sol";
import "./interfaces/ISocketBatcher.sol";
import "./interfaces/ISwitchboard.sol";
import "./interfaces/ICCTPSwitchboard.sol";
import "../utils/RescueFundsLib.sol";
import {ExecuteParams, TransmissionParams} from "../utils/common/Structs.sol";
import {ExecuteParams, TransmissionParams, CCTPBatchParams, CCTPExecutionParams} from "../utils/common/Structs.sol";
import {createPayloadId} from "../utils/common/IdUtils.sol";

/**
* @title SocketBatcher
Expand Down Expand Up @@ -55,6 +57,37 @@ contract SocketBatcher is ISocketBatcher, Ownable {
);
}

function attestCCTPAndProveAndExecute(
CCTPExecutionParams calldata execParams_,
CCTPBatchParams calldata cctpParams_,
address switchboard_
) external payable returns (bool, bytes memory) {
bytes32 payloadId = createPayloadId(
execParams_.executeParams.requestCount,
execParams_.executeParams.batchCount,
execParams_.executeParams.payloadCount,
bytes32(uint256(uint160(address(switchboard_)))),
socket__.chainSlug()
);
ICCTPSwitchboard(switchboard_).attestVerifyAndProveExecutions(
execParams_,
cctpParams_,
payloadId
);
(bool success, bytes memory returnData) = socket__.execute{value: msg.value}(
execParams_.executeParams,
TransmissionParams({
transmitterSignature: execParams_.transmitterSignature,
socketFees: 0,
extraData: execParams_.executeParams.extraData,
refundAddress: execParams_.refundAddress
})
);

ICCTPSwitchboard(switchboard_).syncOut(payloadId, cctpParams_.nextBatchRemoteChainSlugs);
return (success, returnData);
}

/**
* @notice Rescues funds from the contract
* @param token_ The address of the token to rescue
Expand Down
61 changes: 61 additions & 0 deletions contracts/protocol/interfaces/ICCTPSwitchboard.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import "./ISwitchboard.sol";
import {ExecuteParams, CCTPExecutionParams, CCTPBatchParams} from "../../utils/common/Structs.sol";

/**
* @title ISwitchboard
* @dev The interface for a switchboard contract that is responsible for verification of payloads if the correct
* digest is executed.
*/
interface ICCTPSwitchboard is ISwitchboard {
/**
* @notice Syncs out a payload to the remote chains
* @param payloadId_ The unique identifier for the payload
* @param remoteChainSlugs_ The remote chain slugs
*/
function syncOut(bytes32 payloadId_, uint32[] calldata remoteChainSlugs_) external;

/**
* @notice Handles the receive message
* @param sourceDomain The source domain
* @param sender The sender
* @param messageBody The message body
*/
function handleReceiveMessage(
uint32 sourceDomain,
bytes32 sender,
bytes calldata messageBody
) external returns (bool);

/**
* @notice Proves the remote executions
* @param previousPayloadIds_ The previous payload ids
* @param currentPayloadId_ The current payload id
* @param transmitterSignature_ The transmitter signature
* @param executeParams_ The execute parameters
*/
function proveRemoteExecutions(
bytes32[] calldata previousPayloadIds_,
bytes32 currentPayloadId_,
bytes calldata transmitterSignature_,
ExecuteParams calldata executeParams_
) external;

/**
* @notice Verifies the attestations
* @param messages_ The messages
* @param attestations_ The attestations
*/
function verifyAttestations(
bytes[] calldata messages_,
bytes[] calldata attestations_
) external;

function attestVerifyAndProveExecutions(
CCTPExecutionParams calldata execParams_,
CCTPBatchParams calldata cctpParams_,
bytes32 payloadId_
) external;
}
21 changes: 21 additions & 0 deletions contracts/protocol/interfaces/IMessageHandler.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;
/**
* @title IMessageHandler
* @notice Handles messages on destination domain forwarded from
* an IReceiver
*/
interface IMessageHandler {
/**
* @notice handles an incoming message from a Receiver
* @param sourceDomain the source domain of the message
* @param sender the sender of the message
* @param messageBody The message raw bytes
* @return success bool, true if successful
*/
function handleReceiveMessage(
uint32 sourceDomain,
bytes32 sender,
bytes calldata messageBody
) external returns (bool);
}
19 changes: 19 additions & 0 deletions contracts/protocol/interfaces/IMessageTransmitter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

interface IMessageTransmitter {
function sendMessage(
uint32 destinationDomain,
bytes32 recipient,
bytes calldata messageBody
) external returns (uint64 nonce);

function receiveMessage(
bytes calldata message,
bytes calldata attestation
) external returns (bool success);

function localDomain() external view returns (uint32);

function attestationManager() external view returns (address);
}
8 changes: 7 additions & 1 deletion contracts/protocol/interfaces/ISocket.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import {ExecuteParams, TransmissionParams} from "../../utils/common/Structs.sol";
import {ExecuteParams, TransmissionParams, ExecutionStatus} from "../../utils/common/Structs.sol";

/**
* @title ISocket
Expand Down Expand Up @@ -76,4 +76,10 @@ interface ISocket {
function getPlugConfig(
address plugAddress_
) external view returns (bytes32 appGatewayId, address switchboard);

function payloadExecuted(bytes32 payloadId_) external view returns (ExecutionStatus);

function chainSlug() external view returns (uint32);

function payloadIdToDigest(bytes32 payloadId_) external view returns (bytes32);
}
Loading