Skip to content

v3.1: Add check for existing program data account on migration (backport of #8982)#9128

Closed
mergify[bot] wants to merge 1 commit intov3.1from
mergify/bp/v3.1/pr-8982
Closed

v3.1: Add check for existing program data account on migration (backport of #8982)#9128
mergify[bot] wants to merge 1 commit intov3.1from
mergify/bp/v3.1/pr-8982

Conversation

@mergify
Copy link

@mergify mergify bot commented Nov 18, 2025

Problem

When migrating builtin/loader-v2 programs to loader-v3, the migration can be blocked by pre-funding the program data account so it appears to already exist.

Summary of Changes

Add an additional check when the program data account is found to assert that it is a "real" program data account; otherwise, burn and purge the account so the migration succeeds.

Note: the PR also updates the p-token feature id.


This is an automatic backport of pull request #8982 done by Mergify.

* Add check for existing program data account

* Move bank mutation

* Update p-token feature id

* Simplify program data account lamports handling

* Improve owner check

(cherry picked from commit 3e5af27)
@mergify mergify bot requested a review from a team as a code owner November 18, 2025 14:50
@mergify mergify bot assigned febo Nov 18, 2025
@febo febo requested a review from buffalojoec November 18, 2025 15:29
use super::Pubkey;

solana_pubkey::declare_id!("ptokSWRqZz5u2xdqMdstkMKpFurauUpVen7TZXgDpkQ");
solana_pubkey::declare_id!("ptokEXBPT9HuYdAQRysaStZNTY9bHsAcQzNscEoA6HC");

Choose a reason for hiding this comment

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

why's this under ptoken upgrade instead of its own thing? seems orthogonal

Copy link

@buffalojoec buffalojoec Nov 19, 2025

Choose a reason for hiding this comment

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

P-token is the next (only) active migration and this fix should go in before/alongside that codepath, since it's susceptible.

Choose a reason for hiding this comment

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

i'm sorry, how does that justify doing two totally unrelated things under the same feature gate?

Copy link

@febo febo Nov 19, 2025

Choose a reason for hiding this comment

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

They are related in the sense that the codepath of the fix is only ever executed during a migration of a "loader v2 program -> loader v3 program" (p-token falls in this category); the fix also applies to migration of "native program -> loader v3 program", but we don't have active migrations for this at the moment.

Choose a reason for hiding this comment

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

ok but that's not how we do feature gates. please take it back to master and key it separately. if there's not already a simd for these changes (don't see one referenced here or master pr), that is also required before changing consensus logic

@t-nelson
Copy link

are we planning to do this right?

@buffalojoec
Copy link

are we planning to do this right?

I suppose technically the correct thing to do is:

  • Amend SIMD-0088 to include the lamports/owner check.
  • Create a new SIMD to spec the v2 -> v3 migration path, including the lamports/owner check above.
  • Make the P-Token upgrade dependent on the previous.

Note that implementing the codepath to migrate from a v2 to a v3 program can't really use a feature gate. The code would simply exist off of the hot path and cannot become active until a migration is scheduled. That next migration will be P-Token, so we basically end up in almost the same position.

However, I'm personally not against proper procedure here.

@febo
Copy link

febo commented Nov 27, 2025

Created SIMD-0418 detailing the migration of Loader v2 programs to v3 based on SIMD-0088.

@buffalojoec Happy to amend SIMD-0088 with the lamports/owners check once we agree on the wording.

@t-nelson
Copy link

t-nelson commented Dec 1, 2025

since simd-0088 is already active, i believe we should not modify it. rather this would need to be a separate simd back-referencing simd-0088. luckily we don't seem to have documented how to do this. closest reference i'm aware of is simd-0118 supersedes simd-0015

@t-nelson
Copy link

t-nelson commented Jan 7, 2026

@febo any eta on splitting this one up as discussed at breakpoint?

@febo
Copy link

febo commented Jan 8, 2026

@febo any eta on splitting this one up as discussed at breakpoint?

Most likely by the end of the week. Reviewing the code with @buffalojoec and then creating the PRs.

@t-nelson
Copy link

t-nelson commented Jan 8, 2026

Most likely by the end of the week. Reviewing the code with @buffalojoec and then creating the PRs.

great! can we close this now? it comes up every week in the backport review call

@febo
Copy link

febo commented Jan 9, 2026

This will be broken down into separate PRs and documented in SIMDs.

@febo febo closed this Jan 9, 2026
@steviez steviez deleted the mergify/bp/v3.1/pr-8982 branch January 22, 2026 21:45
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.

3 participants