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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ uint32 sourceDomain
uint64 nonce
```

##### CCTP v2 Request

```solidity
bytes4 prefix = "ERC2" // 4-byte prefix for this struct
uint8 autoDiscover // Currently, must be one.
```

#### Relay Instructions

##### Gas Instruction
Expand Down
35 changes: 34 additions & 1 deletion evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ executor.requestExecution{value: executorArgs.value}(

<!-- cspell:enable -->

#### Example v2 CCTP Request

The `depositForBurn` function in CCTP v2 doesn't return anything, so we don't have a unique identifier for a transfer.
The off-chain executor will detect all Circle V2 transfers in the transaction and relay them.

<!-- cspell:disable -->

```solidity
import "example-messaging-executor/evm/src/interfaces/IExecutor.sol";
import "example-messaging-executor/evm/src/libraries/ExecutorMessages.sol";
...
circleTokenMessenger.depositForBurn(amount, destinationDomain, mintRecipient, burnToken, destinationCaller, maxFee, minFinalityThreshold);

executor.requestExecution{value: executorArgs.value}(
0,
bytes32(0),
executorArgs.refundAddress,
executorArgs.signedQuote,
ExecutorMessages.makeCCTPv2Request(),
executorArgs.instructions
);
```

<!-- cspell:enable -->

### Execution Support

#### v1 VAA Execution
Expand All @@ -117,7 +142,15 @@ function receiveMessage(bytes memory encodedMessage) external
The Circle Message Transmitter contract implements the following function.

```solidity
function receiveMessage(bytes calldata message,bytes calldata attestation) external override whenNotPaused returns (bool success)
function receiveMessage(bytes calldata message, bytes calldata attestation) external override whenNotPaused returns (bool success)
```

#### v2 CCTP Execution

The Circle Message Transmitter contract implements the following function.

```solidity
function receiveMessage(bytes calldata message, bytes calldata attestation) external override whenNotPaused returns (bool success)
```

## Executor Development
Expand Down
9 changes: 9 additions & 0 deletions evm/src/libraries/ExecutorMessages.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ library ExecutorMessages {
bytes4 private constant REQ_VAA_V1 = "ERV1";
bytes4 private constant REQ_NTT_V1 = "ERN1";
bytes4 private constant REQ_CCTP_V1 = "ERC1";
bytes4 private constant REQ_CCTP_V2 = "ERC2";

/// @notice Payload length will not fit in a uint32.
/// @dev Selector: 492f620d.
Expand Down Expand Up @@ -63,4 +64,12 @@ library ExecutorMessages {
function makeCCTPv1Request(uint32 sourceDomain, uint64 nonce) internal pure returns (bytes memory) {
return abi.encodePacked(REQ_CCTP_V1, sourceDomain, nonce);
}

/// @notice Encodes a version 2 CCTP request payload.
/// This request currently assumes the Executor will auto detect the event off chain.
/// That may change in the future, in which case this interface would change.
/// @return bytes The encoded request.
function makeCCTPv2Request() internal pure returns (bytes memory) {
return abi.encodePacked(REQ_CCTP_V2, uint8(1));
}
}
6 changes: 6 additions & 0 deletions evm/test/ExecutorMessages.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ contract ExecutorMessagesTest is Test {
bytes memory buf = ExecutorMessages.makeCCTPv1Request(srcDomain, nonce);
assertEq(keccak256(expected), keccak256(buf));
}

function test_makeCCTPv2Request() public pure {
bytes memory expected = abi.encodePacked("ERC2", uint8(1));
bytes memory buf = ExecutorMessages.makeCCTPv2Request();
assertEq(keccak256(expected), keccak256(buf));
}
}
Loading