-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: develop
Are you sure you want to change the base?
Conversation
jinhoonbang
commented
Jan 7, 2025
•
edited
Loading
edited
- add hooks to CCIP onramp and offramps for pre/post-processing messages using custom transformer
-
- introduces MessageTransformerOnRamp/OffRamps which inherit canonical on/offRamps
Static analysis results are availableHey @Rishabh570, you can view Slither reports in the job summary here or download them as artifact here. |
AER Report: CI Core ran successfully ✅AER Report: Operator UI CI ran successfully ✅ |
…it/chainlink into ccip-message-transformers
I see you updated files related to |
123c8c8
to
05f3201
Compare
compileContract() { | ||
local contract | ||
contract=$(basename "$1") | ||
echo "Compiling" "$contract" | ||
|
||
local viaIR="" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing setMessageTransformer
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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
@@ -0,0 +1,84 @@ | |||
// SPDX-License-Identifier: BUSL-1.1 | |||
pragma solidity ^0.8.24; | |||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in separate files
8360166
to
6d2b8fe
Compare
6d2b8fe
to
3dac425
Compare
Quality Gate failedFailed conditions See analysis details on SonarQube Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
import {Internal} from "../../../libraries/Internal.sol"; | ||
|
||
import {OffRamp} from "../../../offRamp/OffRamp.sol"; | ||
|
There was a problem hiding this comment.
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
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove