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
1 change: 1 addition & 0 deletions .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Custom Dictionary Words
Aptos
CCTP
Devnet
hashv
idls
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@ uint32 payloadLen // Length of the payload
bytes payload // The full payload, the keccak of which was sent to `endpoint.sendMessage`
```

##### NTT v1 Request

```solidity
bytes4 prefix = "ERN1" // 4-byte prefix for this struct
uint16 srcChain
bytes32 srcManager
bytes32 messageId
```

##### CCTP v1 Request

```solidity
bytes4 prefix = "ERC1" // 4-byte prefix for this struct
uint32 sourceDomain
uint64 nonce
```

#### Relay Instructions

##### Gas Instruction
Expand Down
64 changes: 64 additions & 0 deletions evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,54 @@ executor.requestExecution{value: executionAmount}(

<!-- cspell:enable -->

#### Example v1 NTT Request

<!-- cspell:disable -->

```solidity
import "example-messaging-executor/evm/src/interfaces/IExecutor.sol";
import "example-messaging-executor/evm/src/libraries/ExecutorMessages.sol";
...
uint64 msgId = nttm.transfer{value: msg.value - executorArgs.value}(
amount, recipientChain, recipientAddress, refundAddress, shouldQueue, encodedInstructions
);

executor.requestExecution{value: executorArgs.value}(
recipientChain,
nttm.getPeer(recipientChain).peerAddress,
executorArgs.refundAddress,
executorArgs.signedQuote,
ExecutorMessages.makeNTTv1Request(
chainId, bytes32(uint256(uint160(address(nttm)))), bytes32(uint256(msgId))
),
executorArgs.instructions
);
```

<!-- cspell:enable -->

#### Example v1 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);

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

<!-- cspell:enable -->

### Execution Support

#### v1 VAA Execution
Expand All @@ -56,6 +104,22 @@ Your contract must implement the following function.
function receiveMessage(bytes calldata encodedTransferMessage) public payable
```

#### v1 NTT Execution

The NTT Transceiver contract implements the following function.

```solidity
function receiveMessage(bytes memory encodedMessage) external
```

#### v1 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 @@ -5,6 +5,7 @@ library ExecutorMessages {
bytes4 private constant REQ_MM = "ERM1";
bytes4 private constant REQ_VAA_V1 = "ERV1";
bytes4 private constant REQ_NTT_V1 = "ERN1";
bytes4 private constant REQ_CCTP_V1 = "ERC1";

/// @notice Payload length will not fit in a uint32.
/// @dev Selector: 492f620d.
Expand Down Expand Up @@ -54,4 +55,12 @@ library ExecutorMessages {
{
return abi.encodePacked(REQ_NTT_V1, srcChain, srcManager, messageId);
}

/// @notice Encodes a version 1 CCTP request payload.
/// @param sourceDomain The source chain for the CCTP transfer.
/// @param nonce The nonce of the CCTP transfer.
/// @return bytes The encoded request.
function makeCCTPv1Request(uint32 sourceDomain, uint64 nonce) internal pure returns (bytes memory) {
return abi.encodePacked(REQ_CCTP_V1, 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 @@ -38,4 +38,12 @@ contract ExecutorMessagesTest is Test {
bytes memory buf = ExecutorMessages.makeNTTv1Request(srcChain, srcManager, messageId);
assertEq(keccak256(expected), keccak256(buf));
}

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