Skip to content

Instantly share code, notes, and snippets.

View michaelsproul's full-sized avatar

Michael Sproul michaelsproul

View GitHub Profile
@michaelsproul
michaelsproul / empty_validator_definitions.md
Last active May 20, 2021 23:10
How to fix empty validator_definitions.yml

Lighthouse: how to fix empty validator_definitions.yml

Lighthouse is affected by a bug (sigp/lighthouse#2159) which can cause the validator_definitions.yml file to become corrupted if the disk where Lighthouse's datadir is stored becomes completely full.

Preventing the bug

The best defense against this bug is to ensure your disk doesn't fill to 100%. If you have been running Geth since December 2020 with a 1TB SSD, you may be close to reaching this limit and we recommend that you:

  1. Stop Geth immediately: sudo systemctl stop geth.service (tweak the service name appropriately)
  2. [Optional] If you do not already have an Eth1 failover configured, add one to your Lighthouse beacon node config. You can sign up for a free service like Infura or Alchemy and add the URL to the ExecStart line for your Lighthouse beacon node. More info in the book.
@michaelsproul
michaelsproul / participation_rate.fish
Last active October 15, 2020 01:35
Participation rate script
#!/usr/bin/env fish
# Usage: ./participation_rate.fish 3150
# Requires: fish, curl, jq, Lighthouse BN API on port 5052
# Set the target epoch to at least 2 before the current epoch
set target_epoch (math "$argv[1] + 1")
set global_votes (curl --fail --show-error -s "http://localhost:5052/consensus/global_votes?epoch=$target_epoch"; or exit)
set prev_active_gwei (echo $global_votes | jq .previous_epoch_active_gwei)
set prev_attesting_gwei (echo $global_votes | jq .previous_epoch_attesting_gwei)
@michaelsproul
michaelsproul / get_slashed.sh
Last active August 15, 2020 02:26
Get list of slashed validators from Lighthouse
#!/usr/bin/env bash
curl -s "http://localhost:5052/beacon/validators/all" \
| jq -r 'map(select(.validator.slashed == true) | .validator_index) | join("\n")'
@michaelsproul
michaelsproul / portable_bls_benchmarks.txt
Created July 30, 2020 07:36
Supranational BLST Benchmarks (portable)
Running target/release/deps/blst_benches-a4084c38c76b1d19
Gnuplot not found, using plotters backend
verify_multi_aggregate/verify_multi_aggregate/8
time: [3.4410 ms 3.4688 ms 3.5025 ms]
change: [+4.5451% +5.4146% +6.4445%] (p = 0.00 < 0.05)
Performance has regressed.
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe
verify_multi_aggregate/verify_multi_aggregate/16
@michaelsproul
michaelsproul / type_dispatch.rs
Created September 3, 2019 05:48
Callin' a generic function with different type arguments based on runtime values
macro_rules! type_dispatch {
($function:ident,
($($arg:expr),*),
$base_ty:ident,
<$($param_ty:ty),*>,
[ $value:expr => primitive_type ] $($rest:tt)*) => {
match $value {
"bool" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* bool>, $($rest)*),
"uint8" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u8>, $($rest)*),
"uint16" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u16>, $($rest)*),
@michaelsproul
michaelsproul / generic_beacon_state.rs
Last active May 7, 2019 06:39
Experiments with generic-array and BeaconState
use generic_array::*;
use std::marker::PhantomData;
use typenum::Unsigned;
use typenum::{U1024, U4096, U512, U8192};
type Hash = [u8; 32];
type Crosslink = u64;
trait FixedArray<T> {
// Not using `std::Default` for brevity.
@michaelsproul
michaelsproul / excel_tax.xlsx
Created May 2, 2019 07:27
Excel Nightmares
IF(EXACT($C12, "Sell"), IF($E12 - $I12 < VLOOKUP($K12, $A$1:$N$146, 5) - SUMIF($H$2:$H11, $H12, $I$2:$I11) - SUMIF($K$2:$K11, $K12, $L$2:$L11), $E12 - $I12, VLOOKUP($K12, $A$1:$N$146, 5) - SUMIF($H$2:$H11, $H12, $I$2:$I11) - SUMIF($K$2:$K11, $K12, $L$2:$L11)), "")
@michaelsproul
michaelsproul / slack_matrix.md
Last active July 19, 2018 07:52
Notes on Matrix <-> Slack Integration
@michaelsproul
michaelsproul / cap_types.sh
Last active July 16, 2018 00:08
Find types of caps used in a capDL spec
grep '.type = CDL_' capdl_spec.c | sed 's/.*\(\.type = CDL_[[:alnum:]]*\).*/\1/' | sort | uniq
@michaelsproul
michaelsproul / constraints.txt
Last active February 18, 2018 20:09
Populus and Vyper setup
ethereum==1.6.1
eth-utils==0.7.1