filswan / go-swan-provider

A golang implementation for Swan Service provider.
Apache License 2.0
36 stars 29 forks source link

Swan Provider

Discord Twitter Follow standard-readme compliant

Table of Contents

Features

Swan Provider listens to offline deals that come from the Swan platform. It provides the following functions:

Prerequisite

Start Lotus-miner

Before launching the swan-provider, you must ensure that Lotus-miner is running normally. and Lotus-miner token is necessary for importing deals.

lotus-miner auth create-token --perm write

Note that the Lotus-miner needs to be running in the background! The created token is located at $LOTUS_MINER_PATH/token Reference: Lotus: API tokens

Aria2 Service

sudo apt install aria2

Installation

You can set the $SWAN_PATH by the environment variable, default ~/.swan:

export SWAN_PATH="/data/.swan"

Option:one: Prebuilt package: See release assets

Build Instructions

wget --no-check-certificate https://github.com/filswan/go-swan-provider/releases/download/v2.3.0/install.sh
chmod +x ./install.sh
./install.sh

Config and Run

ulimit -SHn 1048576
export SWAN_PATH="/data/.swan"
nohup swan-provider-2.3.0-linux-amd64 daemon >> swan-provider.log 2>&1 & 

Option:two: Source Code

Building the swan-provider requires some system dependencies:

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt install mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev wget -y && sudo apt upgrade -y

Build Instructions

git clone https://github.com/filswan/go-swan-provider.git
cd go-swan-provider
git checkout release-2.3.0
./build_from_source.sh

Configuration and Run

The configuration needs to be set according to the different market_version.

port = 8888
release = true                                  # when working in release mode: set this to true, otherwise to false and environment variable GIN_MODE not to release

[lotus]
client_api_url = "http://[ip]:[port]/rpc/v0"    # Url of lotus client web API, generally the [port] is 1234
client_api_token = ""                           # Access token of lotus client web API. (lotus auth api-info --perm=admin)
market_api_url = "http://[ip]:[port]/rpc/v0"    # Url of lotus market web API, generally the [port] is 2345, when market and miner are not separate, it is also the URL of miner web API
market_access_token = ""                        # Access token of lotus market web API, when market and miner are not separate, it is also the access token of miner web API
max_sealing = 5                                 # Limit the number of concurrently executing tasks for sealing sectors.
max_addPiece = 2                                # Limit the number of concurrently executing tasks for addPiece.

[aria2]
aria2_download_dir = "%%ARIA2_DOWNLOAD_DIR%%"   # Directory where offline deal files will be downloaded for importing
aria2_candidate_dirs = ["/tmp"]         # Directories to find the CAR file required for the offline deal
aria2_host = "127.0.0.1"                        # Aria2 server address
aria2_port = 6800                               # Aria2 server port
aria2_secret = "my_aria2_secret"                # Must be the same value as RPC-secure in aria2.conf
aria2_auto_delete_car_file= false               # After the deal becomes Active or Error, the CAR file will be deleted automatically
aria2_max_downloading_tasks = 10                # Aria2 max downloading tasks. default: 10

[main]
market_version = "1.2"                          # Send deal type, 1.1 or 1.2, config(market_version=1.1) is DEPRECATION, will REMOVE SOON (default: "1.2"), If set to 1.2, you need to set the [market] section
api_url = "https://go-swan-server.filswan.com"  # Swan API address. For Swan production, it is "https://go-swan-server.filswan.com"
api_key = ""                                    # Your api key. Acquire from Filswan -> "My Profile"->"Developer Settings". You can also check the Guide.
access_token = ""                               # Your access token. Acquire from Filswan -> "My Profile"->"Developer Settings". You can also check the Guide.
miner_fid = "f0xxxx"                            # Your Filecoin MinerID, this miner must be added to the Swan Storage providers list by Swan Platform -> "My Profile" -> "As Storage Provider" -> "Manage" -> "Add"
import_interval = 600                           # 600 seconds or 10 minutes. Importing interval between each deal.
scan_interval = 600                             # 600 seconds or 10 minutes. Time interval to scan all the ongoing deals and update status on the Swan platform.
api_heartbeat_interval = 300                    # 300 seconds or 5 minutes. Time interval to send a heartbeat.

[bid]
bid_mode = 1                                    # 0: manual, 1: auto
expected_sealing_time = 1920                    # 1920 epoch or 16 hours. The time expected for sealing deals. Deals starting too soon will be rejected.
start_epoch = 2880                              # 2880 epoch or 24 hours. The relative value to current epoch
auto_bid_deal_per_day = 600                     # auto-bid deal limit per day for your miner defined above

[market]
collateral_wallet = ""                          # wallet to be used for deal collateral
publish_wallet = ""                             # wallet to be used for PublishStorageDeals messages

(1) when market_version = "1.1", the storage provider will import deals using the Market built-in lotus, so the [market] section is not necessary to set.

(2) when market_version = "1.2 (Recommend)", the storage provider will import deals using the Market like Boost, so you must ensure the storage provider is reachable. The following steps are:

Interact with the Swan Provider

The swan-provider command allows you to interact with a running swan provider daemon. Check the current version of your swan-provider

swan-provider version

Common issues and solutions

For usage questions or issues reach out to the Swan Provider team either in the Discord channel or open a new issue here on GitHub.

License

Apache