Skip to content

Commit

Permalink
Update State Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
defrisk0 authored Nov 7, 2023
1 parent 25d6afa commit a62dd3a
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions FIRMACHAIN/readme.md
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -16,51 +17,51 @@ 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
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="[email protected]:28656,[email protected]:43576,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:35656,[email protected]:26656,[email protected]: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]
Expand All @@ -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
````
#### <a id="title1">State Sync</a>
````
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
````

0 comments on commit a62dd3a

Please sign in to comment.