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: fix stack access violation #17

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "lib/example-liquidity-layer"]
path = lib/example-liquidity-layer
url = https://github.com/wormhole-foundation/example-liquidity-layer.git
branch = v0.3.2
branch = v0.3.3
12 changes: 6 additions & 6 deletions e2e/tests/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,18 @@ export async function completeSwapForTest(
},
);

let ix;
let swapIxes;
if (opts.redeemMode === "direct") {
ix = await swapLayer.completeSwapDirectIx(accounts, { cpiInstruction });
swapIxes = await swapLayer.completeSwapDirectIxes(accounts, { cpiInstruction });
} else if (opts.redeemMode === "relay") {
ix = await swapLayer.completeSwapRelayIx(accounts, { cpiInstruction });
swapIxes = await swapLayer.completeSwapRelayIxes(accounts, { cpiInstruction });
}

const ixs = [
ComputeBudgetProgram.setComputeUnitLimit({
units: 700_000,
}),
ix,
...swapIxes,
];

const addressLookupTableAccounts = await Promise.all(
Expand Down Expand Up @@ -239,7 +239,7 @@ export async function swapExactInForTest(
let { additionalLuts, signers } = opts;
additionalLuts ??= [];

const ix = await swapLayer.initiateSwapExactInIx(accounts, args);
const swapIxes = await swapLayer.initiateSwapExactInIxes(accounts, args);

const computeIx = ComputeBudgetProgram.setComputeUnitLimit({
units: 700_000,
Expand All @@ -252,7 +252,7 @@ export async function swapExactInForTest(
}),
);

await expectIxOk(swapLayer.connection(), [computeIx, ix], signers, {
await expectIxOk(swapLayer.connection(), [computeIx, ...swapIxes], signers, {
addressLookupTableAccounts,
});
}
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions solana/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ url = "https://api.mainnet-beta.solana.com"
### every 400 ms. A fast voting cadence ensures faster finality and convergence
ticks_per_slot = 16

deactivate_feature = ["EenyoWx9UMXYKpR8mW5Jmfmy2fRjzUtM7NduYMY8bx33"]

### Wormhole Core Bridge Program
[[test.genesis]]
address = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"
Expand Down
13 changes: 7 additions & 6 deletions solana/programs/swap-layer/src/composite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
},
};
use anchor_lang::{prelude::*, system_program};
use anchor_spl::{associated_token, token, token_interface};
use anchor_spl::{token, token_interface};
use common::{
admin::utils::{
assistant::{self, only_authorized},
Expand Down Expand Up @@ -328,9 +328,10 @@ pub struct CompleteSwap<'info> {

/// Temporary swap token account to receive USDC from the prepared fill. This account will be
/// closed at the end of this instruction.
///
/// NOTE: This ATA must already be created.
#[account(
init_if_needed,
payer = payer,
mut,
associated_token::mint = usdc,
associated_token::authority = authority,
associated_token::token_program = token_program
Expand All @@ -339,9 +340,10 @@ pub struct CompleteSwap<'info> {

/// Temporary swap token account to receive destination mint after the swap. This account will
/// be closed at the end of this instruction.
///
/// NOTE: This ATA must already be created.
#[account(
init_if_needed,
payer = payer,
mut,
associated_token::mint = dst_mint,
associated_token::authority = authority,
associated_token::token_program = dst_token_program
Expand All @@ -365,7 +367,6 @@ pub struct CompleteSwap<'info> {

pub token_program: Program<'info, token::Token>,
pub dst_token_program: Interface<'info, token_interface::TokenInterface>,
associated_token_program: Program<'info, associated_token::AssociatedToken>,
pub system_program: Program<'info, System>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
state::{StagedInbound, StagedInboundInfo, StagedInboundSeeds},
};
use anchor_lang::prelude::*;
use anchor_spl::{associated_token, token, token_interface};
use anchor_spl::{token, token_interface};
use swap_layer_messages::{
messages::SwapMessageV1,
types::{OutputToken, RedeemMode},
Expand Down Expand Up @@ -35,9 +35,10 @@ pub struct CompleteSwapPayload<'info> {

/// Temporary swap token account to receive USDC from the prepared fill. This account will be
/// closed at the end of this instruction.
///
/// NOTE: This ATA must already be created.
#[account(
init_if_needed,
payer = payer,
mut,
associated_token::mint = usdc,
associated_token::authority = staged_inbound,
associated_token::token_program = token_program
Expand All @@ -46,9 +47,10 @@ pub struct CompleteSwapPayload<'info> {

/// Temporary swap token account to receive destination mint after the swap. This account will
/// be closed at the end of this instruction.
///
/// NOTE: This ATA must already be created.
#[account(
init_if_needed,
payer = payer,
mut,
associated_token::mint = dst_mint,
associated_token::authority = staged_inbound,
associated_token::token_program = dst_token_program
Expand All @@ -72,7 +74,6 @@ pub struct CompleteSwapPayload<'info> {

token_program: Program<'info, token::Token>,
dst_token_program: Interface<'info, token_interface::TokenInterface>,
associated_token_program: Program<'info, associated_token::AssociatedToken>,
system_program: Program<'info, System>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
PREPARED_ORDER_SEED_PREFIX,
};
use anchor_lang::prelude::*;
use anchor_spl::{associated_token, token, token_interface};
use anchor_spl::{token, token_interface};
use common::wormhole_io::TypePrefixedPayload;

#[derive(Accounts)]
Expand Down Expand Up @@ -89,9 +89,10 @@ pub struct InitiateSwapExactIn<'info> {

/// Temporary swap token account to receive source mint from the staged custody token. This
/// account will be closed at the end of this instruction.
///
/// NOTE: This ATA must already be created.
#[account(
init_if_needed,
payer = payer,
mut,
associated_token::mint = src_mint,
associated_token::authority = swap_authority,
associated_token::token_program = src_token_program
Expand All @@ -100,9 +101,10 @@ pub struct InitiateSwapExactIn<'info> {

/// Temporary swap token account to receive destination mint after the swap. This account will
/// be closed at the end of this instruction.
///
/// NOTE: This ATA must already be created.
#[account(
init_if_needed,
payer = payer,
mut,
associated_token::mint = usdc,
associated_token::authority = swap_authority
)]
Expand All @@ -126,7 +128,6 @@ pub struct InitiateSwapExactIn<'info> {
prepared_custody_token: UncheckedAccount<'info>,

token_router_program: Program<'info, token_router::program::TokenRouter>,
associated_token_program: Program<'info, associated_token::AssociatedToken>,
src_token_program: Interface<'info, token_interface::TokenInterface>,
token_program: Program<'info, token::Token>,
system_program: Program<'info, System>,
Expand Down
Loading
Loading