diff --git a/docs/zetachain/sync/state-sync.mdx b/docs/zetachain/sync/state-sync.mdx index 95d6402c..4942a3ce 100644 --- a/docs/zetachain/sync/state-sync.mdx +++ b/docs/zetachain/sync/state-sync.mdx @@ -9,6 +9,8 @@ description: State Sync import SelectPaste from '@site/src/components/SelectPaste'; +import { stateSync } from '@site/src/components/SelectPaste/stateSync.ts'; + export let rpc = [ 'https://rpc1.node1111.test9999999.com', 'https://rpc2.node2222.test9999999.com', @@ -20,4 +22,4 @@ export let rpc = [ 'https://rpc8.node8888.test9999999.com', ]; - \ No newline at end of file + \ No newline at end of file diff --git a/src/components/SelectPaste/index.tsx b/src/components/SelectPaste/index.tsx index a64524ee..6f44137e 100644 --- a/src/components/SelectPaste/index.tsx +++ b/src/components/SelectPaste/index.tsx @@ -4,11 +4,14 @@ import Admonition from "@theme/Admonition"; interface SelectPasteProps { rpc: string[]; + codeTemplate: string; } -const SelectPaste: React.FC = ({ rpc }) => { +const SelectPaste: React.FC = ({ rpc, codeTemplate }) => { const [selectedRpc, setSelectedRpc] = useState(rpc[0]); + const renderedCode = codeTemplate.replace("{{selectedRpc}}", selectedRpc); + return (
@@ -16,29 +19,7 @@ const SelectPaste: React.FC = ({ rpc }) => { - {`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 - `} + {renderedCode}
diff --git a/src/components/SelectPaste/stateSync.ts b/src/components/SelectPaste/stateSync.ts new file mode 100644 index 00000000..3f4aaf06 --- /dev/null +++ b/src/components/SelectPaste/stateSync.ts @@ -0,0 +1,22 @@ +export const stateSync = `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`; diff --git a/static/img/undraw3.svg b/static/img/undraw3.svg index b70a6ff3..c40ca1ba 100644 --- a/static/img/undraw3.svg +++ b/static/img/undraw3.svg @@ -1,4 +1,4 @@ - +