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/// An event emitted by the consensus layer.
35#[derive(Clone, Debug, cbor::Encode, cbor::Decode)]
36pub enum Event {
37    #[cbor(rename = "staking")]
38    Staking(staking::Event),
39    // TODO: Add support for other kind of events.
40}
41
42/// BlockMetadata contains additional metadata related to the executing block.
43///
44/// The metadata is included in the form of a special transaction where this structure is the
45/// transaction body.
46#[derive(Clone, Debug, Default, PartialEq, Eq, cbor::Encode, cbor::Decode)]
47pub struct BlockMetadata {
48    /// State root after executing all logic in the block.
49    pub state_root: Hash,
50    // EventsRoot is the provable events root.
51    pub events_root: Vec<u8>,
52}