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

local-cluster: Custom genesis size #2427

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ use {
rand::Rng,
rayon::iter::{IntoParallelIterator, ParallelIterator},
rocksdb::{DBRawIterator, LiveFile},
solana_accounts_db::hardened_unpack::{
unpack_genesis_archive, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
},
solana_accounts_db::hardened_unpack::unpack_genesis_archive,
solana_entry::entry::{create_ticks, Entry},
solana_measure::measure::Measure,
solana_metrics::{
Expand Down Expand Up @@ -4956,6 +4954,22 @@ macro_rules! create_new_tmp_ledger {
$crate::blockstore::create_new_ledger_from_name(
$crate::tmp_ledger_name!(),
$genesis_config,
$crate::macro_reexports::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
$crate::blockstore_options::LedgerColumnOptions::default(),
)
};
}

#[macro_export]
macro_rules! create_new_tmp_ledger_with_size {
(
$genesis_config:expr,
$max_genesis_archive_unpacked_size:expr $(,)?
) => {
$crate::blockstore::create_new_ledger_from_name(
$crate::tmp_ledger_name!(),
$genesis_config,
$max_genesis_archive_unpacked_size,
$crate::blockstore_options::LedgerColumnOptions::default(),
)
};
Expand All @@ -4967,6 +4981,7 @@ macro_rules! create_new_tmp_ledger_fifo {
$crate::blockstore::create_new_ledger_from_name(
$crate::tmp_ledger_name!(),
$genesis_config,
$crate::macro_reexports::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
$crate::blockstore_options::LedgerColumnOptions {
shred_storage_type: $crate::blockstore_options::ShredStorageType::RocksFifo(
$crate::blockstore_options::BlockstoreRocksFifoOptions::new_for_tests(),
Expand All @@ -4983,6 +4998,7 @@ macro_rules! create_new_tmp_ledger_auto_delete {
$crate::blockstore::create_new_ledger_from_name_auto_delete(
$crate::tmp_ledger_name!(),
$genesis_config,
$crate::macro_reexports::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
$crate::blockstore_options::LedgerColumnOptions::default(),
)
};
Expand All @@ -4994,6 +5010,7 @@ 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::macro_reexports::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
$crate::blockstore_options::LedgerColumnOptions {
shred_storage_type: $crate::blockstore_options::ShredStorageType::RocksFifo(
$crate::blockstore_options::BlockstoreRocksFifoOptions::new_for_tests(),
Expand All @@ -5020,10 +5037,15 @@ pub(crate) fn verify_shred_slots(slot: Slot, parent: Slot, root: Slot) -> bool {
pub fn create_new_ledger_from_name(
name: &str,
genesis_config: &GenesisConfig,
max_genesis_archive_unpacked_size: u64,
column_options: LedgerColumnOptions,
) -> (PathBuf, Hash) {
let (ledger_path, blockhash) =
create_new_ledger_from_name_auto_delete(name, genesis_config, column_options);
let (ledger_path, blockhash) = create_new_ledger_from_name_auto_delete(
name,
genesis_config,
max_genesis_archive_unpacked_size,
column_options,
);
(ledger_path.into_path(), blockhash)
}

Expand All @@ -5034,13 +5056,14 @@ pub fn create_new_ledger_from_name(
pub fn create_new_ledger_from_name_auto_delete(
name: &str,
genesis_config: &GenesisConfig,
max_genesis_archive_unpacked_size: u64,
column_options: LedgerColumnOptions,
) -> (TempDir, Hash) {
let ledger_path = get_ledger_path_from_name_auto_delete(name);
let blockhash = create_new_ledger(
ledger_path.path(),
genesis_config,
MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
max_genesis_archive_unpacked_size,
column_options,
)
.unwrap();
Expand Down
5 changes: 5 additions & 0 deletions ledger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ extern crate log;
#[cfg_attr(feature = "frozen-abi", macro_use)]
#[cfg(feature = "frozen-abi")]
extern crate solana_frozen_abi_macro;

#[doc(hidden)]
pub mod macro_reexports {
pub use solana_accounts_db::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE;
}
15 changes: 11 additions & 4 deletions local-cluster/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use {
contact_info::{ContactInfo, Protocol},
gossip_service::discover_cluster,
},
solana_ledger::{create_new_tmp_ledger, shred::Shred},
solana_ledger::{create_new_tmp_ledger_with_size, shred::Shred},
solana_rpc_client::rpc_client::RpcClient,
solana_runtime::{
genesis_utils::{
Expand Down Expand Up @@ -312,9 +312,13 @@ impl LocalCluster {
.native_instruction_processors
.extend_from_slice(&config.native_instruction_processors);

let (leader_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_config);
let leader_contact_info = leader_node.info.clone();
let mut leader_config = safe_clone_config(&config.validator_configs[0]);
let (leader_ledger_path, _blockhash) = create_new_tmp_ledger_with_size!(
&genesis_config,
leader_config.max_genesis_archive_unpacked_size,
);

let leader_contact_info = leader_node.info.clone();
leader_config.rpc_addrs = Some((
leader_node.info.rpc().unwrap(),
leader_node.info.rpc_pubsub().unwrap(),
Expand Down Expand Up @@ -494,7 +498,10 @@ impl LocalCluster {
let validator_pubkey = validator_keypair.pubkey();
let validator_node = Node::new_localhost_with_pubkey(&validator_keypair.pubkey());
let contact_info = validator_node.info.clone();
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&self.genesis_config);
let (ledger_path, _blockhash) = create_new_tmp_ledger_with_size!(
&self.genesis_config,
validator_config.max_genesis_archive_unpacked_size,
);

// Give the validator some lamports to setup vote accounts
if is_listener {
Expand Down