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: full getValidatedFee flow [NONEVM-676] #405

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

PabloMansanet
Copy link
Contributor

@PabloMansanet PabloMansanet commented Dec 23, 2024

Full implementation of ccip billing, with the exception of ExtraArgs (TODO left to that effect). The logic is extracted and refactored from FeeQuoter.sol.

Integration tests don't yet compare the total calculation with the EVM code. For now, all that's tested (between unit and integration tests) is that increasing the various variables that affect fees does indeed result in a difference in the output.

I feel like the best way to approach those tests will be to sample the EVM implementation for a large set of scenarios, and reproduce these scenarios in integration tests here to ensure the result is the same. I plan to add these after the holidays in a follow-up PR.

@PabloMansanet PabloMansanet requested a review from a team as a code owner December 23, 2024 14:12
@toblich toblich self-requested a review December 23, 2024 14:17
Copy link
Contributor

@toblich toblich left a comment

Choose a reason for hiding this comment

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

I haven't reviewed the tests yet, but here are a few comments in the meantime. It mostly looks good, but there are some opportunities to simplify the passed-in accounts and iterations, as well as some places where more validations of the remaining_accounts may be beneficial.

@PabloMansanet PabloMansanet changed the title Solana ccip_send network fee calculation Solana: full getValidatedFee flow [NONEVM-676] Dec 24, 2024
Implement network fee calculation

Refactor and cleanup

Update unit test values

Add unit tests

More unit tests

Use account array for GetFee

Fix all tests except token happy path

Cleanup

Use lookup table for fee calculation in ccip_send

Cleanup

Rebase fixes

Fix lints

Comment improvement

Implement all fee calculations

Fix unit tests

Validate accounts

Make fee billing config optional

Address review comments

Adjust test values for BPS

Regenerate bindings and update tests
Copy link

Metric network_fees main
Coverage 76.5% 76.5%

Copy link
Contributor

@agusaldasoro agusaldasoro left a comment

Choose a reason for hiding this comment

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

Amazing work!
Changes look good to me, just one comment that we can address in a follow up PR.

message.validate(dest_chain, token_config)?;

let token = if message.fee_token == Pubkey::default() {
let fee_token = if message.fee_token == Pubkey::default() {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a check here for Chain family right? And only run this when the chain family is EVM

Comment on lines +115 to +120
FEE_BILLING_TOKEN_CONFIG,
if mint.key() == Pubkey::default() {
native_mint::ID.as_ref() // pre-2022 WSOL
} else {
mint.key.as_ref()
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably not necessary for tokenpools. Although this is how we solve for fee_token_config accounts, AFAIK it should never be the case that someone is sending native SOL through CCIP (@agusaldasoro or @aalu1418 to confirm, IMHO they should send WSOL in that case instead).
If my above statement holds, you can just require a non-zero mint and remove this if.

) -> Usd18Decimals {
// Sums up byte lengths of fixed message fields and dynamic message fields.
// Fixed message fields do account for the offset and length slot of the dynamic fields.
let data_availability_length_bytes = ANY_2_EVM_MESSAGE_FIXED_BYTES
Copy link
Contributor

Choose a reason for hiding this comment

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

Food for thought for upcoming PRs (no change required here), based on a chat with @agusaldasoro... The terminology any2evm is imported from the EVM contracts; should we rename it to solana2any or solana2evm in the solana contract?

anotherUserATA solana.PublicKey
tokenlessUserATA solana.PublicKey
billingConfigPDA solana.PublicKey
perChainPerTokenConfigPDA solana.PublicKey
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this represents just one chain's config PDA for the particular token, please include it in the attribute name. That way we can later have stuff like wsol.evmConfigPDA or wsol.solanaConfigPDA for the different chains for a given token.
Feel free to merge as-is and change this in a separate PR if you prefer

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