Skip to content

lang: Make stack frames slimmer on ATA creation#3065

Merged
acheroncrypto merged 2 commits into
otter-sec:masterfrom
andreisilviudragnea:slim-stack-frame
Jul 3, 2024
Merged

lang: Make stack frames slimmer on ATA creation#3065
acheroncrypto merged 2 commits into
otter-sec:masterfrom
andreisilviudragnea:slim-stack-frame

Conversation

@andreisilviudragnea

@andreisilviudragnea andreisilviudragnea commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Initializing many associated token accounts in the same instruction can result in too large stack frames at compile time:

    #[account(
        init,
        payer = payer,
        associated_token::authority = system_program,
        associated_token::mint = mint,
    )]
Error: Function _ZN137_$LT$pda_derivation..AssociatedTokenResolution$u20$as$u20$anchor_lang..Accounts$LT$pda_derivation..AssociatedTokenResolutionBumps$GT$$GT$12try_accounts17hddc314f570fb4fb5E Stack offset of 7696 exceeded max offset of 4096 by 3600 bytes, please minimize large stack variables

The problem has been fixed similar to #2913 by inlining local variables created while generating associated token account creation code.

@vercel

vercel Bot commented Jul 2, 2024

Copy link
Copy Markdown

@andreisilviudragnea is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added lang performance Performance related issues/PRs labels Jul 2, 2024

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is an area we'd like to improve, so thank you for the PR!

Please see the comments.

Comment thread lang/syn/src/codegen/accounts/constraints.rs Outdated
Comment thread spl/src/associated_token.rs Outdated
Comment thread tests/pda-derivation/programs/pda-derivation/src/lib.rs
@andreisilviudragnea andreisilviudragnea changed the title Make stack frames slimmer on ATA creation lang: Make stack frames slimmer on ATA creation Jul 2, 2024
Comment thread tests/misc/tests/misc/misc.ts Outdated

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great now, thanks!

@acheroncrypto acheroncrypto merged commit 5727865 into otter-sec:master Jul 3, 2024
@andreisilviudragnea andreisilviudragnea deleted the slim-stack-frame branch July 4, 2024 06:47
@andreisilviudragnea

Copy link
Copy Markdown
Contributor Author

@acheroncrypto When will a new Anchor version be released? This fix is quite important for me.

@acheroncrypto

Copy link
Copy Markdown
Collaborator

Not sure, but we might need to make a patch release depending on the resolution of #3044.

Do you publish your crates? If not, you can just depend on the git version until the next release.

@andreisilviudragnea

andreisilviudragnea commented Aug 20, 2024

Copy link
Copy Markdown
Contributor Author

@acheroncrypto When approximately will a new Anchor version be released?

Depending on git versions for dependencies can sometimes be seen as an unsafe habit. I see there is very active development on master branch, so I expect it to take some time.

@acheroncrypto

Copy link
Copy Markdown
Collaborator

@acheroncrypto When approximately will a new Anchor version be released?

~3 weeks

Depending on git versions for dependencies can sometimes be seen as an unsafe habit. I see there is very active development on master branch, so I expect it to take some time.

This PR was merged slightly after the last release, so there won't be many changes if you depend on this PR's commit hash 5727865.

Otter-0x4ka5h pushed a commit to Otter-0x4ka5h/anchor that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang performance Performance related issues/PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants