Skip to content

Instantly share code, notes, and snippets.

@ZenGround0
ZenGround0 / client.go
Last active August 8, 2023 04:55
golang http auto-streaming with transfer-encoding: chunked
package main
import (
"net/http"
"net/url"
"os"
"fmt"
)
@ZenGround0
ZenGround0 / client.go
Created January 3, 2018 20:26
Golang HTTP multipart streaming
package main
import (
"io"
"mime/multipart"
"net/http"
"net/url"
"os"
"fmt"
)

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

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 / 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()
@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