Filecoin Mainnet¶
The Powergate makes it easy to run on Mainnet.
Info
Running a fully-synced Lotus node can take a considerable amount of time and resources. It may take over a day to sync the current chain the first time you run the Powergate. This effort is normal on live blockchain networks.
Getting Started¶
There are a few resources you'll need before you start running any nodes.
- Docker Desktop. In the examples below, you'll run node instances using local Docker containers. You can do the same with any Docker enabled system, but to get started we recommend Docker Desktop and the default configurations we provide.
- Powergate.
- Golang. Building the Powergate CLI from code requires Go. Other sections of the tutorials below don't need Go.
Mainnet with Powergate¶
Installation¶
Clone the Powergate and cd
into the project
git clone git@github.com:textileio/powergate.git
cd powergate
Setup¶
A default setup is available in the docker-compose
configuration shipped with the Powergate. With the default setup, you'll run Powergate connected to live Filecoin Mainnet.
Run the docker-compose
Docker files for the Powergate are all contained in the folder, /docker
.
cd docker
make up
On initial setup, Docker will download the required instances before any Powergate setup begins. Downloads may take a few minutes and only happen on the first run.
If this is the first time you're running the Powergate on the mainnet, or if you have been offline for any amount of time, you'll need to wait for the chain to properly sync. This can take over a day.
Once running, you will begin to see log outputs.
lotus_1 | 2020-05-29T20:35:08.644Z WARN miner miner/miner.go:177\
mined block in the past {"block-time": "2009-01-01T04:44:30.000Z",\
"time": "2020-05-29T20:35:08.644Z", "duration": 359999438.64444387}
When complete, you'll have a fully functional Powergate (powd
), a Lotus node, and an IPFS node wired together to start using on the Mainnet!
Bootstrap a clean Lotus node from a snapshot¶
Syncing a new Lotus node from genesis can take a long time. The current mainnet
network provides snapshots of the VM state every hour, which means having to sync less than 250 blocks from the tip of the chain in the worst case.
Warning
Bootstrapping the Lotus node from a snapshot implies complete trust in the party who generated it. This is a pragmatic solution for getting up to speed fast. Depending on your use case, you should consider the security risks of accepting snapshots from trusted parties.
The snapshot described in this section is generated by Protocol Labs, the founders of Filecoin.
To bootstrap a clean Lotus node from a mainnet
snapshot, you should edit the docker/docker-compose.yaml
in the following way:
After doing that you should:
- Run
make up
. - If you inspect the Lotus node with
docker logs mainnet_lotus_1
, you'll see messages describing that a snapshot is being imported with other Badger compaction messages interleaved. - After the importing is done, the Lotus node will continue to sync, as usual, showing the typical logs.
- At this point, you should
make down
(you don't need to wait to full syncing), revert or comment out the added line indocker/docker-compose.yaml
. - And
make up
again.
Congratulations! You're now syncing from a trusted checkpoint.
Recover or prune your existing Lotus node with a snapshot¶
If you run a Lotus node for a long time, its underlying chain
datastore will become bigger, affecting the syncing process and possibly producing other problems.
Also, if your node falls behind syncing and stays far away from the tip, it's sometimes faster to re-import a snapshot again than waiting for the syncing process to catch up.
In any case, you should perform the following steps:
- Execute
make down
to shutdown your Lotus node. - Execute
docker run --rm -v mainnet_powergate-lotus:/data ubuntu rm -rf /data/.lotus/datastore/chain
- Execute the steps described in Boostrap a clean Lotus node from a snapshot.
This only deletes chain data and not your wallet address and other important metadata information.
Using the Powergate CLI and API on Mainnet¶
All the CLI and API commands are the same as localnet.
Install the CLI¶
From the root of the powergate
repo, you can build the CLI from the latest code. This will install the Powergate CLI, pow
, on your machine.
make build
Test your installation.
pow --help
Start storing data¶
You're now ready to start storing and retrieving data using the Powergate. Read more on Storing Data.