From e7cf84a5935ac9a91cf3223fb06e1416cc81b906 Mon Sep 17 00:00:00 2001 From: steviez Date: Tue, 15 Mar 2022 00:07:16 -0500 Subject: [PATCH] Remove AccessType arg from create_new_ledger (#23591) Creating a new ledger implicitly means that no other process could have previously held access to it. Additionally, creating a new ledger implicitly requires writing, so it follows that Primary access is required and we can drop access type as an argument. --- genesis/src/main.rs | 6 +----- ledger-tool/src/main.rs | 1 - ledger/src/blockstore.rs | 17 +++-------------- test-validator/src/lib.rs | 1 - 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/genesis/src/main.rs b/genesis/src/main.rs index 9ccdaa8d04..cf5ea70fcd 100644 --- a/genesis/src/main.rs +++ b/genesis/src/main.rs @@ -13,10 +13,7 @@ use { }, solana_entry::poh::compute_hashes_per_tick, solana_genesis::{genesis_accounts::add_genesis_accounts, Base64Account}, - solana_ledger::{ - blockstore::create_new_ledger, - blockstore_db::{AccessType, BlockstoreAdvancedOptions}, - }, + solana_ledger::{blockstore::create_new_ledger, blockstore_db::BlockstoreAdvancedOptions}, solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, solana_sdk::{ account::{Account, AccountSharedData, ReadableAccount, WritableAccount}, @@ -632,7 +629,6 @@ fn main() -> Result<(), Box> { &ledger_path, &genesis_config, max_genesis_archive_unpacked_size, - AccessType::PrimaryOnly, BlockstoreAdvancedOptions::default(), )?; diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 0aa6733fb1..ad9aa72d57 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -1723,7 +1723,6 @@ fn main() { &output_directory, &genesis_config, solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, - AccessType::PrimaryOnly, BlockstoreAdvancedOptions::default(), ) .unwrap_or_else(|err| { diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 0aac089cb5..3b0c8bba22 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -4150,7 +4150,6 @@ pub fn create_new_ledger( ledger_path: &Path, genesis_config: &GenesisConfig, max_genesis_archive_unpacked_size: u64, - access_type: AccessType, advanced_options: BlockstoreAdvancedOptions, ) -> Result { Blockstore::destroy(ledger_path)?; @@ -4161,7 +4160,7 @@ pub fn create_new_ledger( let blockstore = Blockstore::open_with_options( ledger_path, BlockstoreOptions { - access_type, + access_type: AccessType::PrimaryOnly, recovery_mode: None, enforce_ulimit_nofile: false, advanced_options: advanced_options.clone(), @@ -4333,7 +4332,6 @@ macro_rules! create_new_tmp_ledger { $crate::blockstore::create_new_ledger_from_name( $crate::tmp_ledger_name!(), $genesis_config, - $crate::blockstore_db::AccessType::PrimaryOnly, $crate::blockstore_db::BlockstoreAdvancedOptions::default(), ) }; @@ -4345,7 +4343,6 @@ macro_rules! create_new_tmp_ledger_auto_delete { $crate::blockstore::create_new_ledger_from_name_auto_delete( $crate::tmp_ledger_name!(), $genesis_config, - $crate::blockstore_db::AccessType::PrimaryOnly, $crate::blockstore_db::BlockstoreAdvancedOptions::default(), ) }; @@ -4357,7 +4354,6 @@ macro_rules! create_new_tmp_ledger_fifo_auto_delete { $crate::blockstore::create_new_ledger_from_name_auto_delete( $crate::tmp_ledger_name!(), $genesis_config, - $crate::blockstore_db::AccessType::PrimaryOnly, $crate::blockstore_db::BlockstoreAdvancedOptions { shred_storage_type: $crate::blockstore_db::ShredStorageType::RocksFifo( $crate::blockstore_db::BlockstoreRocksFifoOptions::default(), @@ -4392,15 +4388,10 @@ pub fn verify_shred_slots(slot: Slot, parent_slot: Slot, last_root: Slot) -> boo pub fn create_new_ledger_from_name( name: &str, genesis_config: &GenesisConfig, - access_type: AccessType, advanced_options: BlockstoreAdvancedOptions, ) -> (PathBuf, Hash) { - let (ledger_path, blockhash) = create_new_ledger_from_name_auto_delete( - name, - genesis_config, - access_type, - advanced_options, - ); + let (ledger_path, blockhash) = + create_new_ledger_from_name_auto_delete(name, genesis_config, advanced_options); (ledger_path.into_path(), blockhash) } @@ -4411,7 +4402,6 @@ pub fn create_new_ledger_from_name( pub fn create_new_ledger_from_name_auto_delete( name: &str, genesis_config: &GenesisConfig, - access_type: AccessType, advanced_options: BlockstoreAdvancedOptions, ) -> (TempDir, Hash) { let ledger_path = get_ledger_path_from_name_auto_delete(name); @@ -4419,7 +4409,6 @@ pub fn create_new_ledger_from_name_auto_delete( ledger_path.path(), genesis_config, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE, - access_type, advanced_options, ) .unwrap(); diff --git a/test-validator/src/lib.rs b/test-validator/src/lib.rs index c88c63bb1e..46c90a1325 100644 --- a/test-validator/src/lib.rs +++ b/test-validator/src/lib.rs @@ -582,7 +582,6 @@ impl TestValidator { config .max_genesis_archive_unpacked_size .unwrap_or(MAX_GENESIS_ARCHIVE_UNPACKED_SIZE), - solana_ledger::blockstore_db::AccessType::PrimaryOnly, BlockstoreAdvancedOptions::default(), ) .map_err(|err| {