Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: fixing docker setup
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <[email protected]>
  • Loading branch information
Freyskeyd committed Oct 27, 2023
1 parent 6afe5ea commit 3ee53ce
Show file tree
Hide file tree
Showing 21 changed files with 123 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
max_attempts: 5
retry_wait_seconds: 40
timeout_minutes: 10
on_retry_command: docker inspect --format "{{ .Id }} {{ .State.Health.Status }}" $(docker compose -f tools/docker-compose.yml ps -aq peer boot) | grep "healthy$" | cut -d ' ' -f 1 | xargs -I{} sh -c 'echo "\nLogs for => {}\n" && docker logs {}'
on_retry_command: docker inspect --format "{{ .Name }} {{ .State.Health.Status }}" $(docker compose -f tools/docker-compose.yml ps -aq peer boot) | grep "healthy$" | cut -d ' ' -f 1 | xargs -I{} sh -c 'echo "\nLogs for => {}\n" && docker logs {}'
command: |
EXPECTED=$(docker compose -f tools/docker-compose.yml ps -aq peer boot|wc -l)
COUNT=$(docker inspect --format "{{.State.Health.Status }}" $(docker compose -f tools/docker-compose.yml ps -aq peer boot)|grep "^healthy$"|wc -l)
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ polygon-edge

# macOS directory attributes
**/.DS_Store

tools/node_config/node/test/libp2p/
tools/node_config/node/test/consensus/
12 changes: 1 addition & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ ENV USER=topos
ENV UID=10001
ENV PATH="${PATH}:/usr/src/app"

RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"

WORKDIR /usr/src/app

COPY --from=build /usr/src/app/target/release/topos .
Expand All @@ -46,8 +37,7 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

USER topos:topos

RUN mkdir /tmp/node_config
RUN mkdir /tmp/shared

ENTRYPOINT ["./init.sh"]
1 change: 0 additions & 1 deletion crates/topos-p2p/src/behaviour/grpc/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ impl IntoFuture for OutboundConnection {
type IntoFuture = BoxFuture<'static, Self::Output>;

fn into_future(self) -> Self::IntoFuture {
println!("Outbound future is in: {:?}", self);
async move {
match self {
// The outbound connection is already opened
Expand Down
7 changes: 6 additions & 1 deletion crates/topos-tce-storage/src/epoch/tables.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::path::PathBuf;
use std::{fs::create_dir_all, path::PathBuf};

use rocksdb::ColumnFamilyDescriptor;
use topos_core::uci::CertificateId;
use tracing::warn;

use crate::{
constant::cfs,
Expand Down Expand Up @@ -44,6 +45,10 @@ impl ValidatorPerEpochTables {
pub(crate) fn open(epoch_id: EpochId, mut path: PathBuf) -> Self {
path.push("epochs");
path.push(epoch_id.to_string());
if !path.exists() {
warn!("Path {:?} does not exist, creating it", path);
create_dir_all(&path).expect("Cannot create ValidatorPerEpochTables directory");
}
let cfs = vec![
ColumnFamilyDescriptor::new(cfs::EPOCH_SUMMARY, default_options()),
ColumnFamilyDescriptor::new(cfs::BROADCAST_STATES, default_options()),
Expand Down
7 changes: 6 additions & 1 deletion crates/topos-tce-storage/src/index/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::path::PathBuf;
use std::{fs::create_dir_all, path::PathBuf};

use rocksdb::ColumnFamilyDescriptor;
use topos_core::{
types::stream::{CertificateTargetStreamPosition, Position},
uci::{CertificateId, SubnetId},
};
use tracing::warn;

use crate::{
constant::cfs,
Expand Down Expand Up @@ -32,6 +33,10 @@ pub struct IndexTables {
impl IndexTables {
pub fn open(mut path: PathBuf) -> Self {
path.push("index");
if !path.exists() {
warn!("Path {:?} does not exist, creating it", path);
create_dir_all(&path).expect("Cannot create IndexTables directory");
}
let mut options_stream = default_options();
options_stream.set_prefix_extractor(rocksdb::SliceTransform::create_fixed_prefix(
constants::TARGET_STREAMS_PREFIX_SIZE,
Expand Down
17 changes: 13 additions & 4 deletions crates/topos-tce-storage/src/validator/tables.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::{collections::BTreeSet, path::PathBuf, sync::atomic::AtomicU64};
use std::{collections::BTreeSet, fs::create_dir_all, path::PathBuf, sync::atomic::AtomicU64};

use rocksdb::ColumnFamilyDescriptor;
use topos_core::{
types::{stream::CertificateSourceStreamPosition, CertificateDelivered, ProofOfDelivery},
uci::{Certificate, CertificateId},
};
use tracing::warn;

use crate::{
constant::cfs,
Expand Down Expand Up @@ -32,7 +33,10 @@ pub struct ValidatorPendingTables {
impl ValidatorPendingTables {
pub fn open(mut path: PathBuf) -> Self {
path.push("pending");

if !path.exists() {
warn!("Path {:?} does not exist, creating it", path);
create_dir_all(&path).expect("Cannot create ValidatorPendingTables directory");
}
let cfs = vec![
ColumnFamilyDescriptor::new(cfs::PENDING_POOL, default_options()),
ColumnFamilyDescriptor::new(cfs::PENDING_POOL_INDEX, default_options()),
Expand Down Expand Up @@ -66,6 +70,10 @@ pub struct ValidatorPerpetualTables {
impl ValidatorPerpetualTables {
pub fn open(mut path: PathBuf) -> Self {
path.push("perpetual");
if !path.exists() {
warn!("Path {:?} does not exist, creating it", path);
create_dir_all(&path).expect("Cannot create ValidatorPerpetualTables directory");
}
let mut options_stream = default_options();
options_stream.set_prefix_extractor(rocksdb::SliceTransform::create_fixed_prefix(
constants::SOURCE_STREAMS_PREFIX_SIZE,
Expand All @@ -78,8 +86,9 @@ impl ValidatorPerpetualTables {
ColumnFamilyDescriptor::new(cfs::UNVERIFIED, default_options()),
];

let db = init_with_cfs(&path, default_options(), cfs)
.unwrap_or_else(|_| panic!("Cannot open DB at {:?}", path));
let db = init_with_cfs(&path, default_options(), cfs).unwrap_or_else(|e| {
panic!("Cannot open DB at {:?} => error {:?}", path, e);
});

Self {
certificates: DBColumn::reopen(&db, cfs::CERTIFICATES),
Expand Down
2 changes: 1 addition & 1 deletion crates/topos-wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub const VALIDATOR_BLS_KEY: &str = "consensus/validator-bls.key";
/// Load from the filesystem
pub fn load_fs_secret(file: PathBuf) -> Option<SecretKey> {
match &fs::read_to_string(&file) {
Ok(s) => Some(hex::decode(s).expect("decode failure")),
Ok(s) => Some(hex::decode(s).unwrap_or_else(|_| panic!("decode failure for {}", s))),
Err(e) => panic!("Failed at reading {file:?}: {e}"),
}
}
Expand Down
55 changes: 36 additions & 19 deletions tools/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
version: "3.3"
services:
init:
container_name: init
command: sh -c "cp /tmp/libp2p_keys.json /tmp/shared/libp2p_keys.json && \
cp /tmp/validator_bls_keys.json /tmp/shared/validator_bls_keys.json && \
cp /tmp/validator_keys.json /tmp/shared/validator_keys.json && \
chmod a+rwx /tmp/shared/* && ls /tmp && ls /tmp/shared"
image: debian:bullseye-slim
volumes:
- shared:/tmp/shared
- ./libp2p_keys.json:/tmp/libp2p_keys.json
- ./validator_bls_keys.json:/tmp/validator_bls_keys.json
- ./validator_keys.json:/tmp/validator_keys.json
healthcheck:
test: ["CMD-SHELL", "test -f /tmp/shared/libp2p_keys.json"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s

boot:
container_name: boot
command: boot node up --name test --home /tmp/node_config --no-edge-process
command: node up --name boot --home /tmp/node_config --no-edge-process
image: ghcr.io/topos-protocol/topos:main
init: true
labels:
Expand All @@ -14,16 +32,18 @@ services:
interval: 15s
volumes:
- shared:/tmp/shared
- ./node_config:/tmp/node_config
- ./libp2p_keys.json:/tmp/shared/libp2p_keys.json
- ./validator_bls_keys.json:/tmp/shared/validator_bls_keys.json
- ./validator_keys.json:/tmp/shared/validator_keys.json
- ./node_config/node/boot/config.toml:/tmp/node_config/node/boot/config.toml:ro
- ./node_config/node/boot/libp2p/:/tmp/node_config/node/boot/libp2p/:ro
- ./node_config/node/boot/consensus/:/tmp/node_config/node/boot/consensus/:ro
- ./node_config/subnet/topos/genesis.json:/tmp/node_config/subnet/topos/genesis.json:ro
build:
context: ../
args:
- TOOLCHAIN_VERSION=stable
- FEATURES=tce,network
- FEATURES=tce,network,node,subnet
depends_on:
init:
condition: service_completed_successfully
autoheal:
condition: service_started
ports:
Expand All @@ -36,7 +56,6 @@ services:
- env/node.env
- env/telemetry.env
environment:
- TCE_LOCAL_KS=1 # 12D3KooWRhFCXBhmsMnur3up3vJsDoqWh4c39PKXgSWwzAzDHNLn
- RUST_LOG=topos=debug,topos_tce_storage=info,topos_tce_synchronizer=info

peer:
Expand All @@ -50,16 +69,16 @@ services:
interval: 5s
volumes:
- shared:/tmp/shared
- ./node_config:/tmp/node_config
- ./libp2p_keys.json:/tmp/shared/libp2p_keys.json
- ./validator_bls_keys.json:/tmp/shared/validator_bls_keys.json
- ./validator_keys.json:/tmp/shared/validator_keys.json
- ./node_config/node/test/config.toml:/tmp/node_config/node/test/config.toml
- ./node_config/subnet/topos/genesis.json:/tmp/node_config/subnet/topos/genesis.json
build:
context: ../
args:
- TOOLCHAIN_VERSION=stable
- FEATURES=tce
- FEATURES=tce,network,node,subnet
depends_on:
init:
condition: service_completed_successfully
autoheal:
condition: service_started
boot:
Expand All @@ -70,7 +89,7 @@ services:
- "3000"
- "4000"
deploy:
replicas: 2
replicas: 14
env_file:
- env/base.env
- env/node.env
Expand All @@ -86,10 +105,8 @@ services:
"autoheal": "true"
volumes:
- shared:/tmp/shared
- ./node_config:/tmp/node_config
- ./libp2p_keys.json:/tmp/shared/libp2p_keys.json
- ./validator_bls_keys.json:/tmp/shared/validator_bls_keys.json
- ./validator_keys.json:/tmp/shared/validator_keys.json
- ./node_config/node/test/config.toml:/tmp/node_config/node/test/config.toml
- ./node_config/subnet/topos/genesis.json:/tmp/node_config/subnet/topos/genesis.json
build:
context: ../
args:
Expand Down Expand Up @@ -144,7 +161,7 @@ services:
- check
init: true
volumes:
- shared:/tmp/shared
- ./peer_nodes.json:/tmp/peer_nodes.json
build:
context: ../
args:
Expand All @@ -159,7 +176,7 @@ services:
environment:
- LOCAL_TEST_NET=true
- RUST_LOG=info,topos=info
- TARGET_NODES_PATH=/tmp/shared/peer_nodes.json
- TARGET_NODES_PATH=/tmp/peer_nodes.json

autoheal:
container_name: autoheal
Expand Down
6 changes: 0 additions & 6 deletions tools/env/node.env
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
RUST_LOG=warn,topos=warn
LOCAL_TEST_NET=true

TCE_DB_PATH=/tmp/default-db

TOPOS_MINIMUM_TCE_CLUSTER_SIZE=7

TCE_API_ADDR=0.0.0.0:1340
TCE_GRAPHQL_API_ADDR=0.0.0.0:4000
TCE_METRICS_API_ADDR=0.0.0.0:3000

TCE_ECHO_SAMPLE_SIZE=14
TCE_READY_SAMPLE_SIZE=14
TCE_DELIVERY_SAMPLE_SIZE=14
Expand Down
Loading

0 comments on commit 3ee53ce

Please sign in to comment.