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

Fix/mtg-1223 improve clap implementation for Injester #381

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 8 additions & 8 deletions nft_ingester/src/bin/ingester/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ pub async fn main() -> Result<(), IngesterError> {

info!("Starting Ingester...");
info!("___________________________________",);
info!("API: {}", args.run_api);
if args.run_api {
info!("API: {}", args.run_api.unwrap_or(false));
if args.run_api.unwrap_or(false) {
info!("API port: localhost:{}", args.server_port);
}
info!("Back Filler: {}", args.run_backfiller);
info!("Bubblegum BackFiller: {}", args.run_bubblegum_backfiller);
info!("Back Filler: {}", args.run_backfiller.unwrap_or(false));
info!("Bubblegum BackFiller: {}", args.run_bubblegum_backfiller.unwrap_or(false));
info!("Gap Filler: {}", args.run_gapfiller);
info!("Run Profiling: {}", args.run_profiling);
info!("Sequence Consistent Checker: {}", args.run_sequence_consistent_checker);
Expand Down Expand Up @@ -130,7 +130,7 @@ pub async fn main() -> Result<(), IngesterError> {
let primary_rocks_storage = Arc::new(
init_primary_storage(
&args.rocks_db_path_container,
args.enable_rocks_migration,
args.enable_rocks_migration.unwrap_or(false),
&args.rocks_migration_storage_path,
&metrics_state,
mutexed_tasks.clone(),
Expand Down Expand Up @@ -327,7 +327,7 @@ pub async fn main() -> Result<(), IngesterError> {
let cloned_rx = shutdown_rx.resubscribe();
let file_storage_path = args.file_storage_path_container.clone();

if args.run_api {
if args.run_api.unwrap_or(false) {
info!("Starting API (Ingester)...");
let middleware_json_downloader = args
.json_middleware_config
Expand Down Expand Up @@ -390,7 +390,7 @@ pub async fn main() -> Result<(), IngesterError> {
let shutdown_token = CancellationToken::new();

// Backfiller
if args.run_backfiller {
if args.run_backfiller.unwrap_or(false) {
info!("Start backfiller...");

let backfill_bubblegum_updates_processor = Arc::new(BubblegumTxProcessor::new(
Expand Down Expand Up @@ -425,7 +425,7 @@ pub async fn main() -> Result<(), IngesterError> {
.await,
);

if args.run_bubblegum_backfiller {
if args.run_bubblegum_backfiller.unwrap_or(false) {
info!("Runing Bubblegum backfiller (ingester)...");

if args.should_reingest {
Expand Down
6 changes: 3 additions & 3 deletions nft_ingester/src/bin/ingester/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Run indexer with minimum functionality. (without API/Back Filler/Bubblegum BackF
--pg-database-url postgres://solana:solana@localhost:5432/aura_db \
--rpc-host https://mainnet-aura.metaplex.com/{personal_rpc_key} \
--redis-connection-config '{"redis_connection_str":"redis://127.0.0.1:6379/0"}' \
--disable-api \
--disable-backfiller \
--disable-rocks-migration
--run-api false \
--run-backfiller false \
--enable-rocks-migration false

```

Expand Down
56 changes: 28 additions & 28 deletions nft_ingester/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{ArgAction, Parser, ValueEnum};
use clap::{Parser, ValueEnum};
use figment::value::Dict;
use serde::Deserialize;
use solana_sdk::commitment_config::CommitmentLevel;
Expand Down Expand Up @@ -68,13 +68,12 @@ pub struct IngesterClapArgs {
pub parallel_json_downloaders: i32,

#[clap(
long("disable-api"),
default_value_t = true,
action = ArgAction::SetFalse,
long("run-api"),
default_value = "true",
env = "RUN_API",
help = "Disable API (default: true)"
help = "Run API (default: true)"
)]
pub run_api: bool,
pub run_api: Option<bool>,

#[clap(
long("run-gapfiller"),
Expand All @@ -89,7 +88,7 @@ pub struct IngesterClapArgs {
pub gapfiller_peer_addr: Option<String>,

#[clap(
long("run-profiling"),
long,
default_value_t = false,
env = "INGESTER_RUN_PROFILING",
help = "Start profiling (default: false)"
Expand All @@ -114,16 +113,19 @@ pub struct IngesterClapArgs {
#[clap(long, env, help = "Rocks backup archives dir")]
pub rocks_backup_archives_dir: Option<String>,

// requires = "rocks_migration_storage_path" is not working because default value is true. (clap issue)
#[clap(
long("disable-rocks-migration"),
long,
env = "ENABLE_ROCKS_MIGRATION",
action = ArgAction::SetFalse,
default_value_t = true,
help = "Disable migration for rocksdb (default: true) requires: rocks_migration_storage_path"
default_value = "true",
help = "Enable migration for rocksdb (default: true) requires: rocks_migration_storage_path"
)]
pub enable_rocks_migration: Option<bool>,
#[clap(
long,
env,
requires_if("true", "enable_rocks_migration"),
help = "Migration storage path dir"
)]
pub enable_rocks_migration: bool,
#[clap(long, env, help = "Migration storage path dir")]
pub rocks_migration_storage_path: Option<String>,

#[clap(long, env, help = "Start consistent checker (default: false)")]
Expand Down Expand Up @@ -181,18 +183,17 @@ pub struct IngesterClapArgs {
#[clap(long, env, help = "#api Storage service base url")]
pub storage_service_base_url: Option<String>,

// requires = "rocks_slots_db_path" is not working because default value is true.
#[clap(
long("disable-backfiller"),
action = ArgAction::SetFalse,
long,
env = "RUN_BACKFILLER",
default_value_t = true,
help = "Disable backfiller. (default: true) requires: rocks_slots_db_path",
default_value = "true",
help = "Run backfiller. (default: true) requires: rocks_slots_db_path"
)]
pub run_backfiller: bool,
pub run_backfiller: Option<bool>,
#[clap(
long,
env,
requires_if("true", "run_backfiller"),
help = "#backfiller Path to the RocksDB instance with slots (required for the backfiller to work)"
)]
pub rocks_slots_db_path: Option<String>,
Expand All @@ -213,13 +214,12 @@ pub struct IngesterClapArgs {
pub big_table_config: Option<BigTableConfig>,

#[clap(
long("disable-bubblegum-backfiller"),
action = ArgAction::SetFalse,
long,
env = "RUN_BUBBLEGUM_BACKFILLER",
default_value_t = true,
help = "#bubbl Disable bubblegum backfiller (default: true)"
default_value = "true",
help = "#bubbl Run bubblegum backfiller (default: true)"
kstepanovdev marked this conversation as resolved.
Show resolved Hide resolved
)]
pub run_bubblegum_backfiller: bool,
pub run_bubblegum_backfiller: Option<bool>,
#[clap(
long,
env = "SHOULD_REINGEST",
Expand Down Expand Up @@ -581,18 +581,18 @@ mod tests {
assert_eq!(args.pg_max_db_connections, 100);
assert_eq!(args.sequence_consistent_checker_wait_period_sec, 60);
assert_eq!(args.parallel_json_downloaders, 100);
assert_eq!(args.run_api, true);
assert!(args.run_api.unwrap_or(false));
assert_eq!(args.run_gapfiller, false);
assert_eq!(args.run_profiling, false);
assert_eq!(args.is_restore_rocks_db, false);
assert_eq!(args.run_bubblegum_backfiller, true);
assert!(args.run_bubblegum_backfiller.unwrap_or(false));
assert_eq!(args.run_sequence_consistent_checker, false);
assert_eq!(args.should_reingest, false);
assert_eq!(args.check_proofs, false);
assert_eq!(args.check_proofs_commitment, CommitmentLevel::Finalized);
assert_eq!(args.archives_dir, "/rocksdb/_rocks_backup_archives");
assert_eq!(args.skip_check_tree_gaps, false);
assert_eq!(args.run_backfiller, true);
assert!(args.run_backfiller.unwrap_or(false));
assert_eq!(args.backfiller_source_mode, BackfillerSourceMode::RPC);
assert_eq!(args.heap_path, "/usr/src/app/heaps");
assert_eq!(args.log_level, "info");
Expand Down
Loading