THORChain 백서

THORChain

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 19쪽 중 14쪽

r cluster by nodes, deployments, etc, and also a specific **`THORNode / THORChain`** dashboard to see the THORChain status, with current block height, how many validators are currently active and other chain related information. {% hint style="info" %} Click the 🔍 SEARCH ICON to find the list of dashboards {% endhint %} ![Example of Grafana Dashboard](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-0dc1caf02fc73ff875ed7cc8e76d6ae65225cf90%2Fimage%20\(9\)%20\(1\).png?alt=media) For a more in-depth introduction of Grafana, please[ follow the documentation here](https://grafana.com/docs/grafana/latest/getting-started/what-is-grafana/)**.** ## Kubernetes Dashboard You can also deploy the Kubernetes dashboard to monitor your cluster resources. {% tabs %} {% tab title="DEPLOY" %} ```bash make install-dashboard ``` This command will deploy the Kubernetes dashboard chart. It can take a while to deploy all the services, usually up to 5 minutes depending on resources running your kubernetes cluster. {% endtab %} {% tab title="ACCESS" %} We have created a make command to automate this task to access the Dashboard from your local workstation: ```bash make dashboard ``` Open [http://localhost:8000](http://localhost:8000/) in your browser. {% endtab %} {% endtabs %} View your kubernetes dashboard by running the following: ```bash make dashboard ``` ![Kubernetes Dashboard](https://3337783180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfvaTNxU33ciP7UstKtwU%2Fuploads%2Fgit-blob-11140e084fb5abc37ade7c3b99e67850c372723b%2Fimage%20\(14\)%20\(1\).png?alt=media) ## Backing up a THORNode You should backup your THORNode in case of failures. By default, if you are using the Kubernetes deployments solution, all the deployments are automatically backed up by persistent volume disks.\ Depending on your provider, the volumes are usually available in the provider administration UI, for example in AWS, you can find those volumes in your regular console, in the region you chose to deploy your Kubernetes cluster. Again by default, with Kubernetes, by using persistent volumes used in the default configuration, you are already protected again restart failures at container level, or node failures. As long as you don’t specifically use the destroy commands from the Makefile or manually delete your Kubernetes deployments, your volumes will NOT be deleted at any time. It is still recommended, as any project, to have different backups on top of those volumes to make sure you can recover in admin error deleting those volumes or other Kubernetes resources that would imply deleting those volumes. Also see the Create and Validator Backup guide. {% embed url="<https://gitlab.com/thorchain/devops/node-launcher/-/blob/master/docs/Restore-Validator-Backup.md>" %} For AWS, you can easily setup in your console to have snapshots of your cluster volumes be taken every day. For other provider there can be different ways to achieve this as well either manually or automatically. It is up to the node operator to setup those extra backups of the core volumes to be able to recover in any kind of failures or human errors. Some volumes would be more critical than others, for example Midgard deployment are also by default backed up by persistent volumes, so it can recover in case of container restarts, failures or node failures and the deployment being automatically scheduled to a different node, but if you were to delete the Midgard volume, it would reconstruct its data from your THORNode API and events from scratch. For that specific service having extra backups might not be critical, at the time of the writing of that document, Midgard implementation might change in the future. At minimum you should also securely backup your node keys: `node_key.json` and `priv_validator_key.json`. Do this as follows: ```bash kubectl get pods -n thornode ``` Copy the thornode pod name, e.g. `thornode-abcdefg-hijkl` and replace with `{thornode pod name}` below: ```bash kubectl cp thornode/{thornode pod name}:root/.thornode/config/node_key.json node_key.json kubectl cp thornode/{thornode pod name}:root/.thornode/config/priv_validator_key.json priv_validator_key.json ``` For full disaster recovery (complete loss of cluster), it is possible to issue LEAVE command from the original BOND wallet. See [Leaving](https://docs.thorchain.org/thornodes/leaving) for detailed procedures. ## Node Security The following are attack vectors: 1. If anyone accesses your cloud credentials, they can log in and steal your funds 2. If anyone accesses the device you used to log into kubernetes, they can log in and steal your funds 3. If anyone accesses your hardware device used to bond, they can sign a LEAVE transaction and steal your bond once it is returned 4. If anyone has access to your node's private keys through logs or configuration files, they can steal your funds 5. If any GitLab repo is compromised and you `git pull` any nefarius code into your node and run `make <any command>`, you can lose all your funds. #### Checking diffs Prior to `git pull` or `make pull` updates, review node-launcher repo diffs: ```bash git fetch git diff master..origin/master ``` Regularly review patches in GitLab: <https://gitlab.com/thorchain/devops/node-launcher/-/commits/multichain> When chain clients have updated tags (version number or sha256), inspect the GitLab diffs for the relevant image in <https://gitlab.com/thorchain/devops> and ensure the CI build checksum matches the expected. This ensures you are executing code on your node that you are satisfied is free from exploits. Some images such as Ethereum use the 'official' docker image, e.g. <https://hub.docker.com/r/ethereum/client-go/tags>. {% hint style="danger" %} **RUNNING A NODE IS SERIOUS BUSINESS** DO SO AT YOUR OWN RISK, YOU CAN LOSE A SIGNIFICANT QUANTITY OF FUNDS IF AN ERROR IS MADE THORNODE SOFTWARE IS PROVIDED AS IS - YOU ARE SOLELY RESPONSIBLE FOR USING IT YOU ARE RESPONSIBLE FOR THE CODE RUNNING ON YOUR NODE. **YOU ARE** THE NETWORK. INSPECT ALL CODE YOU EXECUTE. {% endhint %} When running a node, it is quite common to get slashed. The network relies on slash points to rate node quality. When your node is slashed, the first thing you need to do is run `make status`, and make sure all your chains are 100% in sync. If any of the external chains are not 100% in sync, then it will cause node to be slashed due to missing observations. The best prevention is to have a cluster with lots of fast resources (cpu, memory, IO, network) and good backups/redundancy to prevent downtime. Unfortunately even when your node is fully in-sync, it is still possible to be slashed due to external chain events. #### Constantly accumulating slash points **Problem:** Sometimes bifrost fails to forward observations to thornode, due to an account number / sequence number mismatch. Here is what you need to check: 1. run `make logs` , and choose `bifrost` 2. Search your bifrost logs for `{"level":"error","service":"bifrost","module":"observer","error":"fail to send the tx to thorchain: fail to broadcast to THORChain,code:32, log:account sequence mismatch, expected 26806, got 26807: incorrect account sequence","time":"2021-05-30T07:28:18Z","message":"fail to send to THORChain"}` 3. **Solution:** `make restart` and choose `bifrost` # Pooled THORNodes How to manage a pooled THORNode with separate Operator and Providers. ## Summary Skilled Node Operators who don't individually have enough $RUNE to run a node themselves can use the Bond Provider feature to collect bond from other $RUNE holders. Node Operators can define up to **100 THOR addresses** as Bond Providers. These addresses will be able to bond and unbond to the node, earning rewards proportional to the amount of bond they contribute. Node Operators define an operator fee in basis points, which defaults to zero and must be set explicitly when bond providers are added. The Node Operator fee is taken from rewards and paid directly to the Node Operator address after each churn. ### Rationale The minimum $RUNE needed to churn in as a THORNode is currently set at 300K - but with bond competition, this number could be much higher. Not many people in the world have both the technical skills to run a validator AND at least 300K $RUNE, which limits the supply of Node Operators who secure THORChain. Pooled THORNodes provide a way for a skilled Operator to enter a trusted agreement with known Bond Providers to bootstrap enough capital for running a THORNode. The Network's security increases, and more RUNE holders have access to yield-bearing bond-space. ### Economic Security At first glance it might seem Pooled Validators contradict the economic security model of THORChain (i.e. that Node Operators put up twice the value in slash-able bond as the assets they secure). With Pooled Validators it is possible for the Node Operator to individually put up less bond than the value of the assets that the node secures. However this nuance only exists within the relationship between the Node Operator and the Bond Providers. The Network only considers the THORNode as single entity thus the economic model is intact. {% hint style="warning" %} It would be disastrous to THORChain if operators could collect unlimited bond quantities from anon/retail providers. Malicious Operators could start marketing campaigns collecting RUNE and then rug-pull their users, or worse, access economies of scale and take over the network. This is why Pooled THORNodes are invite-only and limited to 100 per node to moderate this. {% endhint %} ## Managing a Pooled THORNode {% hint style="info" %} All RUNE `Amount` values are in 1e8 decimals, e.g. 1 RUNE = 100000000. {% endhint %} ### Node Operator #### Adding a Bond Provider Add a bond provider using a BOND transaction with a modified memo from a wallet you control (ledger, desktop, thorcli): `BOND:<NodeAddress>:<BondProviderAddress>:<NodeOperatorFee>` **Example:** `BOND:thor1agftrgu74z84hef6dt6ykhe7cmjf3f8dcpkfun:thor1tfm4q8u57qzsznpvh02s8j483aga63cl02k6jt:2000` * NodeAddress - THORNode address (prefixed by `thor`) * BondProviderAddress - Bond Provider address to whitelist (prefixed by `thor`) * NodeOperatorFee - fee in basis points to be taken from rewards and paid directly to Node Operator's address after each churn. * RUNE TX Value - 1.02 minimum (anything over 1.02 is added to the Operator's Bond). *A Node Operator is the first on-chain bonding transaction to a new node. You cannot change the operator address after the fact.* *The Operator is also added as a Bond Provider.* #### **Removing a Bond Provider** While the node is churned out and the vault has successfully migrated, a Node Operator can remove a Bond Provider using an UNBOND transaction with a modified memo: `UNBOND:<NodeAddress>:<AmountToUnbond>:<BondProviderAddress>` * NodeAddress - THORNode address (prefixed by `thor`) * AmountToUnbond - Amount of Bond Provider's bond to refund * BondProviderAddress - Bond Provider address to refund/remove (prefixed by `thor`) * Amount - Most UIs will require an 'amount' for the transaction, this must be 0 (A gas fee of 0.02 RUNE will still need to be paid for the transaction but the UI will handle this) *This command will refund the Bond Provider their bond and remove them from the Bond Provider list only if `Amount` constitutes all of the bond the Bond Provider is owed. 0 (ZERO) will work to remove the BP from the Whitelist Addresseses if they have already unbonded all their bond.* #### Node Operator Fee Node operators can set a fee that is paid to them from the earnings each churn. To set a Node Operator fee, send a deposit transaction with the following memo: `BOND:<node address>:<bond wallet address>:<operator fee in basis pts>` Example: `BOND:thor1agftrgu74z84hef6dt6ykhe7cmjf3f8dcpkfun:thor1tfm4q8u57qzsznpvh02s8j483aga63cl02k6jt:2000` To adjust the fee, the no operators can send:\ `BOND:<NodeAddress>::<OperatorFeeInBasisPts>` **Example**: `BOND:thor1agftrgu74z84hef6dt6ykhe7cmjf3f8dcpkfun::4000` to see the fee to 40%. Fees can range from 0 to 10000 basis pts. Setting 10000 causes all rewards to be to the node operator each churn. Setting it to 0 causes rewards to accrue to the bond. See [here](/thornodes/joining#node-operator-fee) for more details. ### Bond Provider #### Adding/Removing Bond Once whitelisted, a Bond Provider can Bond and Unbond from the node as normal. **Adding Bond:** `BOND:<NodeAddress>` * NodeAddress - THORNode address (prefixed by `thor`) * RUNE Tx Value - Amount of RUNE to bond **Removing Bond:** `UNBOND:<NodeAddress>:<AmountToUnbond>` * NodeAddress - THORNode address (prefixed by `thor`) * AmountToUnbond - Amount of Bond Provider's bond to refund * Amount - Most UIs will require an 'amount' for the transaction, this must be 0 (A gas fee of 0.02 RUNE will still need to be paid for the transaction but the UI will handle this) {% hint style="info" %} **When you can add Bond** When the node is standby, active or not churning, bond amounts can be increased/decreased.\ Bond can always be increased (whether Active or on Standby). You can tell the network is migrating if there are `retiring` Asgard Vaults.\ <https://runescan.io/vaults> {% endhint %} ### Reward Shares Operators and Providers all have a bond amount registered to the node. Operators can start at 0.00 bonded. This on-chain bond amount is summed to the total bond, and thus everyone has a fair share in the THORNode's principle + rewards. The Operator Fee is distributed to the Node Operator address from all RUNE rewards earned by a node after each churn. Bond Provider rewards are added to their Bond and auto-compounded. If an Operator LEAVES, all the bond is fairly distributed. # Fullnode Setting up a THORNode & Midgard The term fullnode describes a basic setup of a synced THORNode daemon and optionally Midgard and is meant to provide API endpoints for private or public use. Because the THORNode doesn't take part in the chains consensus other chain clients aren't needed. See [Overview](/thornodes/overview) for more information about the different node types. {% hint style="info" %} The installation guides for running a fullnode via Docker or directly on Linux are not officially supported by the development team. The preferred and supported way is by using [Kubernetes](/thornodes/fullnode/thornode-kubernetes). {% endhint %} # Thornode - Kubernetes Setting up a fullnode on Kubernetes For deploying Thornode and Midgard on Kubernetes, follow the instructions for [Cluster Launcher](/thornodes/kubernetes) and [Deployment](/thornodes/deploying). Instead of `TYPE=validator`, use `TYPE=fullnode` at the [Thornode deployment](/thornodes/deploying#deploy-thornode) step. ```sh NET=mainnet TYPE=fullnode NAME=thornode make install ``` # Thornode - Linux Setting up a fullnode on Linux {% hint style="info" %} The steps shown here are tested on `Ubuntu 24.04`, different distributions may need adjustments to the commands. All commands are meant to be run as root user, if not specified otherwise. Depending on the server installation, they may need to be run from a different user via `sudo`. {% endhint %} ## Prerequisites Install all needed packages for building and configuring the THORNode daemon ```sh apt install -y --no-install-recommends aria2 ca-certificates curl git golang jq make pv ``` ## Application user Add the application user that is used to run the THORNode application ```sh useradd -m thornode -s /bin/bash ``` ## Build Checkout the latest code and build the binary As `thornode` user run: ```sh git clone --branch v2.135.1 https://gitlab.com/thorchain/thornode $HOME/build cd $HOME/build ln -fs /usr/bin/true docker; export PATH=$(pwd):$PATH; TAG=mainnet make install # remove bifrost binary and build directory rm $HOME/go/bin/bifrost rm -rf $HOME/build ``` Note: The build process currently expects to have a docker binary available, which isn't needed for building the `thornode` binary, so providing it a fake docker command via symlink is just a hack around that limitation. ## Prepare environment ### Config Before running the fullndode the first time, the configuration files and directory layout need to be created. As `thornode` user run: ```sh $HOME/go/bin/thornode init thornode --overwrite --chain-id thorchain-1 ``` ### Seed nodes Seeds provide a list of active thorchain nodes, which are needed to join the network. {% hint style="warning" %} Nine Realms infrastructure has been decommissioned. Refer to the upstream [node-launcher documentation](https://gitlab.com/thorchain/devops/node-launcher/-/tree/master/docs) for the current seed list. {% endhint %} ### Ports THORChain doesn't use the cosmos-sdk default ports. Technically this step isn't needed, but it is meant to stay in line with all other THORNode deployments. As `thornode` user run: ```sh sed -ri 's/:2665([0-9])/:2714\1/g' $HOME/.thornode/config/config.toml ``` ### Genesis For joining the network, the correct genesis file is required. {% hint style="warning" %} Nine Realms infrastructure has been decommissioned. Refer to the upstream [node-launcher documentation](https://gitlab.com/thorchain/devops/node-launcher/-/tree/master/docs) for the current genesis file source. {% endhint %} ### Sync The fastest way to join the network is by downloading a current snapshot and syncing from it. {% hint style="warning" %} Nine Realms infrastructure has been decommissioned. Refer to the upstream [Thornode Snapshot Recovery and Storage Management](https://gitlab.com/thorchain/devops/node-launcher/-/blob/master/docs/Thornode-Snapshot-Recovery-and-Storage-Management.md) doc for the current snapshot source and recovery procedure. {% endhint %} ## Systemd Create a service file to be able to manage the thornode process via systemd {% code title="/etc/systemd/system/thornode.service" overflow="wrap" %} ```toml [Unit] Description=Thornode Daemon After=network-online.target [Service] User=thornode ExecStart=/home/thornode/go/bin/thornode start Restart=on-abort RestartSec=3 LimitNOFILE=65535 [Install] WantedBy=multi-user.target ``` {% endcode %} Reload systemd config ```sh systemctl daemon-reload ``` ## Start Start the daemon ```sh systemctl start thornode.service ``` # Thornode - Docker Setting up a fullnode with Docker {% hint style="info" %} The steps shown here are tested on `Ubuntu 24.04`, different distributions may need adjustments to the commands. All commands are meant to be run as root user, if not specified otherwise. Depending on the server installation, they may need to be run from a different user via `sudo`. {% endhint %} ## Prerequisites Install all packages needed for running and configuring the THORNode container ```sh apt install -y --no-install-recommends aria2 curl docker.io jq pv ``` {% hint style="info" %} The published image is built for `linux/amd64`. On an `arm64` host (e.g. Apple Silicon) add `--platform linux/amd64` to the `docker run` command to run it under emulation. {% endhint %} ## Configuration ### Work directory Prepare work directory ```sh mkdir -p /opt/thornode/.thornode/config ``` ### Genesis No manual step is required. On first start the container fetches the genesis file automatically from the network's seed nodes (discovered via the configured seed-nodes endpoint, then pulled from a peer's RPC). A successful genesis fetch is **not** by itself enough to join the network — you must also choose a sync method below, otherwise the node will attempt to initialize from the fetched genesis and fail. ### Sync A fullnode cannot replay the chain from genesis with a current binary; you must bootstrap from a recent state. Choose one of the following. #### Option A — Automatic StateSync (self-contained) Set `THOR_AUTO_STATE_
프로젝트로 돌아가기