feat: use human-readable byte sizes and durations

This commit is contained in:
Daniil Polyakov
2026-02-26 16:25:24 +03:00
parent 8b5524901c
commit 437e5addb4
35 changed files with 154 additions and 134 deletions
+10 -10
View File
@@ -1,4 +1,4 @@
use std::{net::SocketAddr, path::PathBuf};
use std::{net::SocketAddr, path::PathBuf, time::Duration};
use anyhow::{Context, Result};
use bytesize::ByteSize;
@@ -20,13 +20,13 @@ pub fn indexer_config(
) -> Result<IndexerConfig> {
Ok(IndexerConfig {
home,
consensus_info_polling_interval_millis: 10000,
consensus_info_polling_interval: Duration::from_secs(1),
bedrock_client_config: ClientConfig {
addr: addr_to_url(UrlProtocol::Http, bedrock_addr)
.context("Failed to convert bedrock addr to URL")?,
auth: None,
backoff: BackoffConfig {
start_delay_millis: 100,
start_delay: Duration::from_millis(100),
max_retries: 10,
},
},
@@ -42,7 +42,7 @@ pub struct SequencerPartialConfig {
pub max_num_tx_in_block: usize,
pub max_block_size: ByteSize,
pub mempool_max_size: usize,
pub block_create_timeout_millis: u64,
pub block_create_timeout: Duration,
}
impl Default for SequencerPartialConfig {
@@ -51,7 +51,7 @@ impl Default for SequencerPartialConfig {
max_num_tx_in_block: 20,
max_block_size: ByteSize::mib(1),
mempool_max_size: 10_000,
block_create_timeout_millis: 10_000,
block_create_timeout: Duration::from_secs(10),
}
}
}
@@ -67,7 +67,7 @@ pub fn sequencer_config(
max_num_tx_in_block,
max_block_size,
mempool_max_size,
block_create_timeout_millis,
block_create_timeout,
} = partial;
Ok(SequencerConfig {
@@ -78,15 +78,15 @@ pub fn sequencer_config(
max_num_tx_in_block,
max_block_size,
mempool_max_size,
block_create_timeout_millis,
retry_pending_blocks_timeout_millis: 120_000,
block_create_timeout,
retry_pending_blocks_timeout: Duration::from_secs(120),
port: 0,
initial_accounts: initial_data.sequencer_initial_accounts(),
initial_commitments: initial_data.sequencer_initial_commitments(),
signing_key: [37; 32],
bedrock_config: BedrockConfig {
backoff: BackoffConfig {
start_delay_millis: 100,
start_delay: Duration::from_millis(100),
max_retries: 5,
},
channel_id: bedrock_channel_id(),
@@ -107,7 +107,7 @@ pub fn wallet_config(
override_rust_log: None,
sequencer_addr: addr_to_url(UrlProtocol::Http, sequencer_addr)
.context("Failed to convert sequencer addr to URL")?,
seq_poll_timeout_millis: 30_000,
seq_poll_timeout: Duration::from_secs(30),
seq_tx_poll_max_blocks: 15,
seq_poll_max_retries: 10,
seq_block_poll_max_amount: 100,
+3 -3
View File
@@ -16,7 +16,7 @@ async fn reject_oversized_transaction() -> Result<()> {
max_num_tx_in_block: 100,
max_block_size: ByteSize::mib(1),
mempool_max_size: 1000,
block_create_timeout_millis: 10_000,
block_create_timeout: Duration::from_secs(10),
})
.build()
.await?;
@@ -57,7 +57,7 @@ async fn accept_transaction_within_limit() -> Result<()> {
max_num_tx_in_block: 100,
max_block_size: ByteSize::mib(1),
mempool_max_size: 1000,
block_create_timeout_millis: 10_000,
block_create_timeout: Duration::from_secs(10),
})
.build()
.await?;
@@ -99,7 +99,7 @@ async fn transaction_deferred_to_next_block_when_current_full() -> Result<()> {
max_num_tx_in_block: 100,
max_block_size: block_size,
mempool_max_size: 1000,
block_create_timeout_millis: 10_000,
block_create_timeout: Duration::from_secs(10),
})
.build()
.await?;
+7 -7
View File
@@ -8,22 +8,22 @@ use wallet::cli::{Command, config::ConfigSubcommand};
async fn modify_config_field() -> Result<()> {
let mut ctx = TestContext::new().await?;
let old_seq_poll_timeout_millis = ctx.wallet().config().seq_poll_timeout_millis;
let old_seq_poll_timeout = ctx.wallet().config().seq_poll_timeout;
// Change config field
let command = Command::Config(ConfigSubcommand::Set {
key: "seq_poll_timeout_millis".to_string(),
value: "1000".to_string(),
key: "seq_poll_timeout".to_string(),
value: "1s".to_string(),
});
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
let new_seq_poll_timeout_millis = ctx.wallet().config().seq_poll_timeout_millis;
assert_eq!(new_seq_poll_timeout_millis, 1000);
let new_seq_poll_timeout = ctx.wallet().config().seq_poll_timeout;
assert_eq!(new_seq_poll_timeout, std::time::Duration::from_secs(1));
// Return how it was at the beginning
let command = Command::Config(ConfigSubcommand::Set {
key: "seq_poll_timeout_millis".to_string(),
value: old_seq_poll_timeout_millis.to_string(),
key: "seq_poll_timeout".to_string(),
value: format!("{:?}", old_seq_poll_timeout),
});
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
+1 -1
View File
@@ -181,7 +181,7 @@ impl TpsTestManager {
max_num_tx_in_block: 300,
max_block_size: ByteSize::mb(500),
mempool_max_size: 10_000,
block_create_timeout_millis: 12_000,
block_create_timeout: Duration::from_secs(12),
}
}
}