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

solana: support any extra args on ccip_send #488

Merged
merged 12 commits into from
Jan 30, 2025
Merged

Conversation

aalu1418
Copy link
Collaborator

@aalu1418 aalu1418 commented Jan 22, 2025

  • extra arg handling
  • address validation
  • test case fixes

@aalu1418 aalu1418 force-pushed the solana/any-extra-args branch from 2f8cb00 to c2718d1 Compare January 28, 2025 17:06
@aalu1418 aalu1418 marked this pull request as ready for review January 29, 2025 16:35
@aalu1418 aalu1418 requested a review from a team as a code owner January 29, 2025 16:35
@@ -17,10 +17,9 @@ Collapsed Router + OnRamp + OffRamp Contracts Implementation for CCIP in SVM.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this readme still valid? I remember we used to write all the TODOs here, but I don't know if that's still the case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure - but i can go through and remove things since it's probably out of date

pub fn default_config(cfg: &DestChainConfig) -> EVMExtraArgsV2 {
EVMExtraArgsV2 {
gas_limit: cfg.default_tx_gas_limit as u128,
..Default::default()
Copy link
Contributor

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?

Copy link
Collaborator Author

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 validate

and on the EVM side, if EnforceOutOfOrder = true then it requires the user to explicitly set it rather than use a default


#[derive(Clone, AnchorSerialize, AnchorDeserialize, Default)]
pub struct SVMExtraArgsV1 {
pub compute_units: u32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing something with this value? Or is this just for the offramp to know if they may need to increase the compute units?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

correct, this would be for the offchain side

Copy link
Contributor

Choose a reason for hiding this comment

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

so we need it here for the hashing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this would be for sending from SVM -> SVM, but all extraArgs should be encoded as bytes during hashing

pub struct SVMExtraArgsV1 {
pub compute_units: u32,
pub account_is_writable_bitmap: u64,
pub allow_out_of_order_execution: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this field can be removed? As it always will be out of order

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this aligns with the SVM ExtraArgs that are defined in the solidity contracts since this is just for the ccipSend side

(also see previous comment about requiring users to explicitly allow ooo processing even if it's required)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, now I get OOO

pub account_is_writable_bitmap: u64,
pub allow_out_of_order_execution: bool,
pub token_receiver: [u8; 32],
pub accounts: Vec<[u8; 32]>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct? Shouldn't this be part of the transaction in additional accounts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i should add a comment that these ExtraArgs are only for SVM -> XXX on the onramp (it has no connection to the offramp)

so the extra accounts would be passed in explicitly for the remote SVM chain

match u32::from_be_bytes(dest_config.chain_family_selector) {
CHAIN_FAMILY_SELECTOR_EVM => parse_and_validate_evm_extra_args(dest_config, tag, &mut data),
CHAIN_FAMILY_SELECTOR_SVM => {
parse_and_validate_svm_extra_args(dest_config, tag, &mut data, message_contains_tokens)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the switch case is defined twice, yes

one function is for parsing/validating extra args, the other is for validating the receiver address

@aalu1418 aalu1418 requested a review from agusaldasoro January 29, 2025 18:55
@@ -306,13 +310,21 @@ fn token_transfer(
// Helpers //
/////////////

// ProcessedExtraArgs contains serialized extra args and unpacks commonly used parameters
#[derive(Debug)]
pub struct ProcessedExtraArgs {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this only for EVM should it declare it in the type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no it's chain agnostic - it has the serialized bytes, and two parameters that are checked for all chains (gas_limit + ooo)

@aalu1418 aalu1418 requested a review from agusaldasoro January 29, 2025 21:50
Copy link

Metric solana/any-extra-args main
Coverage 76.7% 76.7%

@aalu1418 aalu1418 merged commit 1b2ee24 into main Jan 30, 2025
17 checks passed
@aalu1418 aalu1418 deleted the solana/any-extra-args branch January 30, 2025 16:21
toblich added a commit that referenced this pull request Feb 1, 2025
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.

2 participants