Skip to main content

linera_core/
lib.rs

1// Copyright (c) Facebook, Inc. and its affiliates.
2// Copyright (c) Zefchain Labs, Inc.
3// SPDX-License-Identifier: Apache-2.0
4
5//! This module defines the core Linera protocol.
6//!
7//! The consensus protocol it drives is specified and proved correct in the `linera-spec` crate,
8//! which indexes both halves of the argument: safety and accountability in `linera_chain`, and
9//! progress and liveness in [`proof`], next to the client code that discharges them.
10
11#![recursion_limit = "256"]
12#![deny(missing_docs)]
13// We conditionally add autotraits to the traits here.
14#![allow(async_fn_in_trait)]
15
16mod chain_worker;
17pub use chain_worker::{
18    spawn_block_export_queue, BlockExportConfig, BlockExportHandle, ChainWorkerConfig,
19    ProcessConfirmedBlockMode,
20};
21/// The high-level client for interacting with chains and validators.
22pub mod client;
23pub use client::Client;
24/// Data types exchanged between clients, workers, and validator nodes.
25pub mod data_types;
26pub mod join_set_ext;
27mod local_node;
28/// Traits for communicating with validator nodes.
29pub mod node;
30/// Utilities for notifying subscribers about chain events.
31pub mod notifier;
32pub mod proof;
33/// A validator node paired with the validator's public key.
34pub mod remote_node;
35/// Helpers for writing tests against the core protocol.
36#[cfg(with_testing)]
37#[path = "unit_tests/test_utils.rs"]
38pub mod test_utils;
39/// The worker that validates and processes blocks and certificates for chains.
40pub mod worker;
41
42pub(crate) mod updater;
43
44pub use local_node::LocalNodeError;
45pub use updater::DEFAULT_QUORUM_GRACE_PERIOD;
46
47pub use crate::join_set_ext::{JoinSetExt, TaskHandle};
48
49/// The execution environment tying together storage, networking, signing, and the wallet.
50pub mod environment;
51/// The genesis configuration describing a network's initial chains and committee.
52pub mod genesis_config;
53pub use environment::{
54    wallet::{self, Wallet},
55    Environment,
56};
57pub use genesis_config::GenesisConfig;
58
59/// The maximum number of entries in a `received_log` included in a `ChainInfo` response.
60// TODO(#4638): Revisit the number.
61pub const CHAIN_INFO_MAX_RECEIVED_LOG_ENTRIES: usize = 20_000;
62
63/// Registers every metric this crate declares.
64///
65/// Without this, a metric is only exported after the code path that observes it has run, so a
66/// rarely-taken path leaves its panels blank and makes a routine restart look like the metric
67/// was removed.
68#[cfg(with_metrics)]
69pub fn init_metrics() {
70    linera_base::init_metrics();
71    linera_cache::init_metrics();
72    linera_chain::init_metrics();
73    linera_execution::init_metrics();
74    linera_storage::init_metrics();
75    linera_views::init_metrics();
76    chain_worker::export::metrics::init_metrics();
77    chain_worker::state::metrics::init_metrics();
78    client::metrics::init_metrics();
79    client::requests_scheduler::init_metrics();
80    updater::metrics::init_metrics();
81    worker::metrics::init_metrics();
82}