Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lava stateSync added #27

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/lava-network/sync/state-sync.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
sidebar_position: 2
description: State Sync
---

# State Sync

> State Sync allows new nodes to join a blockchain network by downloading a recent snapshot of the application state instead of processing all historical blocks. This approach is typically faster and requires less data, as the application state is usually more concise than the entire block history.

import SelectPaste from '@site/src/components/SelectPaste';

import { stateSync } from '@site/src/components/SelectPaste/stateSyncLava.ts';

export let endpoints = [
'https://lava.rpc.t.anode.team',
'https://rpc.lava-testnet-2.lava.aviaone.com',
'https://lava-testnet-rpc.itrocket.net:443',
'https://lava-testnet.rpc.kjnodes.com',
'https://t-lava.rpc.utsa.tech',
'https://lava.rpc.liveraven.net',
'https://lava-testnet.nodejumper.io:443',
'https://rpc-t.lava.nodestake.top',
'https://rpc.lava-t.nodexcapital.com',
'https://lava-testnet-rpc.polkachu.com',
'https://lava-testnet.rpc.stakevillage.net:443',
];

<SelectPaste endpoints={endpoints} codeTemplate={stateSync} tip="Click on any RPC to paste it into the code block." />
22 changes: 22 additions & 0 deletions src/components/SelectPaste/stateSyncLava.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const stateSync = `sudo systemctl stop lavad

cp $HOME/.lava/data/priv_validator_state.json $HOME/.lava/priv_validator_state.json.backup
lavad tendermint unsafe-reset-all --home $HOME/.lava --keep-addr-book

CUSTOM_RPC="{{endpoint}}"

LATEST_HEIGHT=$(curl -s $CUSTOM_RPC/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1500))
TRUST_HASH=$(curl -s "$CUSTOM_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)

echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH

sed -i 's|^enable *=.*|enable = true|' $HOME/.lava/config/config.toml
sed -i 's|^rpc_servers *=.*|rpc_servers = "'$CUSTOM_RPC,$CUSTOM_RPC'"|' $HOME/.lava/config/config.toml
sed -i 's|^trust_height *=.*|trust_height = '$BLOCK_HEIGHT'|' $HOME/.lava/config/config.toml
sed -i 's|^trust_hash *=.*|trust_hash = "'$TRUST_HASH'"|' $HOME/.lava/config/config.toml

mv $HOME/.lava/priv_validator_state.json.backup $HOME/.lava/data/priv_validator_state.json

sudo systemctl restart lavad
sudo journalctl -fu lavad -o cat`;