validator option: accounts-db-skip-rewrites (#24504)

This commit is contained in:
Jeff Washington (jwash) 2022-04-20 09:41:00 -05:00 committed by GitHub
parent 957849f4a5
commit cfe2177e16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -963,6 +963,13 @@ fn main() {
.validator(is_slot) .validator(is_slot)
.takes_value(true) .takes_value(true)
.help("Halt processing at the given slot"); .help("Halt processing at the given slot");
let skip_rewrites_arg = Arg::with_name("accounts_db_skip_rewrites")
.long("accounts-db-skip-rewrites")
.help(
"Accounts that are rent exempt and have no changes are not rewritten. \
This produces snapshots that older versions cannot read.",
)
.hidden(true);
let verify_index_arg = Arg::with_name("verify_accounts_index") let verify_index_arg = Arg::with_name("verify_accounts_index")
.long("verify-accounts-index") .long("verify-accounts-index")
.takes_value(false) .takes_value(false)
@ -1295,6 +1302,7 @@ fn main() {
.arg(&accounts_filler_count) .arg(&accounts_filler_count)
.arg(&accounts_filler_size) .arg(&accounts_filler_size)
.arg(&verify_index_arg) .arg(&verify_index_arg)
.arg(&skip_rewrites_arg)
.arg(&hard_forks_arg) .arg(&hard_forks_arg)
.arg(&no_accounts_db_caching_arg) .arg(&no_accounts_db_caching_arg)
.arg(&accounts_db_test_hash_calculation_arg) .arg(&accounts_db_test_hash_calculation_arg)
@ -2096,6 +2104,7 @@ fn main() {
index: Some(accounts_index_config), index: Some(accounts_index_config),
accounts_hash_cache_path: Some(ledger_path.clone()), accounts_hash_cache_path: Some(ledger_path.clone()),
filler_accounts_config, filler_accounts_config,
skip_rewrites: matches.is_present("accounts_db_skip_rewrites"),
..AccountsDbConfig::default() ..AccountsDbConfig::default()
}); });

View File

@ -134,6 +134,7 @@ pub const ACCOUNTS_DB_CONFIG_FOR_TESTING: AccountsDbConfig = AccountsDbConfig {
filler_accounts_config: FillerAccountsConfig::const_default(), filler_accounts_config: FillerAccountsConfig::const_default(),
hash_calc_num_passes: None, hash_calc_num_passes: None,
write_cache_limit_bytes: None, write_cache_limit_bytes: None,
skip_rewrites: false,
}; };
pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig { pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig {
index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS), index: Some(ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS),
@ -141,6 +142,7 @@ pub const ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS: AccountsDbConfig = AccountsDbConfig
filler_accounts_config: FillerAccountsConfig::const_default(), filler_accounts_config: FillerAccountsConfig::const_default(),
hash_calc_num_passes: None, hash_calc_num_passes: None,
write_cache_limit_bytes: None, write_cache_limit_bytes: None,
skip_rewrites: false,
}; };
pub type BinnedHashData = Vec<Vec<CalculateHashIntermediate>>; pub type BinnedHashData = Vec<Vec<CalculateHashIntermediate>>;
@ -178,6 +180,7 @@ pub struct AccountsDbConfig {
pub filler_accounts_config: FillerAccountsConfig, pub filler_accounts_config: FillerAccountsConfig,
pub hash_calc_num_passes: Option<usize>, pub hash_calc_num_passes: Option<usize>,
pub write_cache_limit_bytes: Option<u64>, pub write_cache_limit_bytes: Option<u64>,
pub skip_rewrites: bool,
} }
struct FoundStoredAccount<'a> { struct FoundStoredAccount<'a> {
@ -1014,6 +1017,9 @@ pub struct AccountsDb {
/// Keeps tracks of index into AppendVec on a per slot basis /// Keeps tracks of index into AppendVec on a per slot basis
pub accounts_index: AccountInfoAccountsIndex, pub accounts_index: AccountInfoAccountsIndex,
/// true iff rent exempt accounts are not rewritten in their normal rent collection slot
pub skip_rewrites: bool,
pub storage: AccountStorage, pub storage: AccountStorage,
pub accounts_cache: AccountsCache, pub accounts_cache: AccountsCache,
@ -1624,6 +1630,7 @@ impl AccountsDb {
AccountsDb { AccountsDb {
active_stats: ActiveStats::default(), active_stats: ActiveStats::default(),
skip_rewrites: false,
accounts_index, accounts_index,
storage: AccountStorage::default(), storage: AccountStorage::default(),
accounts_cache: AccountsCache::default(), accounts_cache: AccountsCache::default(),
@ -1716,6 +1723,10 @@ impl AccountsDb {
.as_ref() .as_ref()
.map(|config| config.filler_accounts_config) .map(|config| config.filler_accounts_config)
.unwrap_or_default(); .unwrap_or_default();
let skip_rewrites = accounts_db_config
.as_ref()
.map(|config| config.skip_rewrites)
.unwrap_or_default();
let filler_account_suffix = if filler_accounts_config.count > 0 { let filler_account_suffix = if filler_accounts_config.count > 0 {
Some(solana_sdk::pubkey::new_rand()) Some(solana_sdk::pubkey::new_rand())
@ -1725,6 +1736,7 @@ impl AccountsDb {
let paths_is_empty = paths.is_empty(); let paths_is_empty = paths.is_empty();
let mut new = Self { let mut new = Self {
paths, paths,
skip_rewrites,
cluster_type: Some(*cluster_type), cluster_type: Some(*cluster_type),
account_indexes, account_indexes,
caching_enabled, caching_enabled,

View File

@ -1540,6 +1540,13 @@ pub fn main() {
.help("Enables faster starting of validators by skipping shrink. \ .help("Enables faster starting of validators by skipping shrink. \
This option is for use during testing."), This option is for use during testing."),
) )
.arg(
Arg::with_name("accounts_db_skip_rewrites")
.long("accounts-db-skip-rewrites")
.help("Accounts that are rent exempt and have no changes are not rewritten. \
This produces snapshots that older versions cannot read.")
.hidden(true),
)
.arg( .arg(
Arg::with_name("accounts_db_cache_limit_mb") Arg::with_name("accounts_db_cache_limit_mb")
.long("accounts-db-cache-limit-mb") .long("accounts-db-cache-limit-mb")
@ -2276,6 +2283,7 @@ pub fn main() {
write_cache_limit_bytes: value_t!(matches, "accounts_db_cache_limit_mb", u64) write_cache_limit_bytes: value_t!(matches, "accounts_db_cache_limit_mb", u64)
.ok() .ok()
.map(|mb| mb * MB as u64), .map(|mb| mb * MB as u64),
skip_rewrites: matches.is_present("accounts_db_skip_rewrites"),
..AccountsDbConfig::default() ..AccountsDbConfig::default()
}; };