Merge branch 'master' into chore-cryptarchia-unit-tests-update

This commit is contained in:
Roman Zajic 2024-05-30 12:56:07 +02:00 committed by GitHub
commit 21388e142a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 167 additions and 75 deletions

View File

@ -1,18 +1,14 @@
# BUILD IMAGE --------------------------------------------------------- # BUILD IMAGE ---------------------------------------------------------
FROM rust:1.76.0-slim-bullseye AS builder FROM rust:1.78.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
WORKDIR /nomos WORKDIR /nomos
COPY . . 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 RUN cargo build --release -p nomos-node
# NODE IMAGE ---------------------------------------------------------- # NODE IMAGE ----------------------------------------------------------

View File

@ -1,11 +1,11 @@
version: '3.7' version: '3.7'
services: services:
bootstrap: bootstrap:
container_name: bootstrap container_name: bootstrap
build: build:
context: . context: .
dockerfile: testnet/Dockerfile dockerfile: testnet/Dockerfile
image: nomos:latest
ports: ports:
- "3000:3000/udp" - "3000:3000/udp"
- "18080:18080/tcp" - "18080:18080/tcp"
@ -20,9 +20,7 @@ services:
libp2p-node-1: libp2p-node-1:
container_name: libp2p_node_1 container_name: libp2p_node_1
build: image: nomos:latest
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
depends_on: depends_on:
@ -43,9 +41,7 @@ services:
libp2p-node-2: libp2p-node-2:
container_name: libp2p_node_2 container_name: libp2p_node_2
build: image: nomos:latest
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
depends_on: depends_on:
@ -66,9 +62,7 @@ services:
libp2p-node-3: libp2p-node-3:
container_name: libp2p_node_3 container_name: libp2p_node_3
build: image: nomos:latest
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
depends_on: depends_on:
@ -89,9 +83,7 @@ services:
chatbot: chatbot:
container_name: chatbot container_name: chatbot
build: image: nomos:latest
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
entrypoint: /etc/nomos/scripts/run_nomos_bot.sh entrypoint: /etc/nomos/scripts/run_nomos_bot.sh

View File

@ -8,6 +8,7 @@ use crate::DataAvailability;
use crate::{Tx, Wire, MB16}; use crate::{Tx, Wire, MB16};
use clap::{Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use color_eyre::eyre::{eyre, Result}; use color_eyre::eyre::{eyre, Result};
use cryptarchia_ledger::Coin;
use hex::FromHex; use hex::FromHex;
use nomos_api::ApiService; use nomos_api::ApiService;
use nomos_libp2p::{secp256k1::SecretKey, Multiaddr}; use nomos_libp2p::{secp256k1::SecretKey, Multiaddr};
@ -83,6 +84,27 @@ pub struct CryptarchiaArgs {
#[clap(long = "consensus-slot-duration", env = "CONSENSUS_SLOT_DURATION")] #[clap(long = "consensus-slot-duration", env = "CONSENSUS_SLOT_DURATION")]
slot_duration: Option<u64>, slot_duration: Option<u64>,
#[clap(
long = "consensus-coin-sk",
env = "CONSENSUS_COIN_SK",
requires("coin_nonce")
)]
coin_secret_key: Option<String>,
#[clap(
long = "consensus-coin-nonce",
env = "CONSENSUS_COIN_NONCE",
requires("coin_secret_key")
)]
coin_nonce: Option<String>,
#[clap(
long = "consensus-coin-value",
env = "CONSENSUS_COIN_VALUE",
requires("coin_secret_key")
)]
coin_value: Option<u32>,
} }
#[derive(Parser, Debug, Clone)] #[derive(Parser, Debug, Clone)]
@ -204,6 +226,9 @@ impl Config {
let CryptarchiaArgs { let CryptarchiaArgs {
chain_start_time, chain_start_time,
slot_duration, slot_duration,
coin_secret_key,
coin_nonce,
coin_value,
} = consensus_args; } = consensus_args;
if let Some(start_time) = chain_start_time { 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); 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) Ok(self)
} }

View File

@ -5,8 +5,6 @@ mod tx;
use color_eyre::eyre::Result; use color_eyre::eyre::Result;
use full_replication::Certificate; use full_replication::Certificate;
use full_replication::{AbsoluteNumber, Attestation, Blob, FullReplication}; use full_replication::{AbsoluteNumber, Attestation, Blob, FullReplication};
#[cfg(feature = "metrics")]
use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService};
use api::AxumBackend; use api::AxumBackend;
use bytes::Bytes; use bytes::Bytes;

View File

@ -8,7 +8,7 @@ use nomos_metrics::{
}; };
use overwatch_rs::services::ServiceId; use overwatch_rs::services::ServiceId;
// internal // internal
use super::service::TxMempoolMsg; use crate::MempoolMsg;
#[derive(Debug, Clone, Hash, PartialEq, Eq, EncodeLabelValue)] #[derive(Debug, Clone, Hash, PartialEq, Eq, EncodeLabelValue)]
enum MempoolMsgType { enum MempoolMsgType {
@ -18,17 +18,17 @@ enum MempoolMsgType {
MarkInBlock, MarkInBlock,
} }
impl<BlockId, I, K> From<&TxMempoolMsg<BlockId, I, K>> for MempoolMsgType impl<BlockId, I, K> From<&MempoolMsg<BlockId, I, K>> for MempoolMsgType
where where
I: 'static + Debug, I: 'static + Debug,
K: 'static + Debug, K: 'static + Debug,
{ {
fn from(event: &TxMempoolMsg<BlockId, I, K>) -> Self { fn from(event: &MempoolMsg<BlockId, I, K>) -> Self {
match event { match event {
TxMempoolMsg::Add { .. } => MempoolMsgType::Add, MempoolMsg::Add { .. } => MempoolMsgType::Add,
TxMempoolMsg::View { .. } => MempoolMsgType::View, MempoolMsg::View { .. } => MempoolMsgType::View,
TxMempoolMsg::Prune { .. } => MempoolMsgType::Prune, MempoolMsg::Prune { .. } => MempoolMsgType::Prune,
TxMempoolMsg::MarkInBlock { .. } => MempoolMsgType::MarkInBlock, MempoolMsg::MarkInBlock { .. } => MempoolMsgType::MarkInBlock,
_ => unimplemented!(), _ => unimplemented!(),
} }
} }
@ -60,16 +60,16 @@ impl Metrics {
Self { messages } Self { messages }
} }
pub(crate) fn record<BlockId, I, K>(&self, msg: &TxMempoolMsg<BlockId, I, K>) pub(crate) fn record<BlockId, I, K>(&self, msg: &MempoolMsg<BlockId, I, K>)
where where
I: 'static + Debug, I: 'static + Debug,
K: 'static + Debug, K: 'static + Debug,
{ {
match msg { match msg {
TxMempoolMsg::Add { .. } MempoolMsg::Add { .. }
| TxMempoolMsg::View { .. } | MempoolMsg::View { .. }
| TxMempoolMsg::Prune { .. } | MempoolMsg::Prune { .. }
| TxMempoolMsg::MarkInBlock { .. } => { | MempoolMsg::MarkInBlock { .. } => {
self.messages self.messages
.get_or_create(&MessageLabels { label: msg.into() }) .get_or_create(&MessageLabels { label: msg.into() })
.inc(); .inc();

View File

@ -1,19 +1,19 @@
# BUILD IMAGE --------------------------------------------------------- # BUILD IMAGE ---------------------------------------------------------
FROM rust:1.76.0-slim-bullseye AS builder FROM rust:1.78.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
WORKDIR /nomos WORKDIR /nomos
COPY . . 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 RUN cargo build --release --all --features metrics
# NODE IMAGE ---------------------------------------------------------- # NODE IMAGE ----------------------------------------------------------
FROM bitnami/minideb:bullseye FROM bitnami/minideb:latest
LABEL maintainer="augustinas@status.im" \ LABEL maintainer="augustinas@status.im" \
source="https://github.com/logos-co/nomos-node" \ source="https://github.com/logos-co/nomos-node" \

View File

@ -2,19 +2,45 @@ log:
backend: "Stdout" backend: "Stdout"
format: "Json" format: "Json"
level: "info" 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] cryptarchia:
fountain_settings: null config:
overlay_settings: epoch_stake_distribution_stabilization: 3
nodes: [] epoch_period_nonce_buffer: 3
number_of_committees: 1 epoch_period_nonce_stabilization: 4
current_leader: "0x0000000000000000000000000000000000000000000000000000000000000000" consensus_config:
leader: security_param: 10
cur: 0 active_slot_coeff: 0.9
committee_membership: !Sad time:
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] slot_duration:
leader_super_majority_threshold: 1 secs: 5
super_majority_threshold: 1 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: network:
backend: backend:

View File

@ -2,19 +2,45 @@ log:
backend: "Stdout" backend: "Stdout"
format: "Json" format: "Json"
level: "info" 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] cryptarchia:
fountain_settings: null config:
overlay_settings: epoch_stake_distribution_stabilization: 3
nodes: [] epoch_period_nonce_buffer: 3
number_of_committees: 1 epoch_period_nonce_stabilization: 4
current_leader: "0x0000000000000000000000000000000000000000000000000000000000000000" consensus_config:
leader: security_param: 10
cur: 0 active_slot_coeff: 0.9
committee_membership: !Sad time:
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] slot_duration:
leader_super_majority_threshold: 1 secs: 5
super_majority_threshold: 1 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: network:
backend: backend:

View File

@ -2,18 +2,26 @@
set -e 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 DA_VOTER=$BOOTSTRAP_NODE_KEY
NET_NODE_KEY=$BOOTSTRAP_NODE_KEY NET_NODE_KEY=$BOOTSTRAP_NODE_KEY
OVERLAY_NODES=$(/etc/nomos/scripts/consensus_node_list.sh) 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 \ DA_VOTER \
OVERLAY_NODES \ OVERLAY_NODES \
NET_NODE_KEY NET_NODE_KEY
echo "I am a container ${HOSTNAME} node ${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 "DA_VOTER: ${DA_VOTER}"
echo "OVERLAY_NODES: ${OVERLAY_NODES}" echo "OVERLAY_NODES: ${OVERLAY_NODES}"

View File

@ -4,8 +4,11 @@ set -e
# Set env variables for nomos-node. # Set env variables for nomos-node.
NET_NODE_KEY=$(/etc/nomos/scripts/register_node.sh) NET_NODE_KEY=$(/etc/nomos/scripts/register_node.sh)
CONSENSUS_PRIV_KEY=$NET_NODE_KEY CONSENSUS_CHAIN_START=$(date +%s)
DA_VOTER=$CONSENSUS_PRIV_KEY 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) OVERLAY_NODES=$(/etc/nomos/scripts/consensus_node_list.sh)
node_ids=$(etcdctl get "/node/" --prefix --keys-only) node_ids=$(etcdctl get "/node/" --prefix --keys-only)
@ -21,14 +24,19 @@ for node_id in $node_ids; do
fi fi
done done
export CONSENSUS_PRIV_KEY \ export CONSENSUS_COIN_SK \
CONSENSUS_COIN_NONCE \
CONSENSUS_COIN_VALUE \
CONSENSUS_CHAIN_START \
DA_VOTER \ DA_VOTER \
OVERLAY_NODES \ OVERLAY_NODES \
NET_NODE_KEY \ NET_NODE_KEY \
NET_INITIAL_PEERS NET_INITIAL_PEERS
echo "I am a container ${HOSTNAME} node ${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 "DA_VOTER: ${DA_VOTER}"
echo "OVERLAY_NODES: ${OVERLAY_NODES}" echo "OVERLAY_NODES: ${OVERLAY_NODES}"
echo "NET_INITIAL_PEERS: ${NET_INITIAL_PEERS}" echo "NET_INITIAL_PEERS: ${NET_INITIAL_PEERS}"