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

FM-150: Subnet deployment scripts #222

Merged
merged 44 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
06040d1
wip: first few strokes
adlrocha Aug 28, 2023
198f0ef
Merge branch 'main' into fm-150-deployment-scripts
dnkolegov Sep 1, 2023
44d0db1
Update makefile
dnkolegov Sep 4, 2023
67f74ea
update
dnkolegov Sep 4, 2023
a0cad1c
fix misprints
dnkolegov Sep 4, 2023
d81a940
start working on testnet config
dnkolegov Sep 5, 2023
d594806
add persistent peers
dnkolegov Sep 6, 2023
14dbaba
fmt
dnkolegov Sep 6, 2023
2f56b51
Add docs and polish
dnkolegov Sep 7, 2023
842981e
Merge branch 'main' into fm-150-deployment-scripts
dnkolegov Sep 7, 2023
88d1e51
Fix misprint in key.rs
dnkolegov Sep 7, 2023
2b9d626
Remove unused imports key.rs
dnkolegov Sep 7, 2023
60ac4f4
move infra
dnkolegov Sep 7, 2023
2a45713
Update docs/localnet.md
dnkolegov Sep 12, 2023
d4f8e00
fix ports in docs
dnkolegov Sep 12, 2023
5d84019
Update docs/localnet.md
dnkolegov Sep 12, 2023
d0f08c8
use deployment
dnkolegov Sep 12, 2023
d1d5ba8
Update fendermint/app/src/cmd/key.rs
dnkolegov Sep 12, 2023
49eb9f4
Update fendermint/app/src/cmd/key.rs
dnkolegov Sep 12, 2023
03b1ac5
Update fendermint/app/src/options/key.rs
dnkolegov Sep 12, 2023
e7a124e
fix comments
dnkolegov Sep 12, 2023
7de41ad
fix push
dnkolegov Sep 12, 2023
ee33f10
fix comments
dnkolegov Sep 12, 2023
3cbb4da
fix push
dnkolegov Sep 12, 2023
9794e8c
fix env
dnkolegov Sep 12, 2023
4f201bb
Fix comments
dnkolegov Sep 12, 2023
bd884f8
Fix comments
dnkolegov Sep 12, 2023
51fee11
fix comments
dnkolegov Sep 13, 2023
075e26f
fox comments
dnkolegov Sep 13, 2023
1e9e9c2
fix docs
dnkolegov Sep 14, 2023
2a7ea81
Merge branch 'main' into fm-150-deployment-scripts
dnkolegov Sep 14, 2023
d0d0eb3
add user
dnkolegov Sep 18, 2023
b69fccc
add UID GID
dnkolegov Sep 18, 2023
26ae867
add UID GID
dnkolegov Sep 18, 2023
809f259
use extend
dnkolegov Sep 19, 2023
02ed819
update
dnkolegov Sep 19, 2023
b1e701e
test new impl
dnkolegov Sep 19, 2023
a683928
remove unused script
dnkolegov Sep 21, 2023
c060163
fix new comments and minor things
dnkolegov Sep 21, 2023
08aabd6
Merge branch 'main' into fm-150-deployment-scripts
dnkolegov Sep 22, 2023
97157e2
fix compose
dnkolegov Sep 25, 2023
7f77aaf
fix scripts
dnkolegov Sep 25, 2023
f642507
remove net
dnkolegov Sep 26, 2023
8aad8ea
fm-150: fix infra/run.sh
adlrocha Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 74 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ cid = { version = "0.8", features = ["serde-codec", "std"] }
# Using the same tendermint-rs dependency as tower-abci. From both we are interested in v037 modules.
tower-abci = { version = "0.7" }
tendermint = { version = "0.31", features = ["secp256k1"] }
tendermint-config = "0.33.0"
tendermint-rpc = { version = "0.31", features = ["secp256k1", "http-client", "websocket-client"] }
tendermint-proto = { version = "0.31" }

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Fendermint is an effort to implement [IPC with Tendermint Core](https://docs.google.com/document/d/1cFoTdoRuYgxmWJia6K-b5vmEj-4MvyHCNvShZpyconU/edit#). There is a preliminary [roadmap](https://docs.google.com/spreadsheets/d/1eVwkHEPGNg0js8DKRDIX7sugf5JqbI9zRBddIqzJFfI/edit#gid=0) that lays out the tasks towards implementing subnets that run IPLD and FVM under the Filecoin rootnet, sharing components with the Lotus/Eudico based implementation.

## Quick Start
- [Local testnets](./docs/localnet.md)

## Docs

Expand Down
61 changes: 61 additions & 0 deletions docs/localnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Local Testnets

Prerequisites:
```bash
make build docker-build
```

## Single node deployment

To run IPC in the local rootnet just perform the following :
```bash
cargo make --makefile ./infra/Makefile.toml node

```

It will create three docker containers (cometbft, fendermint, and eth-api).

To stop run the following:
```bash
cargo make --makefile ./infra/Makefile.toml node-down
```

## Local 4-nodes deployment
To run IPC in the local rootnet with 4 nodes perform the following command :
```bash
cargo make --makefile ./infra/Makefile.toml testnet

```

To stop the network:
```bash
cargo make --makefile ./infra/Makefile.toml testnet-down
```

The testnet contains four logical nodes. Each node consists of cometbft, fendermint, and ethapi containers.
The Docker internal network is `192.167.10.0/24`.

ETH-API is accessible on the following interfaces on the Docker internal network:
- `192.167.10.10:8545` or `ethapi-node0:8545`
- `192.167.10.11:8545` or `ethapi-node1:8545`
- `192.167.10.12:8545` or `ethapi-node2:8545`
- `192.167.10.13:8545` or `ethapi-node3:8545`

and on the following interfaces from the host machine:
- `127.0.0.1:8545`
- `127.0.0.1:8546`
- `127.0.0.1:8547`
- `127.0.0.1:8548`

## Deployment process

The deployment process is as follows:
- Remove all docker containers, files, networks, etc. from the previous deployment
- Create all necessary directories
- Initialize CometBFT testnet by creating `config` and `data` directories using `cometbft` tools
- Read cometbft nodes private keys,derive node IDs and store in `config.toml` for each node
- Create the `genesis` file for Fendermint
- Share the genesis among all Fendermint nodes
- Run Fendermint application in 4 containers
- Run CometBFT in 4 containers
- Run Eth API in 4 containers
1 change: 1 addition & 0 deletions fendermint/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde = { workspace = true }
serde_json = { workspace = true }
serde_with = { workspace = true }
tendermint = { workspace = true }
tendermint-config = { workspace = true }
tendermint-rpc = { workspace = true }
tendermint-proto = { workspace = true }
tokio = { workspace = true }
Expand Down
17 changes: 17 additions & 0 deletions fendermint/app/options/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub enum KeyCommands {
IntoTendermint(KeyIntoTendermintArgs),
/// Convert a public key file from base64 into an f1 Address format an print it to STDOUT.
Address(KeyAddressArgs),
/// Get the peer ID corresponding to a node ID and its network address and print it to a local file.
AddPeer(AddPeer),
}

#[derive(Args, Debug)]
Expand All @@ -21,6 +23,21 @@ pub struct KeyArgs {
pub command: KeyCommands,
}

#[derive(Args, Debug)]
pub struct AddPeer {
/// The path to a CometBFT node key file.
#[arg(long, short = 'n')]
pub node_key_file: PathBuf,
/// The path to a temporal local file where the peer IDs will be added.
/// The file will be created if it doesn't exist.
#[arg(long, short)]
pub local_peers_file: PathBuf,
/// The target CometBFT node network interface in the following format `IP:Port`.
/// For example: `192.168.10.7:26656`.
#[arg(long, short)]
pub network_addr: String,
}

#[derive(Args, Debug)]
pub struct KeyGenArgs {
/// Name used to distinguish the files from other exported keys.
Expand Down
46 changes: 34 additions & 12 deletions fendermint/app/src/cmd/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ use libsecp256k1::{PublicKey, SecretKey};
use rand_chacha::{rand_core::SeedableRng, ChaCha20Rng};
use serde_json::json;
use std::path::{Path, PathBuf};
use tendermint_config::NodeKey;

use super::{from_b64, to_b64};
use crate::{
cmd,
options::key::{KeyAddressArgs, KeyArgs, KeyCommands, KeyGenArgs, KeyIntoTendermintArgs},
options::key::{
AddPeer, KeyAddressArgs, KeyArgs, KeyCommands, KeyGenArgs, KeyIntoTendermintArgs,
},
};

cmd! {
KeyArgs(self) {
match &self.command {
KeyCommands::Gen(args) => args.exec(()).await,
KeyCommands::IntoTendermint(args) => args.exec(()).await,
KeyCommands::Address(args) => args.exec(()).await,
KeyArgs(self) {
match &self.command {
KeyCommands::Gen(args) => args.exec(()).await,
KeyCommands::IntoTendermint(args) => args.exec(()).await,
KeyCommands::AddPeer(args) => args.exec(()).await,
KeyCommands::Address(args) => args.exec(()).await,
}
}
}
}

cmd! {
Expand Down Expand Up @@ -67,14 +71,32 @@ cmd! {
}

cmd! {
KeyAddressArgs(self) {
let pk = read_public_key(&self.public_key)?;
let addr = Address::new_secp256k1(&pk.serialize())?;
println!("{}", addr);
Ok(())
AddPeer(self) {
let node_key = NodeKey::load_json_file(&self.node_key_file).context("failed to read node key file")?;
let peer_id = format!("{}@{}", node_key.node_id(), self.network_addr);
let mut peers = std::fs::read_to_string(&self.local_peers_file).unwrap_or_default();

if peers.is_empty() {
peers.push_str(&peer_id);
} else {
peers.push(',');
peers.push_str(peer_id.as_str());
}

std::fs::write(&self.local_peers_file, peers).context("failed to write to the peers file")?;
Ok(())
}
}

cmd! {
KeyAddressArgs(self) {
let pk = read_public_key(&self.public_key)?;
let addr = Address::new_secp256k1(&pk.serialize())?;
println!("{}", addr);
Ok(())
}
}

fn secret_to_b64(sk: &SecretKey) -> String {
to_b64(&sk.serialize())
}
Expand Down
1 change: 1 addition & 0 deletions infra/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMETBFT_VERSION=v0.37.x
11 changes: 11 additions & 0 deletions infra/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "fendermint_infra"
description = "Workflows for the deployment of Fendermint infrastructure"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Loading