Skip to content

Instantly share code, notes, and snippets.

@vmx
vmx / pc1-labelling.md
Last active Jan 20, 2023
Filecoin PreCommit1 phase labelling
View pc1-labelling.md

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 Jan 18, 2023
IPLD Shallow dive 2023-01-18
View ipld-shallow-dive.md
title tags description slideOptions
IPLD Shallow Dive
IPLD, Launchpad
Launchpad V8 presentaiton 2023-01-18
width theme
1280
blood
@vmx
vmx / indent.py
Created Oct 12, 2022
Takes a file and indents at `(` and `[`.
View indent.py
# 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 Sep 30, 2022
Multiexp Halo2/sppark comparison
View Cargo.toml
[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
OSGeo wiki LDAP migration debgging
View osgeo-wiki-ldap-migration-debugging.md
  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 Jan 21, 2022
Make GDB skip Rust's standard library files
View skip-rustc.py
# 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
#
@vmx
vmx / cid-as-enum.rs
Created Jan 12, 2022
Trying to serialize a CID as enum
View cid-as-enum.rs
use std::fmt;
use serde::{de, ser, Deserialize, Serialize};
pub const ENUM_NAME: &str = "enumname";
pub const ENUM_VARIANT_NAME: &str = "enumvariantname";
//#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[derive(Debug, PartialEq)]
pub struct Cid(String);
@vmx
vmx / runit.sh
Last active May 10, 2022
Get some power/energy metrics while running Filecoin proofs/sealing
View runit.sh
#!/bin/sh
# From https://aweirdimagination.net/2020/06/28/kill-child-jobs-on-script-exit/
cleanup() {
# kill all processes whose parent is this process
sudo pkill -P $$
}
for sig in INT QUIT HUP TERM; do
trap "
@vmx
vmx / README.md
Created Oct 11, 2021
Installing Nvidia drivers on Debian testing 2021-10-11
View README.md

Current (2021-10-11) Debian testing cannot install Nvidia drivers properly. There [bug report 994860], which contains [a patch].

Here are the steps I took to apply that patch and make things work.

Download the fix-kernel514.patch from this Gist.

Then run these commands:

$ sudo apt install nvidia-installer-cleanup glx-alternative-nvidia update-glx glx-diversions glx-alternative-mesa  nvidia-support nvidia-kernel-common  nvidia-modprobe xserver-xorg-core libvdpau1
@vmx
vmx / kernel.cu
Created Aug 25, 2021
Multiexp and FFT OpenCL/CUDA kernel
View kernel.cu
// Defines to make the code work with both, CUDA and OpenCL
//#ifdef __NVCC__
#ifdef __CUDACC__
#define DEVICE __device__
#define GLOBAL
#define KERNEL extern "C" __global__
#define LOCAL __shared__
#define GET_GLOBAL_ID() blockIdx.x * blockDim.x + threadIdx.x
#define GET_GROUP_ID() blockIdx.x