-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
22 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
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'; | ||
|
||
explore let rpc = [ | ||
'https://rpc1.node1111.test9999999.com', | ||
'https://rpc2.node2222.test9999999.com', | ||
'https://rpc3.node3333.test9999999.com', | ||
'https://rpc4.node4444.test9999999.com', | ||
'https://rpc5.node5555.test9999999.com', | ||
'https://rpc6.node6666.test9999999.com', | ||
'https://rpc7.node7777.test9999999.com', | ||
'https://rpc8.node8888.test9999999.com', | ||
]; | ||
|
||
<SelectPaste rpc={rpc} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { useState } from "react"; | ||
import CodeBlock from "@theme/CodeBlock"; | ||
import Admonition from "@theme/Admonition"; | ||
|
||
interface SelectPasteProps { | ||
rpc: string[]; | ||
} | ||
|
||
const SelectPaste: React.FC<SelectPasteProps> = ({ rpc }) => { | ||
const [selectedRpc, setSelectedRpc] = useState<string>(rpc[0]); | ||
|
||
return ( | ||
<div> | ||
<Admonition type="tip" icon="📘" title="How to Use"> | ||
<p>Click on any RPC to paste it into the code block.</p> | ||
</Admonition> | ||
|
||
<CodeBlock language="bash" showLineNumbers> | ||
{`sudo systemctl stop zetacored | ||
cp $HOME/.zetacored/data/priv_validator_state.json $HOME/.zetacored/priv_validator_state.json.backup | ||
zetacored tendermint unsafe-reset-all --home $HOME/.zetacored --keep-addr-book | ||
CUSTOM_RPC="${selectedRpc}" | ||
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/.zetacored/config/config.toml | ||
sed -i 's|^rpc_servers *=.*|rpc_servers = "'$CUSTOM_RPC,$CUSTOM_RPC'"|' $HOME/.zetacored/config/config.toml | ||
sed -i 's|^trust_height *=.*|trust_height = '$BLOCK_HEIGHT'|' $HOME/.zetacored/config/config.toml | ||
sed -i 's|^trust_hash *=.*|trust_hash = "'$TRUST_HASH'"|' $HOME/.zetacored/config/config.toml | ||
mv $HOME/.zetacored/priv_validator_state.json.backup $HOME/.zetacored/data/priv_validator_state.json | ||
sudo systemctl restart zetacored | ||
sudo journalctl -u zetacored -f --no-hostname -o cat | ||
`} | ||
</CodeBlock> | ||
|
||
<div className="button-group card"> | ||
{rpc.map((item, index) => ( | ||
<button className="button button--secondary" key={index} onClick={() => setSelectedRpc(item)}> | ||
{item} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SelectPaste; |
Oops, something went wrong.