Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IMessageTransformer interface to CCIP onramp and offramp #15849

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from

Conversation

jinhoonbang
Copy link
Contributor

@jinhoonbang jinhoonbang commented Jan 7, 2025

  • add hooks to CCIP onramp and offramps for pre/post-processing messages using custom transformer
    • introduces MessageTransformerOnRamp/OffRamps which inherit canonical on/offRamps

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Static analysis results are available

Hey @Rishabh570, you can view Slither reports in the job summary here or download them as artifact here.
Please check them before merging and make sure you have addressed all issues.

Copy link
Contributor

github-actions bot commented Jan 7, 2025

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

Copy link
Contributor

github-actions bot commented Jan 9, 2025

I see you updated files related to contracts. Please run pnpm changeset in the contracts directory to add a changeset.

@jinhoonbang jinhoonbang force-pushed the ccip-message-transformers branch from 123c8c8 to 05f3201 Compare January 9, 2025 21:55
@jinhoonbang jinhoonbang marked this pull request as ready for review January 9, 2025 23:47
@jinhoonbang jinhoonbang requested review from a team as code owners January 9, 2025 23:47
@jinhoonbang jinhoonbang requested a review from RensR January 9, 2025 23:48
compileContract() {
local contract
contract=$(basename "$1")
echo "Compiling" "$contract"

local viaIR=""
Copy link
Contributor

Choose a reason for hiding this comment

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

Every contract already compiled with via-ir enabled. See the ccip-compile foundry profile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it. removing this logic

import {Internal} from "../libraries/Internal.sol";

/// @notice Interface for plug-in message hook contracts that transform OffRamp & OnRamp messages.
/// The transformer functions are expected to revert on transform failures.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: start the comment at the start of the line.
nit: what does plug-in mean here? I think the comment would be better without it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense. removed plug-in

/// @notice Transforms the given OffRamp message. Reverts on transform failure
/// @param message to transform
/// @return transformed message
function transformInboundMessage(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit switch the two function to follow the msg lifecycle.

Can you add something to the comments why this is useful or what type of transformations could exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes added

import {OffRamp} from "./OffRamp.sol";

/// @notice OffRamp that uses a message transformer to transform messages before execution
contract MessageTransformerOffRamp is OffRamp {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name them OffRampWithMsgTransformer instead? They're primarily a ramp so the name should reflect that imo

}

function getMessageTransformerAddress() external view returns (address) {
return s_messageTransformer;
Copy link
Contributor

Choose a reason for hiding this comment

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

missing setMessageTransformer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it needed?

When a new ramp needs to be introduced, do we usually deploy a new ramp and associate it with existing and other dependencies? If so, I believe we can follow the same convention when a new message transformer is needed and just redeploy a new ramp with new message transformer.

}

function test_executeSingleMessage_WithMessageTransformer() public {
vm.stopPrank();
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to stop the prank, startPrank overrides it anyway. Same in other places. Generally if all tests start with the same startPrank you can put it in the setUp

@@ -53,6 +55,7 @@ contract OffRampSetup is FeeQuoterSetup, MultiOCR3BaseSetup {
MultiOCR3BaseSetup.setUp();

s_inboundMessageInterceptor = new MessageInterceptorHelper();
s_inboundMessageTransformer = new MessageTransformerHelper();
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep these clean from setup they don't need. The testsuite is already pretty slow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

pragma solidity ^0.8.24;

import {AuthorizedCallers} from "../../../../shared/access/AuthorizedCallers.sol";
import {IERC20} from "../../../../vendor/openzeppelin-solidity/v4.8.3/contracts/interfaces/IERC20.sol";
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: vendor goes at the end below a newline, see the style guide

vm.startPrank(address(s_sourceRouter));
}

function test_forwardFromRouter_WithMessageTransformer_Success() public {
Copy link
Contributor

Choose a reason for hiding this comment

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

please follow the new test naming convention for all new tests. See the Foundry guide for the specification. Not all tests in ccip follow it right now but we're slowly replacing them all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep change function names to follow the convention here

uint256 feeAmount = 1234567890;
message.tokenAmounts = new Client.EVMTokenAmount[](1);
message.tokenAmounts[0].amount = 1e18;
message.tokenAmounts[0].token = s_sourceTokens[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this setup actually meaningfully impact the test being done? If not, please remove

@jinhoonbang jinhoonbang requested a review from RensR January 14, 2025 05:12
@@ -0,0 +1,84 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.24;

Copy link
Contributor

Choose a reason for hiding this comment

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

missing tests for the new setMessageTransformer functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added in separate files

@jinhoonbang jinhoonbang force-pushed the ccip-message-transformers branch from 8360166 to 6d2b8fe Compare January 16, 2025 07:23
@jinhoonbang jinhoonbang force-pushed the ccip-message-transformers branch from 6d2b8fe to 3dac425 Compare January 16, 2025 07:27
@jinhoonbang jinhoonbang requested a review from RensR January 16, 2025 07:32
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
16.57% Technical Debt Ratio on New Code (required ≤ 4%)
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

import {Internal} from "../../../libraries/Internal.sol";

import {OffRamp} from "../../../offRamp/OffRamp.sol";

Copy link
Contributor

@RensR RensR Jan 20, 2025

Choose a reason for hiding this comment

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

newlines have meaning in imports, please remove follow the styleguide

<interfaces>

<other>

<third party>

Please check other files as well

@Rishabh570 Rishabh570 requested a review from RensR January 20, 2025 11:53
@@ -2,21 +2,27 @@ GETH_VERSION: 1.14.11
burn_from_mint_token_pool: ../../../contracts/solc/ccip/BurnFromMintTokenPool/BurnFromMintTokenPool.sol/BurnFromMintTokenPool.abi.json ../../../contracts/solc/ccip/BurnFromMintTokenPool/BurnFromMintTokenPool.sol/BurnFromMintTokenPool.bin ae4e15dc926517092d46e108cd5e24863d58e689444ce310bb00c1390f711ba9
burn_mint_token_pool: ../../../contracts/solc/ccip/BurnMintTokenPool/BurnMintTokenPool.sol/BurnMintTokenPool.abi.json ../../../contracts/solc/ccip/BurnMintTokenPool/BurnMintTokenPool.sol/BurnMintTokenPool.bin 7360dc05306d51b247abdf9a3aa8704847b1f4fb91fdb822a2dfc54e1d86cda1
burn_with_from_mint_token_pool: ../../../contracts/solc/ccip/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.sol/BurnWithFromMintTokenPool.abi.json ../../../contracts/solc/ccip/BurnWithFromMintTokenPool/BurnWithFromMintTokenPool.sol/BurnWithFromMintTokenPool.bin 66715c303bb2da2b49bba100a788f6471b0f94d255d40f92306e279b909ae33b
ccip_dummy_receiver: ../../../contracts/solc/ccip/CCIPDummyReceiver/CCIPDummyReceiver.sol/CCIPDummyReceiver.abi.json ../../../contracts/solc/ccip/CCIPDummyReceiver/CCIPDummyReceiver.sol/CCIPDummyReceiver.bin e6c3b994b7d3fe7521e6750939447b4da5f96d9ce9fb47c7e7f4d7e7c605277c
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants