all: make nodes publish coinbase address to stats server (#1967)

* allow customizable stats server parameters

* pass coinbase address to stats server
This commit is contained in:
Wanwiset Peerapatanapokin 2026-02-05 18:59:00 +07:00 committed by GitHub
parent bfc69a09d7
commit 5340ce712c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 97 additions and 24 deletions

View file

@ -73,7 +73,7 @@ fi
sync_mode=full
if test -z "$SYNC_MODE"
then
echo "SYNC_MODE not set, default to full" #full or fast
echo "SYNC_MODE not set, default to $sync_mode" #full or fast
else
echo "SYNC_MODE found, set to $SYNC_MODE"
sync_mode=$SYNC_MODE
@ -82,14 +82,33 @@ fi
gc_mode=archive
if test -z "$GC_MODE"
then
echo "GC_MODE not set, default to archive" #full or archive
echo "GC_MODE not set, default to $gc_mode" #full or archive
else
echo "GC_MODE found, set to $GC_MODE"
gc_mode=$GC_MODE
fi
ethstats_address=localhost:2000
if test -z "$STATS_ADDRESS"
then
echo "STATS_ADDRESS not set, default to $ethstats_address"
else
echo "STATS_ADDRESS found, set to $STATS_ADDRESS"
ethstats_address=$STATS_ADDRESS
fi
echo "Running a node with wallet: ${wallet} at IP: ${instance_ip}"
ethstats_secret=xinfin_xdpos_hybrid_local_stats
if test -z "$STATS_SECRET"
then
echo "STATS_SECRET not set, default to $ethstats_secret"
else
echo "STATS_SECRET found, set to $STATS_SECRET"
ethstats_secret=$STATS_SECRET
fi
netstats="${NODE_NAME}-${wallet}:$ethstats_secret@$ethstats_address"
echo "Running a node with wallet: ${wallet}"
echo "Starting nodes with $bootnodes ..."
# Note: --gcmode=archive means node will store all historical data. This will lead to high memory usage. But sync mode require archive to sync
@ -97,6 +116,7 @@ echo "Starting nodes with $bootnodes ..."
XDC \
--gcmode ${gc_mode} --syncmode ${sync_mode} \
--ethstats ${netstats} \
--nat extip:${instance_ip} \
--bootnodes ${bootnodes} \
--datadir /work/xdcchain \

View file

@ -61,22 +61,41 @@ fi
sync_mode=full
if test -z "$SYNC_MODE"; then
echo "SYNC_MODE not set, default to full" #full or fast
echo "SYNC_MODE not set, default to $sync_mode" #full or fast
else
echo "SYNC_MODE found, set to $SYNC_MODE"
sync_mode=$SYNC_MODE
fi
gc_mode=archive
gc_mode=full
if test -z "$GC_MODE"; then
echo "GC_MODE not set, default to archive" #full or archive
echo "GC_MODE not set, default to $gc_mode" #full or archive
else
echo "GC_MODE found, set to $GC_MODE"
gc_mode=$GC_MODE
fi
ethstats_address=stats.xinfin.network:3000
if test -z "$STATS_ADDRESS"
then
echo "STATS_ADDRESS not set, default to $ethstats_address"
else
echo "STATS_ADDRESS found, set to $STATS_ADDRESS"
ethstats_address=$STATS_ADDRESS
fi
ethstats_secret=xinfin_xdpos_hybrid_network_stats
if test -z "$STATS_SECRET"
then
echo "STATS_SECRET not set, default to $ethstats_secret"
else
echo "STATS_SECRET found, set to $STATS_SECRET"
ethstats_secret=$STATS_SECRET
fi
netstats="${NODE_NAME}-${wallet}:$ethstats_secret@$ethstats_address"
INSTANCE_IP=$(curl https://checkip.amazonaws.com)
netstats="${NODE_NAME}-${wallet}-${INSTANCE_IP}:xinfin_xdpos_hybrid_network_stats@stats.xinfin.network:3000"
echo "Running a node with wallet: ${wallet} at IP: ${INSTANCE_IP}"
echo "Starting nodes with $bootnodes ..."

View file

@ -25,6 +25,7 @@ do
bootnodes="${bootnodes},$line"
fi
done < "$input"
#check last line since it's not included in "read" command https://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line
if [ -z "${bootnodes}" ]
then
@ -72,23 +73,42 @@ fi
sync_mode=full
if test -z "$SYNC_MODE"
then
echo "SYNC_MODE not set, default to full" #full or fast
echo "SYNC_MODE not set, default to $sync_mode" #full or fast
else
echo "SYNC_MODE found, set to $SYNC_MODE"
sync_mode=$SYNC_MODE
fi
gc_mode=archive
gc_mode=full
if test -z "$GC_MODE"
then
echo "GC_MODE not set, default to archive" #full or archive
echo "GC_MODE not set, default to $gc_mode" #full or archive
else
echo "GC_MODE found, set to $GC_MODE"
gc_mode=$GC_MODE
fi
ethstats_address=stats.apothem.network:2000
if test -z "$STATS_ADDRESS"
then
echo "STATS_ADDRESS not set, default to $ethstats_address"
else
echo "STATS_ADDRESS found, set to $STATS_ADDRESS"
ethstats_address=$STATS_ADDRESS
fi
ethstats_secret=xdc_xinfin_apothem_network_stats
if test -z "$STATS_SECRET"
then
echo "STATS_SECRET not set, default to $ethstats_secret"
else
echo "STATS_SECRET found, set to $STATS_SECRET"
ethstats_secret=$STATS_SECRET
fi
netstats="${NODE_NAME}-${wallet}:$ethstats_secret@$ethstats_address"
INSTANCE_IP=$(curl https://checkip.amazonaws.com)
netstats="${NODE_NAME}-${wallet}-${INSTANCE_IP}:xdc_xinfin_apothem_network_stats@stats.apothem.network:2000"
echo "Running a node with wallet: ${wallet} at IP: ${INSTANCE_IP}"

View file

@ -30,6 +30,7 @@ import (
"sync"
"time"
"github.com/XinFinOrg/XDPoSChain/accounts"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/common/mclock"
"github.com/XinFinOrg/XDPoSChain/consensus"
@ -78,6 +79,7 @@ type backend interface {
Downloader() *downloader.Downloader
Engine() consensus.Engine
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
AccountManager() *accounts.Manager
}
// fullNodeBackend encompasses the functionality necessary for a full node
@ -103,9 +105,10 @@ type Service struct {
backend backend
engine consensus.Engine // Consensus engine to retrieve variadic block fields
node string // Name of the node to display on the monitoring page
pass string // Password to authorize access to the monitoring page
host string // Remote address of the monitoring service
node string // Name of the node to display on the monitoring page
coinbase string // Coinbase address of the node
pass string // Password to authorize access to the monitoring page
host string // Remote address of the monitoring service
pongCh chan struct{} // Pong notifications are fed into this channel
histCh chan []uint64 // History request block numbers are fed into this channel
@ -195,14 +198,23 @@ func New(node *node.Node, backend backend, engine consensus.Engine, url string)
return err
}
ethstats := &Service{
backend: backend,
engine: engine,
server: node.Server(),
node: parts[0],
pass: parts[1],
host: parts[2],
pongCh: make(chan struct{}),
histCh: make(chan []uint64, 1),
backend: backend,
engine: engine,
server: node.Server(),
node: parts[0],
coinbase: "", // will be set below
pass: parts[1],
host: parts[2],
pongCh: make(chan struct{}),
histCh: make(chan []uint64, 1),
}
if am := backend.AccountManager(); am != nil {
accounts := am.Accounts()
if len(accounts) > 0 {
coinbase := accounts[0]
ethstats.coinbase = coinbase.String0x()
}
}
node.RegisterLifecycle(ethstats)
@ -480,6 +492,7 @@ func (s *Service) readLoop(conn *connWrapper) {
type nodeInfo struct {
Name string `json:"name"`
Node string `json:"node"`
Coinbase string `json:"coinbase"`
Port int `json:"port"`
Network string `json:"net"`
Protocol string `json:"protocol"`
@ -512,8 +525,9 @@ func (s *Service) login(conn *connWrapper) error {
auth := &authMsg{
ID: s.node,
Info: nodeInfo{
Name: s.node,
Node: infos.Name,
Name: s.node,
Node: infos.Name,
Coinbase: s.coinbase,
Port: infos.Ports.Listener,
Network: network,
Protocol: protocol,