diff --git a/Dockerfile b/Dockerfile index 0063c9a8..d6389d90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,14 @@ # BUILD IMAGE --------------------------------------------------------- -FROM rust:1.76.0-slim-bullseye AS builder - -# Using backports for go 1.19 -RUN echo 'deb http://deb.debian.org/debian bullseye-backports main' \ - >> /etc/apt/sources.list - -# Dependecies for publishing documentation. -RUN apt-get update && apt-get install -yq \ - git clang +FROM rust:1.78.0-slim-bullseye AS builder WORKDIR /nomos COPY . . +# Install dependencies needed for building RocksDB. +RUN apt-get update && apt-get install -yq \ + git clang libssl-dev pkg-config + RUN cargo build --release -p nomos-node # NODE IMAGE ---------------------------------------------------------- diff --git a/compose.static.yml b/compose.static.yml index 4b604d0e..3b9bf7c2 100644 --- a/compose.static.yml +++ b/compose.static.yml @@ -1,11 +1,11 @@ version: '3.7' services: - bootstrap: container_name: bootstrap build: context: . dockerfile: testnet/Dockerfile + image: nomos:latest ports: - "3000:3000/udp" - "18080:18080/tcp" @@ -20,9 +20,7 @@ services: libp2p-node-1: container_name: libp2p_node_1 - build: - context: . - dockerfile: testnet/Dockerfile + image: nomos:latest volumes: - ./testnet:/etc/nomos depends_on: @@ -43,9 +41,7 @@ services: libp2p-node-2: container_name: libp2p_node_2 - build: - context: . - dockerfile: testnet/Dockerfile + image: nomos:latest volumes: - ./testnet:/etc/nomos depends_on: @@ -66,9 +62,7 @@ services: libp2p-node-3: container_name: libp2p_node_3 - build: - context: . - dockerfile: testnet/Dockerfile + image: nomos:latest volumes: - ./testnet:/etc/nomos depends_on: @@ -89,9 +83,7 @@ services: chatbot: container_name: chatbot - build: - context: . - dockerfile: testnet/Dockerfile + image: nomos:latest volumes: - ./testnet:/etc/nomos entrypoint: /etc/nomos/scripts/run_nomos_bot.sh diff --git a/nodes/nomos-node/src/config.rs b/nodes/nomos-node/src/config.rs index f1ce6d1b..b649c60d 100644 --- a/nodes/nomos-node/src/config.rs +++ b/nodes/nomos-node/src/config.rs @@ -8,6 +8,7 @@ use crate::DataAvailability; use crate::{Tx, Wire, MB16}; use clap::{Parser, ValueEnum}; use color_eyre::eyre::{eyre, Result}; +use cryptarchia_ledger::Coin; use hex::FromHex; use nomos_api::ApiService; use nomos_libp2p::{secp256k1::SecretKey, Multiaddr}; @@ -83,6 +84,27 @@ pub struct CryptarchiaArgs { #[clap(long = "consensus-slot-duration", env = "CONSENSUS_SLOT_DURATION")] slot_duration: Option, + + #[clap( + long = "consensus-coin-sk", + env = "CONSENSUS_COIN_SK", + requires("coin_nonce") + )] + coin_secret_key: Option, + + #[clap( + long = "consensus-coin-nonce", + env = "CONSENSUS_COIN_NONCE", + requires("coin_secret_key") + )] + coin_nonce: Option, + + #[clap( + long = "consensus-coin-value", + env = "CONSENSUS_COIN_VALUE", + requires("coin_secret_key") + )] + coin_value: Option, } #[derive(Parser, Debug, Clone)] @@ -204,6 +226,9 @@ impl Config { let CryptarchiaArgs { chain_start_time, slot_duration, + coin_secret_key, + coin_nonce, + coin_value, } = consensus_args; if let Some(start_time) = chain_start_time { @@ -215,6 +240,19 @@ impl Config { self.cryptarchia.time.slot_duration = std::time::Duration::from_secs(duration); } + if let Some(sk) = coin_secret_key { + let sk = <[u8; 32]>::from_hex(sk)?; + + let nonce = coin_nonce.expect("Should be available if coin sk provided"); + let nonce = <[u8; 32]>::from_hex(nonce)?; + + let value = coin_value.expect("Should be available if coin sk provided"); + + self.cryptarchia + .coins + .push(Coin::new(sk, nonce.into(), value.into())); + } + Ok(self) } diff --git a/nodes/nomos-node/src/lib.rs b/nodes/nomos-node/src/lib.rs index d740bf5f..b2df8fe3 100644 --- a/nodes/nomos-node/src/lib.rs +++ b/nodes/nomos-node/src/lib.rs @@ -5,8 +5,6 @@ mod tx; use color_eyre::eyre::Result; use full_replication::Certificate; use full_replication::{AbsoluteNumber, Attestation, Blob, FullReplication}; -#[cfg(feature = "metrics")] -use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService}; use api::AxumBackend; use bytes::Bytes; diff --git a/nomos-services/mempool/src/tx/metrics.rs b/nomos-services/mempool/src/tx/metrics.rs index 94e5a10c..02825ea5 100644 --- a/nomos-services/mempool/src/tx/metrics.rs +++ b/nomos-services/mempool/src/tx/metrics.rs @@ -8,7 +8,7 @@ use nomos_metrics::{ }; use overwatch_rs::services::ServiceId; // internal -use super::service::TxMempoolMsg; +use crate::MempoolMsg; #[derive(Debug, Clone, Hash, PartialEq, Eq, EncodeLabelValue)] enum MempoolMsgType { @@ -18,17 +18,17 @@ enum MempoolMsgType { MarkInBlock, } -impl From<&TxMempoolMsg> for MempoolMsgType +impl From<&MempoolMsg> for MempoolMsgType where I: 'static + Debug, K: 'static + Debug, { - fn from(event: &TxMempoolMsg) -> Self { + fn from(event: &MempoolMsg) -> Self { match event { - TxMempoolMsg::Add { .. } => MempoolMsgType::Add, - TxMempoolMsg::View { .. } => MempoolMsgType::View, - TxMempoolMsg::Prune { .. } => MempoolMsgType::Prune, - TxMempoolMsg::MarkInBlock { .. } => MempoolMsgType::MarkInBlock, + MempoolMsg::Add { .. } => MempoolMsgType::Add, + MempoolMsg::View { .. } => MempoolMsgType::View, + MempoolMsg::Prune { .. } => MempoolMsgType::Prune, + MempoolMsg::MarkInBlock { .. } => MempoolMsgType::MarkInBlock, _ => unimplemented!(), } } @@ -60,16 +60,16 @@ impl Metrics { Self { messages } } - pub(crate) fn record(&self, msg: &TxMempoolMsg) + pub(crate) fn record(&self, msg: &MempoolMsg) where I: 'static + Debug, K: 'static + Debug, { match msg { - TxMempoolMsg::Add { .. } - | TxMempoolMsg::View { .. } - | TxMempoolMsg::Prune { .. } - | TxMempoolMsg::MarkInBlock { .. } => { + MempoolMsg::Add { .. } + | MempoolMsg::View { .. } + | MempoolMsg::Prune { .. } + | MempoolMsg::MarkInBlock { .. } => { self.messages .get_or_create(&MessageLabels { label: msg.into() }) .inc(); diff --git a/testnet/Dockerfile b/testnet/Dockerfile index 446a1d25..90e287d3 100644 --- a/testnet/Dockerfile +++ b/testnet/Dockerfile @@ -1,19 +1,19 @@ # BUILD IMAGE --------------------------------------------------------- -FROM rust:1.76.0-slim-bullseye AS builder - -# Dependecies for publishing documentation. -RUN apt-get update && apt-get install -yq \ - git clang etcd-client libssl-dev pkg-config +FROM rust:1.78.0-slim-bullseye AS builder WORKDIR /nomos COPY . . +# Install dependencies needed for building RocksDB and etcd. +RUN apt-get update && apt-get install -yq \ + git clang etcd-client libssl-dev pkg-config + RUN cargo build --release --all --features metrics # NODE IMAGE ---------------------------------------------------------- -FROM bitnami/minideb:bullseye +FROM bitnami/minideb:latest LABEL maintainer="augustinas@status.im" \ source="https://github.com/logos-co/nomos-node" \ diff --git a/testnet/bootstrap_config.yaml b/testnet/bootstrap_config.yaml index fec85f37..e053891f 100644 --- a/testnet/bootstrap_config.yaml +++ b/testnet/bootstrap_config.yaml @@ -2,19 +2,45 @@ log: backend: "Stdout" format: "Json" level: "info" -consensus: - private_key: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - fountain_settings: null - overlay_settings: - nodes: [] - number_of_committees: 1 - current_leader: "0x0000000000000000000000000000000000000000000000000000000000000000" - leader: - cur: 0 - committee_membership: !Sad - entropy: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - leader_super_majority_threshold: 1 - super_majority_threshold: 1 + +cryptarchia: + config: + epoch_stake_distribution_stabilization: 3 + epoch_period_nonce_buffer: 3 + epoch_period_nonce_stabilization: 4 + consensus_config: + security_param: 10 + active_slot_coeff: 0.9 + time: + slot_duration: + secs: 5 + nanos: 0 + chain_start_time: [2024, 115, 6, 45, 44, 159214915, 0, 0, 0] + coins: + genesis_state: + lead_commitments: + - 20345e93cc65057a391893cbd88d86568efd3073156564797e4a912e4ae1c3ab + - 1594ef82f13d0b64284a9134f2f2ed3b30bca26812a69886a3f9ed737f117bd5 + - 76721421649fbf175aff27470e40f44ade69bac844abcf27215f5c0d79d2ec46 + - 06f7f2078ba6b24af7c5aae6f24889f6c609195ad796fb11b42ad6e0a3f8c10f + spend_commitments: + - 20345e93cc65057a391893cbd88d86568efd3073156564797e4a912e4ae1c3ab + - 1594ef82f13d0b64284a9134f2f2ed3b30bca26812a69886a3f9ed737f117bd5 + - 76721421649fbf175aff27470e40f44ade69bac844abcf27215f5c0d79d2ec46 + - 06f7f2078ba6b24af7c5aae6f24889f6c609195ad796fb11b42ad6e0a3f8c10f + nullifiers: [] + nonce: '0000000000000000000000000000000000000000000000000000000000000000' + slot: 0 + next_epoch_state: + epoch: 1 + nonce: '0000000000000000000000000000000000000000000000000000000000000000' + commitments: [] + total_stake: 4 + epoch_state: + epoch: 0 + nonce: '0000000000000000000000000000000000000000000000000000000000000000' + commitments: [] + total_stake: 4 network: backend: diff --git a/testnet/libp2p_config.yaml b/testnet/libp2p_config.yaml index f060adf9..fa2395fa 100644 --- a/testnet/libp2p_config.yaml +++ b/testnet/libp2p_config.yaml @@ -2,19 +2,45 @@ log: backend: "Stdout" format: "Json" level: "info" -consensus: - private_key: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - fountain_settings: null - overlay_settings: - nodes: [] - number_of_committees: 1 - current_leader: "0x0000000000000000000000000000000000000000000000000000000000000000" - leader: - cur: 0 - committee_membership: !Sad - entropy: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - leader_super_majority_threshold: 1 - super_majority_threshold: 1 + +cryptarchia: + config: + epoch_stake_distribution_stabilization: 3 + epoch_period_nonce_buffer: 3 + epoch_period_nonce_stabilization: 4 + consensus_config: + security_param: 10 + active_slot_coeff: 0.9 + time: + slot_duration: + secs: 5 + nanos: 0 + chain_start_time: [2024, 115, 6, 45, 44, 159214915, 0, 0, 0] + coins: + genesis_state: + lead_commitments: + - 20345e93cc65057a391893cbd88d86568efd3073156564797e4a912e4ae1c3ab + - 1594ef82f13d0b64284a9134f2f2ed3b30bca26812a69886a3f9ed737f117bd5 + - 76721421649fbf175aff27470e40f44ade69bac844abcf27215f5c0d79d2ec46 + - 06f7f2078ba6b24af7c5aae6f24889f6c609195ad796fb11b42ad6e0a3f8c10f + spend_commitments: + - 20345e93cc65057a391893cbd88d86568efd3073156564797e4a912e4ae1c3ab + - 1594ef82f13d0b64284a9134f2f2ed3b30bca26812a69886a3f9ed737f117bd5 + - 76721421649fbf175aff27470e40f44ade69bac844abcf27215f5c0d79d2ec46 + - 06f7f2078ba6b24af7c5aae6f24889f6c609195ad796fb11b42ad6e0a3f8c10f + nullifiers: [] + nonce: '0000000000000000000000000000000000000000000000000000000000000000' + slot: 0 + next_epoch_state: + epoch: 1 + nonce: '0000000000000000000000000000000000000000000000000000000000000000' + commitments: [] + total_stake: 4 + epoch_state: + epoch: 0 + nonce: '0000000000000000000000000000000000000000000000000000000000000000' + commitments: [] + total_stake: 4 network: backend: diff --git a/testnet/scripts/run_bootstrap_node.sh b/testnet/scripts/run_bootstrap_node.sh index 525f7f10..96fc1d7c 100755 --- a/testnet/scripts/run_bootstrap_node.sh +++ b/testnet/scripts/run_bootstrap_node.sh @@ -2,18 +2,26 @@ set -e -CONSENSUS_PRIV_KEY=$BOOTSTRAP_NODE_KEY +CONSENSUS_CHAIN_START=$(date +%s) +CONSENSUS_COIN_SK=$BOOTSTRAP_NODE_KEY +CONSENSUS_COIN_NONCE=$BOOTSTRAP_NODE_KEY +CONSENSUS_COIN_VALUE=1 DA_VOTER=$BOOTSTRAP_NODE_KEY NET_NODE_KEY=$BOOTSTRAP_NODE_KEY OVERLAY_NODES=$(/etc/nomos/scripts/consensus_node_list.sh) -export CONSENSUS_PRIV_KEY \ +export CONSENSUS_COIN_SK \ + CONSENSUS_COIN_NONCE \ + CONSENSUS_COIN_VALUE \ + CONSENSUS_CHAIN_START \ DA_VOTER \ OVERLAY_NODES \ NET_NODE_KEY echo "I am a container ${HOSTNAME} node ${NET_NODE_KEY}" -echo "CONSENSUS_PRIV_KEY: ${CONSENSUS_PRIV_KEY}" +echo "CONSENSUS_COIN_SK: ${CONSENSUS_COIN_SK}" +echo "CONSENSUS_COIN_NONCE: ${CONSENSUS_COIN_NONCE}" +echo "CONSENSUS_COIN_VALUE: ${CONSENSUS_COIN_VALUE}" echo "DA_VOTER: ${DA_VOTER}" echo "OVERLAY_NODES: ${OVERLAY_NODES}" diff --git a/testnet/scripts/run_nomos_node.sh b/testnet/scripts/run_nomos_node.sh index 83327afd..10c0f719 100755 --- a/testnet/scripts/run_nomos_node.sh +++ b/testnet/scripts/run_nomos_node.sh @@ -4,8 +4,11 @@ set -e # Set env variables for nomos-node. NET_NODE_KEY=$(/etc/nomos/scripts/register_node.sh) -CONSENSUS_PRIV_KEY=$NET_NODE_KEY -DA_VOTER=$CONSENSUS_PRIV_KEY +CONSENSUS_CHAIN_START=$(date +%s) +CONSENSUS_COIN_SK=$NET_NODE_KEY +CONSENSUS_COIN_NONCE=$NET_NODE_KEY +CONSENSUS_COIN_VALUE=1 +DA_VOTER=$NET_NODE_KEY OVERLAY_NODES=$(/etc/nomos/scripts/consensus_node_list.sh) node_ids=$(etcdctl get "/node/" --prefix --keys-only) @@ -21,14 +24,19 @@ for node_id in $node_ids; do fi done -export CONSENSUS_PRIV_KEY \ +export CONSENSUS_COIN_SK \ + CONSENSUS_COIN_NONCE \ + CONSENSUS_COIN_VALUE \ + CONSENSUS_CHAIN_START \ DA_VOTER \ OVERLAY_NODES \ NET_NODE_KEY \ NET_INITIAL_PEERS echo "I am a container ${HOSTNAME} node ${NET_NODE_KEY}" -echo "CONSENSUS_PRIV_KEY: ${CONSENSUS_PRIV_KEY}" +echo "CONSENSUS_COIN_SK: ${CONSENSUS_COIN_SK}" +echo "CONSENSUS_COIN_NONCE: ${CONSENSUS_COIN_NONCE}" +echo "CONSENSUS_COIN_VALUE: ${CONSENSUS_COIN_VALUE}" echo "DA_VOTER: ${DA_VOTER}" echo "OVERLAY_NODES: ${OVERLAY_NODES}" echo "NET_INITIAL_PEERS: ${NET_INITIAL_PEERS}"