原文地址:https://blog.sia.tech/how-to-run-a-host-on-sia-2159ebc4725
This guide is fairly comprehensive. If you are already familiar with Sia, feel free to skip sections. This guide is written for v0.6.0 and up.
The first thing that you need to know about hosting is that it’s a commitment. Hosts on Sia are expected to have 95% uptime, which means that the host and data should be available 24/7. Occasional downtime is permitted, but generally the host should always be online. Second, a host is expected to run for a long time. You can control the maximum contract length, but generally it should be at least 12 weeks. A later section explains how to retire a host without losing collateral.
Currently, hosting is primarily done from the command line. We will eventually have support for the host in our graphical UI, though it may be a few months.
1. Downloading and Running Sia
siad is the process that runs in the background and does all of the work. siac is a command line tool that is packaged alongside siad and is used to send commands to siad. You can get the most recent version of each here: https://github.com/NebulousLabs/Sia/releases
Once you have the downloads, you’ll want to run them in a folder that’s designated specifically for Sia. siad is going to create a bunch of folders where it will put logs and database information. After the blockchain has finished downloading, the total size will be around 3GB.
After downloading and extracting the zip, your directory should look something like this:
siad and siac have comprehensive help menus. The menus can be accessed by adding a -h to your command. You can learn more about the various options for siad with siad -h. It's also worth knowing about all of the modules and their functions, which you can get with siad modules.
The options that I most frequently use are the options to choose which modules to run, and to choose which ports to use. There are 3 ports to care about, the API port, the RPC port, and the hosting port. The help menu can explain more. If you want to run just a host (with no miner, and no renter), using the default ports, you can run siad -M gctwh. Windows users (for the time being) will want to run siad as admin.
After startup completes, you will see that siad has created a few folders. For the most part you can ignore them, but know that deleting them or moving them can result in losing data within Sia.
- Setting up a Wallet
Now that siad is running, siac will be the primary tool that we use to interact with Sia. You can see the general state of the blockchain by running siac. You can get a menu of things to do by running siac -h.
You can see that on my client about 18,000 blocks have downloaded, and that the blockchain has not synced (‘synced’ indicates that ‘siad’ believes it has all of the blocks). You can find the current block height at https://explore.sia.tech
It’s worth noting that we don’t have the miner or renter modules enabled, so while we can explore the help menus for those commands, we will get an error if we actually use them. (if you used the default modules, you will be able to run the renter and miner commands).
You can get more information about the wallet by running siac wallet -h.
We need to create a wallet and send it money. This is going to happen in three steps. First we will call siac wallet init, which will create a new, locked wallet. A seed will be provided which serves two purposes: it is both an encryption password for your wallet files, and it is a recovery tool: if you lose all of your wallet files, we can use recovery software to get all of your coins back. The second call is siac wallet unlock, which will allow us to create addresses, send money, and operate a host. The wallet must be unlocked at all times while the host is running. Finally, we'll need an address that we can use to fill the wallet, which we can get by running siac wallet address.
In v0.6.0, unlocking the wallet can take 10 or 20 minutes. Instant wallet unlocking is on the roadmap, but will not be ready until the end of the summer.
You will need to find some way to fund the wallet. Mining is not really a viable option unless you have 6+ GPUs. Most people get their coins from either Poloniex (US based exchange) or Yunbi (China based exchange).
siad will need to fully synchronize before money shows up in your wallet.
3. Configuring the Host — Basic
We need to give the host a place to store data. The host is able to make use of multiple folders, but for now we’re only going to add one. I’ve already created a folder for the host, I can add it to the host with siac host folder add [folder] [size]:
Now we need to configure price. The renter pays for a number of things when uploading to the host, but the most important are storage and bandwidth. Storage price is typically displayed to the user as ‘Siacoins per Terabyte per Month’, and bandwidth is typically displayed as ‘Siacoins per Terabyte’. The host will use a difference price for uploading and downloading. It should note that the words ‘upload’ and ‘download’ refer to the renter’s perspective, meaning that ‘upload bandwidth’ is referring to the renter uploading, meaning the host is downloading. ‘download bandwidth’ similarly refers to the renter downloading, meaning the host is uploading. If you are on a home connection, you likely have a lot more downstream than upstream, and furthermore renters are much more likely to use your upstream than your downstream. Therefore the upstream price should probably be set higher. You can set the prices using siac host config minstorageprice [price], siac host config mindownloadbandwidthprice [price], siac host config minuploadbandwidthprice [price]. The host may increase prices temporarily if there is more demand than the host is able to service.
Collateral is discussed more in the next section. If using the defaults for collateral, you’re going to need between 50,000 and 100,000 siacoins per terabyte you are offering to the network which will be used as collateral. As a reminder, the wallet must be unlocked so that the host can provide collateral.
Now all you need to do is announce the host. If you are planning on doing advanced configuration, you should wait to announce until configuration is complete, otherwise you can announce with siac host announce. This will create a transaction containing your ip address, public key, and will allow renters to find you and upload to you.
And that’s it! Now you are a fully operating host on the Sia network. Depending on demand, your price, and a few other factors, you may start getting contracts right away or it may take a while. Renters will prioritize the cheapest and most reliable hosts. Often, if you are not getting any contracts, all you need to do is lower the price. Especially at this early stage of the Sia network, prices are highly competitive.
4. Configuring the Host — Advanced
Collateral is a major security component that sets Sia apart from other cloud storage platforms. It’s a guarantee to renters that you will hold their data or you will lose money. There are three fields that matter, ‘Collateral Budget’, ‘Max Collateral’, and ‘Collateral’.
Due to the way that file contracts work, you have to set coins aside as collateral when the file contract is created, even if no uploading is happening. Regardless of whether the storage proof is successful or not, you will get this collateral back. The host refers to this as ‘Locked Collateral’ — collateral that is tied up in contracts but is not actually at risk of being lost.
As the renter uploads files, the host will risk the locked collateral on the files. ‘Risked Collateral’ is collateral that is covering data which has been uploading, and will be lost if the host is unable to complete the storage proof.
The ‘Collateral Budget’ is the maximum amount of coins that can be locked into contracts, and subsequently risked if the renter does enough uploading. The wallet will need to have enough coins to meet the collateral budget. A recommended budget is around 100,000 Siacoins per TB that the host is offering.
It should be noted that there is a 3.9% fee on locked collateral (for the siafunds), but that the renter pays that fee in full — the host is not at risk of losing money on a contract which never gets any uploads.
The ‘Max Collateral’ is the maximum amount of collateral that the host will lock away in a single file contract. The default is usually okay, and generally it should be between 3% and 15% of the collateral budget.
‘Collateral’ is the amount of money that the host will put on the line when storage is uploaded. Renters are more likely to pick hosts with higher collateral. The collateral should be at least 1000 siacoins per TB per month, regardless of the storage price.
You can set the collateral variables by using siac host config collateral [value], siac host config collateralbudget [value], and siac host config maxcollateral [value].
The last setting that we should worry about is ‘Max Duration’. The duration is the length of time that the host must hold a file, and it is the amount of time that the host will have to wait to retire if the host does not want to lose any collateral. Renters will ignore all hosts that have a smaller max duration than 12 weeks — this means that, as a host, you are committing to keeping files for at least 12 weeks. Long term hosts are critical to the stability of the Sia ecosystem, and in general are able to command higher prices. (renters strongly prefer hosts that have a long history). The max duration can be set with siac host config maxduration [value].
Unfortunately, siac does not currently have a way to display all of the settings. This will be fixed in v0.6.1
When doing an announcement, you can either use the self-discovered address with siac host announce (usually this will be an IP address), or you can announce a specific address or domain name with siac host announce [hostname:port]. An example call would be siac host announce example.com:9982
5. Retiring a Host
When you announce the host, the ‘accepting contracts’ field is set to true. It means you’ll take on new contracts, and those contracts can expire as late as ‘max duration’ blocks in the future. By default, it’s 6 months, though you can configure it to be as low as desired. Note that below 12 weeks, renters are highly unlikely to select you as a host.
Using the config command, you can stop accepting new contracts. You will still need to run the host so that you can accept uploads, downloads, and perform storage proofs on your existing contracts, but you will stop accepting new contracts which means after ‘max duration’ blocks you will have no more contracts, no more data, and all of your collateral will be returned to you. You can then retire your host gracefully, without destroying anybodies files or losing any collateral. The command is siac host config acceptingcontracts false:
That’s all for now, hope that it helps. Feel free to ask questions or leave comments if there’s anything you feel I missed.