From a00eed27f522809340c237bd6f39dd09ffad5d23 Mon Sep 17 00:00:00 2001 From: Ivan Kalinin Date: Tue, 14 May 2024 18:02:23 +0200 Subject: [PATCH] docs: add docs for using prebuilt rocksdb and local network setup --- README.md | 22 +++++++++++++++++++--- justfile | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d2c4b7955..d598180da 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,21 @@ To format code: just fmt ``` +## Local Network + +```bash +# Generate zerostate config stub (with optional --force flag): +just init_zerostate_config +# Generate node config sub (with optional --force flag): +just init_node_config +# Generate a local network of 3 nodes: +just gen_network 3 + +# Start nodes in separate terminals or spawn them with `&`: +just node 1 +just node 2 +just node 3 +``` ## Prebuilt RocksDB @@ -53,7 +68,8 @@ cd /path/to git clone https://github.com/facebook/rocksdb.git cd rocksdb git checkout v8.10.0 -make -j 10 static_lib -export ROCKSDB_LIB_DIR=/path/to/rocksdb +mkdir -p build && cd ./build +cmake -DWITH_LZ4=ON -DWITH_ZSTD=ON -DWITH_JEMALLOC=ON -DCMAKE_BUILD_TYPE=Release .. +make -j16 rocksdb +export ROCKSDB_LIB_DIR=/path/to/rocksdb/build ``` - diff --git a/justfile b/justfile index b6b4192c2..45b038cd1 100644 --- a/justfile +++ b/justfile @@ -74,6 +74,8 @@ integration_test: prepare_integration_tests gen_network n: build_debug #!/usr/bin/env bash + set -eE + TEMP_DIR="./.temp" TYCHO_BIN="./target/debug/tycho" @@ -126,17 +128,56 @@ node n: build_debug --config "$TEMP_DIR/config{{n}}.json" \ --global-config "$TEMP_DIR/global-config.json" \ --import-zerostate "$TEMP_DIR/zerostate.boc" \ - --logger-config ./logger.json \ + --logger-config ./logger.json -init_node_config: build_debug +init_node_config *flags: build_debug #!/usr/bin/env bash + set -eE + + CONFIG_PATH="./config.json" + LOG_PATH="./logger.json" + TYCHO_BIN="./target/debug/tycho" - $TYCHO_BIN node run --init-config "./config.json" + $TYCHO_BIN node run --init-config "$CONFIG_PATH" {{flags}} + + CONFIG=$(jq '.public_ip = "127.0.0.1"' "$CONFIG_PATH") + echo "$CONFIG" > "$CONFIG_PATH" + + if ! [ -f "$LOG_PATH" ]; then + cat << EOF > "$LOG_PATH" + { + "tycho": "info", + "tycho_core": "debug", + "tycho_network": "info", + "collation_manager": "debug", + "mempool_adapter": "debug", + "state_node_adapter": "debug", + "mq_adapter": "debug", + "collator": "debug", + "validator": "debug", + "async_queued_dispatcher": "debug" + } + EOF + fi -init_zerostate_config: build_debug +init_zerostate_config *flags: build_debug #!/usr/bin/env bash + set -eE + + KEYS_PATH="./keys.json" + CONFIG_PATH="./zerostate.json" + TYCHO_BIN="./target/debug/tycho" - $TYCHO_BIN tool gen-zerostate --init-config "./zerostate.json" + + $TYCHO_BIN tool gen-zerostate --init-config "$CONFIG_PATH" {{flags}} + + if ! [ -f "$KEYS_PATH" ]; then + $TYCHO_BIN tool gen-key > "$KEYS_PATH" + fi + + PUBLIC_KEY=$(jq '.public' "$KEYS_PATH") + CONFIG=$(jq ".config_public_key = $PUBLIC_KEY | .minter_public_key = $PUBLIC_KEY" "$CONFIG_PATH") + echo "$CONFIG" > "$CONFIG_PATH" build_debug: cargo build --bin tycho