Skip to content

Commit 2a9a580

Browse files
committed
update readme
1 parent 6f5bba4 commit 2a9a580

File tree

5 files changed

+311
-3
lines changed

5 files changed

+311
-3
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@ To learn how the Hetu works from a high-level perspective,
3636
go to the [Protocol Overview](https://docs.hetu.org/protocol) section from the documentation.
3737
You can also check the instructions to [Run a Node](https://docs.hetu.org/protocol/hetu-cli#run-a-hetu-node).
3838

39+
## Deployment
40+
41+
### Local Deployment
42+
43+
To deploy locally, use the `local_node.sh` script. This script will set up a local environment for running the Hetu Chain node.
44+
45+
```bash
46+
./local_node.sh
47+
```
48+
49+
### Remote Deployment
50+
51+
For remote deployment, ensure that `hhubd` is available in the `PATH` on each machine. It is also recommended to set up SSH keys on the remote machines for secure and passwordless access.
52+
53+
1. `init_validators.sh`: This script initializes the validators required for the Hetu Chain. You need to provide the remote IPs for the 4 validators in the network as parameters.
54+
55+
```bash
56+
./init_validators.sh <remote_ip1> <remote_ip2> <remote_ip3> <remote_ip4>
57+
```
58+
59+
2. `start_node_archive.sh`: This script starts the node in archive mode.
60+
61+
```bash
62+
./start_node_archive.sh
63+
```
64+
65+
These scripts will help you set up and run the Hetu Chain on a remote server.
66+
3967
## Community
4068

4169
The following chat channels and forums are a great spot to ask questions about Hetu Chain:

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.23.3
44

55
require (
66
cosmossdk.io/api v0.7.6
7+
cosmossdk.io/client/v2 v2.0.0-beta.5
78
cosmossdk.io/core v0.11.1
89
cosmossdk.io/errors v1.0.1
910
cosmossdk.io/log v1.4.1
@@ -68,7 +69,6 @@ require (
6869
cloud.google.com/go/compute/metadata v0.5.0 // indirect
6970
cloud.google.com/go/iam v1.1.9 // indirect
7071
cloud.google.com/go/storage v1.41.0 // indirect
71-
cosmossdk.io/client/v2 v2.0.0-beta.5 // indirect
7272
cosmossdk.io/collections v0.4.0 // indirect
7373
cosmossdk.io/depinject v1.1.0 // indirect
7474
cosmossdk.io/x/circuit v0.1.1 // indirect
@@ -268,6 +268,7 @@ replace (
268268
cosmossdk.io/store => github.com/hetu-project/cosmos-sdk/store v0.0.0-20240718141609-414cbd051fbe
269269
// use cosmos keyring
270270
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
271+
github.com/cometbft/cometbft => github.com/hetu-project/hetu-parallel-engine/hetu-cometbft v0.0.0-20250127071645-b3f53d769924
271272
github.com/cosmos/cosmos-sdk => github.com/hetu-project/cosmos-sdk v0.50.9-hetu
272273

273274
// use geth fork

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,6 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:
371371
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
372372
github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA=
373373
github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c=
374-
github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cVrqXg=
375-
github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ=
376374
github.com/cometbft/cometbft-db v0.15.0 h1:VLtsRt8udD4jHCyjvrsTBpgz83qne5hnL245AcPJVRk=
377375
github.com/cometbft/cometbft-db v0.15.0/go.mod h1:EBrFs1GDRiTqrWXYi4v90Awf/gcdD5ExzdPbg4X8+mk=
378376
github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8=
@@ -771,6 +769,8 @@ github.com/hetu-project/cosmos-sdk/store v0.0.0-20240718141609-414cbd051fbe h1:e
771769
github.com/hetu-project/cosmos-sdk/store v0.0.0-20240718141609-414cbd051fbe/go.mod h1:Bm6h8ZkYgVTytHK5vhHOMKw9OHyiumm3b1UbkYIJ/Ug=
772770
github.com/hetu-project/go-ethereum v1.10.26-hetu h1:YgzTOXOs1jCuBslUifM0KfrImNIPxt1pEhLPuOu2aEI=
773771
github.com/hetu-project/go-ethereum v1.10.26-hetu/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo=
772+
github.com/hetu-project/hetu-parallel-engine/hetu-cometbft v0.0.0-20250127071645-b3f53d769924 h1:vxeVKyee4/Te5uJkFdX+IRNcUIaRldnKkFCm/t+QKUM=
773+
github.com/hetu-project/hetu-parallel-engine/hetu-cometbft v0.0.0-20250127071645-b3f53d769924/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ=
774774
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
775775
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
776776
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8=

init_validators.sh

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
# Check arguments
7+
if [ "$#" -lt 4 ]; then
8+
echo "Usage: $0 <validator0_ip> <validator1_ip> <validator2_ip> <validator3_ip>"
9+
echo "Example: $0 1.2.3.4 5.6.7.8 9.10.11.12 13.14.15.16"
10+
exit 1
11+
fi
12+
13+
# validate dependencies are installed
14+
command -v jq >/dev/null 2>&1 || {
15+
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
16+
exit 1
17+
}
18+
19+
# Set number of validators
20+
NUM_VALIDATORS=4
21+
22+
# Store validator IPs in array
23+
declare -a VALIDATOR_IPS=($1 $2 $3 $4)
24+
echo "All validator IPs: ${VALIDATOR_IPS[@]}"
25+
echo "Number of validators: $NUM_VALIDATORS"
26+
27+
# Configuration
28+
CHAIN_ID="hhub_9000-1"
29+
KEYRING="test"
30+
KEYALGO="eth_secp256k1"
31+
DENOM="ahhub"
32+
HOME_PREFIX="$HOME/.hhubd"
33+
# Set balance and stake amounts (matching local_node.sh exactly)
34+
GENESIS_BALANCE="1000000000000000000000000000" # 1 million hhub
35+
GENTX_STAKE="1000000000000000000000000" # 1 million hhub (1000000000000000000000000 = 10^24)
36+
BASEFEE=1000000000
37+
38+
# Port configuration
39+
P2P_PORT=26656
40+
RPC_PORT=26657 # Must be different from P2P_PORT
41+
API_PORT=1317
42+
GRPC_PORT=9090
43+
GRPC_WEB_PORT=9092
44+
JSON_RPC_PORT=8545
45+
WS_PORT=8546
46+
47+
# Clean up all existing data locally and remotely
48+
echo "Cleaning up all existing data..."
49+
50+
# Clean local node data
51+
rm -rf "${HOME_PREFIX}"/*
52+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
53+
echo "Cleaning up local validator $i data..."
54+
rm -rf "${HOME}/.hhubd$i"
55+
done
56+
57+
# Clean remote node data (skip any IP matching primary)
58+
PRIMARY_IP=${VALIDATOR_IPS[0]}
59+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
60+
TARGET_IP=${VALIDATOR_IPS[$i]}
61+
if [ "$TARGET_IP" = "$PRIMARY_IP" ]; then
62+
echo "Skipping IP $TARGET_IP since it matches primary node"
63+
continue
64+
fi
65+
echo "Cleaning up data on $TARGET_IP..."
66+
ssh root@${TARGET_IP} 'rm -rf ~/.hhubd ~/.hhubd* 2>/dev/null || true'
67+
done
68+
69+
# Initialize primary node
70+
echo "Initializing primary node..."
71+
hhubd init "node0" -o --chain-id="${CHAIN_ID}" --home "${HOME_PREFIX}"
72+
73+
# Path variables
74+
GENESIS="${HOME_PREFIX}/config/genesis.json"
75+
TMP_GENESIS="${HOME_PREFIX}/config/tmp_genesis.json"
76+
77+
# Change parameter token denominations to ahhub
78+
jq --arg denom "$DENOM" '.app_state["staking"]["params"]["bond_denom"]=$denom' "$GENESIS" > "$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
79+
jq --arg denom "$DENOM" '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]=$denom' "$GENESIS" > "$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
80+
jq --arg denom "$DENOM" '.app_state["gov"]["params"]["min_deposit"][0]["denom"]=$denom' "$GENESIS" > "$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
81+
jq --arg denom "$DENOM" '.app_state["inflation"]["params"]["mint_denom"]=$denom' "$GENESIS" > "$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
82+
83+
# Set gas limit in genesis
84+
jq '.consensus_params["block"]["max_gas"]="10000000"' "$GENESIS" > "$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
85+
86+
# Set base fee in genesis
87+
jq --arg fee "$BASEFEE" '.app_state["feemarket"]["params"]["base_fee"]=$fee' "$GENESIS" > "$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS"
88+
89+
# Change proposal periods to pass within a reasonable time
90+
sed -i.bak 's/"max_deposit_period": "172800s"/"max_deposit_period": "30s"/g' "$GENESIS"
91+
sed -i.bak 's/"voting_period": "172800s"/"voting_period": "30s"/g' "$GENESIS"
92+
sed -i.bak 's/"expedited_voting_period": "86400s"/"expedited_voting_period": "15s"/g' "$GENESIS"
93+
94+
# Create gentx directory in primary node
95+
mkdir -p "${HOME_PREFIX}/config/gentx"
96+
97+
# Create validator keys and add genesis accounts
98+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
99+
echo "Creating validator $i key..."
100+
hhubd keys add "validator$i" \
101+
--keyring-backend="${KEYRING}" \
102+
--algo="${KEYALGO}" \
103+
--home "${HOME_PREFIX}"
104+
105+
echo "Adding genesis account for validator $i..."
106+
hhubd add-genesis-account "validator$i" "${GENESIS_BALANCE}${DENOM}" \
107+
--keyring-backend="${KEYRING}" \
108+
--home "${HOME_PREFIX}"
109+
done
110+
111+
# Create clone directories, gentx, and get node IDs
112+
declare -a NODE_IDS
113+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
114+
CLONE_HOME="${HOME}/.hhubd$i"
115+
echo "Creating gentx for validator $i in ${CLONE_HOME}..."
116+
117+
# Initialize fresh node
118+
rm -rf "${CLONE_HOME}"
119+
hhubd init "node$i" --chain-id="${CHAIN_ID}" --home "${CLONE_HOME}" >/dev/null 2>&1
120+
121+
# Get and store node ID early
122+
NODE_IDS[$i]=$(hhubd tendermint show-node-id --home "${CLONE_HOME}")
123+
echo "Node $i ID: ${NODE_IDS[$i]}"
124+
125+
# Copy necessary files from primary node
126+
cp "${HOME_PREFIX}/config/genesis.json" "${CLONE_HOME}/config/"
127+
cp -r "${HOME_PREFIX}/keyring-test" "${CLONE_HOME}/" 2>/dev/null || true
128+
mkdir -p "${CLONE_HOME}/config/gentx"
129+
130+
# Set pruning to nothing for archive mode and configure settings
131+
APP_TOML="${CLONE_HOME}/config/app.toml"
132+
CONFIG_TOML="${CLONE_HOME}/config/config.toml"
133+
134+
# Archive mode settings
135+
sed -i.bak 's/^pruning = "default"/pruning = "nothing"/' "$APP_TOML"
136+
137+
# Configure external access in config.toml
138+
# Update RPC and P2P ports
139+
sed -i.bak -e '/^\[rpc\]/,/^\[/s|^laddr *= *.*|laddr = "tcp://0.0.0.0:26657"|' "$CONFIG_TOML"
140+
sed -i.bak -e '/^\[p2p\]/,/^\[/s|^laddr *= *.*|laddr = "tcp://0.0.0.0:26656"|' "$CONFIG_TOML"
141+
142+
# Update other settings
143+
sed -i.bak \
144+
-e "s/^moniker *=.*/moniker = \"node${i}\"/" \
145+
-e "s/^proxy_app *=.*/proxy_app = \"tcp:\/\/127.0.0.1:26658\"/" \
146+
-e "s/^allow_duplicate_ip *=.*/allow_duplicate_ip = true/" \
147+
-e "s/^#allow_duplicate_ip *=.*/allow_duplicate_ip = true/" \
148+
"$CONFIG_TOML"
149+
150+
# Set minimum gas price to 0
151+
sed -i.bak "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0${DENOM}\"/g" "$APP_TOML"
152+
153+
# Configure API and EVM settings in app.toml
154+
sed -i.bak \
155+
-e "/^\[api\]/,/^\[/s|^address *= *.*|address = \"tcp://0.0.0.0:${API_PORT}\"|" \
156+
-e "/^\[grpc\]/,/^\[/s|^address *= *.*|address = \"0.0.0.0:${GRPC_PORT}\"|" \
157+
-e "/^\[grpc-web\]/,/^\[/s|^address *= *.*|address = \"0.0.0.0:${GRPC_WEB_PORT}\"|" \
158+
-e "/^\[json-rpc\]/,/^\[/s|^address *= *.*|address = \"0.0.0.0:${JSON_RPC_PORT}\"|" \
159+
-e "/^\[json-rpc\]/,/^\[/s|^ws-address *= *.*|ws-address = \"0.0.0.0:${WS_PORT}\"|" \
160+
-e "/^\[json-rpc\]/,/^\[/s|^enable *= *.*|enable = true|" \
161+
-e "/^\[json-rpc\]/,/^\[/s|^api *= *.*|api = \"eth,net,web3,txpool,debug\"|" \
162+
-e 's/^json-rpc.enable-indexer = .*$/json-rpc.enable-indexer = true/' \
163+
-e 's/^evm.tracer = .*$/evm.tracer = ""/' \
164+
"$APP_TOML"
165+
166+
# Set timeouts for better network stability
167+
sed -i.bak 's/timeout_propose = "3s"/timeout_propose = "30s"/g' "$CONFIG_TOML"
168+
sed -i.bak 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' "$CONFIG_TOML"
169+
sed -i.bak 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' "$CONFIG_TOML"
170+
sed -i.bak 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' "$CONFIG_TOML"
171+
sed -i.bak 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' "$CONFIG_TOML"
172+
sed -i.bak 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' "$CONFIG_TOML"
173+
sed -i.bak 's/timeout_commit = "5s"/timeout_commit = "150s"/g' "$CONFIG_TOML"
174+
sed -i.bak 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' "$CONFIG_TOML"
175+
176+
# Use the corresponding validator IP
177+
PUBLIC_IP=${VALIDATOR_IPS[$i]}
178+
179+
# Create gentx
180+
hhubd gentx "validator$i" \
181+
"${GENTX_STAKE}${DENOM}" \
182+
--chain-id="${CHAIN_ID}" \
183+
--moniker="node$i" \
184+
--commission-rate="0.05" \
185+
--commission-max-rate="0.20" \
186+
--commission-max-change-rate="0.01" \
187+
--min-self-delegation="1" \
188+
--ip="${PUBLIC_IP}" \
189+
--home "${CLONE_HOME}" \
190+
--keyring-backend="${KEYRING}"
191+
192+
# Copy gentx back to primary node
193+
if [ -d "${CLONE_HOME}/config/gentx" ] && [ "$(ls -A "${CLONE_HOME}/config/gentx")" ]; then
194+
cp "${CLONE_HOME}/config/gentx/"* "${HOME_PREFIX}/config/gentx/"
195+
else
196+
echo "Warning: No gentx files found in ${CLONE_HOME}/config/gentx"
197+
fi
198+
199+
echo "Gentx created for node $i"
200+
done
201+
202+
# Collect gentxs
203+
echo "Collecting gentxs..."
204+
hhubd collect-gentxs --home "${HOME_PREFIX}"
205+
206+
# Validate genesis
207+
echo "Validating genesis..."
208+
hhubd validate-genesis --home "${HOME_PREFIX}"
209+
210+
# Configure peers for each validator
211+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
212+
CLONE_HOME="${HOME}/.hhubd$i"
213+
PEERS=""
214+
215+
# Build peers string excluding self
216+
for j in $(seq 0 $((NUM_VALIDATORS-1))); do
217+
if [ $i -ne $j ]; then
218+
if [ ! -z "$PEERS" ]; then
219+
PEERS="${PEERS},"
220+
fi
221+
PEERS="${PEERS}${NODE_IDS[$j]}@${VALIDATOR_IPS[$j]}:${P2P_PORT}"
222+
fi
223+
done
224+
225+
# Configure peers
226+
echo "Configuring peers for node $i..."
227+
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" "${CLONE_HOME}/config/config.toml"
228+
done
229+
230+
# Copy genesis to all validators
231+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
232+
CLONE_HOME="${HOME}/.hhubd$i"
233+
cp "${HOME_PREFIX}/config/genesis.json" "${CLONE_HOME}/config/"
234+
done
235+
236+
# Copy validator data to target machines (skip any IP matching primary)
237+
PRIMARY_IP=${VALIDATOR_IPS[0]}
238+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
239+
TARGET_IP=${VALIDATOR_IPS[$i]}
240+
if [ "$TARGET_IP" = "$PRIMARY_IP" ]; then
241+
echo "Skipping IP $TARGET_IP since it matches primary node"
242+
continue
243+
fi
244+
echo "Copying validator $i data to $TARGET_IP..."
245+
# First remove the old directory on remote
246+
ssh root@${TARGET_IP} "rm -rf ${HOME}/.hhubd${i}"
247+
# Then copy the new data
248+
rsync -av "${HOME}/.hhubd${i}/" "root@${TARGET_IP}:${HOME}/.hhubd${i}/"
249+
done
250+
251+
echo "All validators initialized successfully!"
252+
echo "Genesis file location: ${HOME_PREFIX}/config/genesis.json"
253+
echo "Validator information:"
254+
for i in $(seq 0 $((NUM_VALIDATORS-1))); do
255+
CLONE_HOME="${HOME}/.hhubd$i"
256+
echo "Validator $i:"
257+
echo " Directory: ${CLONE_HOME}"
258+
echo " Node ID: ${NODE_IDS[$i]}"
259+
echo " IP: ${VALIDATOR_IPS[$i]}"
260+
done

start_node_archive.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
if [ "$#" -ne 1 ]; then
7+
echo "Usage: $0 <node_number>"
8+
echo "Example: $0 0"
9+
exit 1
10+
fi
11+
12+
NODE_NUMBER=$1
13+
HOME_PREFIX="$HOME/.hhubd${NODE_NUMBER}"
14+
15+
# Start the node
16+
hhubd start \
17+
--home "${HOME_PREFIX}" \
18+
--chain-id hhub_9000-1 \
19+
--log_level info

0 commit comments

Comments
 (0)