Skip to content

Instantly share code, notes, and snippets.

@ZenGround0
ZenGround0 / power-for-debts.txt
Created October 9, 2020 16:18
Filecoin miners in debt as of block ~130000
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
0(0 B) / 551568221367435264(489.9 PiB) ~= 0.0000%
@ZenGround0
ZenGround0 / upgrade-validation-with-ent.md
Last active November 25, 2020 01:09
Use ent for post-upgrade validation

Run a lotus node and sync the filecoin blockchain up to the height you want to validate

One way to see how far you've synced is to inspect the output of ./lotus sync wait

Get the inspection-cid

"inspection-cid" is the cid of the block header at inspection-epoch, the epoch whose parent state you want to validate.

By Using the lotus daemon

  1. ./lotus chain head to get your node's current head if inspection-epoch is head height. A list of cids is output, copy one of them.
  2. ./lotus chain list --height=<inspection-epoch> --count=1 if head is above inspection epoch. A list of cid to miner mappings is output, copy one of them.

By Using filfox

Navigate to https://filfox.info/en/tipset/<inspection-height>

@ZenGround0
ZenGround0 / sectors.sh
Created September 27, 2020 17:06
Convert power into number of sectors by dividing by 32GiB
#!/bin/bash
echo "$1 / 34359738368" | bc -l | sed 's!\.0*$!!'
@ZenGround0
ZenGround0 / tipget
Created September 27, 2020 01:07
parse (base32) cids from output and join with comma
grep $1 -ooE "[a-z2-7]{62}" | tr '\n' ','
@ZenGround0
ZenGround0 / fil.sh
Created September 26, 2020 21:54
attofil to fil
#!/bin/bash
echo "$1" / 10^18 | bc -l
@ZenGround0
ZenGround0 / cborbytes-confusion.md
Created June 15, 2020 18:44
Comparing vmr.CBORByets and cbg.Deferred

cbg.Deferred has the property of accepting and writing raw cbor bytes with any structure. vmr.CBORBytes is just a convenience wrapper for go byte slices, serializes as cbor major type 2, and only deserializes into structs expecting major type 2

I recently became confused about this in large part because the Marshal/Unmarshal CBOR methods for vmr.CBORBytes are essentially the same as those of cbg.Deferred. However cbg.Deferred is handled directly by the cbg code generator so vmr.CBORBytes does not have the same behavior.

To demonstrate we run cbor gen on the following type:

type TestCBORBytes struct {                                                     
        Cbb vmr.CBORBytes                                                       
        Def cbg.Deferred                                                        
@ZenGround0
ZenGround0 / Implicit-Failures.md
Last active June 10, 2020 15:44
Filecoin VM Implicit Failures

Cron and Reward messages are applied implicitly by the filecoin vm and are the entry point to a significant portion of specs-actor code. However their error model is different than that of explicit messages. Whereas explicit message failures are charged gas, rolled back and report back failures through the message receipt, any implicit message error causes a tipset to be rejected as invalid.

Implicit message failures are caused by state changes introduced through explicit messages.

Implicit Message Problem Outline

  1. Implicit failures are bad for validator performance / simplicity — one block author can poison a whole tipset and then validators need to figure out which block contains the explict message that causes the implicit message by replaying other block combinations (potentially sped up by using heuristics)
  2. Implicit failures are bad for block author performance and simplicity — block authors should be vigilant about not publishing an explicit message causing a cron failure in order to be su
@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
@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 / 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