-
Notifications
You must be signed in to change notification settings - Fork 7
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
solana: support any extra args on ccip_send #488
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c2718d1
refactor unit tests
aalu1418 71f337e
contract changes
aalu1418 c8c9ab1
test fixes
aalu1418 18f7512
linter fixes
aalu1418 e477104
Merge branch 'main' into solana/any-extra-args
aalu1418 dc8c35d
address validation
aalu1418 837d8c5
cleanup
aalu1418 0da181a
Merge branch 'main' into solana/any-extra-args
aalu1418 1ab415d
cleanup: remove unused default gas limit + default out of order execu…
aalu1418 0a734c4
cleanup + address comments
aalu1418 e28383f
extraArgs comments
aalu1418 4c0946f
Merge branch 'main' into solana/any-extra-args
aalu1418 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
chains/solana/contracts/programs/ccip-router/src/extra_args.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::DestChainConfig; | ||
|
||
// NOTE: this file contains ExtraArgs for SVM -> remote chains | ||
// these are onramp specific extraArgs for ccipSend only | ||
|
||
// bytes4(keccak256("CCIP EVMExtraArgsV2")); | ||
pub const EVM_EXTRA_ARGS_V2_TAG: u32 = 0x181dcf10; | ||
|
||
// bytes4(keccak256("CCIP SVMExtraArgsV1")); | ||
pub const SVM_EXTRA_ARGS_V1_TAG: u32 = 0x1f3b3aba; | ||
|
||
#[derive(Clone, AnchorSerialize, AnchorDeserialize, Default)] | ||
pub struct EVMExtraArgsV2 { | ||
pub gas_limit: u128, // message gas limit for EVM execution | ||
pub allow_out_of_order_execution: bool, // user configurable OOO execution that must match with the DestChainConfig.EnforceOutOfOrderExecution | ||
} | ||
|
||
impl EVMExtraArgsV2 { | ||
pub fn serialize_with_tag(&self) -> Vec<u8> { | ||
let mut buffer = EVM_EXTRA_ARGS_V2_TAG.to_be_bytes().to_vec(); | ||
let mut data = self.try_to_vec().unwrap(); | ||
|
||
buffer.append(&mut data); | ||
buffer | ||
} | ||
pub fn default_config(cfg: &DestChainConfig) -> EVMExtraArgsV2 { | ||
EVMExtraArgsV2 { | ||
gas_limit: cfg.default_tx_gas_limit as u128, | ||
..Default::default() | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, AnchorSerialize, AnchorDeserialize, Default)] | ||
pub struct SVMExtraArgsV1 { | ||
pub compute_units: u32, // compute units are used by the offchain to add computeUnitLimits to the execute stage | ||
pub account_is_writable_bitmap: u64, | ||
pub allow_out_of_order_execution: bool, // SVM chains require OOO, but users are required to explicitly state OOO is allowed in extraArgs | ||
pub token_receiver: [u8; 32], // cannot be 0-address if tokens are sent in message | ||
pub accounts: Vec<[u8; 32]>, // account list for messaging on remote SVM chain | ||
} | ||
|
||
impl SVMExtraArgsV1 { | ||
pub fn serialize_with_tag(&self) -> Vec<u8> { | ||
let mut buffer = SVM_EXTRA_ARGS_V1_TAG.to_be_bytes().to_vec(); | ||
let mut data = self.try_to_vec().unwrap(); | ||
|
||
buffer.append(&mut data); | ||
buffer | ||
} | ||
pub fn default_config(cfg: &DestChainConfig) -> SVMExtraArgsV1 { | ||
SVMExtraArgsV1 { | ||
compute_units: cfg.default_tx_gas_limit, | ||
..Default::default() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What does this line do? Doesn't the DestChainConfig have the default value for OOO as well?
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.
not quite, the DestChain config has
EnforceOutOfOrder
to make sure that the user sets out of order - otherwise, we don't validateand on the EVM side, if
EnforceOutOfOrder = true
then it requires the user to explicitly set it rather than use a default