oasis_core_runtime/consensus/
mod.rs

1//! Consensus service interfaces.
2
3use crate::common::crypto::hash::Hash;
4
5pub mod address;
6pub mod beacon;
7pub mod governance;
8pub mod keymanager;
9pub mod registry;
10pub mod roothash;
11pub mod scheduler;
12pub mod staking;
13pub mod state;
14pub mod tendermint;
15pub mod transaction;
16pub mod verifier;
17
18/// A unique module name for the consensus module.
19pub const MODULE_NAME: &str = "consensus";
20
21// Method name for the special block metadata transaction.
22pub const METHOD_META: &str = "consensus.Meta";
23
24/// The height that represents the most recent block height.
25pub const HEIGHT_LATEST: u64 = 0;
26
27/// Light consensus block.
28#[derive(Clone, Default, Debug, cbor::Encode, cbor::Decode)]
29pub struct LightBlock {
30    pub height: u64,
31    pub meta: Vec<u8>,
32}
33
34/// Consensus validator set.
35#[derive(Clone, Default, Debug, cbor::Encode, cbor::Decode)]
36pub struct Validators {
37    pub height: u64,
38    pub meta: Vec<u8>,
39}
40
41/// An event emitted by the consensus layer.
42#[derive(Clone, Debug, cbor::Encode, cbor::Decode)]
43pub enum Event {
44    #[cbor(rename = "staking")]
45    Staking(staking::Event),
46    // TODO: Add support for other kind of events.
47}
48
49/// BlockMetadata contains additional metadata related to the executing block.
50///
51/// The metadata is included in the form of a special transaction where this structure is the
52/// transaction body.
53#[derive(Clone, Debug, Default, PartialEq, Eq, cbor::Encode, cbor::Decode)]
54pub struct BlockMetadata {
55    /// State root after executing all logic in the block.
56    pub state_root: Hash,
57    // EventsRoot is the provable events root.
58    pub events_root: Vec<u8>,
59}