A renter for Sia
[!IMPORTANT]
## Meet s3d — the better way to rent storage on Sia
s3d is a lightweight, S3-compatible renter for the Sia network. Connect it
to Sia Storage for renting without the hassle of
managing your own node, acquiring tokens, or dealing with complex
configurations. With s3d, you can start storing data on Sia in minutes, all
through a familiar S3 interface.>
Get started with s3d
Overview
renterd is the successor to siad, offering feature parity while extending its capabilities with new features like an enhanced web UI and an autopilot. That said, renterd does not support backwards compatibility with siad metadata. Consequently, files uploaded via siad cannot currently be migrated to renterd. Our immediate focus is on refining renterd to enhance its stability, scalability, and performance, ensuring it serves as a robust foundation for new Sia applications. Useful links:
Instant Syncing (Experimental)
New users can sync instantly using renterd --instant. When instant syncing, the renterd node initializes using a Utreexo-based checkpoint and can immediately validate blocks from that point forward without replaying the whole chain state. The state is extremely compact and committed in block headers, making this initialization both quick and secure.
The wallet is required to only have v2 history to use instant syncing.
Database
renterd requires a database to store its operational data. We support both SQLite and MySQL, with SQLite set as the default due to its ease of setup. SQLite is ideal for testing and development purposes, whereas MySQL is recommended for production environments.
Configuration
renterd can be configured in various ways, through the use of a yaml file, CLI flags or environment variables. Settings that are configured multiple times will be evaluated in this order. In the CLI, use the help command to see an overview of all settings configurable through the CLI.
| Name | Description | Default Value | CLI Flag | Environment Variable | YAML Path | |--------------------------------------|------------------------------------------------------|-----------------------------------|----------------------------------|------------------------------------------------|----------------------------------------| | HTTP.Address | Address for serving the API | :9980 | --http | - | http.address | | HTTP.Password | Password for the HTTP server | - | - | RENTERDAPIPASSWORD | http.password | | HTTP.Pprof | Enables pprof endpoints on /debug/pprof | false | --http.pprof | RENTERDHTTPPPROF | http.pprof | | Directory | Directory for storing node state | . | --dir | - | directory | | Seed | Seed for the node | - | - | RENTERD_SEED | seed | | AutoOpenWebUI | Automatically open the web UI on startup | true | --openui | - | autoOpenWebUI | | Network | Network to run on (mainnet/zen/anagami) | mainnet | --network | RENTERD_NETWORK | network | | ShutdownTimeout | Timeout for node shutdown | 5m | --node.shutdownTimeout | - | shutdownTimeout | | Log.Level | Global logger level (debug\|info\|warn\|error). Defaults to 'info' | info | --log.level | RENTERDLOGLEVEL | log.level | | Log.File.Enabled | Enables logging to disk. Defaults to 'true' | true | --log.file.enabled | RENTERDLOGFILE_ENABLED | log.file.enabled | | Log.File.Format | Format of log file (json\|human). Defaults to 'json' | json | --log.file.format | RENTERDLOGFILE_FORMAT | log.file.format | | Log.File.Path | Path of log file. Defaults to 'renterd.log' within the renterd directory | renterd.log | --log.file.path | RENTERDLOGFILE_PATH | log.file.path | | Log.StdOut.Enabled | Enables logging to stdout. Defaults to 'true' | true | --log.stdout.enabled | RENTERDLOGSTDOUT_ENABLED | log.stdout.enabled | | Log.StdOut.Format | Format of log output (json\|human). Defaults to 'human' | human | --log.stdout.format | RENTERDLOGSTDOUT_FORMAT | log.stdout.format | | Log.StdOut.EnableANSI | Enables ANSI color codes in log output. Defaults to 'true' on non-Windows systems | true (false on Windows) | --log.stdout.enableANSI | RENTERDLOGSTDOUTENABLEANSI | log.stdout.enableANSI | | Log.Database.Enabled | Enable logging database queries. Defaults to 'true' | true | --log.database.enabled | RENTERDLOGDATABASE_ENABLED | log.database.enabled | | Log.Database.Level | Logger level for database queries (info\|warn\|error). Defaults to 'warn' | warn | --log.database.level | RENTERDLOGDATABASELEVEL, RENTERDLOG_LEVEL | log.database.level | | Log.Database.IgnoreRecordNotFoundError | Enable ignoring 'not found' errors resulting from database queries. Defaults to 'true' | true | --log.database.ignoreRecordNotFoundError | RENTERDLOGDATABASEIGNORERECORDNOTFOUND_ERROR | log.database.ignoreRecordNotFoundError | | Log.Database.SlowThreshold | Threshold for slow queries in logger. Defaults to 500ms | 500ms | --log.database.slowThreshold | RENTERDLOGDATABASESLOWTHRESHOLD | log.database.slowThreshold | | Database.MySQL.URI | Database URI for the bus | - | --db.uri | RENTERDDBURI | database.mysql.uri | | Database.MySQL.User | Database username for the bus | renterd | --db.user | RENTERDDBUSER | database.mysql.user | | Database.MySQL.Password | Database password for the bus | - | - | RENTERDDBPASSWORD | database.mysql.password | | Database.MySQL.Database | Database name for the bus | renterd | --db.name | RENTERDDBNAME | database.mysql.database | | Database.MySQL.MetricsDatabase | Database for metrics | renterdmetrics | --db.metricsName | RENTERDDBMETRICSNAME | database.mysql.metricsDatabase | | Database.SQLite.Database | SQLite database name | - | - | - | database.sqlite.database | | Database.SQLite.MetricsDatabase | SQLite metrics database name | - | - | - | database.sqlite.metricsDatabase | | Bus.AllowPrivateIPs | Allows hosts with private IPs | - | --bus.allowPrivateIPs | - | bus.allowPrivateIPs | | Bus.AnnouncementMaxAgeHours | Max age for announcements | 8760h (1 year) | --bus.announcementMaxAgeHours | - | bus.announcementMaxAgeHours | | Bus.Bootstrap | Bootstraps gateway and consensus modules | true | --bus.bootstrap | - | bus.bootstrap | | Bus.GatewayAddr | Address for Sia peer connections | :9981 | --bus.gatewayAddr | RENTERDBUSGATEWAY_ADDR | bus.gatewayAddr | | Bus.RemoteAddr | Remote address for the bus | - | - | RENTERDBUSREMOTE_ADDR | bus.remoteAddr | | Bus.RemotePassword | Remote password for the bus | - | - | RENTERDBUSAPI_PASSWORD | bus.remotePassword | | Bus.UsedUTXOExpiry | Expiry for used UTXOs in transactions | 24h | --bus.usedUTXOExpiry | - | bus.usedUtxoExpiry | | Bus.SlabBufferCompletionThreshold | Threshold for slab buffer upload | 4096 | --bus.slabBufferCompletionThreshold | RENTERDBUSSLABBUFFERCOMPLETION_THRESHOLD | bus.slabBufferCompletionThreshold | | Worker.AccountsRefillInterval | Interval for refilling workers' account balances | 10s | --worker.accountsRefillInterval | - | worker.accountsRefillInterval | | Worker.BusFlushInterval | Interval for flushing data to bus | 5s | --worker.busFlushInterval | - | worker.busFlushInterval | | Worker.DownloadMaxOverdrive | Max overdrive workers for downloads | 5 | --worker.downloadMaxOverdrive | - | worker.downloadMaxOverdrive | | Worker.DownloadMaxMemory | Max memory for downloads | 1GiB | --worker.downloadMaxMemory | RENTERDWORKERDOWNLOADMAXMEMORY | worker.downloadMaxMemory | | Worker.ID | Unique ID for worker | worker | --worker.id | RENTERDWORKERID | worker.id | | Worker.DownloadOverdriveTimeout | Timeout for overdriving slab downloads | 3s | --worker.downloadOverdriveTimeout | - | worker.downloadOverdriveTimeout | | Worker.UploadMaxMemory | Max amount of RAM the worker allocates for slabs when uploading | 1GiB | --worker.uploadMaxMemory | RENTERDWORKERUPLOADMAXMEMORY | worker.uploadMaxMemory | | Worker.UploadMaxOverdrive | Max overdrive workers for uploads | 5 | --worker.uploadMaxOverdrive | - | worker.uploadMaxOverdrive | | Worker.UploadOverdriveTimeout | Timeout for overdriving slab uploads | 3s | --worker.uploadOverdriveTimeout | - | worker.uploadOverdriveTimeout | | Worker.UploadSectorTimeout | Timeout for upload of individual sectors | 1m | --worker.uploadSectorTimeout | - | worker.uploadSectorTimeout | | Worker.Enabled | Enables/disables worker | true | --worker.enabled | RENTERDWORKERENABLED | worker.enabled | | Worker.AllowUnauthenticatedDownloads | Allows unauthenticated downloads | - | --worker.unauthenticatedDownloads | RENTERDWORKERUNAUTHENTICATED_DOWNLOADS | worker.allowUnauthenticatedDownloads | | Autopilot.Enabled | Enables/disables autopilot | true | --autopilot.enabled | RENTERDAUTOPILOTENABLED | autopilot.enabled | | Autopilot.Heartbeat | Interval for autopilot loop execution | 30m | --autopilot.heartbeat | - | autopilot.heartbeat | | Autopilot.MigratorRefillInterval | Interval for refilling account balances | 24h | --autopilot.migratorAccountRefillInterval | - | autopilot.migratorAccountsRefillInterval | | Autopilot.MigratorHealthCutoff | Threshold for migrating slabs based on health | 0.75 | --autopilot.migratorHealthCutoff | - | autopilot.migratorHealthCutoff | | Autopilot.MigratorNumThreads | Number of threads migrating slabs | 1 | --autopilot.migratorNumThreads | - | autopilot.migratorNumThreads | | Autopilot.MigratorDownloadMaxOverdrive | Max overdrive workers for migration downloads | 5 | --autopilot.migratorDownloadMaxOverdrive | - | autopilot.migratorDownloadMaxOverdrive | | Autopilot.MigratorDownloadOverdriveTimeout | Timeout for overdriving migration downloads | 3s | --autopilot.migratorDownloadOverdriveTimeout | - | autopilot.migratorDownloadOverdriveTimeout | | Autopilot.MigratorUploadMaxOverdrive | Max overdrive workers for migration uploads | 5 | --autopilot.migratorUploadMaxOverdrive | - | autopilot.migratorUploadMaxOverdrive | | Autopilot.MigratorUploadOverdriveTimeout | Timeout for overdriving migration uploads | 3s | --autopilot.migratorUploadOverdriveTimeout | - | autopilot.migratorUploadOverdriveTimeout | | Autopilot.MigratorUploadSectorTimeout | Timeout for upload of individual sectors | 1m | --autopilot.migratorUploadSectorTimeout | - | autopilot.migratorUploadSectorTimeout | | Autopilot.RevisionBroadcastInterval| Interval for broadcasting contract revisions | 168h (7 days) | --autopilot.revisionBroadcastInterval | RENTERDAUTOPILOTREVISIONBROADCASTINTERVAL | autopilot.revisionBroadcastInterval | | Autopilot.ScannerBatchSize | Batch size for host scanning | 1000 | --autopilot.scannerBatchSize | - | autopilot.scannerBatchSize | | Autopilot.ScannerInterval | Interval for scanning hosts | 24h | --autopilot.scannerInterval | - | autopilot.scannerInterval | | Autopilot.ScannerNumThreads | Number of threads for scanning hosts | 100 | - | - | autopilot.scannerNumThreads | | S3.Address | Address for serving S3 API | localhost:8080 | --s3.address | RENTERDS3ADDRESS | s3.address | | S3.DisableAuth | Disables authentication for S3 API | false | --s3.disableAuth | RENTERDS3DISABLE_AUTH | s3.disableAuth | | S3.Enabled | Enables/disables S3 API | true | --s3.enabled | RENTERDS3ENABLED | s3.enabled | | S3.HostBucketBases | Enables bucket rewriting in the router for the provided bases | - | --s3.hostBucketBases | RENTERDS3HOSTBUCKETBASES | s3.hostBucketBases | | S3.HostBucketEnabled | Enables bucket rewriting in the router | - | --s3.hostBucketEnabled | RENTERDS3HOSTBUCKETENABLED | s3.hostBucketEnabled | | Explorer.Disable | Disables explorer service | false | --explorer.disable | RENTERDEXPLORERDISABLE | explorer.disable | | Explorer.URL | URL of service to retrieve data about the Sia network | https://api.siascan.com | --explorer.url | RENTERDEXPLORERURL | explorer.url |
Single-Node Setup
A single-node setup involves running all components (bus, worker, and autopilot) on the same machine. This is ideal for testing, development, or small-scale deployments. This setup is the default when running renterd without any flags.
Cluster Setup
In a cluster setup, the bus, worker, and autopilot run on separate nodes. This setup is ideal for large-scale deployments where you want to horizontally scale your renter. The worker nodes can be spread across multiple machines, and the autopilot can be run on a separate machine.
Bus Node Configuration
The bus is the only node that exposes the UI. To run the bus separately, the autopilot and worker have to be disabled using the --autopilot.enabled and --worker.enabled flags. The only other requirement to run a bus is the (walet) seed.
Worker Node Configuration
To configure the worker as a standalone node, the autopilot has to be disabled using the --autopilot.enabled flag, and the bus has to be disabled. There's no flag to explicitly disable the bus, it's implied by configuring a remote address for the bus using the --bus.remoteAddr and --bus.remotePassword flags. When the bus is remote, the worker has to be configured with an external address of the form http://<worker-ip>:<port>, on localhost however this can be the same as the worker's HTTP address. The worker needs to know its location on the network because it relies on some webhooks it needs to register with the bus, which in turn needs to know how to reach the worker when certain events occur. Therefor it is important to start the worker after the bus is reachable.
Autopilot Node Configuration
To run the autopilot separately, the worker has to be disabled using the --worker.enabled flag. Similar to the worker, the autopilot has to be configured with a remote bus for the node not to start a bus itself.
Example docker-compose with minimal configuration
version: '3.9'
services: bus: image: ghcr.io/siafoundation/renterd:master containername: renterdbus environment: - RENTERD_SEED=<enter seed here> - RENTERDAPIPASSWORD=bus-pass ports: - "9980:9980" - "9981:9981"
worker-1: image: ghcr.io/siafoundation/renterd:master containername: renterdworker-1 environment: - RENTERDAUTOPILOTENABLED=false - RENTERD_SEED=<enter seed here> - RENTERDAPIPASSWORD=worker-pass - RENTERDBUSAPI_PASSWORD=bus-pass - RENTERDBUSREMOTE_ADDR=http://bus:9980/api/bus ports: - "9982:9980" - "8082:8080" depends_on: - bus
worker-2: image: ghcr.io/siafoundation/renterd:master containername: renterdworker-2 environment: - RENTERD_SEED=<enter seed here> - RENTERDAPIPASSWORD=worker-pass - RENTERDBUSAPI_PASSWORD=bus-pass - RENTERDBUSREMOTE_ADDR=http://bus:9980/api/bus ports: - "9983:9980" - "8083:8080" depends_on: - bus
autopilot: image: ghcr.io/siafoundation/renterd:master containername: renterdautopilot environment: - RENTERDAPIPASSWORD=autopilot-pass - RENTERDBUSAPI_PASSWORD=bus-pass - RENTERDBUSREMOTE_ADDR=http://bus:9980/api/bus ports: - "9984:9980" depends_on: - bus - worker-1 - worker-2
Tweaking Performance
Depending on hardware specs, you can change the configuration to better utilize it and gain more performance out of renterd. This section highlights some of the more obvious tweaks one can apply.
Increase/Decrease memory
By default, renterd uses reasonable limits for RAM consumed by uploads and downloads. Especially when downloading or uploading single large files, more RAM can make a difference since it allows for processing the download/upload in parallel. To change the max RAM renterd is going to use update the Worker.DownloadMaxMemory and Worker.UploadMaxMemory settings.
Overdrive
Both uploads and downloads have a setting we call "overdrive". Since renterd operates in a trustless environment, we can't rely on all of our hosts being reliable and of high quality. So when uploading n shards of some data to the network (or downloading from it), the process is bottlenecked by the slowest host. That is where the overdrive comes in.
Worker.UploadMaxOverdrive and Worker.DownloadMaxOverdrive can be used to configure how many additional hosts to the number we need to upload/download we use to reduce the chance of getting hung up on a slow one. The default is 3 which means up to 3 hosts can get stuck with the upload/download remaining mostly unaffected. Worker.UploadOverdriveTimeout and Worker.DownloadOverdriveTimeout specify the time that needs to pass before we launch the overdrive uploads/downloads.
Two conditions need to be met before the overdrive launches:
- When uploading/downloading to/from
nhosts (without overdrive),n - overdriveHostspieces need to finish. - Once condition 1. is met, the configured overdrive timeout needs to pass
Backups
This section provides a step-by-step guide covering the procedures for creating and restoring backups for renterd. Regularly backing up your renter's metadata and verifying its restorability are essential practices to ensure your data's integrity and availability in the event of a disaster scenario. Ensure backups are stored on a different machine than the one running renterd to avoid data loss in case of hardware failure.
IMPORTANT NOTE
It is important to note that having a backup is not enough to ensure the data can be recovered from the network. The renter has to be online enough of the time to ensure data gets migrated away from hosts that went offline.
Creating a backup
Step 1: shut down renter
It's strongly recommended to shut down the renter before creating a backup to ensure data consistency. This precaution addresses the "upload packing" feature (enabled by default), which relies on on-disk buffers. To capture a consistent state between the database and on-disk data, shut down renterd first. Even if the feature is not enabled, it is best to shut down the renter before taking a backup to be on the safe side and ensure consistency.
Step 2: backing up the database
renterd uses two SQL databases: a main database for contracts, host metadata and object metadata essential for data retrieval, and a metrics database for UI features. Both are critical but prioritize the main database for file recovery.
Depending on how the renter is configured, the databases are either SQLite (default) or MySQL databases. By default, the SQLite databases are called db.sqlite and metrics.sqlite and are located in a folder called db, right in the renter's root directory.
SQLite
Use the .backup command to create a backup of the SQLite databases.
sqlite3 db.sqlite ".backup 'db.bkp'"
sqlite3 metrics.sqlite ".backup 'metrics.bkp'"
There should only be two files in the db folder, if you encounter write-ahead log files or index files (usually named -wal or -shm) it indicates the renter was not shut down gracefully. In that case it's best to restart the renter and shut it down again.
MySQL
Use the mysqldump command to create a backup of the MySQL databases. It's a utility provided by MySQL to backup or transfer a MySQL database and it's usually installed alongside the MySQL client tools. Replace placeholders with actual user and password.
mysqldump -u [RENTERDDBUSER] --password=[RENTERDDBPASSWORD] renterd > renterd_bkp.sql
mysqldump -u [RENTERDDBUSER] --password=[RENTERDDBPASSWORD] renterdmetrics > renterdmetrics_bkp.sql
Step 3: backing up partial slabs
If "upload packing" is enabled, back up the partial_slabs folder located in the renter's root directory. These files contain data that has not been uploaded to the network yet, losing these files means an immediate loss of your data.
tar -cvf partialslabs.tar partialslabs/
Restoring from a backup
If the goal is to install renterd from a backup on a new machine, the easiest way is to do a fresh renterd install and then overwrite the empty database with the backup. Use the same RENTERD_SEED as the original installation.
Step 1: shutdown renter
Same as before we advise to shut down the renter before reinstating a backup to ensure consistency. It's a good idea to backup the database right before trying to restore a backup to be safe and have a way out in case overwriting the database renders it corrupt somehow.
Step 2: restore the database backup
SQLite
For SQLite we can reinstate the database by replacing both .sqlite files with our backups. Make sure to rename them to their original filename db.sqlite and metrics.sqlite. These filenames are configurable, so make sure you match the configured values.
MySQL
Depending on when the backup was taken its schema might be out of date. To maximize the chance the schema migrations go smoothly, it's advisable to recreate the databases before importing the backup. Take a backup before doing this.
# log in to MySQL shell
mysql -u [RENTERDDBUSER] -p
recreate renterd database
DROP DATABASE IF EXISTS renterd;
CREATE DATABASE renterd;
recreate renterd_metrics database
DROP DATABASE IF EXISTS renterd_metrics;
CREATE DATABASE renterd_metrics;
The backups can then be imported using the following commands:
cat renterdbkp.sql | mysql -u [RENTERDDBUSER] --password=[RENTERDDB_PASSWORD] renterd
cat renterdmetricsbkp.sql | mysql -u [RENTERDDBUSER] --password=[RENTERDDBPASSWORD] renterd_metrics
Step 3: restore the partial slabs
If applicable, remove the contents of the partial_slabs directory and replace it with your backup.
rm -rf partial_slabs
tar -xvf partial_slabs.tar
Step 4: start the renter
After starting the renter it is possible it has to run through migrations to its database schema. Depending on when the backup was taken, this might take some time. If we restored the backup on a fresh renterd install, it will take some time for consensus to sync.
Docker Support
renterd includes a Dockerfile which can be used for building and running renterd within a docker container. For the time being it is provided as-is without any compatibility guarantees as it will change over time and be extended with more configuration options. The image can also be pulled from ghcr.io/siafoundation/renterd.
Docker Compose
version: "3.9"
services:
renterd:
image: ghcr.io/siafoundation/renterd:master
environment:
- RENTERD_SEED=put your seed here
- RENTERDAPIPASSWORD=test
ports:
- 9980:9980
- 9981:9981
- 8080:8080
volumes:
- ./data:/data
restart: unless-stopped
stopgraceperiod: 5m
Build Image
From within the root of the repo run the following command to build an image of renterd tagged renterd.
docker build -t renterd:master -f ./docker/Dockerfile .
Run Container
Run renterd in the background as a container named renterd that exposes its API to the host system and the gateway to the world.
Mainnet
docker run -d --name renterd -e RENTERDAPIPASSWORD="<PASSWORD>" -e RENTERD_SEED="<SEED>" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ghcr.io/siafoundation/renterd:master
Testnet
To run renterd on testnet use the RENTERD_NETWORK environment variable.
docker run -d --name renterd -e RENTERDAPIPASSWORD="<PASSWORD>" -e RENTERDNETWORK="<network>" -e RENTERDSEED="<SEED>" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ghcr.io/siafoundation/renterd:master
Currently available values for <network> are:
zenanagami
Architecture
renterd distinguishes itself from siad through a unique architecture comprised of three main components: the autopilot, the bus, and one or more workers.
Instead of adopting another Electron app bundle, renterd incorporates an embedded web UI. This approach caters to developers and power users who prefer a streamlined experience. For those who do not require the UI, renterd can be compiled without it, which reduces software bloat and simplifies the build process.
Autopilot
The autopilot in renterd automates high-level functions like host scanning, ranking, and the management of contracts and data. This ensures efficient host selection for data storage. While it offers convenience for most users, those desiring full control can disable the autopilot via a CLI flag. Remarkably, the autopilot is designed over the public renterd HTTP API, allowing for straightforward customization and language porting.
Bus
Serving as the central nervous system of renterd, the bus handles data persistence and connections with Sia's peer-to-peer network. While renterd defaults to an SQLite database, users have the option to configure it for MySQL use. SQLite is the default choice due to its seamless initial experience, but switching to MySQL is recommended for enhanced performance.
Worker(s)
Workers are the direct interface for users, managing tasks such as file uploads/downloads and contract handling. They depend on the bus for consistent data persistence.
Usage
The Web UI streamlines the initial setup and configuration for newcomers. However, if manual configuration is necessary, the subsequent sections outline a step-by-step guide to achieving a functional renterd instance.
Wallet
Make sure the wallet is funded, it's a good rule of thumb to have at least twice the allowance in the wallet. Fetch the wallet's address and transfer some money. Verify the wallet's balance is not zero using the following endpoint:
GET /api/bus/wallet
GET /api/bus/wallet/outputs
Consensus
In order for the contracts to get formed, your node has to be synced with the blockchain. If you are not bootstrapping your node this can take a while. Verify your node's consensus state using the following endpoint:
GET /api/bus/consensus/state
Blocklist
Unfortunately the Sia blockchain is subject to hosts that announced themselves with faulty parameters and/or bad intentions, something which is unavoidable of course in a decentralized environment. We added a blocklist to give users the power to block hosts by IP or domain.
GET /api/bus/hosts/blocklistPUT /api/bus/hosts/blocklist
renterd with a default blocklist, the
following entries exclude a decent amount of bad/old/malicious hosts:
- 45.148.30.56
- 51.158.108.244
- siacentral.ddnsfree.com
- siacentral.mooo.com
