From 9b9cbf0c9f43ebafda9c1f1bb71256325d98f833 Mon Sep 17 00:00:00 2001 From: PabloMansanet Date: Mon, 23 Dec 2024 12:14:20 +0100 Subject: [PATCH] Cleanup --- .../contracts/programs/ccip-router/src/lib.rs | 12 +---- .../contracts/target/idl/ccip_router.json | 10 ---- .../contracts/tests/ccip/ccip_router_test.go | 47 +------------------ .../solana/gobindings/ccip_router/CcipSend.go | 10 ---- .../gobindings/ccip_router/instructions.go | 10 ---- 5 files changed, 3 insertions(+), 86 deletions(-) diff --git a/chains/solana/contracts/programs/ccip-router/src/lib.rs b/chains/solana/contracts/programs/ccip-router/src/lib.rs index 977dd516..ce4074fb 100644 --- a/chains/solana/contracts/programs/ccip-router/src/lib.rs +++ b/chains/solana/contracts/programs/ccip-router/src/lib.rs @@ -696,16 +696,6 @@ pub mod ccip_router { /// The message will be sent to the receiver on the destination chain selector. /// This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code /// - /// # Additional accounts - /// - /// In addition to the fixed amount of accounts defined in the `GetFee` context, - /// the following accounts must be provided: - /// - /// * First, the billing token config accounts for each token involved, including the - /// fee token, sequentially. - /// * Then, the per chain / per token config of those tokens, sequentially in the same - /// order, for the destination chain. - /// /// # Arguments /// /// * `ctx` - The context containing the accounts required for sending the message. @@ -721,6 +711,8 @@ pub mod ccip_router { let dest_chain = &mut ctx.accounts.dest_chain_state; + // TODO this is incorrect and breaks when transfering a token. Derive these accounts + // from the lookup table instead. let (token_billing_config_accounts, per_chain_per_token_config_accounts) = get_accounts_for_fee_retrieval(&ctx.remaining_accounts, &message)?; let fee = fee_for_msg( diff --git a/chains/solana/contracts/target/idl/ccip_router.json b/chains/solana/contracts/target/idl/ccip_router.json index 14919986..3271c23e 100644 --- a/chains/solana/contracts/target/idl/ccip_router.json +++ b/chains/solana/contracts/target/idl/ccip_router.json @@ -1036,16 +1036,6 @@ "The message will be sent to the receiver on the destination chain selector.", "This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code", "", - "# Additional accounts", - "", - "In addition to the fixed amount of accounts defined in the `GetFee` context,", - "the following accounts must be provided:", - "", - "* First, the billing token config accounts for each token involved, including the", - "fee token, sequentially.", - "* Then, the per chain / per token config of those tokens, sequentially in the same", - "order, for the destination chain.", - "", "# Arguments", "", "* `ctx` - The context containing the accounts required for sending the message.", diff --git a/chains/solana/contracts/tests/ccip/ccip_router_test.go b/chains/solana/contracts/tests/ccip/ccip_router_test.go index b2304386..044c948f 100644 --- a/chains/solana/contracts/tests/ccip/ccip_router_test.go +++ b/chains/solana/contracts/tests/ccip/ccip_router_test.go @@ -1878,32 +1878,6 @@ func TestCCIPRouter(t *testing.T) { instruction, err := raw.ValidateAndBuild() require.NoError(t, err) - // // TESTBLOCK accounts exist - // { - // deserializedTokenConfigPda := ccip_router.BillingTokenConfigWrapper{} - // deserializedBillingPda := ccip_router.PerChainPerTokenConfig{} - // deserializedEvmDestChainStatePda := ccip_router.DestChainState{} - - // err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, wsol.billingConfigPDA, config.DefaultCommitment, &deserializedTokenConfigPda) - // require.NoError(t, err) - // t.Log(deserializedTokenConfigPda) - // err := utils.GetAccountDataBorshInto(ctx, solanaGoClient, token0BillingConfigPda, config.DefaultCommitment, &deserializedTokenConfigPda) - // require.NoError(t, err) - // t.Log(deserializedTokenConfigPda) - - // err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, wsol.perChainPerTokenConfigPDA, config.DefaultCommitment, &deserializedBillingPda) - // require.NoError(t, err) - // t.Log(deserializedBillingPda) - // err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, token0PerChainPerConfigPda, config.DefaultCommitment, &deserializedBillingPda) - // require.NoError(t, err) - // t.Log(deserializedBillingPda) - - // err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, config.EvmDestChainStatePDA, config.DefaultCommitment, &deserializedEvmDestChainStatePda) - // require.NoError(t, err) - // t.Log(deserializedEvmDestChainStatePda) - - // } - feeResult := utils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment) require.NotNil(t, feeResult) t.Log(feeResult.Meta.LogMessages) @@ -2071,8 +2045,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment) @@ -2134,8 +2106,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment) @@ -2198,8 +2168,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment) @@ -2261,8 +2229,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(token2022.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(token2022.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment) @@ -2321,8 +2287,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) @@ -2356,8 +2320,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) @@ -2391,8 +2353,7 @@ func TestCCIPRouter(t *testing.T) { ) // do NOT mark the user ATA as writable - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) + instruction, err := raw.ValidateAndBuild() require.NoError(t, err) @@ -2439,8 +2400,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) @@ -2483,8 +2442,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(token2022.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(token2022.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) testutils.SendAndFailWith(ctx, t, solanaGoClient, []solana.Instruction{instruction}, anotherUser, config.DefaultCommitment, []string{ccip_router.InvalidInputs_CcipRouterError.String()}) @@ -2518,8 +2475,6 @@ func TestCCIPRouter(t *testing.T) { config.ExternalTokenPoolsSignerPDA, ) raw.GetFeeTokenUserAssociatedAccountAccount().WRITE() - raw.AccountMetaSlice.Append(solana.Meta(token2022.billingConfigPDA)) - raw.AccountMetaSlice.Append(solana.Meta(token2022.perChainPerTokenConfigPDA)) instruction, err := raw.ValidateAndBuild() require.NoError(t, err) result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, anotherUser, config.DefaultCommitment) diff --git a/chains/solana/gobindings/ccip_router/CcipSend.go b/chains/solana/gobindings/ccip_router/CcipSend.go index 8426faef..c8aca920 100644 --- a/chains/solana/gobindings/ccip_router/CcipSend.go +++ b/chains/solana/gobindings/ccip_router/CcipSend.go @@ -19,16 +19,6 @@ import ( // The message will be sent to the receiver on the destination chain selector. // This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code // -// # Additional accounts -// -// In addition to the fixed amount of accounts defined in the `GetFee` context, -// the following accounts must be provided: -// -// * First, the billing token config accounts for each token involved, including the -// fee token, sequentially. -// * Then, the per chain / per token config of those tokens, sequentially in the same -// order, for the destination chain. -// // # Arguments // // * `ctx` - The context containing the accounts required for sending the message. diff --git a/chains/solana/gobindings/ccip_router/instructions.go b/chains/solana/gobindings/ccip_router/instructions.go index d72a9df7..36f2e303 100644 --- a/chains/solana/gobindings/ccip_router/instructions.go +++ b/chains/solana/gobindings/ccip_router/instructions.go @@ -295,16 +295,6 @@ var ( // The message will be sent to the receiver on the destination chain selector. // This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code // - // # Additional accounts - // - // In addition to the fixed amount of accounts defined in the `GetFee` context, - // the following accounts must be provided: - // - // * First, the billing token config accounts for each token involved, including the - // fee token, sequentially. - // * Then, the per chain / per token config of those tokens, sequentially in the same - // order, for the destination chain. - // // # Arguments // // * `ctx` - The context containing the accounts required for sending the message.