Skip to content

Instantly share code, notes, and snippets.

@ZenGround0
ZenGround0 / practical-on-chain-on-ramp.md
Last active May 1, 2024 23:32
WIP practical on ramps

Practical on chain on ramps

Zenground0

May 1 2024

An “on-ramp” is a system that helps users easily store data on filecoin. An on chain on ramp is such a system that works by sending blockchain messages to blockchain systems. With the FVM we are able to build on-chain on-ramps but they don’t exist yet. There is at least one fledgling project – Eastore, running on calibration net– that is fairly far along. This document lays out the issues and opportunities in quickly deploying smart contracts to filecoin and L2s that get us web3 native on-ramps in 3-6 months.

Disclaimer

FilOz is not interested in building or maintaining new production systems. This presents an extra challenge in figuring out how to coordinate the necessary work and system ownership. This document will ignore this altogether.

@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"
)
@ZenGround0
ZenGround0 / FIL__FIL.txt
Created August 30, 2023 01:22
A plan for FIL__FIL
Fil_Fil Product:
a small incentivized data network overlay on top of filecoin specifically for filecoin snapshots
User requirement: snapshots are incentivized to be stored for a long time, ~2-5 years with replication
User requirement: snapshots are committed in real time < 1 hour after they are generated
User nice-to-have: snapshots are available for content delivery on the saturn network
Big idea: providers participate in the network for an incentive. Users of the network get guarantee that snapshot data is stored and (ideally) a reliable way to get the snapshot data out if they pay. Basically it is like filecoin but for a tiny subset of specific data.
Users: 1. People installing lotus who need to sync (ideally FilecoinFoundation would subsiize saturn payments for people downloading from lotus-chain management website within reason 2. SPs who are out of sync 3. Devs / analysts who need historical data
@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 / AMT-Churn.md
Created July 31, 2023 22:49
Summary of findings related to AMT churn and the nv18-nv19 market cron disruption

AMT Churn Explanation

Background

Market Churn

Churn is defined to be the size in bytes of the data in a datastructure that is overwritten over some period of time. Because GC in lotus is somewhat difficult lots of churn in filecoin state has a high system cost

We learned after nv19 that AMT churn is > 100x higher than optimal

@ZenGround0
ZenGround0 / cron-data.sh
Last active July 21, 2023 19:50
Commands for analyzing miner cron
#!/bin/bash
# Use a trailing slash in directory if not provided
[[ "$2" != */ ]] && dir="$2"/ || dir="$2"
./lotus state --tipset=@$1 compute-state --json | jq --argjson height "$1" '. + {Height: $height}' > "${dir}"gas-trace-"$1".json
cat "${dir}"gas-trace-$1.json | jq -c '.Trace | .[] | select( .Msg | .To== "f03") | .ExecutionTrace | .Subcalls | .[] | select( .Msg | .To == "f04") | .Subcalls | .[] | select( .Msg | .Method == 12) | {"To":( .Msg | .To) , "Gas": (reduce (.. | .GasCharges? | select(.) | .[]) as $gas ({tg: 0}; {tg: ($gas.tg + .tg)}))} ' | jq --argjson height "$1" -s '[.[] | . + {Height: $height}]' > "${dir}"crongas-"$1".json
cat "${dir}"gas-trace-$1.json | jq -c '.Trace | .[] | select( .Msg | .To== "f03") | .ExecutionTrace | .Subcalls | .[] | select( .Msg | .To == "f04") | .Subcalls | .[] | select( .Msg | .Method == 12) | {"To":( .Msg | .To) , "Gas": (reduce (.. | .GasCharges? | select(.) | .[] | select(.Name == "wasm_exec") ) as $gas ({tt: 0}; {tt: ($gas.tt + .tt)}))} ' | jq --argjs
@ZenGround0
ZenGround0 / devnet-clean.fish
Last active January 18, 2023 21:50
Fish scripts for an easy local devnet (mostly plagiarized and adapted from scripts of @jennijuju)
function devnet-clean
rm -rf ~/.lotus
rm -rf ~/.lotusminer
rm -rf ~/.genesis-sectors
end
@ZenGround0
ZenGround0 / MessageContract.md
Last active November 4, 2022 12:23
A statement of purpose and system overview of the Filecoin Message Contract

Contract as a Deal Client for Archiving Filecoin Blockchain Message Data

Motivation

  1. Use web3 infrastructure to solve the filecoin message archive problem currently solved with web2 clouds
  2. Provide an EVM contract template for contract as a client data storage on the filecoin network
  3. Identify sticking points in the current model of data preparation, data transfer and deal negotiation for contract as a client storage deals. For example learn how the ask protocol should change to support this model.
  4. Demonstrate a new model for FIL+ auditing with significantly better fraud resilience properties

The core idea is that as system and protocol developers we will benefit from building a small application to understand how to adapt the network to similar applications. The nice thing is that fil infrastructure has a concrete application today which serves PLs broader goal of using our own tech.

@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 / miner-power-lf-ab.csv
Created October 9, 2020 19:54
Balance and power info for all miners with power
miner_addr locked_fund available_balance percentage_power
f02767 24696253356480328192907 3448319756017030661503 0.7425%
f03482 1865243360901916413517 284784336988146748135 0.0810%
f024468 0 6487534081779092886 0.0001%
f01287 7776632751493145606495 37962621493834690048 0.3178%
f08403 0 8749842251001152016 0.0005%
f07709 0 28493585174620871928 0.0085%
f010048 159954177664607847768 1532512088095547333 0.0094%
f014701 234878149345434458855 2197893315693632270 0.0063%
f010558 208996663265050539014 9403947183209253002 0.0006%