Skip to content

Instantly share code, notes, and snippets.

@vmx
vmx / fr32padding.py
Created May 15, 2024 11:37
Poor man's fr32 padding (replacing the a full byte, not only two bits).
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Override every 32 byte with a zero. The input file is modified!
#
# Start e.g. with a file with random bytes:
#
# dd if=/dev/urandom of=/tmp/random.dat count=1 bs=1MiB
#
@vmx
vmx / replica-encode.go
Created December 7, 2023 14:08
Filecoin replica encoding in Go
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
)
@vmx
vmx / run-lotus-bench.sh
Created September 20, 2023 13:57
Running lotus-bench for 2KiB sector
#!/bin/sh
# `OUT_DIR` determines where to put the files generated by this script.
# The default directory is `/tmp/lotusbenchdata`
${OUT_DIR:=/tmp/lotusbenchdata}
mkdir -p "${OUT_DIR}"
# Create unsealed sector file
./lotus-bench simple addpiece --sector-size 2K /dev/zero "${OUT_DIR}/unsealed"
# Run PreCommit1
@vmx
vmx / encode-in-go.md
Created April 3, 2023 12:47
Filecoin replica encoding in Go
@vmx
vmx / pc1-labelling.md
Last active January 20, 2023 15:47
Filecoin PreCommit1 phase labelling

This is the pseudocode on how the labelling in PC1 works. It's for the 32GiB sector size production parameters.

Glossary:

  • node: A "node" refers to a 256-bit (32 bytes) value of the padded input data. A 32 GiB sector as 1m nodes.
  • label: A "label" refers to a 256-bit (32 bytes) value of one of the layers. It's the result of hashing the node index, layer index, replica ID and multiple labels together.

Inputs:

  • parent_file: That's a pre-generated file (it's fixed and the same for everyone) that contains a list of random 32-bit integers that are used as offsets to read from a file.
  • padded_data: A 32GiB file that has the padding already applied. "Padding" in this case means that each 0th and 1st bit is zero. It could be validated as:
@vmx
vmx / ipld-shallow-dive.md
Created January 18, 2023 11:01
IPLD Shallow dive 2023-01-18
title tags description slideOptions
IPLD Shallow Dive
IPLD, Launchpad
Launchpad V8 presentaiton 2023-01-18
width theme
1280
blood
@vmx
vmx / indent.py
Created October 12, 2022 10:15
Takes a file and indents at `(` and `[`.
# SPDX-License-Identifier: MIT
#
# Takes a file and indents at `(` and `[`.
import sys
def main(argv=None):
if argv is None:
argv = sys.argv
@vmx
vmx / Cargo.toml
Created September 30, 2022 16:26
Multiexp Halo2/sppark comparison
[package]
name = "halo2_sppark_msm"
version = "0.1.0"
edition = "2021"
[dependencies]
halo2_proofs = "0.2.0"
pasta-msm = "0.1.3"
@vmx
vmx / osgeo-wiki-ldap-migration-debugging.md
Last active May 23, 2022 09:34
OSGeo wiki LDAP migration debgging
  1. I'm opening a new Firefox window
  2. I'm going to https://staging.wiki.osgeo.org/
  3. I click on Log in on top right corner, which gets me to https://staging.wiki.osgeo.org/w/index.php?title=Special:UserLogin&returnto=Main+Page
  4. It redirects to https://staging.wiki.osgeo.org/wiki/Main_Page
  5. (BTW: It's 2022-05-23 9:54 CEST)
  6. I enter:
    • Username: Vmische
    • Password: :)
    • Keep me logged in: No
  7. I press "Log in" which gets me to https://staging.wiki.osgeo.org/w/index.php?title=Special:WikiUserMerge&returnto=Main_Page
@vmx
vmx / skip-rustc.py
Created January 21, 2022 15:55
Make GDB skip Rust's standard library files
# This script defines a command called `skiprustc` which skips all Rust
# standard library source files when debugging. Just drop this file into your
# `~/.gdbinit.d` directory.
# In order to enable it automatically whenever you debug Rust, you can add
# this hook to your `.gdbinit`:
#
# define hookpost-run
# skiprustc
# end
#