Skip to content

fix(v2): support explicit bumps with init_if_needed#4582

Open
abhinavgautam01 wants to merge 1 commit into
otter-sec:anchor-nextfrom
abhinavgautam01:fix/2996-init-if-needed-bump
Open

fix(v2): support explicit bumps with init_if_needed#4582
abhinavgautam01 wants to merge 1 commit into
otter-sec:anchor-nextfrom
abhinavgautam01:fix/2996-init-if-needed-bump

Conversation

@abhinavgautam01
Copy link
Copy Markdown

Fixes #2996

Summary

  • Allows #[account(init_if_needed, ..., bump = <expr>)] in the v2 derive.
  • Keeps #[account(init, ..., bump = <expr>)] rejected so plain init still uses the canonical bump.
  • Runs explicit-bump PDA verification only on the existing-account branch of init_if_needed.
  • Preserves canonical bump behavior on the create branch, so handlers can store ctx.bumps.<account> for later reuse.

Testing

  • rustfmt --check lang-v2/derive/src/parse.rs tests-v2/programs/constraints/src/lib.rs tests-v2/tests/constraints.rs
  • cargo test -p anchor-derive-accounts-v2 explicit_bump
  • cargo test -p tests-v2 init_if_needed
  • git diff --check

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.

1 participant