solana
solana copied to clipboard
Add feature for tracking dynamic reserved account set
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
https://github.com/solana-labs/solana/pull/34901/commits/b02c297872be782401375e36d2f595149716cc95: refactors tests to minimize diff size when plumbing reserved accounts
https://github.com/solana-labs/solana/pull/34901/commits/c02bbb11cb63b55d66d26aae072351c78552877f: adds the zk token module to the sdk so that reserved accounts can reference the program id
https://github.com/solana-labs/solana/pull/34901/commits/7db755cea0537ee57228ac6992ca26e779dff052: removes the TryFrom<Message>
impl for SanitizedMessage
and replaces it with SanitizedMessage::try_from_legacy_message
which will allow plumbing the reserved accounts through
https://github.com/solana-labs/solana/pull/34901/commits/c7f27d490e993830bdd983fa3cc270044dc3ee9a: 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)
https://github.com/solana-labs/solana/pull/34901/commits/7b7cf251cc79fe461abb66d4ff8b5fb171ea22fe: is the meat of the change, it introduces the reserved accounts module, adds it to bank, and plumbs the reserved accounts set everywhere
https://github.com/solana-labs/solana/pull/34901/commits/8685df2ce940c510c6ffbca3164710023e3c4daa: 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
tomaybe_uses_durable_nonce
to prevent misuse - Renamed
solana_sdk::transaction::uses_durable_nonce
tomaybe_uses_durable_nonce
to prevent misuse - Renamed
solana_sdk::transaction::VersionedTransaction::uses_durable_nonce
tomaybe_uses_durable_nonce
to prevent misuse -
solana_sdk::transaction::SanitizedTransaction::try_from_legacy_transaction
has a newreserved_account_keys
argument -
solana_sdk::transaction::SanitizedTransaction::try_create
has a newreserved_account_keys
argument -
solana_sdk::transaction::SanitizedTransaction::try_new
has a newreserved_account_keys
argument -
solana_program::message::Message::is_writable
has a newreserved_account_keys
argument -
solana_program::message::Message::get_account_keys_by_lock_type
has a newreserved_account_keys
argument -
solana_program::message::LegacyMessage::new
has a newreserved_account_keys
argument -
solana_program::message::SanitizedMessage::try_new
has a newreserved_account_keys
argument -
solana_program::message::LoadedMessage::new
has a newreserved_account_keys
argument -
solana_program::message::LoadedMessage::new_borrowed
has a newreserved_account_keys
argument -
solana_program::message::SanitizedMessage
no longer implementsTryFrom<Message>
(I added atry_from_legacy_message
method instead in order to pass thereserved_account_keys
argument)
Feature Gate Issue: https://github.com/solana-labs/solana/issues/34899
oof. the number of touch points here begs a refactor... i'm going to have to look at it more closely :thinking:
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.
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.
:exclamation: 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
Is it possible to break this up into logical commits? Right now, review is horrible.
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.
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?
@CriesofCarrots @t-nelson ping on this!
Sorry for the delay. This is on my list for tomorrow. Is it worth waiting on a rebase at this point?
@CriesofCarrots I just rebased!
This repository is no longer in use. Please re-open this pull request in the agave repo: https://github.com/anza-xyz/agave