Skip to content
Closed
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
30 changes: 30 additions & 0 deletions evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ executor.requestExecution{value: executorArgs.value}(

<!-- cspell:enable -->

#### Example v2 CCTP Request

<!-- cspell:disable -->

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

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

<!-- cspell:enable -->

### Execution Support

#### v1 VAA Execution
Expand All @@ -120,6 +142,14 @@ The Circle Message Transmitter contract implements the following function.
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

### Testing
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.
/// @param sourceDomain The source chain for the CCTP transfer.
/// @param nonce The nonce of the CCTP transfer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From our convo, just leaving a comment here that nonce is no longer returned and is set to 0 on-chain. Judging by this testnet tx API response, it also isn't u64 anymore, but maybe a hash of something?

/// @return bytes The encoded request.
function makeCCTPv2Request(uint32 sourceDomain, uint64 nonce) internal pure returns (bytes memory) {
return abi.encodePacked(REQ_CCTP_V2, sourceDomain, nonce);
}
}
8 changes: 8 additions & 0 deletions evm/test/ExecutorMessages.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ contract ExecutorMessagesTest is Test {
bytes memory buf = ExecutorMessages.makeCCTPv1Request(srcDomain, nonce);
assertEq(keccak256(expected), keccak256(buf));
}

function test_makeCCTPv2Request() public pure {
uint32 srcDomain = 7;
uint64 nonce = 42;
bytes memory expected = abi.encodePacked("ERC2", srcDomain, nonce);
bytes memory buf = ExecutorMessages.makeCCTPv2Request(srcDomain, nonce);
assertEq(keccak256(expected), keccak256(buf));
}
}
Loading