Da voter config for docker compose (#513)

* Readd docker build context

* Configurable da protocol voter

* Do not use private key naming for da voter
This commit is contained in:
gusto 2023-11-07 13:52:27 +02:00 committed by GitHub
parent df683ad154
commit c14998bb9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 53 additions and 9 deletions

View File

@ -3,7 +3,9 @@ services:
bootstrap: bootstrap:
container_name: bootstrap container_name: bootstrap
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
ports: ports:
- "3000:3000/tcp" - "3000:3000/tcp"
- "18080:8080/tcp" - "18080:8080/tcp"
@ -22,7 +24,9 @@ services:
libp2p-node-1: libp2p-node-1:
container_name: libp2p_node_1 container_name: libp2p_node_1
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
depends_on: depends_on:
@ -46,7 +50,9 @@ services:
libp2p-node-2: libp2p-node-2:
container_name: libp2p_node_2 container_name: libp2p_node_2
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
depends_on: depends_on:
@ -70,7 +76,9 @@ services:
libp2p-node-3: libp2p-node-3:
container_name: libp2p_node_3 container_name: libp2p_node_3
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
depends_on: depends_on:
@ -94,7 +102,9 @@ services:
mix-node-0: mix-node-0:
container_name: mix_node_0 container_name: mix_node_0
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
ports: ports:
@ -105,7 +115,9 @@ services:
mix-node-1: mix-node-1:
container_name: mix_node_1 container_name: mix_node_1
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
ports: ports:
@ -116,7 +128,9 @@ services:
mix-node-2: mix-node-2:
container_name: mix_node_2 container_name: mix_node_2
build: "testnet" build:
context: .
dockerfile: testnet/Dockerfile
volumes: volumes:
- ./testnet:/etc/nomos - ./testnet:/etc/nomos
ports: ports:

View File

@ -108,6 +108,12 @@ pub struct OverlayArgs {
pub overlay_super_majority_threshold: Option<f32>, pub overlay_super_majority_threshold: Option<f32>,
} }
#[derive(Parser, Debug, Clone)]
pub struct DaArgs {
#[clap(long = "da-voter", env = "DA_VOTER")]
da_voter: Option<String>,
}
#[derive(Deserialize, Debug, Clone, Serialize)] #[derive(Deserialize, Debug, Clone, Serialize)]
pub struct Config { pub struct Config {
pub log: <Logger as ServiceData>::Settings, pub log: <Logger as ServiceData>::Settings,
@ -264,4 +270,15 @@ impl Config {
Ok(self) Ok(self)
} }
pub fn update_da(mut self, da_args: DaArgs) -> Result<Self> {
let DaArgs { da_voter } = da_args;
if let Some(voter) = da_voter {
let bytes = <[u8; 32]>::from_hex(voter)?;
self.da.da_protocol.voter = bytes;
}
Ok(self)
}
} }

View File

@ -35,7 +35,7 @@ use nomos_storage::{
StorageService, StorageService,
}; };
pub use config::{Config, ConsensusArgs, HttpArgs, LogArgs, NetworkArgs, OverlayArgs}; pub use config::{Config, ConsensusArgs, DaArgs, HttpArgs, LogArgs, NetworkArgs, OverlayArgs};
use nomos_core::{ use nomos_core::{
da::certificate::select::FillSize as FillSizeWithBlobsCertificate, da::certificate::select::FillSize as FillSizeWithBlobsCertificate,
tx::select::FillSize as FillSizeWithTx, tx::select::FillSize as FillSizeWithTx,

View File

@ -1,6 +1,6 @@
use full_replication::{Blob, Certificate}; use full_replication::{Blob, Certificate};
use nomos_node::{ use nomos_node::{
Config, ConsensusArgs, HttpArgs, LogArgs, NetworkArgs, Nomos, NomosServiceSettings, Config, ConsensusArgs, DaArgs, HttpArgs, LogArgs, NetworkArgs, Nomos, NomosServiceSettings,
OverlayArgs, Tx, OverlayArgs, Tx,
}; };
@ -40,11 +40,15 @@ struct Args {
/// Overrides overlay config. /// Overrides overlay config.
#[clap(flatten)] #[clap(flatten)]
overlay_args: OverlayArgs, overlay_args: OverlayArgs,
/// Overrides da config.
#[clap(flatten)]
da_args: DaArgs,
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let Args { let Args {
config, config,
da_args,
log_args, log_args,
http_args, http_args,
network_args, network_args,
@ -52,6 +56,7 @@ fn main() -> Result<()> {
overlay_args, overlay_args,
} = Args::parse(); } = Args::parse();
let config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)? let config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)?
.update_da(da_args)?
.update_log(log_args)? .update_log(log_args)?
.update_http(http_args)? .update_http(http_args)?
.update_consensus(consensus_args)? .update_consensus(consensus_args)?

View File

@ -70,6 +70,7 @@ http:
da: da:
da_protocol: da_protocol:
voter: [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]
num_attestations: 1 num_attestations: 1
backend: backend:
max_capacity: 10 max_capacity: 10

View File

@ -70,6 +70,7 @@ http:
da: da:
da_protocol: da_protocol:
voter: [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]
num_attestations: 1 num_attestations: 1
backend: backend:
max_capacity: 10 max_capacity: 10

View File

@ -3,15 +3,18 @@
set -e set -e
CONSENSUS_PRIV_KEY=$BOOTSTRAP_NODE_KEY CONSENSUS_PRIV_KEY=$BOOTSTRAP_NODE_KEY
DA_VOTER_KEY=$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_PRIV_KEY \
DA_VOTER_KEY \
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_PRIV_KEY: ${CONSENSUS_PRIV_KEY}"
echo "DA_VOTER_KEY: ${DA_VOTER_KEY}"
echo "OVERLAY_NODES: ${OVERLAY_NODES}" echo "OVERLAY_NODES: ${OVERLAY_NODES}"
exec /usr/bin/nomos-node /etc/nomos/bootstrap_config.yaml exec /usr/bin/nomos-node /etc/nomos/bootstrap_config.yaml

View File

@ -5,6 +5,7 @@ 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_PRIV_KEY=$NET_NODE_KEY
DA_VOTER_KEY=$CONSENSUS_PRIV_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,12 +22,14 @@ for node_id in $node_ids; do
done done
export CONSENSUS_PRIV_KEY \ export CONSENSUS_PRIV_KEY \
DA_VOTER_KEY \
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_PRIV_KEY: ${CONSENSUS_PRIV_KEY}"
echo "DA_VOTER_KEY: ${DA_VOTER_KEY}"
echo "OVERLAY_NODES: ${OVERLAY_NODES}" echo "OVERLAY_NODES: ${OVERLAY_NODES}"
echo "NET_INITIAL_PEERS: ${NET_INITIAL_PEERS}" echo "NET_INITIAL_PEERS: ${NET_INITIAL_PEERS}"