Skip to content

Fix legacy stake account migration after lock layout change#5

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-4342
Draft

Fix legacy stake account migration after lock layout change#5
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-4342

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Jun 6, 2026

Bug and impact

Recent stake-lock changes added locked_until directly to StakeAccount. Existing pre-lock stake PDAs used the old serialized layout, so deposit_sol, withdraw_sol, and claim_mentik could fail during Anchor account deserialization before handlers ran. A user with SOL already staked before the redeploy could be unable to withdraw or claim.

Root cause

Instruction account validation used Account<StakeAccount>, which requires the current account layout. Old stake accounts were shorter by 8 bytes and could not be loaded.

Fix

  • Load stake PDAs manually and accept both current and pre-lock serialized layouts.
  • Treat legacy stake accounts as unlocked (locked_until = 0) and resize/serialize them to the current layout on the next successful deposit, withdraw, or claim.
  • Preserve PDA seed/owner/user checks and update claim clients/IDL for the required system_program account.
  • Add LiteSVM regressions for legacy withdraw and legacy claim migration.

Validation

  • anchor build --ignore-keys
  • cargo test -p mentik_sol_pool
  • cargo test -p mentik-integration-tests (8 passed, including legacy migration tests)
  • npm run build --prefix app
Open in Web View Automation 

cursoragent and others added 2 commits June 6, 2026 09:13
Co-authored-by: PhiTapTrung67 <taihl.work@gmail.com>
Co-authored-by: PhiTapTrung67 <taihl.work@gmail.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Error Error Jun 6, 2026 9:23am

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