From a62dd3abeae2fc70cf46d396ea991c87dc8ec004 Mon Sep 17 00:00:00 2001 From: SRG0Z10 <86466857+defrisk0@users.noreply.github.com> Date: Tue, 7 Nov 2023 21:12:01 +0300 Subject: [PATCH] Update State Sync --- FIRMACHAIN/readme.md | 52 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/FIRMACHAIN/readme.md b/FIRMACHAIN/readme.md index 27c2a10..b368677 100644 --- a/FIRMACHAIN/readme.md +++ b/FIRMACHAIN/readme.md @@ -1,11 +1,12 @@ # FIRMACHAIN +[RPC](http://firmachain.srgts.xyz:26657) | [API](http://firmachain.srgts.xyz:1317) | [STATESYNC](#title1) -Let's update and install the necessary packages: +#### Let's update and install the necessary packages: ```` sudo apt update && sudo apt upgrade -y sudo apt install build-essential jq wget git curl -y ```` -Install Go: +#### Install Go: ```` cd $HOME VRS="1.20.5" @@ -16,7 +17,7 @@ rm "go$VRS.linux-amd64.tar.gz" echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile source $HOME/.bash_profile ```` -Install CLI: +#### Install CLI: ```` cd $HOME git clone https://github.com/firmachain/firmachain @@ -24,43 +25,43 @@ cd firmachain git checkout v0.3.5-patch make install ```` -Let's check the version (current as of November 2023 - v0.3.5-patch commit: ac86456416cf590b081ddbe4ff8268e38c21adbd): +#### Let's check the version (current as of November 2023 - v0.3.5-patch commit: ac86456416cf590b081ddbe4ff8268e38c21adbd): ```` firmachaind version --long ```` -Set the correct chain (gitopia), chooses his moniker and initialize node: +#### Set the correct chain (gitopia), chooses his moniker and initialize node: ```` cd $HOME MNK=FRCH_NODE firmachaind config chain-id colosseum-1 firmachaind init $MNK --chain-id colosseum-1 ```` -Download the current genesis file: +#### Download the current genesis file: ```` wget https://raw.githubusercontent.com/FirmaChain/mainnet/main/colosseum-1/genesis.json -O ~/.firmachain/config/genesis.json ```` -Let's check sum genesis file (current as of November 2023 - d03edc3362a677f4a0c2f605c7f848f9516fd4f55432fda63625398c52419954): +#### Let's check sum genesis file (current as of November 2023 - d03edc3362a677f4a0c2f605c7f848f9516fd4f55432fda63625398c52419954): ```` sha256sum $HOME/.firmachain/config/genesis.json ```` -Edit minimum-gas-prices parameter: +#### Edit minimum-gas-prices parameter: ```` sed -i 's|^minimum-gas-prices *=.*|minimum-gas-prices = "0.01ufct"|g' $HOME/.firmachain/config/app.toml ```` -Adding seeds and peers: +#### Adding seeds and peers: ```` seeds="f89dcc15241e30323ae6f491011779d53f9a5487@mainnet-seed1.firmachain.dev:26656,04cce0da4cf5ceb5ffc04d158faddfc5dc419154@mainnet-seed2.firmachain.dev:26656,940977bdc070422b3a62e4985f2fe79b7ee737f7@mainnet-seed3.firmachain.dev:26656" peers="c5d73a7ebd292123068125356c615cc8db4c607a@65.109.154.185:28656,e5a99c4de697ad16ac74620ad3faf9ffabc728d8@136.243.55.237:43576,697e738961cfb28e67c7655bda49282dcf6b153a@140.82.53.152:26656,d5ac7fb49b76373cc2722ff802b1d245dcf85d75@178.250.154.15:26656,66b5ce316c5ba1dce402d48b22abb94331184795@65.109.231.247:26656,061bc813fe8aa0f6e90ac31e78e7b9e08ff585aa@65.108.70.119:35656,2a1f831aafb2225c797355163ba9a1d1090a2da2@164.92.231.224:26656,102ce7393900fe56d3bf06f7370939ca2b8b6fe3@207.244.245.6:56656" sed -i -e 's|^seeds *=.*|seeds = "'$seeds'"|; s|^persistent_peers *=.*|persistent_peers = "'$peers'"|' $HOME/.firmachain/config/config.toml ```` -Edit pruning parameter: +#### Edit pruning parameter: ```` sed -i 's|pruning = "default"|pruning = "custom"|g' $HOME/.firmachain/config/app.toml sed -i 's|pruning-keep-recent = "0"|pruning-keep-recent = "100"|g' $HOME/.firmachain/config/app.toml sed -i 's|pruning-interval = "0"|pruning-interval = "10"|g' $HOME/.firmachain/config/app.toml sed -i 's|^snapshot-interval *=.*|snapshot-interval = 0|g' $HOME/.firmachain/config/app.toml ```` -Create a service file: +#### Create a service file: ```` sudo tee /etc/systemd/system/firmachaind.service > /dev/null << EOF [Unit] @@ -76,22 +77,43 @@ LimitNOFILE=65535 WantedBy=multi-user.target EOF ```` -Reset this node's validator to genesis state: +#### Reset this node's validator to genesis state: ```` firmachaind tendermint unsafe-reset-all --home $HOME/.firmachain --keep-addr-book ```` -Download Snapshot file +#### Download Snapshot file ```` wget https://firmachain-mainnet-snapshot.s3.ap-northeast-2.amazonaws.com/colosseum-1_2023-01-13_5150845.tar -O ~/.firmachain/data/firmachain.tar tar -xvf ~/.firmachain/data/firmachain.tar ```` -Starting the node: +#### Starting the node: ```` sudo systemctl daemon-reload sudo systemctl enable firmachaind sudo systemctl restart firmachaind ```` -Checking the logs +#### Checking the logs ```` sudo journalctl -u firmachaind -f -o cat ```` +#### State Sync +```` +sudo systemctl stop firmachaind +cp $HOME/.firmachain/data/priv_validator_state.json $HOME/.firmachain/priv_validator_state.json.backup +firmachaind tendermint unsafe-reset-all --home $HOME/.firmachain --keep-addr-book +SNAP_RPC="http://firmachain.srgts.xyz:26657" + +LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \ +BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000)); \ +TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) + +echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH + +sed -i -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \ +s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \ +s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \ +s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.firmachain/config/config.toml + +mv $HOME/.firmachain/priv_validator_state.json.backup $HOME/.firmachain/data/priv_validator_state.json +sudo systemctl restart firmachaind && sudo journalctl -u firmachaind -f -o cat +````