Testnet consensus configuration (#656)

* Update metrics for split mempool

* Update required packages for node in docker

* Expose env and cli params for coin

* Set coin params via env in testnet

* Predefined genesis state

* Chain start time from env vars
This commit is contained in:
gusto 2024-05-30 12:46:02 +03:00 committed by GitHub
parent e904793b7e
commit 7d6ae1b823
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 ---------------------------------------------------------
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 ----------------------------------------------------------

View File

@ -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

View File

@ -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<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)]
@ -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)
}

View File

@ -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;

View File

@ -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<BlockId, I, K> From<&TxMempoolMsg<BlockId, I, K>> for MempoolMsgType
impl<BlockId, I, K> From<&MempoolMsg<BlockId, I, K>> for MempoolMsgType
where
I: 'static + Debug,
K: 'static + Debug,
{
fn from(event: &TxMempoolMsg<BlockId, I, K>) -> Self {
fn from(event: &MempoolMsg<BlockId, I, K>) -> 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<BlockId, I, K>(&self, msg: &TxMempoolMsg<BlockId, I, K>)
pub(crate) fn record<BlockId, I, K>(&self, msg: &MempoolMsg<BlockId, I, K>)
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();

View File

@ -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" \

View File

@ -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:

View File

@ -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:

View File

@ -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}"

View File

@ -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}"