From 229523ceec1975f965bbc4d4c906b49df7926dc8 Mon Sep 17 00:00:00 2001 From: 0g-peterzhb <158457852+0g-peterzhb@users.noreply.github.com> Date: Wed, 30 Apr 2025 14:50:18 +0800 Subject: [PATCH] update the dockerfile to build the node (#366) --- Dockerfile | 29 +++++++++++++++++++++++++++++ DockerfileTurbo | 6 ------ node/src/cli/mod.rs | 1 + run/config-testnet-turbo.toml | 10 +++++----- 4 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 Dockerfile delete mode 100644 DockerfileTurbo diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..63a30db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# ---------- Dockerfile ---------- +FROM rust + +# 0) Install build deps (same as you had) +RUN apt-get update && \ + apt-get install -y clang cmake build-essential pkg-config libssl-dev + +# 1) Copy sources and build the binary +WORKDIR /app +COPY . . +RUN cargo build --release + +# 2) Keep the binary on $PATH (optional convenience) +RUN install -Dm755 target/release/zgs_node /usr/local/bin/zgs_node + +# 3) Persist chain data +VOLUME ["/data"] + +############################################################################### +# 4) Runtime flags – grab everything from env vars that you’ll pass with +# `docker run -e …`. Shell-form CMD lets us interpolate ${…} at start-time. +############################################################################### +CMD zgs_node \ + --config run/config-testnet-turbo.toml \ + --log-config-file run/log_config \ + --miner-key "${STORAGE_MINER_PRIVATE_KEY:?missing STORAGE_MINER_PRIVATE_KEY}" \ + --blockchain-rpc-endpoint "${STORAGE_BLOCKCHAIN_RPC_ENDPOINT:?missing STORAGE_BLOCKCHAIN_RPC_ENDPOINT}" \ + --network-enr-address "${STORAGE_ENR_ADDRESS:?missing STORAGE_ENR_ADDRESS}" \ + --db-max-num-chunks "${STORAGE_DB_MAX_NUM_SECTORS:-8000000000}" diff --git a/DockerfileTurbo b/DockerfileTurbo deleted file mode 100644 index 8c14404..0000000 --- a/DockerfileTurbo +++ /dev/null @@ -1,6 +0,0 @@ -FROM rust -VOLUME ["/data"] -COPY . . -RUN apt-get update && apt-get install -y clang cmake build-essential pkg-config libssl-dev -RUN cargo build --release -CMD ["./target/release/zgs_node", "--config", "run/config-testnet-turbo.toml", "--log", "run/log_config"] \ No newline at end of file diff --git a/node/src/cli/mod.rs b/node/src/cli/mod.rs index 031d11c..0e1042e 100644 --- a/node/src/cli/mod.rs +++ b/node/src/cli/mod.rs @@ -9,6 +9,7 @@ pub fn cli_app() -> Command { arg!(--"blockchain-rpc-endpoint" [URL] "Sets blockchain RPC endpoint (Default: http://127.0.0.1:8545)") ) .arg(arg!(--"db-max-num-chunks" [NUM] "Sets the max number of chunks to store in db (Default: None)")) + .arg(arg!(--"network-enr-address" [URL] "Sets the network ENR address (Default: None)")) .allow_external_subcommands(true) .version(zgs_version::VERSION) } diff --git a/run/config-testnet-turbo.toml b/run/config-testnet-turbo.toml index 0b4e1d0..397c00f 100644 --- a/run/config-testnet-turbo.toml +++ b/run/config-testnet-turbo.toml @@ -33,7 +33,7 @@ # List of nodes to bootstrap UDP discovery. Note, `network_enr_address` should be # configured as well to enable UDP discovery. -network_boot_nodes = ["/ip4/47.251.117.133/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/47.76.61.226/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"] +network_boot_nodes = ["/ip4/47.251.79.83/udp/1234/p2p/16Uiu2HAkvJYQABP1MdvfWfUZUzGLx1sBSDZ2AT92EFKcMCCPVawV", "/ip4/47.238.87.44/udp/1234/p2p/16Uiu2HAmFGsLoajQdEds6tJqsLX7Dg8bYd2HWR4SbpJUut4QXqCj", "/ip4/47.251.78.104/udp/1234/p2p/16Uiu2HAmSe9UWdHrqkn2mKh99b9DwYZZcea6krfidtU3e5tiHiwN", "/ip4/47.76.30.235/udp/1234/p2p/16Uiu2HAm5tCqwGtXJemZqBhJ9JoQxdDgkWYavfCziaqaAYkGDSfU"] # List of libp2p nodes to initially connect to. # network_libp2p_nodes = [] @@ -80,11 +80,11 @@ network_boot_nodes = ["/ip4/47.251.117.133/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJ # blockchain_rpc_endpoint = "http://127.0.0.1:8545" # Flow contract address to sync event logs. -log_contract_address = "0xbD2C3F0E65eDF5582141C35969d66e34629cC768" +log_contract_address = "0x56A565685C9992BF5ACafb940ff68922980DBBC5" # Block number to sync event logs from blockchain. Generally, this is # the block number when flow contract deployed. -log_sync_start_block_number = 595059 +log_sync_start_block_number = 1 # Number of blocks to confirm a transaction. # confirmation_block_count = 3 @@ -158,7 +158,7 @@ log_sync_start_block_number = 595059 ####################################################################### # Mine contract address for incentive. -mine_contract_address = "0x6815F41019255e00D6F34aAB8397a6Af5b6D806f" +mine_contract_address = "0xB87E0e5657C25b4e132CB6c34134C0cB8A962AD6" # Miner key is used to sign blockchain transaction for incentive. # The value should be a hex string of length 64 without 0x prefix. @@ -194,7 +194,7 @@ db_max_num_sectors = 4000000000 # This only applies if there is no stored shard config in db. # shard_position = "0/2" -reward_contract_address = "0x51998C4d486F406a788B766d93510980ae1f9360" +reward_contract_address = "0x233B2768332e4Bae542824c93cc5c8ad5d44517E" # The time interval to check if we should half `shard_position` to prune data. # # prune_check_time_s = 60