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 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 examples/Cargo.lock

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

4 changes: 2 additions & 2 deletions linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ where
options.long_lived_services,
chain_modes,
name,
options.chain_worker_ttl,
options.sender_chain_worker_ttl,
crate::util::non_zero_duration(options.chain_worker_ttl),
crate::util::non_zero_duration(options.sender_chain_worker_ttl),
options.prioritize_bundles_from.clone().unwrap_or_default(),
options.ignore_bundles_from.clone().unwrap_or_default(),
options.to_chain_client_options(),
Expand Down
24 changes: 12 additions & 12 deletions linera-client/src/unit_tests/chain_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ async fn test_chain_listener() -> anyhow::Result<()> {
false,
[(chain_id0, ListeningMode::FullChain)],
format!("Client node for {:.8}", chain_id0),
Duration::from_secs(30),
Duration::from_secs(1),
Some(Duration::from_secs(30)),
Some(Duration::from_secs(1)),
HashSet::new(),
HashSet::new(),
chain_client::Options::test_default(),
Expand Down Expand Up @@ -235,8 +235,8 @@ async fn test_chain_listener_follow_only() -> anyhow::Result<()> {
(chain_b_id, ListeningMode::FullChain),
],
"Client node with follow-only and owned chains".to_string(),
Duration::from_secs(30),
Duration::from_secs(1),
Some(Duration::from_secs(30)),
Some(Duration::from_secs(1)),
HashSet::new(),
HashSet::new(),
chain_client::Options::test_default(),
Expand Down Expand Up @@ -386,8 +386,8 @@ async fn test_chain_listener_admin_chain() -> anyhow::Result<()> {
false,
std::iter::empty::<(ChainId, ListeningMode)>(),
"Client node with no chains".to_string(),
Duration::from_secs(30),
Duration::from_secs(1),
Some(Duration::from_secs(30)),
Some(Duration::from_secs(1)),
HashSet::new(),
HashSet::new(),
chain_client::Options::test_default(),
Expand Down Expand Up @@ -465,8 +465,8 @@ async fn test_chain_listener_listen_command_adds_chains_to_wallet() -> anyhow::R
false,
std::iter::empty::<(ChainId, ListeningMode)>(),
"Client node with no chains".to_string(),
Duration::from_secs(30),
Duration::from_secs(1),
Some(Duration::from_secs(30)),
Some(Duration::from_secs(1)),
HashSet::new(),
HashSet::new(),
chain_client::Options::test_default(),
Expand Down Expand Up @@ -584,8 +584,8 @@ async fn test_listener_uses_autosigner_for_incoming_messages() -> anyhow::Result
false,
[(chain_id0, ListeningMode::FullChain)],
format!("Client node for {:.8}", chain_id0),
Duration::from_secs(30),
Duration::from_secs(1),
Some(Duration::from_secs(30)),
Some(Duration::from_secs(1)),
HashSet::new(),
HashSet::new(),
chain_client::Options::test_default(),
Expand Down Expand Up @@ -787,8 +787,8 @@ async fn test_chain_listener_sparse_event_download() -> anyhow::Result<()> {
false,
[(receiver_id, ListeningMode::FullChain)],
format!("Client node for {:.8}", receiver_id),
Duration::from_secs(30),
Duration::from_secs(1),
Some(Duration::from_secs(30)),
Some(Duration::from_secs(1)),
HashSet::new(),
HashSet::new(),
chain_client::Options::test_default(),
Expand Down
5 changes: 5 additions & 0 deletions linera-client/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ use linera_base::{
use linera_core::{data_types::RoundTimeout, node::NotificationStream, worker::Reason};
use tokio_stream::StreamExt as _;

/// Treats a zero `Duration` as `None` (disabled).
pub fn non_zero_duration(d: Duration) -> Option<Duration> {
(d > Duration::ZERO).then_some(d)
}

pub fn parse_json<T: serde::de::DeserializeOwned>(s: &str) -> anyhow::Result<T> {
Ok(serde_json::from_str(s.trim())?)
}
Expand Down
1 change: 1 addition & 0 deletions linera-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ proptest = { workspace = true, optional = true }
rand = { workspace = true, features = ["std_rng"] }
serde.workspace = true
serde_json.workspace = true
sync_wrapper.workspace = true
test-log = { workspace = true, optional = true }
test-strategy = { workspace = true, optional = true }
thiserror.workspace = true
Expand Down
26 changes: 18 additions & 8 deletions linera-core/src/chain_worker/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ use linera_base::{crypto::ValidatorSecretKey, identifiers::ChainId, time::Durati

use crate::CHAIN_INFO_MAX_RECEIVED_LOG_ENTRIES;

/// Configuration parameters for the [`ChainWorkerState`][`super::state::ChainWorkerState`].
/// Configuration parameters for the chain worker and its owning
/// [`WorkerState`][`crate::worker::WorkerState`].
#[derive(Clone)]
pub struct ChainWorkerConfig {
/// A name used for logging.
pub nickname: String,
/// The signature key pair of the validator. The key may be missing for replicas
/// without voting rights (possibly with a partial view of chains).
pub key_pair: Option<Arc<ValidatorSecretKey>>,
Expand All @@ -24,13 +27,17 @@ pub struct ChainWorkerConfig {
/// Blocks with a timestamp this far in the future will still be accepted, but the validator
/// will wait until that timestamp before voting.
pub block_time_grace_period: Duration,
/// Idle chain workers free their memory after that duration without requests.
pub ttl: Duration,
/// TTL for sender chains.
// We don't want them to keep in memory forever since usually they're short-lived.
pub sender_chain_ttl: Duration,
/// Idle chain workers free their memory after this duration without requests.
/// `None` means no expiry (handle lives forever).
pub ttl: Option<Duration>,
/// TTL for sender chains. `None` means no expiry.
pub sender_chain_ttl: Option<Duration>,
/// The size to truncate receive log entries in chain info responses.
pub chain_info_max_received_log_entries: usize,
/// Maximum number of entries in the block cache.
pub block_cache_size: usize,
/// Maximum number of entries in the execution state cache.
pub execution_state_cache_size: usize,
/// Chain IDs whose incoming bundles should be processed first.
pub priority_bundle_origins: HashSet<ChainId>,
/// Chain IDs whose incoming bundles should be ignored.
Expand Down Expand Up @@ -63,14 +70,17 @@ impl ChainWorkerConfig {
impl Default for ChainWorkerConfig {
fn default() -> Self {
Self {
nickname: String::new(),
key_pair: None,
allow_inactive_chains: false,
allow_messages_from_deprecated_epochs: false,
long_lived_services: false,
block_time_grace_period: Default::default(),
ttl: Default::default(),
sender_chain_ttl: Default::default(),
ttl: None,
sender_chain_ttl: None,
chain_info_max_received_log_entries: CHAIN_INFO_MAX_RECEIVED_LOG_ENTRIES,
block_cache_size: crate::worker::DEFAULT_BLOCK_CACHE_SIZE,
execution_state_cache_size: crate::worker::DEFAULT_EXECUTION_STATE_CACHE_SIZE,
priority_bundle_origins: HashSet::new(),
ignored_bundle_origins: HashSet::new(),
cross_chain_message_chunk_limit: usize::MAX,
Expand Down
Loading
Loading