lotus/README.md

276 lines
8.1 KiB
Markdown
Raw Normal View History

2019-10-15 14:54:29 +00:00
![Lotus](docs/images/lotus_logo_h.png)
2019-08-02 04:26:11 +00:00
# project lotus - 莲
Lotus is an experimental implementation of the Filecoin Distributed Storage Network. For more details about Filecoin, check out the [Filecoin Spec](https://github.com/filecoin-project/specs).
## Development
All work is tracked via issues. An attempt at keeping an up-to-date view on remaining work is in the [lotus testnet github project board](https://github.com/filecoin-project/lotus/projects/1).
2019-08-02 04:26:11 +00:00
## Building
*Dependencies:*
- go (1.13 or higher)
- gcc (7.4.0 or higher)
2019-08-02 04:26:11 +00:00
- git
- bzr (some go dependency needs this)
2019-09-19 18:31:54 +00:00
- jq
- pkg-config
2019-08-02 04:26:11 +00:00
*Building:*
```
$ make
```
2019-09-27 14:53:34 +00:00
## Devnet
### Node setup
If you have run lotus before and want to remove all previous data: `rm -rf ~/.lotus ~/.lotusstorage`
[You can copy `lotus` and `lotus-storage-miner` to your `$GOPATH/bin` or `$PATH`, or reference all lotus commands below from your local build directory with `./lotus`]
The following sections describe how to use the lotus CLI. Alternately you can run lotus nodes and miners using the [Pond GUI](#pond).
### Genesis & Bootstrap
2019-10-14 13:59:01 +00:00
The current lotus build will automatically join the lotus Devnet using the genesis and bootstrap files in the `build/` directory. No configuration is needed.
### Start Daemon
2019-10-07 19:04:13 +00:00
2019-09-27 14:53:34 +00:00
```sh
2019-10-03 16:59:15 +00:00
$ lotus daemon
2019-09-27 14:53:34 +00:00
```
In another window check that you are connected to the network:
2019-09-27 14:53:34 +00:00
```sh
2019-10-09 03:21:43 +00:00
$ lotus net peers | wc -l
2 # number of peers
2019-09-27 14:53:34 +00:00
```
[wait for the chain to finish syncing]
You can follow sync status with:
2019-09-27 23:14:38 +00:00
```sh
$ watch lotus sync status
2019-09-27 23:14:38 +00:00
```
2019-09-27 14:53:34 +00:00
### Basics
Create a new address:
2019-09-27 14:53:34 +00:00
```sh
$ lotus wallet new bls
t3...
```
Grab some funds from faucet - go to http://147.75.80.29:777/, paste the address
you just created, and press Send.
2019-09-27 14:53:34 +00:00
2019-10-14 13:59:01 +00:00
(You can also generate a public key address using secp256k1 with
`lotus wallet new secp256k1`. BLS signatures use less space so will have lower fees.)
Check the wallet balance:
2019-09-27 14:53:34 +00:00
```sh
$ lotus wallet balance [optional address (t3...)]
```
(NOTE: If you see an error like `actor not found` after executing this command,
it means that either there are no transactions to this address on chain - using
faucet should 'fix' this, or your node isn't fully synced).
2019-09-27 14:53:34 +00:00
### Mining
Ensure that at least one BLS address (`t3..`) in your wallet has enough funds to
cover pledge collateral:
```sh
$ lotus state pledge-collateral
1234
$ lotus wallet balance t3...
8999
```
(Balance must be higher than the returned pledge collateral for the next step to work)
Initialize storage miner:
```sh
$ lotus-storage-miner init --owner=t3...
```
This command should return successfully after miner is setup on-chain (30-60s)
Start mining:
```sh
$ lotus-storage-miner run
```
To view the miner id used for deals:
```sh
$ lotus-storage-miner info
```
e.g. miner id `t0111`
2019-09-27 14:53:34 +00:00
Seal random data to start producing PoSts:
2019-09-27 14:53:34 +00:00
```sh
$ lotus-storage-miner store-garbage
```
You can check miner power and sector usage with the miner id:
2019-10-11 20:37:31 +00:00
```sh
# Total power of the network
2019-10-11 20:37:31 +00:00
$ lotus-storage-miner state power
2019-10-11 21:12:07 +00:00
$ lotus-storage-miner state power <miner>
2019-10-11 20:37:31 +00:00
$ lotus-storage-miner state sectors <miner>
```
You can view a list of miners with:
```sh
$ lotus state list-miners
```
### Stage Data
Import some data:
```sh
# Create a simple file
$ echo "Hi my name is $USER" > hello.txt
# Import the file into lotus & get a Data CID
$ lotus client import ./hello.txt
<Data CID>
# List imported files by CID, name, size, status
$ lotus client local
```
(CID is short for Content Identifier, a self describing content address used throughout the IPFS ecosystem. It is a cryptographic hash that uniquely maps to the data and verifies it has not changed.)
### Make a deal
(It is possible for a Client to make a deal with a Miner on the same lotus Node.)
```sh
# List asks proposed by a miner
$ lotus client query-ask <miner>
# Propose a deal with a miner
$ lotus client deal <Data CID> <miner> <price> <duration>
```
For example `$ lotus client deal bafkre...qvtjsi t0111 36000 12` proposes a deal to store CID `bafkre...qvtjsi` with miner `t0111` at price `36000` for a duration of `12` blocks.
### Search & Retrieval
If you've stored data with a miner in the network, you can search for it by CID:
```sh
# Search for data by CID
$ lotus client find <Data CID>
LOCAL
RETRIEVAL <miner>@<miner peerId>-<deal funds>-<size>
```
To retrieve data from a miner:
```sh
$ lotus client retrieve <Data CID> <outfile>
```
This will initiate a retrieval deal and write the data to the outfile. (This process may take some time.)
2019-09-27 14:53:34 +00:00
### Pond UI
-----
2019-10-11 16:17:26 +00:00
As an alternative to the CLI you can use Pond, a graphical testbed for lotus. It can be used to spin up nodes, connect them in a given topology, start them mining, and observe how they function over time.
2019-09-27 14:53:34 +00:00
Build:
2019-09-27 14:53:34 +00:00
```
$ make pond
```
Run:
```
$ ./pond run
Listening on http://127.0.0.1:2222
```
Now go to http://127.0.0.1:2222.
2019-09-27 14:53:34 +00:00
**Things to try:**
2019-10-11 16:17:26 +00:00
- The `Spawn Node` button starts a new lotus Node in a new draggable window.
- Click `[Spawn Storage Miner]` to start mining (make sure the Node's wallet has funds).
- Click on `[Client]` to open the Node's client interface and propose a deal with an existing Miner. If successful you'll see a payment channel open up with that Miner.
> Note: Don't leave Pond unattended for long periods of time (10h+), the web-ui tends to
> eventually consume all the available RAM.
2019-09-27 14:53:34 +00:00
### Troubleshooting
* Turn it off and on - Start at the top
2019-09-27 14:53:34 +00:00
* `rm -rf ~/.lotus ~/.lotusstorage/`
* Verify you have the correct versions of dependencies
* If stuck on a bad fork, try `lotus chain sethead --genesis`
2019-10-11 16:17:26 +00:00
* If that didn't help, open a new issue, ask in the [Community Forum](https://discuss.filecoin.io) or reach out via [Community chat](https://github.com/filecoin-project/community#chat).
2019-09-27 14:53:34 +00:00
## Architecture
Lotus is architected modularly, and aims to keep clean API boundaries between everything, even if they are in the same process. Notably, the 'lotus full node' software, and the 'lotus storage miner' software are two separate programs.
The lotus storage miner is intended to be run on the machine that manages a single storage miner instance, and is meant to communicate with the full node via the websockets jsonrpc api for all of its chain interaction needs. This way, a mining operation may easily run one or many storage miners, connected to one or many full node instances.
## Notable Modules
### API
The systems API is defined in here. The RPC maps directly to the API defined here using the JSON RPC package in `lib/jsonrpc`. Initial API documentation in [docs/API.md](docs/API.md).
### Chain/Types
Implementation of data structures used by Filecoin and their serializations.
### Chain/Store
The chainstore manages all local chain state, including block headers, messages, and state.
### Chain/State
A package for dealing with the Filecoin state tree. Wraps the [HAMT](https://github.com/ipfs/go-hamt-ipld).
### Chain/Actors
Implementations of the builtin Filecoin network actors.
### Chain/Vm
The Filecoin state machine 'vm'. Implemented here are utilities to invoke Filecoin actor methods.
### Miner
The block producer logic. This package interfaces with the full node through the API, despite currently being implemented in the same process (very likely to be extracted as its own separate process in the near future).
### Storage
The storage miner logic. This package also interfaces with the full node through a subset of the api. This code is used to implement the `lotus-storage-miner` process.
2019-08-02 05:35:37 +00:00
## Pond
Pond is a graphical testbed for lotus. It can be used to spin up nodes, connect them in a given topology, start them mining, and observe how they function over time.
2019-08-02 05:35:37 +00:00
To try it out, run `make pond`, then run `./pond run`.
2019-08-02 05:35:37 +00:00
Once it is running, visit localhost:2222 in your browser.
2019-08-02 06:26:24 +00:00
## Tracing
Lotus has tracing built into many of its internals. To view the traces, first download jaeger](https://www.jaegertracing.io/download/) (Choose the 'all-in-one' binary). Then run it somewhere, start up the lotus daemon, and open up localhost:16686 in your browser.
2019-08-02 06:26:24 +00:00
For more details, see [this document](./docs/tracing.md).
2019-08-02 04:26:11 +00:00
## License
2019-10-09 01:27:59 +00:00
Dual-licensed under [MIT](https://github.com/filecoin-project/lotus/blob/master/LICENSE-MIT) + [Apache 2.0](https://github.com/filecoin-project/lotus/blob/master/LICENSE-APACHE)