Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC Docker compose for small libp2p node network #364

Merged
merged 23 commits into from
Sep 15, 2023
Merged

Conversation

bacv
Copy link
Member

@bacv bacv commented Aug 31, 2023

POC for testnet using Docker compose, the same approach that waku is using for simulations.

Before going further, it would be great to discuss some nuances using this approach:

  • Should node private key be persistent? At the moment libp2p node keys depends on container name - that means it will likely change between the runs (consensus private key is ignored atm). This might be a problem with persistence in the future, if we decide to write some node state into a file and load it when restarting.
    Writing and loading can be done from the host system using volumes, the problem is to determine which node should load a particular state and how not to load the same state twice.
  • Should the network be managed by some hypervisor? For a small number of nodes, every container could be defined explicitly and specific configuration file provided. However, when dealing with an indefinite number of nodes, there might be a need for a "hypervisor" where nodes can register and be configured. This could be solved with libp2p discovery or the node client.

Alternative tools to Docker Compose include Ansible and bash scripts; however, these may not function seamlessly on local setups. Another advantage of using Docker Compose is the straightforward integration of Prometheus and Grafana.

@@ -84,6 +86,9 @@ impl Swarm {
.timeout(TRANSPORT_TIMEOUT)
.boxed();

// Wrapping TCP transport into DNS transport to resolve hostnames.
let tcp_transport = dns::TokioDnsConfig::system(tcp_transport)?.boxed();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes had it's own PR (#346) and was merged into this branch.

@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2023

Codecov Report

Patch has no changes to coverable lines.

Files Changed Coverage
nodes/nomos-node/src/config.rs ø
nomos-libp2p/src/lib.rs 0.00%

📢 Thoughts on this report? Let us know!.

@vpavlin
Copy link

vpavlin commented Sep 11, 2023

  • Should node private key be persistent? At the moment libp2p node keys depends on container name - that means it will likely change between the runs (consensus private key is ignored atm). This might be a problem with persistence in the future, if we decide to write some node state into a file and load it when restarting.
    Writing and loading can be done from the host system using volumes, the problem is to determine which node should load a particular state and how not to load the same state twice.

We could not figure out how to deal with this in Compose directly (since, sadly, Docker Compose does not expose the container name in the container itself)

I wrote this simple golang tool to generate our compose based on simple (?:)) manifest

waku-org/waku-simulator#6

It was just a few hours PoC, so it is very simplistic, but it feels like a reasonable approach, unless someone can figure out a more general way how to figure out "who am I?" from the container perspective

@bacv
Copy link
Member Author

bacv commented Sep 11, 2023

We could not figure out how to deal with this in Compose directly (since, sadly, Docker Compose does not expose the container name in the container itself)

I wrote this simple golang tool to generate our compose based on simple (?:)) manifest

waku-org/waku-simulator#6

It was just a few hours PoC, so it is very simplistic, but it feels like a reasonable approach, unless someone can figure out a more general way how to figure out "who am I?" from the container perspective

Thank you very much for sharing your approach! I've taken a look and I believe that for our case it's too coupled with docker compose. I think it's perfectly fine for your use case, but even if nomos goes with docker compose for now, I'm not too sure about the long run. It's very likely that parts of infra will be provisioned by Ansible, especially the machines running nodes.

Ideally Docker Compose will stay for local tests and new users, by some parts being reused on the public testnet.

Having that in mind, I've been experimenting with observability tools like etcd and consul. I'll share results this week and would really value your insights. The basic idea is to have service registrar container, bootstrap node, and other nodes. The run_somekind_of_node.sh would do registering and config retrieval using the KV store provided by observability tool.

testnet/run_libp2p.sh Outdated Show resolved Hide resolved
testnet/run_bootstrap.sh Outdated Show resolved Hide resolved
Dockerfile.libp2p Outdated Show resolved Hide resolved
compose.yml Outdated Show resolved Hide resolved
compose.yml Outdated Show resolved Hide resolved
testnet/etcd/install_etcd.sh Outdated Show resolved Hide resolved
testnet/etcd/register_etcd.sh Outdated Show resolved Hide resolved
testnet/run_libp2p.sh Outdated Show resolved Hide resolved
testnet/etcd/register_etcd.sh Outdated Show resolved Hide resolved
compose.yml Outdated Show resolved Hide resolved
compose.yml Outdated Show resolved Hide resolved
testnet/run_libp2p.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@jakubgs jakubgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good for the most part.

testnet/Dockerfile Outdated Show resolved Hide resolved
testnet/Dockerfile Outdated Show resolved Hide resolved
compose.yml Outdated Show resolved Hide resolved
testnet/configure_node.sh Outdated Show resolved Hide resolved
testnet/register_node.sh Outdated Show resolved Hide resolved
testnet/register_node.sh Outdated Show resolved Hide resolved
Copy link
Collaborator

@danielSanchezQ danielSanchezQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎸

@bacv bacv merged commit 97c653e into master Sep 15, 2023
11 of 13 checks passed
@bacv bacv deleted the docker-compose branch September 15, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants