Skip to content
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 bin/node/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ MIDEN_NODE_VALIDATOR_INSECURE_SECRET_KEY=
MIDEN_NODE_RPC_URL=http://0.0.0.0:57291
MIDEN_NODE_DATA_DIRECTORY=./
MIDEN_NODE_ENABLE_OTEL=true
MIDEN_NTX_DATA_STORE_SCRIPT_CACHE_SIZE=
1 change: 1 addition & 0 deletions bin/node/src/commands/bundled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ impl BundledCommand {
ntx_builder.tx_prover_url,
ntx_builder.ticker_interval,
checkpoint,
ntx_builder.script_cache_size,
)
.run()
.await
Expand Down
10 changes: 10 additions & 0 deletions bin/node/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ const ENV_GENESIS_CONFIG_FILE: &str = "MIDEN_GENESIS_CONFIG_FILE";
const ENV_MAX_TXS_PER_BATCH: &str = "MIDEN_MAX_TXS_PER_BATCH";
const ENV_MAX_BATCHES_PER_BLOCK: &str = "MIDEN_MAX_BATCHES_PER_BLOCK";
const ENV_MEMPOOL_TX_CAPACITY: &str = "MIDEN_NODE_MEMPOOL_TX_CAPACITY";
const ENV_NTX_SCRIPT_CACHE_SIZE: &str = "MIDEN_NTX_DATA_STORE_SCRIPT_CACHE_SIZE";
const ENV_VALIDATOR_INSECURE_SECRET_KEY: &str = "MIDEN_NODE_VALIDATOR_INSECURE_SECRET_KEY";

const DEFAULT_NTX_TICKER_INTERVAL: Duration = Duration::from_millis(200);
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10);
const DEFAULT_NTX_SCRIPT_CACHE_SIZE: NonZeroUsize = NonZeroUsize::new(1000).unwrap();

// Formats a Duration into a human-readable string for display in clap help text.
fn duration_to_human_readable_string(duration: Duration) -> String {
Expand All @@ -65,6 +67,14 @@ pub struct NtxBuilderConfig {
value_name = "DURATION"
)]
pub ticker_interval: Duration,

#[arg(
long = "ntx-builder.script-cache-size",
env = ENV_NTX_SCRIPT_CACHE_SIZE,
value_name = "NUM",
default_value_t = DEFAULT_NTX_SCRIPT_CACHE_SIZE
)]
pub script_cache_size: NonZeroUsize,
}

/// Configuration for the Block Producer component
Expand Down
9 changes: 2 additions & 7 deletions crates/ntx-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,16 @@ pub struct NetworkTransactionBuilder {
}

impl NetworkTransactionBuilder {
/// Default cache size for note scripts.
///
/// Each cached script contains the deserialized `NoteScript` object, so the actual memory usage
/// depends on the complexity of the scripts being cached.
const DEFAULT_SCRIPT_CACHE_SIZE: NonZeroUsize = NonZeroUsize::new(1000).unwrap();

/// Creates a new instance of the network transaction builder.
pub fn new(
store_url: Url,
block_producer_url: Url,
tx_prover_url: Option<Url>,
ticker_interval: Duration,
bp_checkpoint: Arc<Barrier>,
script_cache_size: NonZeroUsize,
) -> Self {
let script_cache = LruCache::new(Self::DEFAULT_SCRIPT_CACHE_SIZE);
let script_cache = LruCache::new(script_cache_size);
let coordinator = Coordinator::new(MAX_IN_PROGRESS_TXS);
Self {
store_url,
Expand Down