From b1f8a89da54cb11ecf14a053b9ea62ada1a3f1ea Mon Sep 17 00:00:00 2001 From: HaoranYi Date: Mon, 29 Jan 2024 09:00:40 -0600 Subject: [PATCH 01/13] Fix bank new_from_field for epoch reward status (#34992) * fix bank new_from_field for epoch reward status * fix bank serde test assert for epoch reward status --------- Co-authored-by: HaoranYi --- runtime/src/bank.rs | 2 +- runtime/src/bank/serde_snapshot.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index e7b17913e3aa57..da2bc0fce84b87 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1853,7 +1853,7 @@ impl Bank { fields.epoch, ))), check_program_modification_slot: false, - epoch_reward_status: EpochRewardStatus::default(), + epoch_reward_status: fields.epoch_reward_status, }; bank.finish_init( genesis_config, diff --git a/runtime/src/bank/serde_snapshot.rs b/runtime/src/bank/serde_snapshot.rs index ca6c6ee6adebd8..df51d31e568cee 100644 --- a/runtime/src/bank/serde_snapshot.rs +++ b/runtime/src/bank/serde_snapshot.rs @@ -411,7 +411,7 @@ mod tests { ); // assert epoch_reward_status is the same as the set epoch reward status - let epoch_reward_status = bank + let epoch_reward_status = dbank .get_epoch_reward_status_to_serialize() .unwrap_or(&EpochRewardStatus::Inactive); if let Some(rewards) = epoch_reward_status_active { @@ -504,7 +504,7 @@ mod tests { ); // assert epoch_reward_status is the same as the set epoch reward status - let epoch_reward_status = bank + let epoch_reward_status = dbank .get_epoch_reward_status_to_serialize() .unwrap_or(&EpochRewardStatus::Inactive); if let Some(rewards) = epoch_reward_status_active { @@ -593,7 +593,7 @@ mod tests { assert_eq!(0, dbank.fee_rate_governor.lamports_per_signature); // epoch_reward status should default to `Inactive` - let epoch_reward_status = bank + let epoch_reward_status = dbank .get_epoch_reward_status_to_serialize() .unwrap_or(&EpochRewardStatus::Inactive); assert_matches!(epoch_reward_status, EpochRewardStatus::Inactive); From 16a2f1bd3dc5a0786e9ea50e821462f010e7366a Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang <93241502+yhchiang-sol@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:05:47 -0800 Subject: [PATCH 02/13] [TS] Add get_account() and account_matches_owner() to TieredStorageReader (#34968) #### Problem TieredStorageReader is a wrapper enum that works for both Hot and Cold storage readers, but its get_account() and account_matches_owner() API are missing. #### Summary of Changes Add get_account() and account_matches_owner() to TieredStorageReader. #### Test Plan hot.rs offers similar coverage for HotStorageReader. --- accounts-db/src/tiered_storage/hot.rs | 2 +- accounts-db/src/tiered_storage/readable.rs | 37 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/accounts-db/src/tiered_storage/hot.rs b/accounts-db/src/tiered_storage/hot.rs index 730ace5aa310ed..311da9916785f6 100644 --- a/accounts-db/src/tiered_storage/hot.rs +++ b/accounts-db/src/tiered_storage/hot.rs @@ -326,7 +326,7 @@ impl HotStorageReader { } /// Returns the offset to the account given the specified index. - fn get_account_offset( + pub(super) fn get_account_offset( &self, index_offset: IndexOffset, ) -> TieredStorageResult { diff --git a/accounts-db/src/tiered_storage/readable.rs b/accounts-db/src/tiered_storage/readable.rs index aff29a79fb03ab..647c78d5ca91c1 100644 --- a/accounts-db/src/tiered_storage/readable.rs +++ b/accounts-db/src/tiered_storage/readable.rs @@ -1,9 +1,12 @@ use { crate::{ + account_storage::meta::StoredAccountMeta, + accounts_file::MatchAccountOwnerError, accounts_hash::AccountHash, tiered_storage::{ footer::{AccountMetaFormat, TieredStorageFooter}, hot::HotStorageReader, + index::IndexOffset, meta::TieredAccountMeta, TieredStorageResult, }, @@ -111,4 +114,38 @@ impl TieredStorageReader { Self::Hot(hot) => hot.num_accounts(), } } + + /// Returns the account located at the specified index offset. + pub fn get_account( + &self, + index_offset: u32, + ) -> TieredStorageResult, usize)>> { + match self { + Self::Hot(hot) => hot.get_account(IndexOffset(index_offset)), + } + } + + /// Returns Ok(index_of_matching_owner) if the account owner at + /// `account_offset` is one of the pubkeys in `owners`. + /// + /// Returns Err(MatchAccountOwnerError::NoMatch) if the account has 0 + /// lamports or the owner is not one of the pubkeys in `owners`. + /// + /// Returns Err(MatchAccountOwnerError::UnableToLoad) if there is any internal + /// error that causes the data unable to load, including `account_offset` + /// causes a data overrun. + pub fn account_matches_owners( + &self, + index_offset: u32, + owners: &[Pubkey], + ) -> Result { + match self { + Self::Hot(hot) => { + let account_offset = hot + .get_account_offset(IndexOffset(index_offset)) + .map_err(|_| MatchAccountOwnerError::UnableToLoad)?; + hot.account_matches_owners(account_offset, owners) + } + } + } } From c8cdd0087f85c709cd445ee0b0e74364764b4048 Mon Sep 17 00:00:00 2001 From: Brooks Date: Mon, 29 Jan 2024 17:19:55 -0500 Subject: [PATCH 03/13] Removes pushing and pulling account hashes in gossip (#34979) --- gossip/src/cluster_info.rs | 38 +++----------------------------------- gossip/src/crds_value.rs | 9 +-------- 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 23038b0407d30e..7cddbdb5a963b1 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -32,8 +32,8 @@ use { CrdsFilter, CrdsTimeouts, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS, }, crds_value::{ - self, AccountsHashes, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, - NodeInstance, SnapshotHashes, Version, Vote, MAX_WALLCLOCK, + self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, NodeInstance, + SnapshotHashes, Version, Vote, MAX_WALLCLOCK, }, duplicate_shred::DuplicateShred, epoch_slots::EpochSlots, @@ -259,14 +259,6 @@ struct PullData { filter: CrdsFilter, } -pub fn make_accounts_hashes_message( - keypair: &Keypair, - accounts_hashes: Vec<(Slot, Hash)>, -) -> Option { - let message = CrdsData::AccountsHashes(AccountsHashes::new(keypair.pubkey(), accounts_hashes)); - Some(CrdsValue::new_signed(message, keypair)) -} - pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>; // TODO These messages should go through the gpu pipeline for spam filtering @@ -392,7 +384,6 @@ fn retain_staked(values: &mut Vec, stakes: &HashMap) { // the various dashboards. CrdsData::Version(_) => true, CrdsData::NodeInstance(_) => true, - // getHealth fails if account hashes are not propagated. CrdsData::AccountsHashes(_) => true, CrdsData::LowestSlot(_, _) | CrdsData::LegacyVersion(_) @@ -1021,19 +1012,6 @@ impl ClusterInfo { .push(message); } - pub fn push_accounts_hashes(&self, accounts_hashes: Vec<(Slot, Hash)>) { - if accounts_hashes.len() > MAX_ACCOUNTS_HASHES { - warn!( - "accounts hashes too large, ignored: {}", - accounts_hashes.len(), - ); - return; - } - - let message = CrdsData::AccountsHashes(AccountsHashes::new(self.id(), accounts_hashes)); - self.push_message(CrdsValue::new_signed(message, &self.keypair())); - } - pub fn push_snapshot_hashes( &self, full: (Slot, Hash), @@ -1221,16 +1199,6 @@ impl ClusterInfo { Ok(()) } - pub fn get_accounts_hash_for_node(&self, pubkey: &Pubkey, map: F) -> Option - where - F: FnOnce(&Vec<(Slot, Hash)>) -> Y, - { - self.time_gossip_read_lock("get_accounts_hash", &self.stats.get_accounts_hash) - .get::<&CrdsValue>(&CrdsValueLabel::AccountsHashes(*pubkey)) - .map(|x| &x.accounts_hash().unwrap().hashes) - .map(map) - } - pub fn get_snapshot_hashes_for_node(&self, pubkey: &Pubkey) -> Option { self.gossip .crds @@ -3185,7 +3153,7 @@ mod tests { super::*, crate::{ crds_gossip_pull::tests::MIN_NUM_BLOOM_FILTERS, - crds_value::{CrdsValue, CrdsValueLabel, Vote as CrdsVote}, + crds_value::{AccountsHashes, CrdsValue, CrdsValueLabel, Vote as CrdsVote}, duplicate_shred::{self, tests::new_rand_shred, MAX_DUPLICATE_SHREDS}, }, itertools::izip, diff --git a/gossip/src/crds_value.rs b/gossip/src/crds_value.rs index ad6422fc2e5188..6dcbbde2d14373 100644 --- a/gossip/src/crds_value.rs +++ b/gossip/src/crds_value.rs @@ -87,7 +87,7 @@ pub enum CrdsData { Vote(VoteIndex, Vote), LowestSlot(/*DEPRECATED:*/ u8, LowestSlot), LegacySnapshotHashes(LegacySnapshotHashes), // Deprecated - AccountsHashes(AccountsHashes), + AccountsHashes(AccountsHashes), // Deprecated EpochSlots(EpochSlotsIndex, EpochSlots), LegacyVersion(LegacyVersion), Version(Version), @@ -663,13 +663,6 @@ impl CrdsValue { } } - pub(crate) fn accounts_hash(&self) -> Option<&AccountsHashes> { - match &self.data { - CrdsData::AccountsHashes(slots) => Some(slots), - _ => None, - } - } - pub(crate) fn epoch_slots(&self) -> Option<&EpochSlots> { match &self.data { CrdsData::EpochSlots(_, slots) => Some(slots), From 9ad6198d2db6395eb8914fc38d9ef2f85163d271 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:28:59 +0800 Subject: [PATCH 04/13] build(deps): bump serde from 1.0.195 to 1.0.196 (#34996) * build(deps): bump serde from 1.0.195 to 1.0.196 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.195 to 1.0.196. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.195...v1.0.196) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * [auto-commit] Update all Cargo lock files --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot-buildkite --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- programs/sbf/Cargo.lock | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc5fcebdd70b53..5a2115c61cea7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4841,9 +4841,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] @@ -4859,9 +4859,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index e1177f23f60c80..f28cdf4949f2e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -292,7 +292,7 @@ rustversion = "1.0.14" scopeguard = "1.2.0" semver = "1.0.21" seqlock = "0.2.0" -serde = "1.0.195" +serde = "1.0.196" serde_bytes = "0.11.14" serde_derive = "1.0.103" serde_json = "1.0.111" diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index d441666b28835f..d5942d7b60163c 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -4279,9 +4279,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] @@ -4297,9 +4297,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", From 0f376254af69952e5090d085503dfa2c0d392749 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:29:24 +0800 Subject: [PATCH 05/13] build(deps): bump chrono from 0.4.32 to 0.4.33 (#34997) * build(deps): bump chrono from 0.4.32 to 0.4.33 Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.32 to 0.4.33. - [Release notes](https://github.com/chronotope/chrono/releases) - [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md) - [Commits](https://github.com/chronotope/chrono/compare/v0.4.32...v0.4.33) --- updated-dependencies: - dependency-name: chrono dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * [auto-commit] Update all Cargo lock files --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot-buildkite --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- programs/sbf/Cargo.lock | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a2115c61cea7f..489f2f0a41b07f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1064,9 +1064,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chrono" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", diff --git a/Cargo.toml b/Cargo.toml index f28cdf4949f2e4..0e55640443c733 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -170,7 +170,7 @@ bzip2 = "0.4.4" caps = "0.5.5" cargo_metadata = "0.15.4" cc = "1.0.83" -chrono = { version = "0.4.32", default-features = false } +chrono = { version = "0.4.33", default-features = false } chrono-humanize = "0.2.3" clap = "2.33.1" console = "0.15.8" diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index d5942d7b60163c..65776fb60c48c2 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -940,9 +940,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chrono" -version = "0.4.32" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", From 6666660d4c4716c2a8c476a87485d93fd0f0347b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:29:48 +0800 Subject: [PATCH 06/13] build(deps): bump hidapi from 2.5.0 to 2.5.1 (#34998) Bumps [hidapi](https://github.com/ruabmbua/hidapi-rs) from 2.5.0 to 2.5.1. - [Commits](https://github.com/ruabmbua/hidapi-rs/commits/v2.5.1) --- updated-dependencies: - dependency-name: hidapi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 489f2f0a41b07f..93c712b80eacd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2407,9 +2407,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hidapi" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b125253e27c9fd67beac20665348f4bfc5b488b5c8a1020610eeb7e6d205cde" +checksum = "830eccace7c861211d0ad04288e5dad690d6711b0db152084da58882ee7a840a" dependencies = [ "cc", "cfg-if 1.0.0", diff --git a/Cargo.toml b/Cargo.toml index 0e55640443c733..eabe122cc72a68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -212,7 +212,7 @@ gethostname = "0.2.3" getrandom = "0.2.10" goauth = "0.13.1" hex = "0.4.3" -hidapi = { version = "2.5.0", default-features = false } +hidapi = { version = "2.5.1", default-features = false } histogram = "0.6.9" hmac = "0.12.1" http = "0.2.11" From d5ab2fa1df07203387a13e98ad94fa4bb5aee053 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:30:10 +0800 Subject: [PATCH 07/13] build(deps): bump serde_json from 1.0.111 to 1.0.113 (#35000) * build(deps): bump serde_json from 1.0.111 to 1.0.113 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.111 to 1.0.113. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.111...v1.0.113) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * [auto-commit] Update all Cargo lock files --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot-buildkite --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- programs/sbf/Cargo.lock | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93c712b80eacd7..567eb3ccf992c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4870,9 +4870,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index eabe122cc72a68..095f844475fe32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -295,7 +295,7 @@ seqlock = "0.2.0" serde = "1.0.196" serde_bytes = "0.11.14" serde_derive = "1.0.103" -serde_json = "1.0.111" +serde_json = "1.0.113" serde_with = { version = "2.3.3", default-features = false } serde_yaml = "0.9.30" serial_test = "2.0.0" diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index 65776fb60c48c2..d0a8a630e415e7 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -4308,9 +4308,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", From c6c23405d6d869e9d178b04d8d125e54bdd32b1d Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Tue, 30 Jan 2024 08:38:24 -0800 Subject: [PATCH 08/13] Remove SVM dependency on Bank::should_collect_rent() (#35011) --- runtime/src/bank.rs | 1 - runtime/src/bank/tests.rs | 1 - runtime/src/svm/account_loader.rs | 22 ++++++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index da2bc0fce84b87..b5aa6db4913dcc 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -5370,7 +5370,6 @@ impl Bank { self.get_reward_interval(), &program_accounts_map, &programs_loaded_for_tx_batch.borrow(), - self.should_collect_rent(), ); load_time.stop(); diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index e19eaa9aca96ad..324fac49d277e9 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -10998,7 +10998,6 @@ fn test_rent_state_list_len() { RewardInterval::OutsideInterval, &HashMap::new(), &LoadedProgramsForTxBatch::default(), - true, ); let compute_budget = bank.runtime_config.compute_budget.unwrap_or_else(|| { diff --git a/runtime/src/svm/account_loader.rs b/runtime/src/svm/account_loader.rs index beedace9ede1ac..31ce63654670e5 100644 --- a/runtime/src/svm/account_loader.rs +++ b/runtime/src/svm/account_loader.rs @@ -22,7 +22,7 @@ use { create_executable_meta, is_builtin, is_executable, Account, AccountSharedData, ReadableAccount, WritableAccount, }, - feature_set::{include_loaded_accounts_data_size_in_fee_calculation, FeatureSet}, + feature_set::{self, include_loaded_accounts_data_size_in_fee_calculation, FeatureSet}, fee::FeeStructure, message::SanitizedMessage, native_loader, @@ -52,7 +52,6 @@ pub(crate) fn load_accounts( in_reward_interval: RewardInterval, program_accounts: &HashMap, loaded_programs: &LoadedProgramsForTxBatch, - should_collect_rent: bool, ) -> Vec { txs.iter() .zip(lock_results) @@ -87,7 +86,6 @@ pub(crate) fn load_accounts( in_reward_interval, program_accounts, loaded_programs, - should_collect_rent, ) { Ok(loaded_transaction) => loaded_transaction, Err(e) => return (Err(e), None), @@ -128,7 +126,6 @@ fn load_transaction_accounts( reward_interval: RewardInterval, program_accounts: &HashMap, loaded_programs: &LoadedProgramsForTxBatch, - should_collect_rent: bool, ) -> Result { let in_reward_interval = reward_interval == RewardInterval::InsideInterval; @@ -190,7 +187,9 @@ fn load_transaction_accounts( .load_with_fixed_root(ancestors, key) .map(|(mut account, _)| { if message.is_writable(i) { - if should_collect_rent { + if !feature_set + .is_active(&feature_set::disable_rent_fees_collection::id()) + { let rent_due = rent_collector .collect_from_existing_account( key, @@ -514,7 +513,7 @@ mod tests { lamports_per_signature: u64, rent_collector: &RentCollector, error_counters: &mut TransactionErrorMetrics, - feature_set: &FeatureSet, + feature_set: &mut FeatureSet, fee_structure: &FeeStructure, ) -> Vec { let accounts_db = AccountsDb::new_single_for_tests(); @@ -524,6 +523,7 @@ mod tests { } let ancestors = vec![(0, 0)].into_iter().collect(); + feature_set.deactivate(&feature_set::disable_rent_fees_collection::id()); let sanitized_tx = SanitizedTransaction::from_transaction_for_tests(tx); load_accounts( &accounts.accounts_db, @@ -538,7 +538,6 @@ mod tests { RewardInterval::OutsideInterval, &HashMap::new(), &LoadedProgramsForTxBatch::default(), - true, ) } @@ -565,7 +564,7 @@ mod tests { lamports_per_signature, &RentCollector::default(), error_counters, - &all_features_except(exclude_features), + &mut all_features_except(exclude_features), &FeeStructure { lamports_per_signature, ..FeeStructure::default() @@ -768,7 +767,7 @@ mod tests { lamports_per_signature, &rent_collector, &mut error_counters, - &all_features_except(None), + &mut all_features_except(None), &FeeStructure::default(), ); assert_eq!(loaded_accounts.len(), 1); @@ -784,7 +783,7 @@ mod tests { lamports_per_signature, &rent_collector, &mut error_counters, - &FeatureSet::all_enabled(), + &mut FeatureSet::all_enabled(), &FeeStructure::default(), ); assert_eq!(loaded_accounts.len(), 1); @@ -801,7 +800,7 @@ mod tests { lamports_per_signature, &rent_collector, &mut error_counters, - &FeatureSet::all_enabled(), + &mut FeatureSet::all_enabled(), &FeeStructure::default(), ); assert_eq!(loaded_accounts.len(), 1); @@ -1013,7 +1012,6 @@ mod tests { RewardInterval::OutsideInterval, &HashMap::new(), &LoadedProgramsForTxBatch::default(), - true, ) } From 15423928c1d82a635ed02db9b1ade1459bff60a5 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Tue, 30 Jan 2024 21:57:44 +0000 Subject: [PATCH 09/13] Revert "refactor unused parameter (#34970)" This reverts commit 083890928f3558b616850f863e46253c77db9b40. --- sdk/src/fee.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/src/fee.rs b/sdk/src/fee.rs index de77ac11436595..bd3af75e70da18 100644 --- a/sdk/src/fee.rs +++ b/sdk/src/fee.rs @@ -92,12 +92,13 @@ impl FeeStructure { pub fn calculate_fee( &self, message: &SanitizedMessage, - _unused: u64, + lamports_per_signature: u64, budget_limits: &FeeBudgetLimits, include_loaded_account_data_size_in_fee: bool, ) -> u64 { self.calculate_fee_details( message, + lamports_per_signature, budget_limits, include_loaded_account_data_size_in_fee, ) @@ -109,6 +110,7 @@ impl FeeStructure { pub fn calculate_fee_details( &self, message: &SanitizedMessage, + _lamports_per_signature: u64, budget_limits: &FeeBudgetLimits, include_loaded_account_data_size_in_fee: bool, ) -> FeeDetails { From df2ee120e9277acaf533b9da1d0bfbce51b20e20 Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Tue, 30 Jan 2024 21:58:42 +0000 Subject: [PATCH 10/13] Revert "separate priority fee and transaction fee from fee calculation (#34757)" This reverts commit 5ecc47ec5a8867ca04b8b616c72749329e6a3aed. --- sdk/src/fee.rs | 47 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/sdk/src/fee.rs b/sdk/src/fee.rs index bd3af75e70da18..2fb045aba5d73e 100644 --- a/sdk/src/fee.rs +++ b/sdk/src/fee.rs @@ -31,19 +31,6 @@ pub struct FeeStructure { pub compute_fee_bins: Vec, } -/// Return type of calculate_fee(...) -#[derive(Debug, Default, Clone, Eq, PartialEq)] -pub struct FeeDetails { - transaction_fee: u64, - prioritization_fee: u64, -} - -impl FeeDetails { - pub fn total_fee(&self) -> u64 { - self.transaction_fee.saturating_add(self.prioritization_fee) - } -} - pub const ACCOUNT_DATA_COST_PAGE_SIZE: u64 = 32_u64.saturating_mul(1024); impl FeeStructure { @@ -88,32 +75,15 @@ impl FeeStructure { .saturating_mul(heap_cost) } + /// Calculate fee for `SanitizedMessage` #[cfg(not(target_os = "solana"))] pub fn calculate_fee( - &self, - message: &SanitizedMessage, - lamports_per_signature: u64, - budget_limits: &FeeBudgetLimits, - include_loaded_account_data_size_in_fee: bool, - ) -> u64 { - self.calculate_fee_details( - message, - lamports_per_signature, - budget_limits, - include_loaded_account_data_size_in_fee, - ) - .total_fee() - } - - /// Calculate fee details for `SanitizedMessage` - #[cfg(not(target_os = "solana"))] - pub fn calculate_fee_details( &self, message: &SanitizedMessage, _lamports_per_signature: u64, budget_limits: &FeeBudgetLimits, include_loaded_account_data_size_in_fee: bool, - ) -> FeeDetails { + ) -> u64 { let signature_fee = message .num_signatures() .saturating_mul(self.lamports_per_signature); @@ -145,13 +115,12 @@ impl FeeStructure { .unwrap_or_default() }); - FeeDetails { - transaction_fee: (signature_fee - .saturating_add(write_lock_fee) - .saturating_add(compute_fee) as f64) - .round() as u64, - prioritization_fee: budget_limits.prioritization_fee, - } + (budget_limits + .prioritization_fee + .saturating_add(signature_fee) + .saturating_add(write_lock_fee) + .saturating_add(compute_fee) as f64) + .round() as u64 } } From 0dcac3fe7c4832fc6f358f010ddba8a116da70ab Mon Sep 17 00:00:00 2001 From: Tao Zhu Date: Tue, 30 Jan 2024 21:59:34 +0000 Subject: [PATCH 11/13] Revert "Remove congestion multiplier from calculate fee (#34865)" This reverts commit 73d3973c7c26848c50522396962daf520be4536e. --- runtime/src/bank.rs | 11 ----------- runtime/src/bank/tests.rs | 1 + sdk/src/fee.rs | 12 ++++++++++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index b5aa6db4913dcc..6f5cd9a07f607b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6719,17 +6719,6 @@ impl Bank { &self.runtime_config.compute_budget.unwrap_or_default(), false, /* debugging_features */ )); - - // genesis_config loaded by accounts_db::open_genesis_config() from ledger - // has it's lamports_per_signature set to zero; bank sets its value correctly - // after the first block with a transaction in it. This is a hack to mimic - // the process. - let derived_fee_rate_governor = - FeeRateGovernor::new_derived(&genesis_config.fee_rate_governor, 0); - // new bank's fee_structure.lamports_per_signature should be inline with - // what's configured in GenesisConfig - self.fee_structure.lamports_per_signature = - derived_fee_rate_governor.lamports_per_signature; } pub fn set_inflation(&self, inflation: Inflation) { diff --git a/runtime/src/bank/tests.rs b/runtime/src/bank/tests.rs index 324fac49d277e9..ad28005fccfe7e 100644 --- a/runtime/src/bank/tests.rs +++ b/runtime/src/bank/tests.rs @@ -3335,6 +3335,7 @@ fn test_bank_parent_account_spend() { let key2 = Keypair::new(); let (parent, bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config); let amount = genesis_config.rent.minimum_balance(0); + println!("==== amount {}", amount); let tx = system_transaction::transfer(&mint_keypair, &key1.pubkey(), amount, genesis_config.hash()); diff --git a/sdk/src/fee.rs b/sdk/src/fee.rs index 2fb045aba5d73e..f3377b5254f0a6 100644 --- a/sdk/src/fee.rs +++ b/sdk/src/fee.rs @@ -80,10 +80,17 @@ impl FeeStructure { pub fn calculate_fee( &self, message: &SanitizedMessage, - _lamports_per_signature: u64, + lamports_per_signature: u64, budget_limits: &FeeBudgetLimits, include_loaded_account_data_size_in_fee: bool, ) -> u64 { + // Fee based on compute units and signatures + let congestion_multiplier = if lamports_per_signature == 0 { + 0.0 // test only + } else { + 1.0 // multiplier that has no effect + }; + let signature_fee = message .num_signatures() .saturating_mul(self.lamports_per_signature); @@ -115,11 +122,12 @@ impl FeeStructure { .unwrap_or_default() }); - (budget_limits + ((budget_limits .prioritization_fee .saturating_add(signature_fee) .saturating_add(write_lock_fee) .saturating_add(compute_fee) as f64) + * congestion_multiplier) .round() as u64 } } From b3ea62fba31767fae75238a714081ab924cc6fbc Mon Sep 17 00:00:00 2001 From: steviez Date: Tue, 30 Jan 2024 22:50:37 -0400 Subject: [PATCH 12/13] ledger-tool: Change --snapshot-archive-path to --snapshots (#35019) This change makes solana-ledger-tool match solana-validator CLI; the old flag --snapshot-archive-path is retained as an argument alias and can still be used for the sake of backwards compatibility. --- ledger-tool/src/main.rs | 9 +++++---- ledger-tool/src/program.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 50bc3a40263743..d4a5a3eb18ea69 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -819,12 +819,13 @@ fn main() { ), ) .arg( - Arg::with_name("snapshot_archive_path") - .long("snapshot-archive-path") + Arg::with_name("snapshots") + .long("snapshots") + .alias("snapshot-archive-path") .value_name("DIR") .takes_value(true) .global(true) - .help("Use DIR for snapshot location"), + .help("Use DIR for snapshot location [default: --ledger value]"), ) .arg( Arg::with_name("incremental_snapshot_archive_path") @@ -1420,7 +1421,7 @@ fn main() { info!("{} {}", crate_name!(), solana_version::version!()); let ledger_path = PathBuf::from(value_t_or_exit!(matches, "ledger_path", String)); - let snapshot_archive_path = value_t!(matches, "snapshot_archive_path", String) + let snapshot_archive_path = value_t!(matches, "snapshots", String) .ok() .map(PathBuf::from); let incremental_snapshot_archive_path = diff --git a/ledger-tool/src/program.rs b/ledger-tool/src/program.rs index 732c2e8fe3aaee..b56affd4c905c2 100644 --- a/ledger-tool/src/program.rs +++ b/ledger-tool/src/program.rs @@ -71,7 +71,7 @@ fn load_accounts(path: &Path) -> Result { fn load_blockstore(ledger_path: &Path, arg_matches: &ArgMatches<'_>) -> Arc { let process_options = parse_process_options(ledger_path, arg_matches); - let snapshot_archive_path = value_t!(arg_matches, "snapshot_archive_path", String) + let snapshot_archive_path = value_t!(arg_matches, "snapshots", String) .ok() .map(PathBuf::from); let incremental_snapshot_archive_path = From 056930483531424f2ef584be8aeaa1cee56b0db7 Mon Sep 17 00:00:00 2001 From: Brooks Date: Wed, 31 Jan 2024 10:52:59 -0500 Subject: [PATCH 13/13] Replaces bare Arc::default() in CacheHashData::new() (#35017) --- accounts-db/src/cache_hash_data.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts-db/src/cache_hash_data.rs b/accounts-db/src/cache_hash_data.rs index e9675b9fd22798..a0e8507c50520e 100644 --- a/accounts-db/src/cache_hash_data.rs +++ b/accounts-db/src/cache_hash_data.rs @@ -214,7 +214,7 @@ impl CacheHashData { cache_dir, pre_existing_cache_files: Arc::new(Mutex::new(HashSet::default())), deletion_policy, - stats: Arc::default(), + stats: Arc::new(CacheHashDataStats::default()), }; result.get_cache_files();