Skip to content

Commit

Permalink
Merge pull request #27 from tonlabs/feature/console
Browse files Browse the repository at this point in the history
Added node console
  • Loading branch information
ar-tmp authored Oct 18, 2022
2 parents b5e2631 + 70e90fe commit 65b38c2
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [0.2.0] – 2022-10-18

## New

- Node console added
- ton-q-server updated to 0.54.0 version (ext_in_msg_max_size increased to 64 kb)

### Improvements

- updated ton-labs-node from `c5ee530c54199e81e2ca241a17ec23be7290229a` to `befb1ba4d91733ee2c14fa3cf4ebe8047b279e92`

## [0.1.9] – 2022-08-12

### Improvements
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This HOWTO contains instructions on how to build and configure your own free ins
- [2.1 Set the Environment](#21-set-the-environment)
- [2.2 Install Dependencies](#22-install-dependencies)
- [2.3 Deploy Full Node](#23-deploy-full-node)
- [Check Node synchronization status](#Check-Node-synchronization-status)
- [Stopping, restarting and deleting DApp Server](#stopping-restarting-and-deleting-dapp-server)
- [Redeploying DApp Server](#redeploying-dapp-server)

Expand Down Expand Up @@ -77,6 +78,43 @@ Deploy full node:

**Note**: the log generated by this command will be located in the `evernode-ds/scripts/` folder and can be useful for troubleshooting.

# Check Node synchronization status

Use the following command to check if the node is synced:

docker exec rnode /ton-node/tools/console -C /ton-node/configs/console.json --cmd getstats

Script output example:
```
tonlabs console 0.1.286
COMMIT_ID: 5efe6bb8f2a974ba0e6b1ea3e58233632236e182
BUILD_DATE: 2022-10-17 02:32:44 +0300
COMMIT_DATE: 2022-08-12 00:22:07 +0300
GIT_BRANCH: master
{
"sync_status": "synchronization_finished",
"masterchainblocktime": 1665988670,
"masterchainblocknumber": 9194424,
"node_version": "0.51.1",
"public_overlay_key_id": "S4TaVdGitzTApe7GFCj8DbuRIkVEbg+ODzBxhQGIUG0=",
"timediff": 6,
"shards_timediff": 6,
"in_current_vset_p34": false,
"in_next_vset_p36": false,
"last_applied_masterchain_block_id": {"shard":"-1:8000000000000000","seq_no":9194424,"rh":"ff88c27c9bc65762da222d6c14a163a96f7c74b65d1930735e23266a3b07ee8b","fh":"208bf95293feec1afdfdbd65a63c5f3ac4cd6a6fa15ac9e4e88fbfbd6a883edc"},
"processed_workchain": "masterchain",
"validation_stats": {},
"collation_stats": {},
"tps_10": 2,
"tps_300": 2
}
```
If the `timediff` parameter is less than 10 seconds, synchronization with masterchain is complete.
`"sync_status": "synchronization finished"` means synchronization with workchains is complete

**Note**: The sync process may not start for up to one hour after node deployment, during which this command may result in error messages. If errors persist for more than an hour after deployment, review deployment log for errors and check the network status.


# Stopping, restarting and deleting DApp Server

**Note**: call docker-compose commands from the `evernode-ds/docker-compose/ton-node` folder.
Expand Down
2 changes: 2 additions & 0 deletions docker-compose/ton-node/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ STATSD_DOMAIN=statsd:
STATSD_PORT=9125
ADNL_PORT=30303
VALIDATOR_NAME=my_validator
# Supported values: normal, bash
NODE_CMD_1=normal
11 changes: 6 additions & 5 deletions docker-compose/ton-node/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FROM ubuntu:18.04 as build
ARG RUST_VERSION

COPY ton-node /tonlabs/ton-node/
COPY ton-labs-node-tools /tonlabs/ton-labs-node-tools/

# install deps
ENV TZ=Europe/Moscow
Expand Down Expand Up @@ -41,13 +42,14 @@ RUN curl https://packages.confluent.io/deb/5.5/archive.key | apt-key add;\

# Get Rust
COPY rust_install.sh /tmp/rust_install.sh

RUN bash -c "/tmp/rust_install.sh ${RUST_VERSION}"

WORKDIR /tonlabs/ton-node
#RUN cargo update && cargo build --release --features "external_db,metrics,compression"
RUN cargo update && cargo build --release --features "external_db,metrics"

WORKDIR /tonlabs/ton-labs-node-tools
RUN cargo update && cargo build --release

FROM ubuntu:18.04 as build2

ARG RUST_VERSION
Expand Down Expand Up @@ -87,6 +89,5 @@ COPY rust_install.sh /tmp/rust_install.sh
RUN bash -c "/tmp/rust_install.sh ${RUST_VERSION}"

COPY --from=build /tonlabs/ton-node/target/release/ton_node /ton-node/
COPY entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
COPY --from=build /tonlabs/ton-labs-node-tools/target/release/console /ton-node/tools/
COPY --from=build /tonlabs/ton-labs-node-tools/target/release/keygen /ton-node/tools/
5 changes: 5 additions & 0 deletions docker-compose/ton-node/configs/console_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"config": null,
"wallet_id": null,
"max_factor": 3
}
4 changes: 3 additions & 1 deletion docker-compose/ton-node/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ services:
- proxy_nw
volumes:
- ./configs/:/ton-node/configs/
- ./scripts/:/ton-node/scripts/
- ./logs/:/ton-node/logs/
- DB:/ton-node/node_db/
- /tmp/metrics/:/tmp/metrics/
command: ["normal"]
entrypoint: /ton-node/scripts/entrypoint.sh
command: ["${NODE_CMD_1}"]
mem_limit: "${MEM_LIMIT}"
logging:
driver: json-file
Expand Down
File renamed without changes.
48 changes: 48 additions & 0 deletions docker-compose/ton-node/scripts/generate_console_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash -eEx

if [ "$DEBUG" = "yes" ]; then
set -x
fi

export TON_NODE_ROOT_DIR="/ton-node"
export TON_NODE_CONFIGS_DIR="${TON_NODE_ROOT_DIR}/configs"
export TON_NODE_TOOLS_DIR="${TON_NODE_ROOT_DIR}/tools"
export TON_NODE_LOGS_DIR="${TON_NODE_ROOT_DIR}/logs"
export RNODE_CONSOLE_SERVER_PORT="3031"

HOSTNAME=$(hostname -f)
TMP_DIR="/tmp/$(basename "$0" .sh)_$$"
rm -rf "${TMP_DIR}"
mkdir -p "${TMP_DIR}"

"${TON_NODE_TOOLS_DIR}/keygen" >"${TON_NODE_CONFIGS_DIR}/${HOSTNAME}_console_client_keys.json"
cat "${TON_NODE_CONFIGS_DIR}/${HOSTNAME}_console_client_keys.json"
jq -c .public "${TON_NODE_CONFIGS_DIR}/${HOSTNAME}_console_client_keys.json" >"${TON_NODE_CONFIGS_DIR}/console_client_public.json"

jq ".control_server_port = ${RNODE_CONSOLE_SERVER_PORT}" "${TON_NODE_CONFIGS_DIR}/default_config.json" >"${TMP_DIR}/default_config.json.tmp"
cp "${TMP_DIR}/default_config.json.tmp" "${TON_NODE_CONFIGS_DIR}/default_config.json"

# Generate initial config.json
cd "${TON_NODE_ROOT_DIR}" && "${TON_NODE_ROOT_DIR}/ton_node" --configs "${TON_NODE_CONFIGS_DIR}" --ckey "$(cat "${TON_NODE_CONFIGS_DIR}/console_client_public.json")" &

sleep 10

if [ ! -f "${TON_NODE_CONFIGS_DIR}/config.json" ]; then
echo "ERROR: ${TON_NODE_CONFIGS_DIR}/config.json does not exist"
exit 1
fi

cat "${TON_NODE_CONFIGS_DIR}/config.json"

if [ ! -f "${TON_NODE_CONFIGS_DIR}/console_config.json" ]; then
echo "ERROR: ${TON_NODE_CONFIGS_DIR}/console_config.json does not exist"
exit 1
fi

cat "${TON_NODE_CONFIGS_DIR}/console_config.json"

jq ".client_key = $(jq .private "${TON_NODE_CONFIGS_DIR}/${HOSTNAME}_console_client_keys.json")" "${TON_NODE_CONFIGS_DIR}/console_config.json" >"${TMP_DIR}/console_config.json.tmp"
jq ".config = $(cat "${TMP_DIR}/console_config.json.tmp")" "${TON_NODE_CONFIGS_DIR}/console_template.json" >"${TON_NODE_CONFIGS_DIR}/console.json"
rm -f "${TON_NODE_CONFIGS_DIR}/console_config.json"

rm -rf "${TMP_DIR}"
9 changes: 9 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,23 @@ cd "${DOCKER_COMPOSE_DIR}/statsd/" && docker-compose up -d

sed -i "s|ADNL_PORT.*|ADNL_PORT=${ADNL_PORT}|" "${DOCKER_COMPOSE_DIR}/ton-node/.env"
sed -i "s|NETWORK_TYPE.*|NETWORK_TYPE=${NETWORK_TYPE}|" "${DOCKER_COMPOSE_DIR}/ton-node/.env"
sed -i "s|NODE_CMD_1=.*|NODE_CMD_1=bash|g" "${DOCKER_COMPOSE_DIR}/ton-node/.env"

rm -rf "${DOCKER_COMPOSE_DIR}/ton-node/build/ton-node"
cd "${DOCKER_COMPOSE_DIR}/ton-node/build" && git clone --recursive "${TON_NODE_GITHUB_REPO}" ton-node
cd "${DOCKER_COMPOSE_DIR}/ton-node/build/ton-node" && git checkout "${TON_NODE_GITHUB_COMMIT_ID}"

rm -rf "${DOCKER_COMPOSE_DIR}/ton-node/build/ton-labs-node-tools"
cd "${DOCKER_COMPOSE_DIR}/ton-node/build" && git clone --recursive "${TON_NODE_TOOLS_GITHUB_REPO}"
cd "${DOCKER_COMPOSE_DIR}/ton-node/build/ton-labs-node-tools" && git checkout "${TON_NODE_TOOLS_GITHUB_COMMIT_ID}"

echo "==============================================================================="
echo "INFO: starting node on ${HOSTNAME}..."
cd "${DOCKER_COMPOSE_DIR}/ton-node/" && docker-compose up -d
docker exec --tty rnode "/ton-node/scripts/generate_console_config.sh"
sed -i "s|NODE_CMD_1.*|NODE_CMD_1=normal|g" "${DOCKER_COMPOSE_DIR}/ton-node/.env"
cd "${DOCKER_COMPOSE_DIR}/ton-node/" && docker-compose stop
cd "${DOCKER_COMPOSE_DIR}/ton-node/" && docker-compose up -d
echo "INFO: starting node on ${HOSTNAME}... DONE"
echo "==============================================================================="

Expand Down
6 changes: 4 additions & 2 deletions scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export EMAIL_FOR_NOTIFICATIONS="email@yourdomain.com"
export COMPOSE_HTTP_TIMEOUT=120 # in sec, 60 sec - default
HOSTNAME=$(hostname -f)
export TON_Q_SERVER_GITHUB_REPO="https://github.com/tonlabs/ton-q-server"
export TON_Q_SERVER_GITHUB_COMMIT_ID="0.52.1"
export TON_Q_SERVER_GITHUB_COMMIT_ID="0.54.0"
export TON_NODE_GITHUB_REPO="https://github.com/tonlabs/ton-labs-node"
export TON_NODE_GITHUB_COMMIT_ID="c5ee530c54199e81e2ca241a17ec23be7290229a"
export TON_NODE_GITHUB_COMMIT_ID="befb1ba4d91733ee2c14fa3cf4ebe8047b279e92"
export TON_NODE_TOOLS_GITHUB_REPO="https://github.com/tonlabs/ton-labs-node-tools.git"
export TON_NODE_TOOLS_GITHUB_COMMIT_ID="master"

0 comments on commit 65b38c2

Please sign in to comment.