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

Add feature for tracking dynamic reserved account set #34901

Closed
wants to merge 9 commits into from

Conversation

jstarry
Copy link
Member

@jstarry jstarry commented Jan 23, 2024

Problem

There's no way to add new builtin programs and sysvars to the list of read-only reserved accounts.

Summary of Changes

Bank now tracks a dynamic set of reserved account keys which gets updated on epoch boundaries with feature activations. The set of reserved account keys needs to get passed to all the transaction and message constructors and then we take advantage of the is_writable cache to avoid passing the reserved account set to is_writable everywhere. It's inevitable that a change like this will result in breaking changes unfortunately. There is an option of moving towards using more internal sdk crates (like solana-runtime-transactions) for core types rather than thrashing the external sdk whenever internal needs change, but that's a pretty big effort.

Detailed changes

1fa7b7d: refactors tests to minimize diff size when plumbing reserved accounts
c8cb15f: adds the zk token module to the sdk so that reserved accounts can reference the program id
9ea7043: removes the TryFrom<Message> impl for SanitizedMessage and replaces it with SanitizedMessage::try_from_legacy_message which will allow plumbing the reserved accounts through
edbdf6f: adds Message::is_maybe_writable for times when the reserved accounts set is not available but we want a rough guess still (cli output, durable nonce checking in rpc, etc)
8fb6616: is the meat of the change, it introduces the reserved accounts module, adds it to bank, and plumbs the reserved accounts set everywhere
701119b: deprecates uses of static lists of sysvars and builtins. Unfortunately the lists themselves can't be deprecated due to use of lazy_static

  • Deprecated solana_program::message::is_builtin_key_or_sysvar function
  • Deprecated solana_program::sysvar::is_sysvar_id function
  • Bigtable uploader used to skip indexing sysvars, now it skips all reserved keys
  • Replaced some usages of is_sysvar_id which a check for owner equal to sysvar
  • Snapshot minimizer logic now adds all active and inactive reserved account keys to the minimized snapshot

Breaking changes:

  • Renamed solana_rpc_client::rpc_client::SerializableTransaction::uses_durable_nonce to maybe_uses_durable_nonce to prevent misuse
  • Renamed solana_sdk::transaction::uses_durable_nonce to maybe_uses_durable_nonce to prevent misuse
  • Renamed solana_sdk::transaction::VersionedTransaction::uses_durable_nonce to maybe_uses_durable_nonce to prevent misuse
  • solana_sdk::transaction::SanitizedTransaction::try_from_legacy_transaction has a new reserved_account_keys argument
  • solana_sdk::transaction::SanitizedTransaction::try_create has a new reserved_account_keys argument
  • solana_sdk::transaction::SanitizedTransaction::try_new has a new reserved_account_keys argument
  • solana_program::message::Message::is_writable has a new reserved_account_keys argument
  • solana_program::message::Message::get_account_keys_by_lock_type has a new reserved_account_keys argument
  • solana_program::message::LegacyMessage::new has a new reserved_account_keys argument
  • solana_program::message::SanitizedMessage::try_new has a new reserved_account_keys argument
  • solana_program::message::LoadedMessage::new has a new reserved_account_keys argument
  • solana_program::message::LoadedMessage::new_borrowed has a new reserved_account_keys argument
  • solana_program::message::SanitizedMessage no longer implements TryFrom<Message> (I added a try_from_legacy_message method instead in order to pass the reserved_account_keys argument)

Feature Gate Issue: #34899

@jstarry jstarry added the feature-gate Pull Request adds or modifies a runtime feature gate label Jan 23, 2024
@jstarry jstarry force-pushed the feat/reserved-accounts branch 18 times, most recently from 1ac031e to a1ddd7b Compare January 23, 2024 15:39
@jstarry jstarry marked this pull request as ready for review January 23, 2024 15:40
@jstarry jstarry force-pushed the feat/reserved-accounts branch 2 times, most recently from 35d4efd to 3b98447 Compare January 23, 2024 15:51
@t-nelson
Copy link
Contributor

oof. the number of touch points here begs a refactor... i'm going to have to look at it more closely 🤔

@jstarry
Copy link
Member Author

jstarry commented Jan 24, 2024

I don't disagree that a refactor of transaction / message types should be done at some point but I would like to point out that the plumbing for reserved_account_keys is pretty similar to how address lookup tables are loaded since both are bank specific. I think the current approach in this PR already minimizes touch points as much as is possible.

@jstarry jstarry force-pushed the feat/reserved-accounts branch from 5725338 to bf8a046 Compare January 24, 2024 04:27
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: Patch coverage is 91.09415% with 35 lines in your changes are missing coverage. Please review.

Project coverage is 81.7%. Comparing base (bf2e8ee) to head (ea9e3ca).
Report is 6 commits behind head on master.

❗ Current head ea9e3ca differs from pull request most recent head 9f6432b. Consider uploading reports for the commit 9f6432b to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #34901     +/-   ##
=========================================
- Coverage    81.7%    81.7%   -0.1%     
=========================================
  Files         834      830      -4     
  Lines      224232   224570    +338     
=========================================
+ Hits       183382   183476     +94     
- Misses      40850    41094    +244     

@CriesofCarrots
Copy link
Contributor

Is it possible to break this up into logical commits? Right now, review is horrible.

@jstarry jstarry force-pushed the feat/reserved-accounts branch from bf8a046 to 71a02bd Compare January 25, 2024 03:25
@jstarry jstarry force-pushed the feat/reserved-accounts branch from 71a02bd to 8685df2 Compare January 25, 2024 03:26
@jstarry
Copy link
Member Author

jstarry commented Jan 25, 2024

Is it possible to break this up into logical commits? Right now, review is horrible.

I split it up.. apologies for not doing that earlier! The PR description includes a detailed breakdown of each commit as well.

@jstarry
Copy link
Member Author

jstarry commented Feb 8, 2024

Would you prefer I open a pr for each individual commit? Also, considering that 2.0 is coming soon, breaking changes should be an issue?

@jstarry
Copy link
Member Author

jstarry commented Feb 21, 2024

@CriesofCarrots @t-nelson ping on this!

@CriesofCarrots
Copy link
Contributor

Sorry for the delay. This is on my list for tomorrow. Is it worth waiting on a rebase at this point?

@jstarry jstarry force-pushed the feat/reserved-accounts branch from ea9e3ca to 701119b Compare February 27, 2024 01:06
@jstarry
Copy link
Member Author

jstarry commented Feb 27, 2024

@CriesofCarrots I just rebased!

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

Phew, okay, I think I got through everything. (Commit 5 was a bear; splitting out test fixes from other updates might have been nice to draw attention to the critical code paths.)
Generally, looks good to me; just one api suggestion. I didn't catch any issues with the feature/list handling.
The banking_stage changes look straightforward to me, but it might be worth having an module expert sanity check.

ledger-tool/src/output.rs Outdated Show resolved Hide resolved
sdk/src/reserved_account_keys.rs Outdated Show resolved Hide resolved
ledger-tool/src/main.rs Show resolved Hide resolved
Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

lgtm, but recommend at least one more set of eyes on everything

@willhickey
Copy link
Contributor

This repository is no longer in use. Please re-open this pull request in the agave repo: https://github.com/anza-xyz/agave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-gate Pull Request adds or modifies a runtime feature gate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants