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

Refactor - Makes loader-v4 the default #2796

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

Lichtso
Copy link

@Lichtso Lichtso commented Aug 30, 2024

Problem

Loader-v4 was originally planned as a PRv2 loader, but will be used as default loader (superseding loader-v3) in PRv1 now.

Summary of Changes

  • Renames and rekeys enable_program_runtime_v2_and_loader_v4 to enable_loader_v4.
  • Disables new deployments on loader-v3 when the feature is enabled.
  • Adjusts tests:
    • Removes test_program_upgradeable_locks() (which was introduced in Prevent the invoke and upgrade of programs in the same tx batch solana-labs/solana#14653) and is superseded by test_program_sbf_invoke_in_same_tx_as_redeployment().
    • Merges test_program_sbf_invoke_upgradeable() into test_program_sbf_upgrade().
    • Merges test_program_sbf_invoke_upgradeable_via_cpi() and test_program_sbf_set_upgrade_authority_via_cpi() into test_program_sbf_upgrade_via_cpi().
    • Adjusts the error codes for top-level-instructions in test_program_sbf_invoke_in_same_tx_as_redeployment() and test_program_sbf_invoke_in_same_tx_as_undeployment()

Copy link

mergify bot commented Aug 30, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 5 times, most recently from 43b7b38 to 221fd7d Compare September 3, 2024 08:18
@Lichtso Lichtso changed the title Rekey - enable_loader_v4 Refactor - Makes loader-v4 the default Sep 3, 2024
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 5 times, most recently from a1303e6 to f984bbc Compare September 3, 2024 13:38
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 2 times, most recently from eec5813 to 1cb4d44 Compare September 5, 2024 18:20
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 6 times, most recently from 8a2a279 to 19c1df9 Compare November 11, 2024 20:07
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch from 19c1df9 to 30f3fcb Compare November 12, 2024 10:51
@Lichtso Lichtso mentioned this pull request Nov 12, 2024
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 2 times, most recently from 95261f9 to 64c09b6 Compare November 14, 2024 14:47
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch from 64c09b6 to 2d4b884 Compare November 19, 2024 14:38
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch from 2d4b884 to 489694d Compare December 3, 2024 16:34
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch from 489694d to 33f0270 Compare December 12, 2024 14:57
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch from 33f0270 to fc55020 Compare January 9, 2025 14:01
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 6 times, most recently from 8a2d4bc to f7b5eb0 Compare January 16, 2025 02:57
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 3 times, most recently from dbb8d90 to 47a487f Compare January 21, 2025 16:13
@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch 2 times, most recently from d2ab272 to 38dacf0 Compare January 22, 2025 13:22
@Lichtso Lichtso marked this pull request as ready for review January 22, 2025 14:24
@Lichtso Lichtso requested a review from a team as a code owner January 22, 2025 14:24
@anza-xyz anza-xyz deleted a comment from mergify bot Jan 22, 2025
@@ -13277,12 +13278,10 @@ fn test_deploy_last_epoch_slot() {
solana_logger::setup();

// Bank Setup
let (mut genesis_config, mint_keypair) = create_genesis_config(1_000_000 * LAMPORTS_PER_SOL);
genesis_config
Copy link

Choose a reason for hiding this comment

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

Was this line removed on purpose? It doesn't seem related to loader-v4.

Copy link
Author

Choose a reason for hiding this comment

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

I refactored the test to use loader-v4 and have remove_accounts_executable_flag_checks instead of disable_fees_sysvar as the dummy feature to trigger an environment change.

@@ -82,8 +82,17 @@ fn test_cli_program_deploy_non_upgradeable() {
let mint_keypair = Keypair::new();
let mint_pubkey = mint_keypair.pubkey();
let faucet_addr = run_local_faucet(mint_keypair, None);
let test_validator =
TestValidator::with_no_fees(mint_pubkey, Some(faucet_addr), SocketAddrSpace::Unspecified);
let test_validator = TestValidatorGenesis::default()
Copy link

Choose a reason for hiding this comment

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

Maybe it's worth adding a wrapper function, as this block of code is being repeated in multiple tests.

@Lichtso Lichtso force-pushed the rekey/enable_loader_v4 branch from 38dacf0 to 0c10a9f Compare January 23, 2025 17:46
@Lichtso Lichtso merged commit 6ff4dee into anza-xyz:master Jan 23, 2025
57 checks passed
@Lichtso Lichtso deleted the rekey/enable_loader_v4 branch January 23, 2025 22:00
Comment on lines +565 to +571
if invoke_context
.get_feature_set()
.is_active(&enable_loader_v4::id())
{
ic_logger_msg!(log_collector, "Unsupported instruction");
return Err(InstructionError::InvalidInstructionData);
}

Choose a reason for hiding this comment

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

Sorry for the late flyby review, but disabling new deployments on the old loader needs to be done through a separate feature in a future release.

We can't expect all tooling to immediately switch over to loader-v4 as soon as it's available. There needs to be some amount time where both loaders are available for new deployments while people upgrade, same as we did when the upgradeable loader was added. This could be at least 1 minor release, but 3 minor releases (~1 year) would likely be ideal.

cc @nickfrosty for his thoughts, since he's been looking at the associated SIMD solana-foundation/solana-improvement-documents#167

Copy link

Choose a reason for hiding this comment

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

That's a good point. cc @Lichtso

Copy link
Author

@Lichtso Lichtso Jan 27, 2025

Choose a reason for hiding this comment

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

Well, that is why we only disable new deployments. All existing programs can be still be redeployed etc. under loader-v3. There is no point in turning on loader-v4 if we do not deprecate loader-v3, because getting rid of loader-v3 is the entire point. Also, keep in mind that tooling can be tested against the new loader on testnet and devnet, if that is the concern.

Choose a reason for hiding this comment

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

The main point is that we can't immediately break users, especially when they're typically slow to adopt new releases.

Take the anchor deploy code for example: https://github.com/coral-xyz/anchor/blob/2b0f3a7c999771f40e240b3ce421895ce6b066cf/cli/src/lib.rs#L3874 -- they're relying on calling solana program deploy.

If they wanted to avoid breaking immediately, they would need logic to check the feature gate status, conditionally call program-v4 instead of program, and force everybody to upgrade to the newest version of the CLI using that code, all before the feature gate is enabled. It isn't reasonable to expect people to make changes and force adoption of new tools so quickly.

We didn't break people immediately when loader-v3 was added, and we had a fraction of developers at the time. We can't immediately break them here. I'm happy to come up with an alternative roll out plan together.

Copy link
Author

Choose a reason for hiding this comment

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

We could do the feature gate checking in our CLI and alias program deploy to program-v4 deploy.

What I am saying is that the day that people start deploying to loader-v4 will not be the day it becomes available, but the day the old one stops working. And that day will be breaking users independently of whether the new loader is available before or not.

Choose a reason for hiding this comment

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

That plan still requires people to update to the newest tools immediately, which is neither reasonable nor a good developer experience.

And I'm not sure I agree with you -- for example, if we alias program to program-v4 as you suggest, then people will automatically start using loader-v4 as they adopt the new tools without realizing it.

Then, after some time, we can put out a big loud message that solana program deploy will start failing if you're using any version before 2.2, give people 3-6 months to upgrade, and then disable new deployments. That way, only people who haven't upgraded their tools in a long time will be broken, which should be a small amount of people, and we can point to the loud message that we put out months ago.

Either way, this change needs to come with a thoughtful rollout strategy.

Copy link
Author

Choose a reason for hiding this comment

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

Alright, I will add another feature gate. This however would mean there are four phases:

  1. Now: loader-v3 is active, loader-v4 is inactive
  2. v2.2: loader-v4 becomes active, loader-v3 stays active
  3. v2.3: loader-v3 deployments become inactive
  4. v2.4: All loader-v3 programs are force migrated to loader-v4

Choose a reason for hiding this comment

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

Beautiful, thanks!

We can save it for the future, but I'll need to understand more about what "force migration" looks like, since that could potentially break tools like DAOs which rely on using loader-v3 instructions for program management. And we should start signaling this whole process as soon as possible to devrel.

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