Skip to content

Instantly share code, notes, and snippets.

View dapplion's full-sized avatar

Lion - dapplion dapplion

View GitHub Profile
lighthouse % git rev-parse HEAD
3a996fbbee7501adc153e801675ad14966c151d1
crate total lines main owners
account_manager 2242 23,8% Pawan Dhananjay, 23,4% Paul Hauner, 17,5% realbigsean , 14,6% Eitan Seri-Levi, 11,8% Michael Sproul
beacon_node 176046 18,7% Paul Hauner, 16,6% Age Manning, 14,8% Michael Sproul, 8,5% realbigsean , 6,4% Pawan Dhananjay, 6,3% ethDreamer , 4,7% Jimmy Chen, 3,6% Lion -, 3,3% Divma , 2,8% Mac L, 2,4% divma , 2,4% Eitan Seri-Levi
beacon_node/beacon_chain 55795 29,8% Paul Hauner, 18,9% Michael Sproul, 12,1% realbigsean , 10,8% ethDreamer , 8,5% Jimmy Chen, 4,2% Pawan Dhananjay, 2,2% Mac L
import {randomBytes} from "node:crypto";
import {compress} from "snappyjs";
import {phase0, ssz} from "@lodestar/types";
import {BitArray} from "@chainsafe/ssz";
// To run:
// $ ../../node_modules/.bin/ts-node --esm test/unit/network/snappy.test.ts
/* eslint-disable no-console */
@dapplion
dapplion / signature_verify.mjs
Created May 30, 2023 17:55
Verify signature of example payload from beacon chain
import { ssz } from "@lodestar/types";
import { createBeaconConfig } from "@lodestar/config";
import { fromHexString, toHexString } from "@chainsafe/ssz";
import bls from "@chainsafe/bls";
// To run, first install dependencies:
// $ npm install @lodestar/types @lodestar/config @chainsafe/ssz @chainsafe/bls
//
// Then
// $ node signature_verify.mjs
@dapplion
dapplion / slot_finder_gnosis.mjs
Last active January 4, 2024 14:48
Find fork slot and timestamp for a network with Gnosis preset and some time conditions
// Usage
// node slot_finder.mjs chiado
const genesisTimestamp = getGenesis();
const interval = 8192 * 5;
const now = Math.floor(Date.now() / 1000);
const futureDate = new Date();
futureDate.setMonth(futureDate.getMonth() + 2);
const futureTimestamp = Math.floor(futureDate.getTime() / 1000);
@dapplion
dapplion / beacon_chain_withdrawal_type_count.py
Created March 10, 2023 07:39
Beacon chain: count withdrawal credentials by type
import requests
# make the API request
url = "http://localhost:4000/eth/v1/beacon/states/head/validators"
response = requests.get(url)
# check if request was successful
if response.status_code != 200:
print(f"Error: API request returned status code {response.status_code}")
exit()
@dapplion
dapplion / gnosis_bellatrix_readiness.mjs
Created November 27, 2022 17:12
Print Gnosis fork bellatrix readiness, with data from https://nodewatch.chainsafe.io/query
import { execSync } from "node:child_process";
const URL = "https://nodewatch.chainsafe.io/query";
// From https://github.com/gnosischain/configs/blob/main/mainnet/config.yaml
const known_versions = {
"0x00000064": "gnosis-phase0",
"0x01000064": "gnosis-altair",
"0x02000064": "gnosis-bellatrix",
};
import {execSync} from "node:child_process";
// Usage
// ```
// node ttd.mjs https://rpc.eu-central-2.gateway.fm/v3/gnosis/archival/chiado
// ```
const rpcUrl = process.argv[2] ?? "https://rpc.gnosischain.com/";
const blocksPerDay = 17280;
@dapplion
dapplion / ttd.mjs
Last active November 12, 2022 01:35
import { execSync } from "node:child_process";
// Usage
// ```
// node ttd.mjs "Oct 29 2022 14:00:00 GMT+0000" latest https://rpc.eu-central-2.gateway.fm/v3/gnosis/archival/chiado
// ```
const ttdTargetDateStr = process.argv[2];
const blockNumberReference = process.argv[3] ?? "latest";
const rpcUrl = process.argv[4] ?? "https://rpc.gnosischain.com/";
@dapplion
dapplion / attestation.txt
Created April 8, 2022 10:46
Attestation
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore16
Contributor # 245
Hash: e62246a7 79cc0f04 aaa08808 3b9b07d8
689eba3d ca17a156 653f5f57 20439ac0
be869762 878167e3 042faaab d58f4fe8
6c6c14dc 0ecacfa4 a91dad0a 9e52cc5a
@dapplion
dapplion / altair-sync-commitee-balance-hashing.ts
Created September 2, 2021 17:46
Altair hashing count for potential optimization in sync committee balance hashing
const d = 38; // Mainnet specs = 2**40 / 4
const chunkCount = 200_000 / 4; // Mainnet size, GWei = uint64, 4 on each 32 bytes chunk
const syncCommitteeSize = 2 ** 9; // Mainnet specs
const indexes: number[] = [];
for (let i = 0; i < syncCommitteeSize; i++) {
// Does not consider the possibility of two indexes fiting in the same chunk. Tho this is very rare.
indexes.push(Math.floor(chunkCount * Math.random()));
}