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

ledger-tool: support Geyser accounts updates #26909

Merged
merged 1 commit into from
Aug 9, 2022
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ledger-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ solana-clap-utils = { path = "../clap-utils", version = "=1.12.0" }
solana-cli-output = { path = "../cli-output", version = "=1.12.0" }
solana-core = { path = "../core", version = "=1.12.0" }
solana-entry = { path = "../entry", version = "=1.12.0" }
solana-geyser-plugin-manager = { path = "../geyser-plugin-manager", version = "=1.12.0" }
solana-ledger = { path = "../ledger", version = "=1.12.0" }
solana-logger = { path = "../logger", version = "=1.12.0" }
solana-measure = { path = "../measure", version = "=1.12.0" }
Expand Down
35 changes: 34 additions & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
crate_description, crate_name, value_t, value_t_or_exit, values_t_or_exit, App,
AppSettings, Arg, ArgMatches, SubCommand,
},
crossbeam_channel::unbounded,
dashmap::DashMap,
itertools::Itertools,
log::*,
Expand All @@ -20,6 +21,7 @@ use {
},
solana_core::system_monitor_service::SystemMonitorService,
solana_entry::entry::Entry,
solana_geyser_plugin_manager::geyser_plugin_service::GeyserPluginService,
solana_ledger::{
ancestor_iterator::AncestorIterator,
bank_forks_utils,
Expand All @@ -39,6 +41,7 @@ use {
},
accounts_db::{AccountsDbConfig, FillerAccountsConfig},
accounts_index::{AccountsIndexConfig, IndexLimitMb, ScanConfig},
accounts_update_notifier_interface::AccountsUpdateNotifier,
bank::{Bank, RewardCalculationEvent},
bank_forks::BankForks,
cost_model::CostModel,
Expand Down Expand Up @@ -926,6 +929,25 @@ fn load_bank_forks(
vec![non_primary_accounts_path]
};

let mut accounts_update_notifier = Option::<AccountsUpdateNotifier>::default();
if arg_matches.is_present("geyser_plugin_config") {
let geyser_config_files = values_t_or_exit!(arg_matches, "geyser_plugin_config", String)
.into_iter()
.map(PathBuf::from)
.collect::<Vec<_>>();

let (confirmed_bank_sender, confirmed_bank_receiver) = unbounded();
drop(confirmed_bank_sender);
Comment on lines +939 to +940
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lijunwangs can you comment on whether it's ok to setup the geyser plugin service without slot/block notifications? It looks like we expect to send block metadata notifications whenever account data notifications are enabled:

) = if account_data_notifications_enabled || transaction_notifications_enabled {

If it's ok, I think it would be better to change the confirmed_bank_receiver arg in GeyserPluginService::new to an Option and pass None instead of a receiver that will never be triggered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is currently no means to disable block/slot notifications. The plugin implementation can itself just ignore the calls when called if they decided it is needed. I think at least the slot status is needed to make determination of the accounts data, otherwise we would not know if the accounts update are really accepted by the network.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@terorie have you looked into setting up a slot status notification sender that can be used by the ledger tool? Or do you not need it for your use-case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you looked into setting up a slot status notification sender that can be used by the ledger tool?

@jstarry my end-goal is making the ledger-tool verify callback stream a drop-in replacement for validator. I thought it makes sense to split functionality into separate PRs but I'm happy to add all 3 (slot updates, accounts, transactions) to this one.

Or do you not need it for your use-case?

I only need account updates (for https://bpf.wtf/sol-state-history/) but a few users on CT reached out saying they want to backfill their Geyser infra with ledger-tool. I can see the value in only having to build a single Geyser integration for both history & real-time indexing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm happy with separate PR's, just wanted to make sure this PR puts geyser support in a useful state, which it seems it does

let geyser_service =
GeyserPluginService::new(confirmed_bank_receiver, &geyser_config_files).unwrap_or_else(
|err| {
eprintln!("Failed to setup Geyser service: {:?}", err);
exit(1);
},
);
accounts_update_notifier = geyser_service.get_accounts_update_notifier();
}

let (bank_forks, leader_schedule_cache, starting_snapshot_hashes, ..) =
bank_forks_utils::load_bank_forks(
genesis_config,
Expand All @@ -935,7 +957,7 @@ fn load_bank_forks(
snapshot_config.as_ref(),
&process_options,
None,
None,
accounts_update_notifier,
);

let pruned_banks_receiver =
Expand Down Expand Up @@ -1275,6 +1297,13 @@ fn main() {
.default_value(default_max_incremental_snapshot_archives_to_retain)
.help("The maximum number of incremental snapshot archives to hold on to when purging older snapshots.");

let geyser_plugin_args = Arg::with_name("geyser_plugin_config")
.long("geyser-plugin-config")
.value_name("FILE")
.takes_value(true)
.multiple(true)
.help("Specify the configuration file for the Geyser plugin.");

let rent = Rent::default();
let default_bootstrap_validator_lamports = &sol_to_lamports(500.0)
.max(VoteState::get_rent_exempt_reserve(&rent))
Expand Down Expand Up @@ -1559,6 +1588,7 @@ fn main() {
.arg(&allow_dead_slots_arg)
.arg(&max_genesis_archive_unpacked_size_arg)
.arg(&debug_key_arg)
.arg(&geyser_plugin_args)
.arg(
Arg::with_name("skip_poh_verify")
.long("skip-poh-verify")
Expand Down Expand Up @@ -1613,6 +1643,7 @@ fn main() {
.arg(&snapshot_version_arg)
.arg(&maximum_full_snapshot_archives_to_retain)
.arg(&maximum_incremental_snapshot_archives_to_retain)
.arg(&geyser_plugin_args)
.arg(
Arg::with_name("snapshot_slot")
.index(1)
Expand Down Expand Up @@ -1785,6 +1816,7 @@ fn main() {
.arg(&account_paths_arg)
.arg(&halt_at_slot_arg)
.arg(&hard_forks_arg)
.arg(&geyser_plugin_args)
.arg(
Arg::with_name("include_sysvars")
.long("include-sysvars")
Expand All @@ -1811,6 +1843,7 @@ fn main() {
.arg(&halt_at_slot_arg)
.arg(&hard_forks_arg)
.arg(&max_genesis_archive_unpacked_size_arg)
.arg(&geyser_plugin_args)
.arg(
Arg::with_name("warp_epoch")
.required(false)
Expand Down