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

Banking tracer with simulator wip #2

Draft
wants to merge 140 commits into
base: banking-tracer
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
ff90402
replay code and age skip hack
ryoqun Dec 10, 2022
17befa7
save
ryoqun Dec 11, 2022
dfa3b3d
save
ryoqun Dec 11, 2022
b94e74d
save
ryoqun Dec 11, 2022
f10678d
save
ryoqun Dec 11, 2022
019e3ba
save
ryoqun Dec 11, 2022
556895d
save
ryoqun Dec 11, 2022
e0e9161
save
ryoqun Dec 11, 2022
a5fab1b
save
ryoqun Dec 11, 2022
09f3bdc
save
ryoqun Dec 11, 2022
82c51e0
save
ryoqun Dec 11, 2022
340da64
save
ryoqun Dec 12, 2022
ccedae6
save
ryoqun Dec 12, 2022
fa017cf
save
ryoqun Dec 12, 2022
b6cd9e4
save
ryoqun Dec 12, 2022
2b7eaec
save
ryoqun Dec 12, 2022
5203d11
save
ryoqun Dec 12, 2022
ca6a380
save
ryoqun Dec 12, 2022
ff4c2bd
save
ryoqun Dec 12, 2022
12d64ad
save
ryoqun Dec 12, 2022
ccc6f68
save
ryoqun Dec 12, 2022
8dbab25
save
ryoqun Dec 12, 2022
e7fb99a
save
ryoqun Dec 12, 2022
4563ef8
save
ryoqun Dec 12, 2022
865fb11
save
ryoqun Dec 12, 2022
3b5d36b
save
ryoqun Dec 12, 2022
0448fbe
save
ryoqun Dec 12, 2022
1499ac8
save
ryoqun Dec 12, 2022
4e14498
save
ryoqun Dec 12, 2022
2824dc2
save
ryoqun Dec 12, 2022
bd44fa3
save
ryoqun Dec 12, 2022
708dbab
save
ryoqun Dec 12, 2022
26f477e
save
ryoqun Dec 12, 2022
da66722
save
ryoqun Dec 12, 2022
f5e8ca2
save
ryoqun Dec 12, 2022
34ea2e6
save
ryoqun Dec 12, 2022
a6b4703
save
ryoqun Dec 12, 2022
d7f93e9
save
ryoqun Dec 12, 2022
f2bffd6
save
ryoqun Dec 12, 2022
bac0950
save
ryoqun Dec 12, 2022
1db142a
save
ryoqun Dec 12, 2022
7f35f81
save
ryoqun Dec 12, 2022
48b56c8
save
ryoqun Dec 12, 2022
6b45107
save
ryoqun Dec 12, 2022
796911e
save
ryoqun Dec 12, 2022
7da853a
save
ryoqun Dec 12, 2022
eeb4781
save
ryoqun Dec 12, 2022
fb65dd2
save
ryoqun Dec 12, 2022
a5f8b0d
save
ryoqun Dec 12, 2022
eb181ad
save
ryoqun Dec 12, 2022
aa28dd4
save
ryoqun Dec 12, 2022
0c8eef3
save
ryoqun Dec 12, 2022
6d19969
save
ryoqun Dec 12, 2022
d21e56d
save
ryoqun Dec 12, 2022
5883c5b
save
ryoqun Dec 12, 2022
18833bb
save
ryoqun Dec 12, 2022
e41c1ab
save
ryoqun Dec 12, 2022
95a7d14
save
ryoqun Dec 12, 2022
34f5b3e
save
ryoqun Dec 12, 2022
c3a71ed
save
ryoqun Dec 12, 2022
c7ada9c
save
ryoqun Dec 12, 2022
1747cc5
save
ryoqun Dec 12, 2022
1a8d102
save
ryoqun Dec 12, 2022
0bb4703
save
ryoqun Dec 12, 2022
44a6e29
save
ryoqun Dec 12, 2022
ae3e73c
save
ryoqun Dec 12, 2022
f876999
save
ryoqun Dec 12, 2022
5b0ba00
save
ryoqun Dec 12, 2022
f2d11fd
save
ryoqun Dec 12, 2022
83c6c89
save
ryoqun Dec 12, 2022
fa7e44b
save
ryoqun Dec 12, 2022
80337c5
save
ryoqun Dec 12, 2022
8638e1d
save
ryoqun Dec 12, 2022
2818703
save
ryoqun Dec 12, 2022
59a8bd4
save
ryoqun Dec 12, 2022
fcf5cb6
save
ryoqun Dec 12, 2022
b8b2434
save
ryoqun Dec 12, 2022
23638c9
save
ryoqun Dec 12, 2022
ad692ef
save
ryoqun Dec 12, 2022
6a9580c
save
ryoqun Dec 12, 2022
5e60f9a
save
ryoqun Dec 12, 2022
dc19501
save
ryoqun Dec 12, 2022
026e8a6
save
ryoqun Dec 12, 2022
6b3530a
save
ryoqun Dec 12, 2022
0d3daa5
save
ryoqun Dec 12, 2022
45b102f
save
ryoqun Dec 12, 2022
d039bf0
save
ryoqun Dec 12, 2022
6fe24aa
save
ryoqun Dec 12, 2022
ed9e489
save
ryoqun Dec 12, 2022
1ca1c9f
save
ryoqun Dec 12, 2022
45a4e45
save
ryoqun Dec 12, 2022
ec97b7b
save
ryoqun Dec 12, 2022
b660e09
save
ryoqun Dec 12, 2022
a158097
save
ryoqun Dec 12, 2022
1dfc7b5
save
ryoqun Dec 12, 2022
9ce0c4d
odd tx count regression?
ryoqun Dec 14, 2022
b38f4fe
Revert "odd tx count regression?"
ryoqun Dec 14, 2022
06cb8cc
fix odd retrace file truncation bug
ryoqun Dec 14, 2022
09fa8b3
Count tx count by channel label
ryoqun Dec 15, 2022
7dcd48a
Bank thread cont fix
ryoqun Dec 15, 2022
7b9a797
Show delta from reference time
ryoqun Dec 15, 2022
53a03fc
min bank start
ryoqun Dec 15, 2022
71459d7
simulate timed sending...
ryoqun Dec 15, 2022
41ea552
Exit before joining sender_thread
ryoqun Dec 15, 2022
ad54913
Properly create PohRecorder
ryoqun Dec 15, 2022
e9894a2
Properly create PohRecorder fixes
ryoqun Dec 15, 2022
c932508
Properly create PohRecorder tune again
ryoqun Dec 15, 2022
960f241
Implement unprocessed upfront population...
ryoqun Dec 15, 2022
34e3e19
Support blockhash override for simulation
ryoqun Dec 15, 2022
dbe4bd5
save
ryoqun Dec 16, 2022
3e4b566
save
ryoqun Dec 16, 2022
b351e7f
save
ryoqun Dec 16, 2022
0e9dc9c
save
ryoqun Dec 16, 2022
7247121
save
ryoqun Dec 16, 2022
485870e
save
ryoqun Dec 16, 2022
2dadb59
save
ryoqun Dec 16, 2022
b8d66cd
save
ryoqun Dec 16, 2022
1a59870
Support overriding with hash events
ryoqun Dec 16, 2022
3ae9714
save
ryoqun Dec 16, 2022
f3f4247
save
ryoqun Dec 21, 2022
4e1cbb1
save
ryoqun Dec 21, 2022
6b685a3
Add todo idea
ryoqun Dec 21, 2022
76844c7
Document simlation logic
ryoqun Dec 22, 2022
745b34a
don't hard leader...
ryoqun Dec 25, 2022
c6cc2d5
exit properly...
ryoqun Dec 25, 2022
28cb736
poh start from root
ryoqun Dec 25, 2022
63b8a62
poh debug
ryoqun Dec 26, 2022
7cbdf77
poh debug finished?
ryoqun Dec 26, 2022
ec253a0
warmup
ryoqun Dec 26, 2022
50fa9d3
warmup calc
ryoqun Dec 26, 2022
d71bd2c
warmup working...
ryoqun Dec 26, 2022
daf55ae
Update docs...
ryoqun Dec 26, 2022
f7f55df
Update docs...
ryoqun Dec 26, 2022
818fbfc
Update docs...
ryoqun Dec 26, 2022
6e5964f
Update docs...
ryoqun Dec 26, 2022
f7ac77b
Update docs...
ryoqun Dec 26, 2022
ddd3044
follow api change after rebase
ryoqun Jan 15, 2023
060d021
don't pass tracer to BankingStage and address todo
ryoqun Jan 15, 2023
9adf66e
Fix merge conflict...
ryoqun Jan 25, 2023
6c792d2
Disable assert for simulate-leader-blocks...
ryoqun Jan 28, 2023
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
8 changes: 6 additions & 2 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,16 @@ impl BankingStage {
TOTAL_BUFFERED_PACKETS / ((num_threads - NUM_VOTE_PROCESSING_THREADS) as usize);
// Keeps track of extraneous vote transactions for the vote threads
let latest_unprocessed_votes = Arc::new(LatestUnprocessedVotes::new());
let should_split_voting_threads = bank_forks
let mut should_split_voting_threads = bank_forks
.read()
.map(|bank_forks| {
let bank = bank_forks.root_bank();
bank.feature_set
.is_active(&allow_votes_to_directly_update_vote_state::id())
})
.unwrap_or(false);
info!("should_split_voting_threads: {}", should_split_voting_threads);
//should_split_voting_threads = false;
// Many banks that process transactions in parallel.
let bank_thread_hdls: Vec<JoinHandle<()>> = (0..num_threads)
.map(|i| {
Expand Down Expand Up @@ -479,8 +481,9 @@ impl BankingStage {
let data_budget = data_budget.clone();
let connection_cache = connection_cache.clone();
let bank_forks = bank_forks.clone();
let thread_name = format!("solBanknStgTx{i:02}");
Builder::new()
.name(format!("solBanknStgTx{i:02}"))
.name(thread_name.clone())
.spawn(move || {
Self::process_loop(
&mut packet_deserializer,
Expand All @@ -496,6 +499,7 @@ impl BankingStage {
&bank_forks,
unprocessed_transaction_storage,
);
info!("banking thread ended: {}!", thread_name);
})
.unwrap()
})
Expand Down
478 changes: 477 additions & 1 deletion core/src/banking_trace.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/packet_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl PacketDeserializer {

/// Deserialize packet batches, aggregates tracer packet stats, and collect
/// them into ReceivePacketResults
fn deserialize_and_collect_packets(
pub fn deserialize_and_collect_packets(
packet_count: usize,
banking_batches: &[BankingPacketBatch],
) -> ReceivePacketResults {
Expand Down
2 changes: 1 addition & 1 deletion core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ impl ReplayStage {
root_slot,
my_pubkey,
rpc_subscriptions,
NewBankOptions { vote_only_bank },
NewBankOptions { vote_only_bank, ..Default::default() },
);
// make sure parent is frozen for finalized hashes via the above
// new()-ing of its child bank
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl ClusterInfo {
keypair: Arc<Keypair>,
socket_addr_space: SocketAddrSpace,
) -> Self {
assert_eq!(contact_info.id, keypair.pubkey());
//assert_eq!(contact_info.id, keypair.pubkey());
let id = contact_info.id;
let me = Self {
gossip: CrdsGossip::default(),
Expand Down
96 changes: 94 additions & 2 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ use {
},
},
solana_cli_output::{CliAccount, CliAccountNewConfig, OutputFormat},
solana_core::system_monitor_service::{SystemMonitorService, SystemMonitorStatsReportConfig},
solana_core::{
banking_trace::BankingSimulator,
system_monitor_service::{SystemMonitorService, SystemMonitorStatsReportConfig},
},
solana_entry::entry::Entry,
solana_geyser_plugin_manager::geyser_plugin_service::GeyserPluginService,
solana_ledger::{
Expand Down Expand Up @@ -1196,7 +1199,7 @@ fn load_bank_forks(
.map(|_| (bank_forks, starting_snapshot_hashes));

exit.store(true, Ordering::Relaxed);
accounts_background_service.join().unwrap();
//accounts_background_service.join().unwrap();

result
}
Expand Down Expand Up @@ -2027,6 +2030,11 @@ fn main() {
.help("Snapshot archive format to use.")
.conflicts_with("no_snapshot")
)
).subcommand(
SubCommand::with_name("simulate-leader-blocks")
.about("Simulate recreating blocks with banking trace as if a leader")
.arg(&halt_at_slot_arg)
.arg(&max_genesis_archive_unpacked_size_arg)
).subcommand(
SubCommand::with_name("accounts")
.about("Print account stats and contents after processing the ledger")
Expand Down Expand Up @@ -3358,6 +3366,90 @@ fn main() {
}
}
}
("simulate-leader-blocks", Some(arg_matches)) => {
let simulator = BankingSimulator::new(PathBuf::new().join("/dev/stdin"));

if std::env::var("DUMP").is_ok() {
simulator.dump(None);
return
}

let mut accounts_index_config = AccountsIndexConfig::default();
if let Some(bins) = value_t!(arg_matches, "accounts_index_bins", usize).ok() {
accounts_index_config.bins = Some(bins);
}

accounts_index_config.index_limit_mb = if let Some(limit) =
value_t!(arg_matches, "accounts_index_memory_limit_mb", usize).ok()
{
IndexLimitMb::Limit(limit)
} else if arg_matches.is_present("disable_accounts_disk_index") {
IndexLimitMb::InMemOnly
} else {
IndexLimitMb::Unspecified
};

{
let mut accounts_index_paths: Vec<PathBuf> =
if arg_matches.is_present("accounts_index_path") {
values_t_or_exit!(arg_matches, "accounts_index_path", String)
.into_iter()
.map(PathBuf::from)
.collect()
} else {
vec![]
};
if accounts_index_paths.is_empty() {
accounts_index_paths = vec![ledger_path.join("accounts_index")];
}
accounts_index_config.drives = Some(accounts_index_paths);
}

let accounts_db_config = Some(AccountsDbConfig {
ancient_append_vec_offset: value_t!(
matches,
"accounts_db_ancient_append_vecs",
i64
)
.ok(),
skip_initial_hash_calc: arg_matches
.is_present("accounts_db_skip_initial_hash_calculation"),
..AccountsDbConfig::default()
});

let process_options = ProcessOptions {
poh_verify: false,
halt_at_slot: value_t!(arg_matches, "halt_at_slot", Slot).ok(),
accounts_db_config,
..ProcessOptions::default()
};

let blockstore = open_blockstore(
&ledger_path,
AccessType::Secondary,
wal_recovery_mode,
&shred_storage_type,
force_update_to_open,
);
let genesis_config = open_genesis_config_by(&ledger_path, arg_matches);
let (bank_forks, ..) = load_bank_forks(
arg_matches,
&genesis_config,
&blockstore,
process_options,
snapshot_archive_path,
incremental_snapshot_archive_path,
)
.unwrap_or_else(|err| {
eprintln!("Ledger verification failed: {:?}", err);
exit(1);
});

//simulator.seek(bank); => Ok or Err("no BankStart")
simulator.simulate(&genesis_config, bank_forks, Arc::new(blockstore));

println!("Ok");
}
("accounts", Some(arg_matches)) => {
let halt_at_slot = value_t!(arg_matches, "halt_at_slot", Slot).ok();
let process_options = ProcessOptions {
Expand Down
4 changes: 4 additions & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ impl Blockstore {
self.ledger_path.join("banking_trace")
}

pub fn banking_retracer_path(&self) -> PathBuf {
self.ledger_path.join("banking_retrace")
}

/// Opens a Ledger in directory, provides "infinite" window of shreds
pub fn open(ledger_path: &Path) -> Result<Blockstore> {
Self::do_open(ledger_path, BlockstoreOptions::default())
Expand Down
15 changes: 14 additions & 1 deletion poh/src/poh_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,21 @@ type Result<T> = std::result::Result<T, PohRecorderError>;

pub type WorkingBankEntry = (Arc<Bank>, (Entry, u64));

#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct BankStart {
pub working_bank: Arc<Bank>,
pub bank_creation_time: Arc<Instant>,
}

impl std::fmt::Debug for BankStart {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("BankStart")
.field("working_bank", &format!("Bank slot: {}", &self.working_bank.slot()))
.field("bank_creation_time", &self.bank_creation_time)
.finish_non_exhaustive()
}
}

impl BankStart {
fn get_working_bank_if_not_expired(&self) -> Option<&Arc<Bank>> {
if self.should_working_bank_still_be_processing_txs() {
Expand Down Expand Up @@ -351,6 +360,10 @@ impl PohRecorder {
self.ticks_per_slot
}

pub fn slot(&self) -> Slot {
self.tick_height() / self.ticks_per_slot()
}

pub fn recorder(&self) -> TransactionRecorder {
TransactionRecorder::new(self.record_sender.clone(), self.is_exited.clone())
}
Expand Down
1 change: 1 addition & 0 deletions poh/src/poh_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ impl PohService {
let poh = poh_recorder.read().unwrap().poh.clone();
let mut timing = PohTiming::new();
let mut next_record = None;
info!("starting tick producer at {}ns/(1slot={}ticks):", target_ns_per_tick * ticks_per_slot, ticks_per_slot);
loop {
let should_tick = Self::record_or_hash(
&mut next_record,
Expand Down
7 changes: 6 additions & 1 deletion runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ impl Accounts {
feature_set: &FeatureSet,
fee_structure: &FeeStructure,
account_overrides: Option<&AccountOverrides>,
lamports_per_signature_override: Option<u64>,
) -> Vec<TransactionLoadResult> {
txs.iter()
.zip(lock_results)
Expand All @@ -554,7 +555,9 @@ impl Accounts {
.unwrap_or_else(|| {
hash_queue.get_lamports_per_signature(tx.message().recent_blockhash())
});
let fee = if let Some(lamports_per_signature) = lamports_per_signature {
let fee = if let Some(lamports_per_signature) =
lamports_per_signature.or(lamports_per_signature_override)
{
Bank::calculate_fee(
tx.message(),
lamports_per_signature,
Expand Down Expand Up @@ -1422,6 +1425,7 @@ mod tests {
feature_set,
fee_structure,
None,
None,
)
}

Expand Down Expand Up @@ -3078,6 +3082,7 @@ mod tests {
&FeatureSet::all_enabled(),
&FeeStructure::default(),
account_overrides,
None,
)
}

Expand Down
Loading