Skip to content

Commit

Permalink
Improvements on standalone node execution (#55)
Browse files Browse the repository at this point in the history
## What ❔

Documented a guide on setting up and running a local consensus node,
along with a new Makefile containing commands for easy execution. Also
modifies the database directory path for each node.

## Why ❔

The README and the Makefile would streamline generating the
configuration for all nodes with a single command and simplify running
the desired node. About the modification for the database directory
path, it seems beneficial for running multiple nodes on a single
machine, especially for local testing. However, in the broader
architecture of the Test Framework, each node is expected to operate
within a distinct Docker container or a similar setup. In that context,
this change might not be useful.
  • Loading branch information
IAvecilla authored Jan 10, 2024
1 parent 5727a3e commit dbdc531
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions node/tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: run-node node-configs clean
IP?=127.0.0.1:3054

run-node:
export RUST_LOG=INFO && cd node-configs/${IP} && cargo run -- --database ./database/${IP}

node-configs:
cargo run --bin localnet_config -- --input-addrs addresses.txt --output-dir node-configs

clean:
rm -rf node-configs
rm -rf database
5 changes: 5 additions & 0 deletions node/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Running a test node

1. Generate a file named `addresses.txt` in the root directory of the tools crate, containing node addresses in the format `IP:PORT`, with each address on a separate line.
2. Run `make node-configs`. This command will establish a directory named `node-configs` and create a folder for each address listed in the `.txt` file, providing the necessary configuration files for the respective node.
3. Execute `make run-node IP=<NODE_IP>`. The default value for this command would be `127.0.0.1:3054`. Note that running this command will take control of the terminal.
4 changes: 2 additions & 2 deletions node/tools/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ async fn main() -> anyhow::Result<()> {
fs::create_dir_all("logs/")?;
let log_file = fs::File::create("logs/output.log")?;

// Create the logger for stdout. This will produce human-readable logs for
// all events of level INFO or higher.
// Create the logger for stdout. This will produce human-readable logs for ERROR events.
// To see logs for other events, set the RUST_LOG environment to the desired level.
let stdout_log = tracing_subscriber::fmt::layer()
.pretty()
.with_ansi(std::env::var("NO_COLOR").is_err() && std::io::stdout().is_terminal())
Expand Down

0 comments on commit dbdc531

Please sign in to comment.