Skip to content

Commit

Permalink
Nomos http API (#476)
Browse files Browse the repository at this point in the history
* Info api

* Da blob api (#487)

* Add storage api for new http backend (#488)

* Mempool add APIs (#489)
  • Loading branch information
al8n authored Nov 1, 2023
1 parent ff8fc57 commit ba90ed1
Show file tree
Hide file tree
Showing 18 changed files with 374 additions and 63 deletions.
2 changes: 1 addition & 1 deletion consensus-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ default = []
serde = ["dep:serde", "nomos-utils/serde"]
simulation = []

openapi = ["dep:utoipa", "serde_json"]
openapi = ["dep:utoipa", "serde_json", "serde"]

[dev-dependencies]
proptest = "1.2.0"
Expand Down
10 changes: 10 additions & 0 deletions consensus-engine/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub use view::View;
/// can't be directly used in the network as they lack things like cryptographic signatures.
#[derive(Debug, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum Payload {
/// Vote for a block in a view
Vote(Vote),
Expand All @@ -32,13 +33,15 @@ pub enum Payload {
/// Returned
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct Vote {
pub view: View,
pub block: BlockId,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct Timeout {
pub view: View,
pub sender: NodeId,
Expand All @@ -50,6 +53,7 @@ pub struct Timeout {
// We should consider to remove the TimoutQc from the NewView message and use a hash or id instead.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct NewView {
pub view: View,
pub sender: NodeId,
Expand All @@ -59,6 +63,7 @@ pub struct NewView {

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct TimeoutQc {
view: View,
high_qc: StandardQc,
Expand Down Expand Up @@ -96,6 +101,7 @@ impl TimeoutQc {

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct Block {
#[cfg_attr(feature = "serde", serde(skip))]
pub id: BlockId,
Expand All @@ -106,6 +112,7 @@ pub struct Block {

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum LeaderProof {
LeaderId { leader_id: NodeId },
}
Expand Down Expand Up @@ -136,6 +143,7 @@ pub struct Send {

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct StandardQc {
pub view: View,
pub id: BlockId,
Expand All @@ -152,13 +160,15 @@ impl StandardQc {

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct AggregateQc {
pub high_qc: StandardQc,
pub view: View,
}

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub enum Qc {
Standard(StandardQc),
Aggregated(AggregateQc),
Expand Down
1 change: 1 addition & 0 deletions consensus-engine/src/types/committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::BTreeSet;
use crate::NodeId;

#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct CommitteeId(pub(crate) [u8; 32]);

#[cfg(feature = "serde")]
Expand Down
1 change: 1 addition & 0 deletions consensus-engine/src/types/node_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[derive(Clone, Copy, Default, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct NodeId(pub(crate) [u8; 32]);

#[cfg(feature = "serde")]
Expand Down
1 change: 1 addition & 0 deletions consensus-engine/src/types/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use derive_more::{Add, AddAssign, Sub, SubAssign};
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct View(pub(crate) i64);

impl View {
Expand Down
18 changes: 14 additions & 4 deletions nodes/nomos-node-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806"
overwatch-derive = { git = "https://github.com/logos-co/Overwatch", rev = "ac28d01" }
tracing = "0.1"

# axum related dependencies
axum = { version = "0.6", optional = true }
hyper = { version = "0.14", features = ["full"], optional = true }

consensus-engine = { path = "../../consensus-engine" }
nomos-core = { path = "../../nomos-core" }
nomos-consensus = { path = "../../nomos-services/consensus" }
nomos-network = { path = "../../nomos-services/network" }
nomos-da = { path = "../../nomos-services/data-availability" }
nomos-mempool = { path = "../../nomos-services/mempool", features = ["mock", "libp2p", "openapi"] }
full-replication = { path = "../../nomos-da/full-replication", features = ["openapi"] }
nomos-storage = { path = "../../nomos-services/storage", features = ["sled"] }
nomos-libp2p = { path = "../../nomos-libp2p" }
full-replication = { path = "../../nomos-da/full-replication" }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1.33", default-features = false, features = ["sync"] }


# axum related dependencies
axum = { version = "0.6", optional = true }
hyper = { version = "0.14", features = ["full"], optional = true }


# openapi related dependencies
utoipa = "4.0"
utoipa-swagger-ui = { version = "4.0" }

Expand Down
Loading

0 comments on commit ba90ed1

Please sign in to comment.