How To Deploy A BitTorrent (BTFS) Node

How To Deploy A BitTorrent (BTFS) Node
How to Deploy a Bittorrent Node

Decentralization is a key principle that empowers individuals to take entire control of their digital assets. One way to achieve this is by running your own node. Today's post will give valuable insights into BitTorrent nodes and how to deploy a BitTorrent (BTFS) node.

What is a BitTorrent (BTFS) Node?

A BitTorrent node is a computer that participates in the BitTorrent network. Nodes are responsible for storing and sharing files, as well as maintaining the network's infrastructure.

There are two types of BitTorrent nodes:

  • Seeders: Seeders are nodes that have the entire file that is being shared. They are responsible for providing the file to other nodes.
  • Leechers: Leechers are nodes that download the file. They get the file from seeders.

Nodes can also be classified as:

  • Full nodes: Full nodes store the entire BitTorrent blockchain. They are responsible for verifying transactions and ensuring the security of the network.
  • Light nodes: Light nodes do not store the entire blockchain. They rely on full nodes to provide them with information about the blockchain.

BitTorrent nodes are essential for the operation of the BitTorrent network. They allow users to share files quickly and efficiently.

BitTorrent Node Setup Requirements

  • Operating system: Windows, macOS, or Linux (Ubuntu 18.04 at minimum).
  • RAM: The minimum recommended amount of RAM is 2 GB, but you may need more if you plan on seeding a lot of files.
  • CPU: A single CPU core is sufficient for most nodes, but you may want to use more cores if you plan on seeding a lot of files or if you want to improve the performance of your node.
  • Storage: You will need storage space to store the files you are seeding. The amount of storage space you need will depend on the size of the files that you are seeding.
  • Bandwidth: You will need a reliable internet connection with a decent amount of bandwidth. The amount of bandwidth you need will depend on the number of peers that you are connected to and the size of the files that you are seeding.

How to Deploy a BitTorrent Node on Linux

Our guide will strictly follow BTFS Docs. To stay updated, we recommend you regularly check out the documentation.

Step 1: Install BTFS 2.0

Build from Source

  • Copy the go-btfs repository: git clone https://github.com/bittorrent/go-btfs
  • Navigate to the go-btfs directory and run the following commands :
    cd go-btfs
    make install
    make build
  • If you want to get the btfs-binary-releases, head over to BTFS GitHub releases and download it from there.

Set up a BTFS Daemon

To access the btfs directory, use the command cd cmd/btfs. By default, this will start a mainnet miner with chain_id=199. If you prefer to deploy the testnet node, it is also available in the docs.

$ ./btfs init Generating TRON key with BIP39 seed phrase... Master public key:  xpub661MyMwAqRbcGgHpeMqFkS5hnwoGeAcHG5KkDQwke7wFxtKqfsXTCTjWsoU2dYVXVGvV7EuGcviEzEJ143TezxxXvs2zZ9FYTtCei8iRQ66 initializing BTFS node at /home/ubuntu/.btfs generating btfs node keypair with TRON key...done peer identity: 16Uiu2HAmKFQPM72SssFRrqcH1qwUsPwcp7vXSg3SEzfdYua1J5qc to get started, enter: btfs cat /btfs/QmZjrLVdUpqVU6Pnc8pBnyQxVdpn9J8tfcsycP84W6N93C/readme

Activate the Daemon

  • Activate the Daemon: .btfs daemon

$ ./btfs daemon

Initializing daemon...

go-btfs version: 2.0

Repo version: 10

System version: amd64/darwin

Golang version: go1.16.5

Repo location: /Users/btfs/.btfs

Peer identity: 16Uiu2HAmKFQPM72SssFRrqcH1qwUsPwcp7vXSg3SEzfdYua1J5qc

the address of Bttc format is:  0x7Cf4B71017F0312037D53fe966CE625BF98FFff6

the address of Tron format is:  TMMuwwxsuQGrDrN3aanc5y5r4FbibgLYDa

cannot continue until there is sufficient (100 Suggested) BTT (for Gas) available on 0x7cf4b71017f0312037d53fe966ce625bf98ffff6

Run the Daemon

The system will automatically establish a node account upon initiating the BTFS Daemon for the first time. Simultaneously, the system will print  a string of messages: 'cannot continue until there is sufficient (100 Suggested) BTT (for Gas) available on.'

Once you see this message, recharge the node account with BTT through an external account. The system advises maintaining at least 100 BTT, which serves as gas for deploying a node vault contract utilizing said node account.

It is important to note that the BTT in this context is the BTT token on the BTTC chain. You can check out: How do I get BTT/WBTT on the BTTC Mainnet?

Once you finish recharging, the BTFS node will proceed to generate the vault contract. The Daemon is now ready; your node is ready.

cannot continue until there is sufficient (100 Suggested) BTT (for Gas) available on 0x7cf4b71017f0312037d53fe966ce625bf98ffff6

self vault: 0x1f8b3e7e691d733f5eb17e5570c49de3e5aecef9

Swarm listening on /ip4/127.0.0.1/tcp/4001

Swarm listening on /ip4/192.168.21.149/tcp/4001

Swarm listening on /ip6/::1/tcp/4001

Swarm listening on /p2p-circuit

Swarm announcing /ip4/127.0.0.1/tcp/4001

Swarm announcing /ip4/192.168.21.149/tcp/4001

Swarm announcing /ip6/::1/tcp/4001

API server listening on /ip4/127.0.0.1/tcp/5001

Dashboard: http://127.0.0.1:5001/dashboard

Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080

Remote API server listening on /ip4/127.0.0.1/tcp/5101

Daemon is ready

Note: Please ensure you save the node address and private key, keeping the private key secure. Save the vault address by locating the self-vault field in the print message, and note down the address that follows it. You can obtain this information from the provided cmd.

$ ./btfs id

{ "ID": "16Uiu2HAm8tjcJvxYYJL5LM5WSKnHC9REKVfArt8QJx1kZEXkw73E",

"PublicKey": "CAISIQLIFrdEEl2TTQ9alLgK4ntBB/HL1qMxMsS+qgJnPZqueQ==",

"Addresses": null,

"AgentVersion": "go-btfs/2.1.0/",

"ProtocolVersion": "btfs/0.1.0",

"Protocols": null,

"DaemonProcessID": -1,

"TronAddress": "TJowu1DCPt24DYZBNL6HvVW9fPuoq6MQhx",

"BttcAddress": "0x60F8c7a6ce00B94d80Aa51e315be1069940e6eFF",

"VaultAddress": "0xFd3171a158D940955582339E7FF96B47F7592404"}

Step 2: Change the hosting folder

The next step is to modify the storage path of BTFS.

# Modify the Host storage folder path for BTFS client btfs storage path

To specify the new storage path, use the argument 'path-name'. It is important to note that the path must be an absolute one.

To declare the required space for the new storage path, use the argument 'storage-size'. The default unit for this argument is byte, but you can also use a humanized style such as 20G or 100M. However, make sure to specify a value that is equal to or greater than the current BTFS storage size. This ensures the new storage path has enough space to accommodate file migration.

Using dashboard:

Change the storage path using BTFS Dashboard:
https://docs.btfs.io/docs/btfs20-dashboard

Please note that modifying the file path will result in the abnormal interruption of other ongoing tasks. The new path you specify must be empty, and its parent directory must already exist.

Once this operation is performed, the BTFS daemon will automatically restart and proceed with the file migration. Please be aware that the daemon will not be accessible until the file migration is completed.

Additionally, please note that modifying the path successfully will render the original BTFS PATH environment variable ineffective, as it will now be controlled by the path specified in the .btfs.properties file located in the BTFS installation directory.

Step 3: Configure mainnet RPC

To configure the RPC addresses of the main network, ensure that all three addresses have a chainid of 199. You can modify these addresses in the Config file by adjusting the RPC configuration. Make sure your go-btfs version is v2.

Three RPC addresses:

https://bttc.trongrid.io/ (*Recommend)
https://rpc.bt.io/
https://rpc.bittorrentchain.io/

  • Head over to the BTFS PATH directory and open the config file:

$ cd ~/.btfs

$ cat config

{

"ChainInfo": { "ChainId": 199, "CurrentFactory": "0x9AF4bEc1A30BeC47756Ecef4cf43B91592121bC9", "PriceOracleAddress": "0x0064d80C42b6E2cE3aC92eaD445B3D83C510c7AA", "Endpoint": "https://rpc.bt.io/"

},

}

  • Change the Endpoint:

{

"ChainInfo": { "Endpoint": "https://rpc.bittorrentchain.io/"

},

}

  • Restart go-btfs
    $ ./btfs daemon
    ......

Step 4: Migrate your node

Migrate with configurations and revenue from the old node

  • Run the btfs repo command on the old node.
  • Copy the files and configuration directories from the old node to the customized path of the new node.
  • Set the value of the new node's environment variable BTFS PATH to the copied path.
  • Start the BTFS daemon on the new node.

Migrate without stats and revenue from the old node

  • Change the BTFS PATH environment variable by putting in the updated node file and configuration path (don't use the same repo path as those other nodes).
  • Run btfs init -p -i on your new node.
  • Launch the BTFS daemon on the new node.

Note: Following the migration process, all previous node data, including cheques, will be irretrievably lost. It is imperative that you independently back up your old node data to ensure easy access for data retrieval and cheque redemption.

Step 5: Set up static ports

BTFS Configuration Settings

To modify the random swarm port, you can make changes to the config file located within the .btfs directory. Specifically, you should update the port number associated with the Swarm setting to your preferred port.

Below is an example of port 1234 update:

"Addresses": {

"API": "/ip4/127.0.0.1/tcp/5001",

"Announce": [],

"Gateway": "/ip4/127.0.0.1/tcp/8080",

"NoAnnounce": [],

"RemoteAPI": "/ip4/127.0.0.1/tcp/5101",

"Swarm": [

"/ip4/0.0.0.0/tcp/1234",

"/ip6/::/tcp/1234"

]

}

After updating the port value, be sure to restart your daemon:

btfs shutdown btfs daemon

Machine Configuration

Machine configuration is necessary to activate specific ports.

-> Open firewall manually (Linux/MacOS): ufw allow 1234/tcp

Read more