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

feature: set rent_epoch to Epoch::MAX #28690

Merged
merged 9 commits into from
Jan 2, 2023

Conversation

jeffwashington
Copy link
Contributor

@jeffwashington jeffwashington commented Oct 31, 2022

Problem

rent_epoch is no longer being updated for rent exempt accounts.
But, we have to save the value of rent_epoch per account, since it is used in each account's hash.

Summary of Changes

fix rent_epoch field at a known sentinel value for all rent-exempt accounts. This allows us to avoid storing this field per account. This reduces the cost per-account.

Fixes #
Feature Gate Issue: #28683

@jeffwashington jeffwashington changed the title Oct55 feature: set rent_epoch to Epoch::MAX Oct 31, 2022
@jeffwashington jeffwashington force-pushed the oct55 branch 6 times, most recently from 737f5b0 to bc7e38a Compare November 1, 2022 21:38
@jackcmay
Copy link
Contributor

jackcmay commented Dec 7, 2022

Looking good. One nit, it would be cleaner if all_features_except came in on a separate pr. No biggie this time, but nice to isolate the functional changes from the infra changes.

@jeffwashington
Copy link
Contributor Author

Looking good. One nit, it would be cleaner if all_features_except came in on a separate pr. No biggie this time, but nice to isolate the functional changes from the infra changes.

Yes. I'm working on breaking it up already to make the feature alone. This pr just passed the ci for the first time yesterday ;-)

Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Lgtm

@jeffwashington jeffwashington merged commit cf1aa4b into solana-labs:master Jan 2, 2023
nickfrosty pushed a commit to nickfrosty/solana that referenced this pull request Jan 4, 2023
* check android builds

* feature: set rent_epoch to Epoch::MAX

* tweaks

* Update runtime/src/rent_collector.rs

Co-authored-by: Brooks Prumo <[email protected]>

* simplify changes to tests

* back out some test changes

* calculate_rent_result passes through Exempt

* move calc outside loop

* if rent epoch is already max, use 'NoRentCollectionNow'

Co-authored-by: Brooks Prumo <[email protected]>
nickfrosty added a commit to nickfrosty/solana that referenced this pull request Jan 6, 2023
* chore: update docusaurus to latest version

* fix: added required fields

* fix: custom layout pages

* fix: updated doc keywords to array

* fix: remobed breadcrumbs for the default

* feat: added new JSON API example

* feat: created api partial pages

* fix: updated links

* feat: added api landing page and updates api sidebar

* fix: updated the call to action on the http method page

* fix: mobile responsive-ness

* fix: updated sidebar link

* fix: updated internal linking to use new api page

* rolls back merkle shreds on testnet (solana-labs#29340)

solana-labs#29339
adds hash domain to merkle shreds. In order to merge that change, need
to temporarily disable merkle shreds on testnet.

* remove acctdb.min_num_stores (solana-labs#29335)

* Remove println (solana-labs#29342)

* exclude Vote transactions from updating min-fee-cache (solana-labs#29341)

* Add metrics for min/max priority fee per slot, and counters for fee/non-fee transactions (solana-labs#29330)

* Add metrics for min/max priority fee per slot, and counters for fee/non-fee txs

* get fee range of prioritized transactions only

* Update runtime/src/prioritization_fee.rs

Co-authored-by: Trent Nelson <[email protected]>

* Update runtime/src/prioritization_fee.rs

Co-authored-by: Trent Nelson <[email protected]>

* fix format

Co-authored-by: Trent Nelson <[email protected]>

* test_utils::create_test_accounts pre-allocates an append vec first (solana-labs#29336)

* test_utils::create_test_accounts pre-allocates an append vec first

* remove comment

* introduce ShrinkInProgress (solana-labs#29329)

* introduce ShrinkInProgress

* remove redundant check

* add comments

* Fix "tranaction" typo in code base (solana-labs#29347)

Fix typos

* [docs] updating the "writing programs" section (solana-labs#29197)

* docs: added limitations page

* fix: updated deprecated cargo test-bpf

* docs: moved content off of overview

* fix: added compute budget description

* fix: updated compute buddget

* fix: rearranged sections

* fix: update code snippet

* docs: overview page and links

* [docs] Updated transactions overview page (solana-labs#29345)

fix: added broad overview

* docs: transactions fees/confirmation and deploying programs (solana-labs#28895)

docs: adds and updates

* Remove checks for activated feature check_physical_overlapping (solana-labs#29355)

* fix: client-test timeout (solana-labs#29364)

* fix: retry counter doesn't count

* set timeout for wait_for

* Expand solana-sdk API docs. (solana-labs#29063)

* Expand solana-sdk API docs.

* Update sdk/src/genesis_config.rs

Co-authored-by: Tyera <[email protected]>

* Update sdk/src/hard_forks.rs

Co-authored-by: Tyera <[email protected]>

* Update sdk/src/builtins.rs

Co-authored-by: Tyera <[email protected]>

* Update sdk/src/builtins.rs

Co-authored-by: Tyera <[email protected]>

* Update sdk/src/rpc_port.rs

Co-authored-by: Tyera <[email protected]>

* Update sdk/src/lib.rs

Co-authored-by: Tyera <[email protected]>

* Clarify derivation_path docs

* 'entry point' -> 'entrypoint'

Co-authored-by: Tyera <[email protected]>

* Add fee-payer arg to solana feature activate (solana-labs#29367)

* replace ./cargo with cargo in sbf/bpf build scripts (solana-labs#29371)

* Make connection cache to support specified client endpoint (solana-labs#29240)

ConnectionCache is being used for managing connections for sending messages using quic. In the current implementation the connection's endpoint is created in a lazy initialized fashion and set to one per connection pool. In repair we need all connections to use the same Endpoint so that the server can send back the response to the same Endpoint.

* chore: bump futures-util from 0.3.24 to 0.3.25 (solana-labs#29337)

* chore: bump futures-util from 0.3.24 to 0.3.25

Bumps [futures-util](https://github.com/rust-lang/futures-rs) from 0.3.24 to 0.3.25.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](rust-lang/futures-rs@0.3.24...0.3.25)

---
updated-dependencies:
- dependency-name: futures-util
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* [auto-commit] Update all Cargo lock files

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <[email protected]>

* get rid of ./cargo when building downstream projects (solana-labs#29372)

* vote: Prevent commission update in the second half of epochs (solana-labs#29362)

* vote: Prevent commission update in the second half of epochs

* Address feedback

* Fix tests

* Make the feature enabled by single-contributor

* Use a cooler pubkey

* ci: trigger downstream pipeline when cargo-[test|build]-[bpf|sbf] is modified (solana-labs#29390)

* ci: trigger stable-sbf pipeline when cargo-[test|build]-[bpf|sbf] is modified (solana-labs#29391)

* Security TXT: Add source_release and source_revision fields (solana-labs#29392)

* Fix BigTable upload early return (solana-labs#29378)

* Change Err when slot range is empty to Ok and log; add method docs

* Update var and log to be more correct

* Promote log level to warn

* Minor cleanup on bigtable_upload (solana-labs#29379)

Adjust some logs, and remove an unnecessary cloned().

* Adjust ledger-tool bigtable upload starting-slot default value (solana-labs#29384)

Currently, if starting-slot is unspecified, a value of 0 will be chosen.
In the common case where someone is operating on a much more recent
range, this would result in a ton of wasted operations & time.

Instead, choose a smarter default value for starting-slot based on what
we detect is currently in the blockstore.

* feat: Allow for verifying the sigs of partially signed txs in web3.js (solana-labs#29249)

* feat: allow for verifying the sigs of partially signed txs

* fix: make comment ab verifying sigs more specific

Co-authored-by: Steven Luscher <[email protected]>

* feat: add tests for partial signed tx verification

* fix: revert lockfile changes

* fix: make tests more modular

* fix: run linter

Co-authored-by: Steven Luscher <[email protected]>

* Increase Stalebot's operation consumption limit by another 50%

* feat: add getInflationRate RPC call to web3.js (solana-labs#29377)

* Add getInflationRate RPC call

* Fix code formatting

Co-authored-by: steveluscher <[email protected]>

* Temporary increase the build redundancy threshold (solana-labs#29412)

* Add an option to reinstall sbf-tool binaries by cargo-build-sbf (solana-labs#29410)

* Enable full output of cargo-build-sbf tests (solana-labs#29411)

* test: fix get inflation rate test failed at test:live (solana-labs#29413)

* Bump sbf-tools to v1.32 (solana-labs#29325)

* Bump sbf-tools to v1.32

This version of sbf-tools is based on Rust 1.65.0 and LLVM 15.0.

* Temporary ignore build-sbf tests until issue with buildkite cache resolved

* ci: fix web3-commit-lint (solana-labs#29414)

chore: update web3 package-lock.json

* Re-enable cargo-build-sbf tests (solana-labs#29415)

* Plumb dumps from replay_stage to repair (solana-labs#29058)

* Plumb dumps from replay_stage to repair

When dumping a slot from replay_stage as a result of duplicate or
ancestor hashes, properly update repair subtrees to keep weighting and
forks view accurate.

* add test

* pr comments

* experiments different turbine fanouts for propagating shreds (solana-labs#29393)

The commit allocates 2% of slots to running experiments with different
turbine fanouts based on the slot number.
The experiment is feature gated with an additional feature to disable
the experiment.

* Increase the Stalebot operations limit by another 50%.

* Double the Stalebot operations limit

* Add more logging and documentation to flaky optimistic confirmation tests (solana-labs#29418)

* Revert "add retry for flakey local cluster test (solana-labs#29228)"

This reverts commit 7a97121.

* Add logging for repair

* replaced ./cargo with cargo in build docs (solana-labs#29375)

* expands test coverage for merkle/legacy shreds sigverify (solana-labs#29424)

* expands test coverage for sign_shreds_gpu (solana-labs#29429)

* Crank Stalebot's operations limit up to a level that should handle all issues

This thing seems to have been humming along at 300 in the dead zone between NA night and Europe morning. Let's see if it can handle the entire corpus.

* simplifies shreds sigverify (solana-labs#29436)

Simplifying this code in preparation of removing merkle roots from
shreds binary.

* fix typo in rpc client (solana-labs#29434)

* fix typo in runtime docs

* fix typo in rpc client

* chore: typecheck web3.js tests (solana-labs#29422)

* fix: web3.js test typescript errors

Fixes the typescript errors throughout the
web3.js test suite

* fix: node14 test

AbortController is a default in node16 but needs
to be imported for node14

* fix: additional typescript errors

Adds the tests to the tsconfig to auto-include mocha
and fixes remaining typescript errors

* fix: graphql-tools to work with typescript

version of graphql-tools initially installed has incompatible
types preventing ./scripts/typegen.sh from passing when tests
are added to the include path of tsconfig.json

* Don't build typedefs for tests

Co-authored-by: steveluscher <[email protected]>

* implements shred::layout::get_merkle_root (solana-labs#29437)

In preparation of removing merkle roots form shreds binary, the commit
adds api to recover the root from the merkle proof embedded in shreds
payload.

* Update SECURITY.md

* feat: add commission fields matching RPC spec to web3.js client (solana-labs#29435)

* fix: adds commission field matching RPC spec

* fix: update optional to follow type pattern

* chore: bump @babel/runtime from 7.18.0 to 7.20.7 in /web3.js (solana-labs#29439)

Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.18.0 to 7.20.7.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.20.7/packages/babel-runtime)

---
updated-dependencies:
- dependency-name: "@babel/runtime"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump @solana/buffer-layout from 4.0.0 to 4.0.1 in /web3.js (solana-labs#29441)

Bumps [@solana/buffer-layout](https://github.com/solana-labs/buffer-layout) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/solana-labs/buffer-layout/releases)
- [Changelog](https://github.com/solana-labs/buffer-layout/blob/master/CHANGELOG.md)
- [Commits](https://github.com/solana-labs/buffer-layout/commits)

---
updated-dependencies:
- dependency-name: "@solana/buffer-layout"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump @babel/plugin-transform-runtime from 7.17.0 to 7.19.6 in /web3.js (solana-labs#29442)

chore: bump @babel/plugin-transform-runtime in /web3.js

Bumps [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-runtime) from 7.17.0 to 7.19.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.19.6/packages/babel-plugin-transform-runtime)

---
updated-dependencies:
- dependency-name: "@babel/plugin-transform-runtime"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump bn.js from 5.2.0 to 5.2.1 in /web3.js (solana-labs#29443)

Bumps [bn.js](https://github.com/indutny/bn.js) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/indutny/bn.js/releases)
- [Changelog](https://github.com/indutny/bn.js/blob/master/CHANGELOG.md)
- [Commits](indutny/bn.js@v5.2.0...v5.2.1)

---
updated-dependencies:
- dependency-name: bn.js
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* adds shred::layout::get_signed_data (solana-labs#29438)

Working towards removing merkle root from shreds payload, the commit
implements api to obtain signed data from shreds binary.

* removes merkle root comparison in erasure_mismatch (solana-labs#29447)

Merkle shreds within the same erasure batch have the same merkle root.
The root of the merkle tree is signed. So either the signatures match
or one fails sigverify, and the comparison of merkle roots is redundant.

* generalizes the return type of Shred::get_signed_data (solana-labs#29446)

The commit adds an associated SignedData type to Shred trait so that
merkle and legacy shreds can return different types for signed_data
method.
This would allow legacy shreds to point to a section of the shred
payload, whereas merkle shreds would compute and return the merkle root.
Ultimately this would allow to remove the merkle root from the shreds
binary.

* chore: bump @rollup/plugin-json from 4.1.0 to 6.0.0 in /web3.js (solana-labs#29452)

Bumps [@rollup/plugin-json](https://github.com/rollup/plugins/tree/HEAD/packages/json) from 4.1.0 to 6.0.0.
- [Release notes](https://github.com/rollup/plugins/releases)
- [Changelog](https://github.com/rollup/plugins/blob/master/packages/json/CHANGELOG.md)
- [Commits](https://github.com/rollup/plugins/commits/url-v6.0.0/packages/json)

---
updated-dependencies:
- dependency-name: "@rollup/plugin-json"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump @typescript-eslint/parser from 5.40.1 to 5.47.1 in /web3.js (solana-labs#29453)

Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.40.1 to 5.47.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.47.1/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add test_shrink_ancient_overflow (solana-labs#29363)

* cleanup 'shrinking_in_progress' (solana-labs#29359)

* feature: set rent_epoch to Epoch::MAX (solana-labs#28690)

* check android builds

* feature: set rent_epoch to Epoch::MAX

* tweaks

* Update runtime/src/rent_collector.rs

Co-authored-by: Brooks Prumo <[email protected]>

* simplify changes to tests

* back out some test changes

* calculate_rent_result passes through Exempt

* move calc outside loop

* if rent epoch is already max, use 'NoRentCollectionNow'

Co-authored-by: Brooks Prumo <[email protected]>

* test permutations of set_exempt_rent_epoch_max (solana-labs#29461)

* add test and comments (solana-labs#29459)

* simplify get_storages_for_slot (solana-labs#29463)

* handle ancient overflow case correctly (solana-labs#29458)

* migrate tests to not use AccountStorage::get (solana-labs#29464)

* decrease frequency of random shrink of ancient append vec (solana-labs#29462)

* remove metric time_hashing_skipped_rewrites_us (solana-labs#29470)

* Fix snapshot download test (solana-labs#29457)

snapshot download tests will now attempt to load the downloaded snapshot

* test_rent_exempt_temporal_escape works in passes (solana-labs#29460)

* cleanup in account_storage.rs (solana-labs#29467)

* Snapshot download test (solana-labs#29474)

* remove skip rewrite code from collect_rent_from_accounts (solana-labs#29472)

* skip_rewrites will only be feature driven (solana-labs#29468)

* filter get_snapshot_storages for requested_slots earlier (solana-labs#29465)

* filter get_snapshot_storages for requested_slots earlier

* Update runtime/src/accounts_db.rs

Co-authored-by: apfitzge <[email protected]>

Co-authored-by: apfitzge <[email protected]>

* add test (solana-labs#29471)

* Cli: refactor program code slightly (solana-labs#29477)

* Remove unused messages Vecs

* Remove superfluous Option in check_payer and send_deploy_messages

* Remove superfluous Option in do_process_program_write_and_deploy

* Remove unnecessary block-wrapping in do_process_program_write_and_deploy

* Cli: the authority passed to `solana program write-buffer` must be a proper signer (solana-labs#29476)

* Fix upgrade signer parsing in program deploy (noop)

* Fix buffer-authority signer parsing in program write-buffer (error on Pubkey input)

* Move async remove to snapshot_utils.rs (solana-labs#29406)

* remove unnecessary type (solana-labs#29473)

* refactor RecycleStores::add_entries (solana-labs#29475)

* refactor RecycleStores::add_entries

* pr feedback

* add AccountStorage.is_empty (solana-labs#29478)

* add test method get_and_assert_single_storage (solana-labs#29481)

* add test method assert_no_storages_at_slot() (solana-labs#29483)

* remove single use AccountStorage.slot_store_count (solana-labs#29479)

* get_snapshot_storages removes call to AccountStorage.get (solana-labs#29466)

* remove should_retain from mark_dirty_dead_stores (solana-labs#29358)

* typo (solana-labs#29485)

* update leger tool help for db verify refcounts (solana-labs#29486)

* Add retries for get_latest_blockhash for accounts cluster bench (solana-labs#29456)

* retry get_latest_blockhash

* more retries for get_latest_blockhash

* retry for get_fee too

* clippy

* fmt

* sleep

* Update accounts-cluster-bench/src/main.rs

Co-authored-by: Tyera <[email protected]>

* Update accounts-cluster-bench/src/main.rs

Co-authored-by: Tyera <[email protected]>

* rename

Co-authored-by: Tyera <[email protected]>

* dedups gossip addresses, taking the one with highest weight (solana-labs#29421)

dedups gossip addresses, keeping only the one with the highest weight

In order to avoid traffic congestion or sending duplicate packets, when
sampling gossip nodes if several nodes have the same gossip address
(because they are behind a relayer or whatever), they need to be
deduplicated into one.

* add AccountStorage.get_slot_storage_entry (solana-labs#29480)

* cleanup get_snapshot_storages (solana-labs#29488)

* cleanup get_snapshot_storages

* pr feedback

* add AccountStorage.is_empty_entry for tests (solana-labs#29489)

* bank: Record non-vote transaction count (solana-labs#29383)

A subsequent change to `SamplePerformanceService` introduces non-vote transaction counts, which `bank`s need to store.

Part of work on solana-labs#29159

* chore: add missing members back to workspace.members (solana-labs#29450)

* frozen-abi/macro

* program-runtime

* sdk/macro

* sdk/program

* storage-bigtable/build-proto

* fix sorting

* recovers merkle roots from shreds binary in {verify,sign}_shreds_gpu (solana-labs#29445)

{verify,sign}_shreds_gpu need to point to offsets within the packets for
the signed data. For merkle shreds this signed data is the merkle root
of the erasure batch and this would necessitate embedding the merkle
roots in the shreds payload.
However this is wasteful and reduces shreds capacity to store data
because the merkle root can already be recovered from the encoded merkle
proof.

Instead of pointing to offsets within the shreds payload, this commit
recovers merkle roots from the merkle proofs and stores them in an
allocated buffer. {verify,sign}_shreds_gpu would then point to offsets
within this new buffer for the respective signed data.

This would unblock us from removing merkle roots from shreds payload
which would save capacity to send more data with each shred.

* should_move_to_ancient_append_vec works with a single storage (solana-labs#29484)

* Fix typo in blockstore_metrics.rs (solana-labs#29503)

embeded -> embedded

* chore: added algolia keys

* get_storages_for_slot uses get_slot_storage_entry (solana-labs#29498)

* fix: update the api pages for rent PRs

* Rework method for reporting security problems (solana-labs#29511)

* solana-install: check for fixed releases directly (solana-labs#29365)

when initializing, if a specific release is requested, we only need to confirm it exists
this can be done with the download url itself, rather than pulling the list of releases

* Fix TransactionPrecompileVerification RPC error (solana-labs#29490)

* make rpc test tolerant of rent_epoch being set to max (solana-labs#29508)

* logger: Update to env_logger 0.9.3 (solana-labs#29510)

* remove unnecessary to_vec() (solana-labs#29516)

* filter_storages ignores reclaims (solana-labs#29512)

* cleanup ancient append vec tests (solana-labs#29514)

* migrate tests to get_slot_storage_entry (solana-labs#29515)

* require repair request signature, ping/pong for Testnet, Development clusters (solana-labs#29351)

* Adds SnapshotError::IoWithSourceAndFile (solana-labs#29527)

* remove store_ids from a few shrink data structures (solana-labs#29360)

* get_storage_to_move_to_ancient_append_vec returns a single append vec (solana-labs#29482)

get_storages_to_move_to_ancient_append_vec returns a single append vec

* use get_storage_for_slot() in tests (solana-labs#29517)

* process_storage_slot takes a single append vec (solana-labs#29519)

* Stream the executed transaction count in the block notification (solana-labs#29272)

Problem

The plugins need to know when all transactions for a block have been all notified to serve getBlock request correctly. As block and transaction notifications are sent asynchronously to each other it will be difficult.

Summary of Changes

Include the executed transaction count in block notification which can be used to check if all transactions have been notified.

* fixes errors from clippy::useless_conversion (solana-labs#29534)

https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

* Fixes format string (solana-labs#29533)

* fixes errors from clippy::needless_borrow (solana-labs#29535)

https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

* shrink_slot_forced uses a single append vec (solana-labs#29521)

* migrate tests to use get_storage_for_slot (solana-labs#29518)

* fixes errors from clippy::redundant_clone (solana-labs#29536)

https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

* Update CI pipeline to only run `checks` step on version bump PRs (solana-labs#29243)

* Add logic to buildkite pipeline so version bump PRs don't run the full CI

* simplifies sigverify copy_return_values (solana-labs#29495)

* shrink fns take a single append vec (solana-labs#29522)

* Refine appendvec sanitize error message to include path (solana-labs#29541)

* Removed assert on write_version ordering  (solana-labs#29530)

Removed assert on write_version ordering as snapshot created by earlier version
is not honoring that.

* storage rebuilder regex cleanup (solana-labs#29408)

* storage rebuilder regex cleanup

* Update runtime/src/snapshot_utils/snapshot_storage_rebuilder.rs

Co-authored-by: apfitzge <[email protected]>

Co-authored-by: apfitzge <[email protected]>

* conflict fix

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: behzad nouri <[email protected]>
Co-authored-by: Jeff Washington (jwash) <[email protected]>
Co-authored-by: Tyera <[email protected]>
Co-authored-by: Tao Zhu <[email protected]>
Co-authored-by: Trent Nelson <[email protected]>
Co-authored-by: Alessandro Decina <[email protected]>
Co-authored-by: Yihau Chen <[email protected]>
Co-authored-by: Brian Anderson <[email protected]>
Co-authored-by: Tyera <[email protected]>
Co-authored-by: kirill lykov <[email protected]>
Co-authored-by: Lijun Wang <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <[email protected]>
Co-authored-by: Jon Cinque <[email protected]>
Co-authored-by: Daniel Kilimnik <[email protected]>
Co-authored-by: steviez <[email protected]>
Co-authored-by: Nico Schapeler <[email protected]>
Co-authored-by: Steven Luscher <[email protected]>
Co-authored-by: TJDawson10 <[email protected]>
Co-authored-by: steveluscher <[email protected]>
Co-authored-by: Dmitri Makarov <[email protected]>
Co-authored-by: Ashwin Sekar <[email protected]>
Co-authored-by: gr8den <[email protected]>
Co-authored-by: Trent Nelson <[email protected]>
Co-authored-by: Kollan House <[email protected]>
Co-authored-by: Brooks Prumo <[email protected]>
Co-authored-by: Brennan Watt <[email protected]>
Co-authored-by: apfitzge <[email protected]>
Co-authored-by: Xiang Zhu <[email protected]>
Co-authored-by: HaoranYi <[email protected]>
Co-authored-by: Illia Bobyr <[email protected]>
Co-authored-by: Ikko Ashimine <[email protected]>
Co-authored-by: Michael Vines <[email protected]>
Co-authored-by: hana <[email protected]>
Co-authored-by: Jeff Biseda <[email protected]>
Co-authored-by: Brooks <[email protected]>
Co-authored-by: Will Hickey <[email protected]>
gnapoli23 pushed a commit to gnapoli23/solana that referenced this pull request Jan 10, 2023
* check android builds

* feature: set rent_epoch to Epoch::MAX

* tweaks

* Update runtime/src/rent_collector.rs

Co-authored-by: Brooks Prumo <[email protected]>

* simplify changes to tests

* back out some test changes

* calculate_rent_result passes through Exempt

* move calc outside loop

* if rent epoch is already max, use 'NoRentCollectionNow'

Co-authored-by: Brooks Prumo <[email protected]>
gnapoli23 pushed a commit to gnapoli23/solana that referenced this pull request Jan 10, 2023
* check android builds

* feature: set rent_epoch to Epoch::MAX

* tweaks

* Update runtime/src/rent_collector.rs

Co-authored-by: Brooks Prumo <[email protected]>

* simplify changes to tests

* back out some test changes

* calculate_rent_result passes through Exempt

* move calc outside loop

* if rent epoch is already max, use 'NoRentCollectionNow'

Co-authored-by: Brooks Prumo <[email protected]>
gnapoli23 pushed a commit to gnapoli23/solana that referenced this pull request Jan 10, 2023
* check android builds

* feature: set rent_epoch to Epoch::MAX

* tweaks

* Update runtime/src/rent_collector.rs

Co-authored-by: Brooks Prumo <[email protected]>

* simplify changes to tests

* back out some test changes

* calculate_rent_result passes through Exempt

* move calc outside loop

* if rent epoch is already max, use 'NoRentCollectionNow'

Co-authored-by: Brooks Prumo <[email protected]>
gnapoli23 pushed a commit to gnapoli23/solana that referenced this pull request Jan 10, 2023
* check android builds

* feature: set rent_epoch to Epoch::MAX

* tweaks

* Update runtime/src/rent_collector.rs

Co-authored-by: Brooks Prumo <[email protected]>

* simplify changes to tests

* back out some test changes

* calculate_rent_result passes through Exempt

* move calc outside loop

* if rent epoch is already max, use 'NoRentCollectionNow'

Co-authored-by: Brooks Prumo <[email protected]>
@behzadnouri
Copy link
Contributor

@jeffwashington Can you please confirm that this does not introduce discrepancy between accounts-db and stakes-cache?

@jeffwashington
Copy link
Contributor Author

jeffwashington commented Jan 24, 2023

@jeffwashington Can you please confirm that this does not introduce discrepancy between accounts-db and stakes-cache?

My guess is there could be discrepancy. As soon as the epoch begins where the feature is activated, every time a tx loads an account or rent is collected, rent_epoch will be set to Epoch::MAX. Certainly the first few slots in the new epoch, if we skip slots (which we will), some of the stake accounts will have rent collected (they are rent exempt), but they will be rewritten with an update to rent_epoch. This will be inconsistent with the stakes cache. I assume stakes cache does a read(from cache)-modify-write?

One possible fix is when the feature is activated, we go through the stakes cache and update all rent_epoch fields. But, this won't match the accounts in accounts db until each account is used in a tx or had rent collected.
So, we could just update the accounts whose rent collection partition has been reached as we retry on each slot to give rewards.
Or, the rewards store code could check the feature flag and write all accounts with the new rent_epoch once the feature is activated.
This is a step function change so currently rent_epoch is frozen in place for rent exempt accounts. As of this change, from feature activation, rent_epoch will be fixed at Epoch::MAX. So if the store code in rewards checked the feature flag and updated rent_epoch, it won't matter(?) if the stakes cache is inconsistent.
When is the stakes cache repopulated from accounts db?
This seems solvable, but there are details I'm missing.

Good job of identifying this issue ahead of time.

@behzadnouri
Copy link
Contributor

When is the stakes cache repopulated from accounts db?

Never afaik.
The stakes cache is presumed to be consistent with accounts-db when the node starts up. Then every write to accounts-db is intercepted to check that if it is writing to a vote or stake account, and if so mirrors the mutation into the stakes-cache as well.
If no accounts-db write is missed or bypassed then stakes-cache should stay consistent with accounts-db.
Otherwise, if some accounts-db mutations bypass that intercepting code, then the cache will become inconsistent with accounts-db.

Also as a reminder, we did #26479 to make and keep the stakes-cache consistent with accounts-db. Seems like this change is reintroducing some discrepancy.

@jeffwashington
Copy link
Contributor Author

Here's where rent collection will adjust rent_epoch:

solana/runtime/src/bank.rs

Lines 5283 to 5288 in cac52b0

measure!(self.rent_collector.collect_from_existing_account(
pubkey,
account,
self.rc.accounts.accounts_db.filler_account_suffix.as_ref(),
set_exempt_rent_epoch_max,
));

Then we do the store:

solana/runtime/src/bank.rs

Lines 5322 to 5326 in cac52b0

let (_, measure) = measure!(self.store_accounts((
self.slot(),
&accounts_to_store[..],
self.include_slot_in_hash()
)));

store updates the stakes cache:

solana/runtime/src/bank.rs

Lines 6180 to 6188 in cac52b0

pub fn store_accounts<'a, T: ReadableAccount + Sync + ZeroLamport + 'a>(
&self,
accounts: impl StorableAccounts<'a, T>,
) {
assert!(!self.freeze_started());
let mut m = Measure::start("stakes_cache.check_and_store");
(0..accounts.len()).for_each(|i| {
self.stakes_cache
.check_and_store(accounts.pubkey(i), accounts.account(i))

Here's where we modify rent_epoch when loading for tx processing:

let rent_due = rent_collector
.collect_from_existing_account(
key,
&mut account,
self.accounts_db.filler_account_suffix.as_ref(),
set_exempt_rent_epoch_max,
)

I'm sure the store goes through store_accounts() above.

@jeffwashington
Copy link
Contributor Author

Since rent collection is calling store_accounts, it looks like the stakes cache may be updated. However, I recall us putting in logging and maybe asserts for verifying the stakes cache was consistent with accounts db. We found that while we were skipping slots due to rewards calculation taking so long, accounts that had passed their rent collection slot in the new epoch had a differing rent_epoch field in accounts db than the stakes cache. I assume the stakes cache is as of the first slot in the new epoch somehow? I'm not sure why rent collection was not updating the stakes cache when we were advancing rent_epoch prior to activation of #26479. Do we still have asserts on cache validity?

@behzadnouri
Copy link
Contributor

accounts that had passed their rent collection slot in the new epoch had a differing rent_epoch field in accounts db than the stakes cache

Wasn't this due to some rent_epoch adjustments during load time?

I assume the stakes cache is as of the first slot in the new epoch somehow?

no, this is not true. The stakes-cache should be in sync with the accounts-db after each every write (so every slot).

I'm not sure why rent collection was not updating the stakes cache when we were advancing rent_epoch prior to activation of #26479.

again, my recollection is that accounts-db load was adjusting rent-epoch at load time.

Do we still have asserts on cache validity?

yes, we do; this is at startup when bank is deserialized:
https://github.com/solana-labs/solana/blob/1c7662a37/runtime/src/stakes.rs#L224-L272

and then there are some at epoch boundary rewards calculation:
https://github.com/solana-labs/solana/blob/1c7662a37/runtime/src/bank.rs#L1131-L1133

@jeffwashington
Copy link
Contributor Author

Wasn't this due to some rent_epoch adjustments during load time?

That sounds correct. All that load time rent_epoch adjustment code has been removed, so that is good news.

@jeffwashington
Copy link
Contributor Author

jeffwashington commented Jan 24, 2023

Interestingly, we are still not verifying rent_epoch matches:

// Ignoring rent_epoch until the feature for
// preserve_rent_epoch_for_rent_exempt_accounts is activated.
let vote_account = vote_account.account();
if vote_account.lamports() != account.lamports()
|| vote_account.owner() != account.owner()
|| vote_account.executable() != account.executable()
|| vote_account.data() != account.data()

So stakes cache verification will not assert/error EVEN IF there is a mismatch here.
rent_epoch will then be corrected in the stakes cache the next time rent is collected for each account.

@behzadnouri
Copy link
Contributor

Interestingly, we are still not verifying rent_epoch matches:

So stakes cache verification will not assert/error EVEN IF there is a mismatch here. rent_epoch will then be corrected in the stakes cache the next time rent is collected for each account.

That is just some legacy code that I am getting rid of here: #29861

We do actually check rent_epoch at epoch boundary rewards calculation.

@behzadnouri
Copy link
Contributor

@jeffwashington
Copy link
Contributor Author

ok. the reason the cache was out of date previously was because of this:
https://github.com/jeffwashington/solana/blob/d33d0213bb549634873ec8618ca29ce446cd3c11/runtime/src/bank.rs#L6437-L6445
That was required to support some validators skipping rewrites while others didn’t. We decided later not to go with that approach and this code was ripped out. With the code ripped out manually, the stakes cache is correctly kept up to date as of that change.
When rent collection runs, I believe the stakes cache is updated correctly. Therefore, since loading for tx (when we collect rent) and rent collection (from bank freeze) and creation are the places where we set the rent_epoch to max, the stakes cache should be kept up to date with the code in master now.

I'm testing this now.

@jeffwashington
Copy link
Contributor Author

I have reproduced and confirmed why we had the original discrepancy and why that issue is not present anymore in any form we know of.
I applied that same test case to today's code and had the feature activation occur for this rent_epoch max feature. I confirmed that the stakes cache remains perfectly up to date and should always have the correct rent_epoch value before and after the feature activation.

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.

5 participants