#### Problem
Function data_size_for_shared_block() is designed to provide
the data_size when its account shares its account block with
other accounts. However, TieredAccountMeta already has another
function for returning data size.
#### Summary of Changes
This PR removes data_size_for_shared_block() from TieredAccountMeta.
Will follow-up with another PR that includes a better API.
#### Summary of Changes
This PR implements HotAccountMeta's getter functions for accessing
optional fields (e.g. rent_epoch, account_hash, etc) and account data.
#### Test Plan
A new unit test is included in this PR.
#### Summary of Changes
This PR adds several functions to AccountMetaOptionalFields
for obtaining the offset of each optional field.
#### Test Plan
New unit test cases are included in this PR.
#### Summary of Changes
This PR adds byte_block::read_type(), an util function that
reads the raw part of the input byte block at the specified offset
as type T. This function will be later used by the hot storage.
#### Test Plan
Modified existing unit tests to use byte_block::read_type()
when the input byte block is properly aligned.
* When there are too many pubkeys in one slot, kick the one with lowest
stake out.
* Cache last_root to reduce read locks we need.
* Use slots_in_epoch to limit number of slots in the map.
* Fix lint errors.
* Only cache stake and slots per epoch once per epoch.
* Revert "Only cache stake and slots per epoch once per epoch."
This reverts commit 8658aad0083456794b4c4403adaf9c74d1a71d09.
* Vote at the tip of current fork if last vote is outside SlotHash
of the tip and last vote expired.
* Add unittest when last vote is outside slothash, we should vote at the tip
of the current fork.
* Revert "Use slots_in_epoch to limit number of slots in the map."
This reverts commit 93574f57a48d2a70fbbc0f62fa8810d3b6bee0af.
* Revert "Cache last_root to reduce read locks we need."
This reverts commit bb114ec2b62cb9c0207328b19c415f6116be0f1c.
* Revert "When there are too many pubkeys in one slot, kick the one with lowest"
This reverts commit 711e29a6a025fd4f11fbc97dcbbe90e4832be04c.
* Move new vote generation when last vote is outside slothash into the
main path, this actually makes more sense since we don't select where
to vote in two different places, and all the vote generation logic
is seamlessly inherited.
* - Move vote refresh to be behind select vote and do not refresh vote if a new
vote is selected.
- Check whether last vote is inside slothash inside select_vote_and_reset_forks
- rename slot_within_slothash to is_in_slothashes_history
- remove one unittest for now, more tests will be added in a separate CL
* Remove new test, it will be in another file.
* Add is_in_slot_hashes_history test in the new file.
* Add unittest for the case when last vote is outside slot hashes.
* Small improvements and more unittests.
* Fix bad merge.
* Update docs/src/terminology.md
Co-authored-by: mvines <mvines@gmail.com>
* Put SwitchForkDecision::FailedSwitchThreshold logic into separate function.
* Make linter happy.
---------
Co-authored-by: mvines <mvines@gmail.com>
#### Summary of Changes
This PR adds getter functions to the TieredAccountMeta for accessing
optional fields and account data.
#### Test Plan
This PR only adds methods to a trait. More tests will be included in the
follow-up PRs.
Slot::MAX was used to specify that a type of snapshots should not be
created; define a constant to be that value and reference the constant
to have a single point of edit.
* Remove credits_auto_rewind feature logic from stake program
* Obey clean-up orders
* Clippy prefers this match
* Remove credits_auto_rewind feature helpers from Bank
* Comment nit for language, and shrink to fit on one line
#### Summary of Changes
This PR introduces HotAccountMeta, the storage and in-memory struct of
the metadata struct for a hot account.
#### Test Plan
Unit tests are included in this PR.
Tested in mnb w/ the prototype implementation of the tiered account storage (#30626)
#### Summary of Changes
This PR adds AccountMetaOptionalFields::size_from_flags that takes
`&AccountMegaFlags` and returns the size of the AccountMetaOptionalFields
based on the input AccountMegaFlags.
This function is needed because the reader of the TieredAccountMeta
directly extract all the Some fields of AccountMetaOptionalFields
from its account block without constructing the AccountMetaOptionalFields
instance.
#### Test plan
Improve existing unit tests that further verify the correctness of the function.
#### Summary of Changes
This PR introduces TieredAccountMeta, a trait that allows different implementations
of the account meta for different tiers of the accounts storage.
This PR includes the mutator and getter methods for the common TieredAccountMeta
fields. Functions that also work with the account data block will be in separate PRs.
* Restrict access to Bank's HardForks
Callers could previously obtain a a lock to read/write HardForks from
any Bank. This would allow any caller to modify, and creates the
opportunity for inconsistent handling of what is considered a valid hard
fork (ie too old).
This PR adds a function to Bank so consistent sanity checks can be
applied; the caller will already have a Bank as that is where they would
have obtained the HardForks from in the first place. Additionally,
change the getter to return a copy of HardForks (simple Vec).
* Allow hard fork at bank slot if bank is not yet frozen
* add sysvar and logic for last restart slot
* cleanup
* add test for getting last restart slot from account
* format code
* add some basic rustdoc
* copy+paste error
* feature flag for last_restart_slot
* add to sysvars.md
* updated wording in sysvars.md
* rename sol_get_last_restart_slot_sysvar > sol_get_last_restart_slot
* create sbf C header for sol_get_last_restart_slot
* cleanup imports
* reverted hardened_unpack workaround
* cleanup imports
* cleanup logs + blank lines
* Implementing ui changes for last restart slot, nit
* Some more nit change and implementing the UI for sysvar
* fixing the CI
* Minor clippy fix
* format changes
* changes suggested by mvines and lichtso
* increase timeout in local_cluster test
* fix code format
* use keypair for feature flag from mvines
* delete test.json file
* Revert "increase timeout in local_cluster test"
This reverts commit a67465ae22.
* last restart slot should be always less than or equal to current slot
* fixing bug
* changes after steviez comments
* format issue fixed
* fixing the comment on premature application of future hardfork
* nit change in test
Co-authored-by: steviez <steven@solana.com>
* reverting sysvar_cache.rs because change was not necessary
---------
Co-authored-by: steve-gg <grooviegermanikus@gmail.com>
Co-authored-by: steviez <steven@solana.com>
#### Summary of Changes
This PR implements the writer function for AccountMetaOptionalFields
in ByteBlockWriter::write_optional_fields().
#### Test Plan
Unit tests are included in this PR.
Tested in mnb w/ the prototype implementation of the tiered storage (#30626)
#### Summary of Changes
This PR introduces AccountMetaOptionalFields, the in-memory struct for
handling optional fields.
#### Test Plan
Unit tests are included in this PR.
Tested in mnb w/ the prototype implementation of the tiered storage (#30626).
* Makes Bank::load_program() return correct tombstones.
* Removes early TX failure caused by closed and invalid programs.
* Adjusts the feature gate of simplify_writable_program_account_check.
#### Problem
AccountMetaFlags and its fields are required to be public as the visibility of their get
functions generated by `bit_fields` are tied to the visibility of their fields, and the
get functions will later be used to support the TieredAccountMeta for AccountMeta.
#### Summary of Changes
Make AccountMetaFlags and its fields public
#### Summary of Changes
This PR adds raw_len() to ByteBlockWriter which returns
the length of the data after decoding. This information is needed
for the cold storage to keep track of the current size of the account
block after decompression.
#### Test Plan
Improved existing tests to verify the returned raw_len().
Tested in mnb w/ the prototype implementation of the tiered storage (https://github.com/solana-labs/solana/pull/30626)
`Arc` is already a reference internally, so it does not seem to be
beneficial to pass a reference to it. Just adds an extra layer of
indirection.
Functions that need to be able to increment `Arc` reference count need
to take `Arc<AtomicBool>`, but those that just want to read the
`AtomicBool` value can accept `&AtomicBool`, making them a bit more
generic.
This change focuses specifically on `Arc<AtomicBool>`. There are other
uses of `&Arc<T>` in the code base that could be converted in a similar
manner. But it would make the change even larger.
#### Summary of Changes
This PR implements AccountMetaFlags, which will later be used in
the tiered accounts storage to support optional fields.
#### Test Plan
Unit tests are included in this PR.
#### Summary of Changes
Support Lz4 in ByteBlockWriter.
#### Test Plan
Added test cases for Lz4.
Tested in mnb w/ the prototype implementation of the tiered storage (#30626)
The callstack updated in this PR passed an &Arc<...> down only to have
the bottom level clone the reference. Thus, we are giving shared
ownership so the reference is a bit redundant and arguably obscures the
intention to clone further down the callstack.
#### Summary of Changes
This PR includes the util structs for writing byte blocks, which will be used
by the TieredStorage writer (currently used in the prototype #30626).
The PR only includes the Raw encoding format. Will add more in subsequent PRs.
#### Test Plan
Tested in mnb with the prototype implementation of the tiered-storage (#30626)
Unit tests are also included in this PR.
#### Problem
AppendVec currently uses std::io::ErrorKind::Other for its own errors.
#### Summary of Changes
This PR introduces AppendVecError and has AppendVec use it.
#### Problem
The return error type -- io::Error used in reconstruct_single_storage()
isn't suitable to describe all possible errors inside the function such as
AccountsFileError.
#### Summary of Changes
This PR makes it return SnapshotError which can better handle
both AccountsFileError and io::Error.
#### Problem
Part of the snapshot-related code uses io::Error while other parts use SnapshotError.
#### Summary of Changes
As SnapshotError can be created from io::Error, this PR makes snapshot-related
code to use SnapshotError instead.
#### Problem
AccountsFile- and AppendVec-related code uses io::Error for their main error type. However, there're many errors under AccountsFile that don't belong to io::Error.
#### Summary of Changes
This PR introduces AccountsFileError and makes minimum changes to keep the PR small.
Subsequent changes related to this will be in separate PRs.
* hold bank freeze lock in banks-server to prevent RC on slot change
* clean up comments and loop
---------
Co-authored-by: Maximilian Schneider <max@mango.markets>
* Notify replay of pruned duplicate confirmed slots
* Ingest replay signal and run ancestor hashes for pruned
* Forward PDC to ancestor hashes and ingest pruned dumps from ancestor hashes service
* Add local-cluster test
* pass include_slot_in_hash through hash calcs to allow rehashing
* tests use each include_slot_in_hash value
* move include_slot_in_hash
* typo
* reorder struct init
* spelling is hard
* remove IndexAccountMapEntry.store_id
* fix empty case that test hit
* store_id checks
* cleanup generate index when slot contains no storage
* remove unwrap
* Removes builtins::get_builtins(), instead derive them from Bank::builtin_programs.
* Removes BuiltinAction.
Turns BuiltinFeatureTransition from an enum into a struct.
* Makes Bank::remove_builtin() place tombstones.
#### Summary of Changes
This PR includes the implementation of the footer for the tiered account storage.
Tiered account storage proposal: #30551
The prototype implementation of the tiered account storage: #30626.
Counters can only report a single field; this adds an extra step to
debugging efforts to figure out the context for where/why the counted
event occurred. Use datapoints instead to subtmit some extra context.