From d9230753ae82df92bce239cc0c52f103f9e08d72 Mon Sep 17 00:00:00 2001 From: 0xbcdev <0xbcdev@bcdev.tools> Date: Mon, 10 Jun 2024 12:15:45 +0700 Subject: [PATCH 1/4] improve validator web page content --- client/html/index.tmpl | 11 ++++++----- services/web_server/handle_web_page.go | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/client/html/index.tmpl b/client/html/index.tmpl index b93f10f..81dc93c 100644 --- a/client/html/index.tmpl +++ b/client/html/index.tmpl @@ -17,6 +17,7 @@ + @@ -76,7 +77,7 @@
Download: addrbook.json
-wget -O addrbook.json https://{[{ .host }]}/download/addrbook.json --inet4-only
+ wget -O addrbook.json https://{[{ .host }]}/download/addrbook.json
mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config
{[{ else }]}
Addrbook temporary not available
@@ -112,7 +113,7 @@ mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config
cp $HOME/{[{ .generalNodeHomeName }]}/data/priv_validator_state.json $HOME/{[{ .generalNodeHomeName }]}/priv_validator_state.json
Verify `priv_validator_key.json` and the backup are equals
sleep 10 && cat $HOME/{[{ .generalNodeHomeName }]}/data/priv_validator_state.json && cat $HOME/{[{ .generalNodeHomeName }]}/priv_validator_state.json
- Reset your node
+Reset data of the node
{[{ .generalBinaryName }]} tendermint unsafe-reset-all --home $HOME/{[{ .generalNodeHomeName }]} --keep-addr-book
Decompress the snapshot to your database location. Your database location under `{[{ .generalNodeHomeName }]}/data` or something like that, depending on the node implementation.
lz4 -c -d {[{ .snapshot.FileName }]} | tar -x -C $HOME/{[{ .generalNodeHomeName }]}/data
@@ -154,9 +155,9 @@ mv addrbook.json $HOME/{[{ .generalNodeHomeName }]}/config
Our state-sync RPC server for {[{ .chainName }]} is
{[{ .rpcUrl }]}
- Create a reusable shell script such as `state_sync.sh` with the following code. + Prepare a reusable script `state_sync.sh` with the following code. The code will fetch important state-sync information (such as block height and trust hash) - from our server and update your `config.toml` file accordingly. + from RPC server and update your `config.toml` file accordingly.
#!/bin/bash
@@ -175,7 +176,7 @@ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/{[{ .gener
{[{ end }]}
Stop the node
sudo systemctl stop {[{ .generalBinaryName }]}
- Reset the node
+ Reset data of the node
{[{ .generalBinaryName }]} tendermint unsafe-reset-all --home $HOME/{[{ .generalNodeHomeName }]} --keep-addr-book
Execute the script
sh state_sync.sh
diff --git a/services/web_server/handle_web_page.go b/services/web_server/handle_web_page.go
index 7265d2e..9e5b058 100644
--- a/services/web_server/handle_web_page.go
+++ b/services/web_server/handle_web_page.go
@@ -2,6 +2,7 @@ package web_server
import (
"fmt"
+ "github.com/bcdevtools/node-management/constants"
webtypes "github.com/bcdevtools/node-management/services/web_server/types"
"github.com/bcdevtools/node-management/types"
"github.com/bcdevtools/node-management/utils"
@@ -23,7 +24,7 @@ func HandleWebIndex(c *gin.Context) {
var livePeers string
var livePeersCount int
- peers, err := getLivePeers(w.Config())
+ peers, err := getLivePeers(cfg)
if err != nil {
utils.PrintlnStdErr("ERR: failed to get live peers:", err)
} else {
@@ -37,6 +38,10 @@ func HandleWebIndex(c *gin.Context) {
snapshotInfo := getSnapshotInfo(cfg)
+ if snapshotInfo.Error != nil && cfg.Debug {
+ utils.PrintlnStdErr("ERR: failed to get snapshot info:", snapshotInfo.Error)
+ }
+
var chainDescriptionLines []string
if cfg.ChainDescription != "" {
chainDescriptionLines = strings.Split(cfg.ChainDescription, "\\n")
@@ -64,6 +69,7 @@ func HandleWebIndex(c *gin.Context) {
"generalNodeHomeName": cfg.GeneralNodeHomeName,
"generalBinaryName": cfg.GeneralBinaryName,
"snapshot": snapshotInfo,
+ "binaryVersion": constants.VERSION,
})
}
From f562094d4e4ff86e06e7ea58354698b529a06873 Mon Sep 17 00:00:00 2001
From: 0xbcdev <0xbcdev@bcdev.tools>
Date: Mon, 10 Jun 2024 18:07:38 +0700
Subject: [PATCH 2/4] add footer
---
client/html/index.tmpl | 18 ++++++++++++++----
services/web_server/handle_web_page.go | 1 +
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/client/html/index.tmpl b/client/html/index.tmpl
index 81dc93c..e02c242 100644
--- a/client/html/index.tmpl
+++ b/client/html/index.tmpl
@@ -21,17 +21,20 @@
- {[{ if .brand }]}
- {[{ end }]}
-
- {[{ .description }]}
+
+ {[{ .description }]}
{[{ if .logo }]}
@@ -187,6 +190,13 @@ s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/{[{ .gener
+