Skip to content

Instantly share code, notes, and snippets.

go-filecoin file system access April 2019

Quick report on filesystem abstractions in go-filecoin

Strong abstractions

For the most part the repo provides strong abstractions for go-filecoin to use when interacting with fs objects.

Datastores

The paths from the repodir to the datastores are kept either in the config (in the case of the main datastore) or as global variables of the repo package in others in the case of the others. Datastores are opened in interal functions called from OpenFSRepo, and closed by Close. The go objects created are then made available through public methods.

<!--
Please first see README for how to get help before filing a new bug report.
If you have a *QUESTION* about Filecoin, please ask on our forum at https://discuss.filecoin.io/
-->
**Describe the bug**
<!-- A clear and concise description of what the bug is. -->
**To Reproduce**
@ZenGround0
ZenGround0 / powertable.fish
Last active July 10, 2019 15:31
Rough filecoin power table
go-filecoin actor ls | jq 'select(.actorType == "MinerActor") | .address' | xargs -L1 go-filecoin miner power
@ZenGround0
ZenGround0 / setup-go-filecoin-logs-for-chain-debug.sh
Last active September 24, 2019 23:46
go-filecoin chain stalled log debug
# Use this set of commands for tuning your logs to debug scenarios where your node can't sync the chain
# At a high level if your chain is getting stuck it is because one of 2 things is going wrong
# 1. Your node can't fetch the chain data
# 2. Your node can't correctly process the longest chain
# first quiet all logs to ERROR level
go-filecoin log level error
# listen to the details of chain related subsystems
# logs related to fetching
@ZenGround0
ZenGround0 / block-atlas.go
Last active January 21, 2020 07:34
Atlas on type causing refmt stack overflow
var blockAtlasEntry = atlas.BuildEntry(Block{}).Transform().
TransformMarshal(func(liveForm reflect.Value) (serialForm reflect.Value, err error) {
return StructToTuple(liveForm)
}, reflect.TypeOf([]interface{}{})).
TransformUnmarshal(func(serialForm reflect.Value) (liveForm reflect.Value, err error) {
return TupleToStruct(serialForm, reflect.TypeOf(Block{}))
}, reflect.TypeOf(Block{})).
Complete()

Intro

@sternhenri and @jzimmerman have proposed a strict timestamp validation rule for the filecoin network. The rule (1) is that all epochs uniquely determine a period in time fixed by the genesis timestamp. Blocks with timestamps that don't fall within the window specified by their height are marked as invalid by the protocol. This relies on a clock synchrony assumption.

Talking with @Kubuxu I learned that the lotus team is hesitant to adopt these strict timestamp rules for at least one major reason: recovery after chain halting. This document dives into the proposed timing validation rule and its impact on recovery from chain halting. It makes an argument for keeping these strict validation rules and explores some chain halting recovery options.

Timing model

During steady state operation (i.e. CHAIN_FOLLOW mode) a filecoin node mines off of the heaviest tipset it finds. Nodes mine with the appropriate number of null blocks to put their candidate block in the current epoch. If a node wins an

@ZenGround0
ZenGround0 / drand-val.go
Last active April 9, 2020 23:57
non-contiguous round DRAND integration notes
// Protocol Constants
// Time Drand network starts at
DRAND_START_ROUND
// Time of one DRAND Round
DRAND_ROUND_TIME
// Number of epochs in the past that a filecoin block should sample DRAND entries from
DRANDLookback = 2 // might change to 5 for availability reasons
func ValidateBlock(b BlockHeader) {
@ZenGround0
ZenGround0 / gfc-static-port.md
Last active May 14, 2020 14:50
Port Config for go-filecoin

go-filecoin uses static port 6000 by default but if you want to change to another port here's how.

  1. After initializing the node navigate to configuration file config.json by default this will be at ~/.filecoin/config.json
  2. Find the swarm section of the config:
"swarm": {                                                                                                                                           
                "address": "/ip4/0.0.0.0/tcp/6000"                                                                                                           
        }, 
  1. edit the port number in the config
@ZenGround0
ZenGround0 / testnet2-join.md
Last active May 14, 2020 16:05
Join Testnet Phase 2 with go-filecoin

To join a go-filecoin node to the testnet follow these steps:

  1. Download the testnet car file from https://ipfs.io/ipfs/QmXZQeezX1x8uRQX9EUaYxnyivUpTfJqQTvszk3c8SnFPN/testnet.car and keep the local path accessible
  2. Init the go-filecoin node with testnet configuration: go-filecoin init --genesisfile=<local-path-to-testnet.car> --network=testnet
  3. Start the daemon go-filecoin daemon
  4. Connect to existing nodes manually go-filecoin swarm connect <any-filecoin-node-mulitaddr>. Connecting to the bootstrap addresses is a good first step. To display these run go-filecoin config bootstrap.addresses

You will now begin syncing the testnet chain

@ZenGround0
ZenGround0 / testnet-gfc.md
Created May 15, 2020 23:23
go-filecoin mining on testnet

Follow these steps to mine using go-filecoin client on testnet for adding a miner and sealing a sector

  1. Setup a go-filecoin node and sync the chain
  2. Create a bls address for your worker addr go-filecoin address new --type=bls. To get the address run go-filecoin address ls, it should be the last one in the list
  3. Create a miner actor with go-filecoin miner create <collateral> --sectorsize=<number-of-bytes-in-sector> --from=<new-bls-addr> --gas-price=0.0001 --gas-limit=100000
  4. go-filecoin mining start kicks the node into mining mode using the miner actor created in the last step
  5. go-filecoin mining pledge-sector starts sealing the sector