sudo apt update && sudo apt upgrade -y
sudo apt install git gcc make jq curl lz4
cd $HOME
VER=1.22.11
wget -qO go.tar.gz "https://golang.org/dl/go$VER.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go.tar.gz
rm go.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin:~/go/bin" >> ~/.bashrc
source ~/.bashrc
mkdir -p ~/go/bin
cd $HOME
rm -rf story
git clone https://github.com/piplabs/story story
cd story
APP_VERSION=v1.2.1
git checkout tags/$APP_VERSION -b $APP_VERSION
go build -o story ./client
mv $HOME/story/story $HOME/go/bin/.
cd $HOME
rm -rf geth
git clone https://github.com/piplabs/story-geth geth
cd geth
APP_VERSION=v1.0.2
git checkout tags/$APP_VERSION -b $APP_VERSION
go build -v ./cmd/geth
mv ./geth $HOME/go/bin/geth
story init --network story
wget -O $HOME/.story/story/config/genesis.json https://st-snap-1.stakeme.pro/story/archive/genesis.json
wget -O $HOME/.story/story/config/addrbook.json https://st-snap-1.stakeme.pro/story/archive/addrbook.json
PEERS=[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:22425,[email protected]:32425,[email protected]:22425,[email protected]:26646,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:20038,[email protected]:20038,[email protected]:20038,[email protected]:26656,[email protected]:10056 sed -i -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*seeds *=.*/seeds = \"$SEEDS\"/}" -e "/^\[p2p\]/,/^\[/{s/^[[:space:]]*persistent_peers *=.*/persistent_peers = \"$PEERS\"/}" $HOME/.story/story/config/config.toml
sed -i.bak -e "s%:1317%:317%g;
s%:8080%:080%g;
s%:9090%:090%g;
s%:9091%:091%g;
s%:8551%:551%g;
s%:8545%:545%g;
s%:8546%:546%g;
s%:6065%:065%g" $HOME/.story/story/config/story.toml
sed -i.bak -e "s%:26658%:658%g;
s%:26657%:657%g;
s%:6060%:060%g;
s%:26656%:656%g;
s%:26660%:660%g" $HOME/.story/story/config/config.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.story/story/config/config.toml
sudo tee /etc/systemd/system/story.service > /dev/null <<EOF
[Unit]
Description=Story is a purpose-built Layer 1 blockchain designed to revolutionize intellectual property (IP) management
After=network-online.target
[Service]
User=$USER
WorkingDirectory=$HOME/.story/story
ExecStart=$(which story) run
Restart=on-failure
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo tee /etc/systemd/system/story-geth.service > /dev/null <<EOF
[Unit]
Description=Story Geth daemon
After=network-online.target
[Service]
User=$USER
ExecStart=$HOME/go/bin/geth --story --syncmode full --http --http.api eth,net,web3,engine --http.vhosts '*' --http.addr 0.0.0.0 --http.port 545 --authrpc.port 551 --ws --ws.api eth,web3,net,txpool --ws.addr 0.0.0.0 --ws.port 546
Restart=on-failure
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
story tendermint unsafe-reset-all --home $HOME/.story
STATYSYNC_RPC=https://story-rpc.stakeme.pro:443
LATEST_HEIGHT=$(curl -s $STATYSYNC_RPC/block | jq -r .result.block.header.height);
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000));
TRUST_HASH=$(curl -s "$STATYSYNC_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
sed -i.bak -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\"| ;
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $HOME/.story/story/config/config.toml
sudo systemctl daemon-reload
sudo systemctl enable story.service story-geth.service
sudo systemctl start story.service story-geth.service
sudo journalctl -u story -f -o cat