Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Sproul michaelsproul

View GitHub Profile
@michaelsproul
michaelsproul / participation_rate.fish
Last active Oct 15, 2020
Participation rate script
View participation_rate.fish
#!/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 Aug 15, 2020
Get list of slashed validators from Lighthouse
View get_slashed.sh
#!/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 Jul 30, 2020
Supranational BLST Benchmarks (portable)
View portable_bls_benchmarks.txt
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 Sep 3, 2019
Callin' a generic function with different type arguments based on runtime values
View type_dispatch.rs
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
Experiments with generic-array and BeaconState
View generic_beacon_state.rs
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.
View excel_tax.xlsx
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 Jul 19, 2018
Notes on Matrix <-> Slack Integration
View slack_matrix.md
@michaelsproul
michaelsproul / cap_types.sh
Last active Jul 16, 2018
Find types of caps used in a capDL spec
View cap_types.sh
grep '.type = CDL_' capdl_spec.c | sed 's/.*\(\.type = CDL_[[:alnum:]]*\).*/\1/' | sort | uniq
@michaelsproul
michaelsproul / constraints.txt
Last active Feb 18, 2018
Populus and Vyper setup
View constraints.txt
ethereum==1.6.1
eth-utils==0.7.1
View caddy.conf
[program:caddy]
command=/home/caddy/sproul.xyz/start.sh
directory=/home/caddy/sproul.xyz
user=caddy
environment=HOME="/home/caddy",USER="caddy"
You can’t perform that action at this time.