Skip to content

Commit 2c65067

Browse files
authored
feat: support CCTP v2 fast transfers (#6709)
1 parent 7997516 commit 2c65067

File tree

18 files changed

+1476
-286
lines changed

18 files changed

+1476
-286
lines changed

.changeset/light-years-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperlane-xyz/core": minor
3+
---
4+
5+
Implement support for CCTP v2 fast transfers
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
pragma solidity >=0.8.0;
19+
20+
/**
21+
* @title IMessageHandlerV2
22+
* @notice Handles messages on the destination domain, forwarded from
23+
* an IReceiverV2.
24+
*/
25+
interface IMessageHandlerV2 {
26+
/**
27+
* @notice Handles an incoming finalized message from an IReceiverV2
28+
* @dev Finalized messages have finality threshold values greater than or equal to 2000
29+
* @param sourceDomain The source domain of the message
30+
* @param sender The sender of the message
31+
* @param finalityThresholdExecuted the finality threshold at which the message was attested to
32+
* @param messageBody The raw bytes of the message body
33+
* @return success True, if successful; false, if not.
34+
*/
35+
function handleReceiveFinalizedMessage(
36+
uint32 sourceDomain,
37+
bytes32 sender,
38+
uint32 finalityThresholdExecuted,
39+
bytes calldata messageBody
40+
) external returns (bool);
41+
42+
/**
43+
* @notice Handles an incoming unfinalized message from an IReceiverV2
44+
* @dev Unfinalized messages have finality threshold values less than 2000
45+
* @param sourceDomain The source domain of the message
46+
* @param sender The sender of the message
47+
* @param finalityThresholdExecuted The finality threshold at which the message was attested to
48+
* @param messageBody The raw bytes of the message body
49+
* @return success True, if successful; false, if not.
50+
*/
51+
function handleReceiveUnfinalizedMessage(
52+
uint32 sourceDomain,
53+
bytes32 sender,
54+
uint32 finalityThresholdExecuted,
55+
bytes calldata messageBody
56+
) external returns (bool);
57+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2024 Circle Internet Group, Inc. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
pragma solidity >=0.8.0;
19+
20+
import {IMessageTransmitter} from "./IMessageTransmitter.sol";
21+
import {IReceiver} from "./IMessageTransmitter.sol";
22+
23+
/**
24+
* @title IReceiverV2
25+
* @notice Receives messages on the destination chain and forwards them to contracts implementing
26+
* IMessageHandlerV2.
27+
*/
28+
interface IReceiverV2 is IReceiver {}
29+
30+
/**
31+
* @title IRelayerV2
32+
* @notice Sends messages from the source domain to the destination domain
33+
*/
34+
interface IRelayerV2 {
35+
/**
36+
* @notice Sends an outgoing message from the source domain.
37+
* @dev Emits a `MessageSent` event with message information.
38+
* WARNING: if the `destinationCaller` does not represent a valid address as bytes32, then it will not be possible
39+
* to broadcast the message on the destination domain. If set to bytes32(0), anyone will be able to broadcast it.
40+
* This is an advanced feature, and using bytes32(0) should be preferred for use cases where a specific destination caller is not required.
41+
* @param destinationDomain Domain of destination chain
42+
* @param recipient Address of message recipient on destination domain as bytes32
43+
* @param destinationCaller Allowed caller on destination domain (see above WARNING).
44+
* @param minFinalityThreshold Minimum finality threshold at which the message must be attested to.
45+
* @param messageBody Content of the message, as raw bytes
46+
*/
47+
function sendMessage(
48+
uint32 destinationDomain,
49+
bytes32 recipient,
50+
bytes32 destinationCaller,
51+
uint32 minFinalityThreshold,
52+
bytes calldata messageBody
53+
) external;
54+
}
55+
56+
/**
57+
* @title IMessageTransmitterV2
58+
* @notice Interface for V2 message transmitters, which both relay and receive messages.
59+
*/
60+
interface IMessageTransmitterV2 is
61+
IRelayerV2,
62+
IReceiverV2,
63+
IMessageTransmitter
64+
{}

solidity/contracts/interfaces/cctp/ITokenMessenger.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
pragma solidity ^0.8.0;
33

44
interface ITokenMessenger {
5+
function messageBodyVersion() external returns (uint32);
6+
}
7+
8+
interface ITokenMessengerV1 is ITokenMessenger {
59
event DepositForBurn(
610
uint64 indexed nonce,
711
address indexed burnToken,
@@ -19,6 +23,4 @@ interface ITokenMessenger {
1923
bytes32 mintRecipient,
2024
address burnToken
2125
) external returns (uint64 _nonce);
22-
23-
function messageBodyVersion() external returns (uint32);
2426
}

solidity/contracts/interfaces/cctp/ITokenMessengerV2.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
interface ITokenMessengerV2 {
4+
import {ITokenMessenger} from "./ITokenMessenger.sol";
5+
6+
interface ITokenMessengerV2 is ITokenMessenger {
57
event DepositForBurn(
68
address indexed burnToken,
79
uint256 amount,
@@ -24,6 +26,4 @@ interface ITokenMessengerV2 {
2426
uint256 maxFee,
2527
uint32 minFinalityThreshold
2628
) external;
27-
28-
function messageBodyVersion() external returns (uint32);
2929
}

solidity/contracts/libs/CctpMessage.sol renamed to solidity/contracts/libs/CctpMessageV1.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {TypedMemView} from "./TypedMemView.sol";
4040
* messageBody dynamic bytes 116
4141
*
4242
**/
43-
library CctpMessage {
43+
library CctpMessageV1 {
4444
using TypedMemView for bytes;
4545
using TypedMemView for bytes29;
4646

@@ -182,7 +182,7 @@ library CctpMessage {
182182
* amount 32 uint256 68
183183
* messageSender 32 bytes32 100
184184
**/
185-
library BurnMessage {
185+
library BurnMessageV1 {
186186
using TypedMemView for bytes;
187187
using TypedMemView for bytes29;
188188

0 commit comments

Comments
 (0)