Skip to content

Commit

Permalink
Added better db logger
Browse files Browse the repository at this point in the history
  • Loading branch information
markopoloparadox committed Feb 12, 2025
1 parent 17d5a22 commit 7ddd676
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 105 deletions.
17 changes: 17 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ pub struct Cli {
/// Max size cannot exceed 10_000
#[arg(long, default_value_t = 64, value_parser=kate_max_cells_size_upper_bound)]
pub kate_max_cells_size: usize,

/// Enable Transaction State RPC. This allows querying the transaction state (success or failure)
/// using only a transaction hash.
#[clap(long = "enable-tx-state-rpc", default_value_t = true)]
pub tx_state_rpc_enabled: bool,

/// The maximum number of results the transaction state RPC will return for a transaction hash.
/// If a transaction hash appears in multiple blocks, the RPC will return only the top `X` transaction states.
/// In most cases, the transaction hash is unique, so this parameter is usually irrelevant.
#[clap(long, default_value_t = 10)]
pub tx_state_rpc_max_search_results: usize,

/// The maximum number of blocks preserved and stored in the transaction state RPC database.
///
/// The default is 31 days' worth of blocks.
#[clap(long, default_value_t = 133920)]
pub tx_state_rpc_max_stored_block_count: usize,
}

fn kate_max_cells_size_upper_bound(s: &str) -> Result<usize, String> {
Expand Down
1 change: 0 additions & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ where
}

if let Some(deps) = system_rpc_deps {
println!("RPC is UP!");
io.merge(system_rpc::TransactionStateServer::into_rpc(
system_rpc::System::new(deps),
))?;
Expand Down
16 changes: 6 additions & 10 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,8 @@ pub fn new_partial(
let mut system_rpc_deps = None;
let mut tx_state_deps = None;
if tx_state_cli_deps.enabled {
let (search_send, search_recv) =
channel::<system_rpc::TxStateChannel>(tx_state_cli_deps.search_channel_capacity);

let (block_send, block_recv) =
channel::<transaction_state::BlockDetails>(tx_state_cli_deps.block_channel_capacity);
let (search_send, search_recv) = channel::<system_rpc::TxStateChannel>(10_000);
let (block_send, block_recv) = channel::<transaction_state::BlockDetails>(50_000);

let deps = transaction_state::Deps {
block_receiver: block_recv,
Expand Down Expand Up @@ -678,6 +675,7 @@ pub fn new_full_base(
rpc_handlers: rpc_handlers.clone(),
client: client.clone(),
sender: deps.block_sender.clone(),
max_stored_block_count: deps.cli.max_stored_block_count,
};

let db = transaction_state::Database::new(
Expand Down Expand Up @@ -717,11 +715,9 @@ pub fn new_full(config: Configuration, cli: Cli) -> Result<TaskManager, ServiceE
rpc_metrics_enabled: cli.kate_rpc_metrics_enabled,
};
let tx_state_cli_deps = transaction_state::CliDeps {
max_search_results: 10,
max_stored_block_count: 256,
block_channel_capacity: 50_000,
search_channel_capacity: 1024,
enabled: true,
max_search_results: cli.tx_state_rpc_max_search_results,
max_stored_block_count: cli.tx_state_rpc_max_stored_block_count,
enabled: cli.tx_state_rpc_enabled,
};
let task_manager = new_full_base(
config,
Expand Down
Loading

0 comments on commit 7ddd676

Please sign in to comment.