Skip to content

Commit cf6ecba

Browse files
authored
Validator destination (#3896)
## Motivation Essential work to close #3666. Also closes #3667. ## Proposal - Caching for the recently used blocks and other things from the storage. - Dependency resolution with a topological sort for the whole state. - Periodic routine persistence to the shared storage. - Parallelization of the exporters across threads. - Refactoring of the binary crate. - Validator destination. ## Test Plan - Unit tests for the block_processor.rs module. - For the validator destination, tests will be included in a separate PR, as part of the integration tests. ## Release Plan - Nothing to do / These changes follow the usual release cycle.
1 parent fd919c4 commit cf6ecba

File tree

18 files changed

+2319
-568
lines changed

18 files changed

+2319
-568
lines changed

Cargo.lock

Lines changed: 100 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ kube = "0.88.1"
148148
linked-hash-map = "0.5.6"
149149
log = "0.4.21"
150150
lru = "0.12.3"
151+
mini-moka = "0.10.3"
151152
nonzero_lit = "0.1.2"
152153
num-bigint = "0.4.3"
153154
num-format = "0.4.4"
@@ -163,6 +164,7 @@ prometheus = "0.13.3"
163164
prometheus-parse = "0.2.5"
164165
proptest = { version = "1.6.0", default-features = false, features = ["alloc"] }
165166
prost = "0.13.2"
167+
quick_cache = "0.6.13"
166168
quote = "1.0"
167169
rand = { version = "0.8.5", default-features = false }
168170
rand_chacha = { version = "0.3.1", default-features = false }

linera-client/src/config.rs

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use linera_execution::{
1919
};
2020
use linera_persistent as persistent;
2121
use linera_rpc::config::{
22-
ExporterServiceConfig, ValidatorInternalNetworkConfig, ValidatorPublicNetworkConfig,
22+
ExporterServiceConfig, TlsConfig, ValidatorInternalNetworkConfig, ValidatorPublicNetworkConfig,
2323
};
2424
use linera_storage::Storage;
2525
use serde::{Deserialize, Serialize};
@@ -208,15 +208,20 @@ impl GenesisConfig {
208208
/// The configuration file for the linera-exporter.
209209
#[derive(Serialize, Deserialize, Debug, Clone)]
210210
pub struct BlockExporterConfig {
211+
/// Identity for the block exporter state.
212+
pub id: u32,
213+
211214
/// The server configuration for the linera-exporter.
212215
pub service_config: ExporterServiceConfig,
213216

214217
/// The configuration file for the export destinations.
215218
#[serde(default)]
216219
pub destination_config: DestinationConfig,
217220

218-
/// Identity for the block exporter state.
219-
pub id: u32,
221+
/// The configuration file to impose various limits
222+
/// on the resources used by the linera-exporter.
223+
#[serde(default)]
224+
pub limits: LimitsConfig,
220225
}
221226

222227
/// Configuration file for the exports.
@@ -230,11 +235,60 @@ pub struct DestinationConfig {
230235
pub type DestinationId = u16;
231236

232237
/// The uri to provide export services to.
233-
#[allow(dead_code)]
234238
#[derive(Serialize, Deserialize, Debug, Clone)]
235239
pub struct Destination {
240+
/// The gRPC network protocol.
241+
pub tls: TlsConfig,
236242
/// The host name of the target destination (IP or hostname).
237243
pub endpoint: String,
238244
/// The port number of the target destination.
239245
pub port: u16,
240246
}
247+
248+
impl Destination {
249+
pub fn address(&self) -> String {
250+
let tls = match self.tls {
251+
TlsConfig::ClearText => "http",
252+
TlsConfig::Tls => "https",
253+
};
254+
255+
format!("{}://{}:{}", tls, self.endpoint, self.port)
256+
}
257+
}
258+
259+
/// The configuration file to impose various limits
260+
/// on the resources used by the linera-exporter.
261+
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
262+
pub struct LimitsConfig {
263+
/// Time period in milliseconds between periodic persistence
264+
/// to the shared storage.
265+
pub persistence_period_ms: u32,
266+
/// Maximum size of the work queue i.e. maximum number
267+
/// of blocks queued up for exports per destination.
268+
pub work_queue_size: u16,
269+
/// Maximum weight of the blob cache in megabytes.
270+
pub blob_cache_weight_mb: u16,
271+
/// Estimated number of elements for the blob cache.
272+
pub blob_cache_items_capacity: u16,
273+
/// Maximum weight of the block cache in megabytes.
274+
pub block_cache_weight_mb: u16,
275+
/// Estimated number of elements for the block cache.
276+
pub block_cache_items_capacity: u16,
277+
/// Maximum weight in megabytes for the combined
278+
/// cache, consisting of small miscellaneous items.
279+
pub auxiliary_cache_size_mb: u16,
280+
}
281+
282+
impl Default for LimitsConfig {
283+
fn default() -> Self {
284+
Self {
285+
persistence_period_ms: 299 * 1000,
286+
work_queue_size: 256,
287+
blob_cache_weight_mb: 1024,
288+
blob_cache_items_capacity: 8192,
289+
block_cache_weight_mb: 1024,
290+
block_cache_items_capacity: 8192,
291+
auxiliary_cache_size_mb: 1024,
292+
}
293+
}
294+
}

linera-service/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ colored.workspace = true
7272
comfy-table.workspace = true
7373
convert_case.workspace = true
7474
current_platform = "0.2.0"
75+
custom_debug_derive.workspace = true
76+
dashmap.workspace = true
7577
dirs.workspace = true
7678
fs-err = { workspace = true, features = ["tokio"] }
7779
fs_extra = { workspace = true, optional = true }
@@ -94,10 +96,12 @@ linera-storage.workspace = true
9496
linera-storage-service = { workspace = true, optional = true }
9597
linera-version.workspace = true
9698
linera-views.workspace = true
99+
mini-moka.workspace = true
97100
pathdiff = { workspace = true, optional = true }
98101
port-selector.workspace = true
99102
prometheus = { workspace = true, optional = true }
100103
prost = { workspace = true }
104+
quick_cache.workspace = true
101105
rand.workspace = true
102106
reqwest = { workspace = true, features = ["json"] }
103107
serde.workspace = true
@@ -177,7 +181,7 @@ required-features = ["benchmark"]
177181

178182
[[bin]]
179183
name = "linera-exporter"
180-
path = "src/linera-exporter/main.rs"
184+
path = "src/exporter/main.rs"
181185

182186
[[bench]]
183187
name = "transfers"

linera-service/src/cli_wrappers/local_net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl LocalNet {
622622
let child = self
623623
.command_for_binary("linera-exporter")
624624
.await?
625-
.arg(config_path)
625+
.args(["--config_path", &config_path])
626626
.args(["--storage", &storage.to_string()])
627627
.spawn_into()?;
628628

0 commit comments

Comments
 (0)