Skip to content

Instantly share code, notes, and snippets.

View dapplion's full-sized avatar

Lion - dapplion dapplion

View GitHub Profile
@dapplion
dapplion / js-memory.ts
Created July 26, 2021 12:49
Memory used by different JS values or classes
const refs: any[] = [];
const xs: number[] = [];
const arrayBuffersArr: number[] = [];
const externalArr: number[] = [];
const heapTotal: number[] = [];
const heapUsed: number[] = [];
const rss: number[] = [];
enum TestType {
ArrayOfNumbers,
@dapplion
dapplion / eth2-altair-balances-hashing-sync.ts
Last active August 5, 2021 12:11
Numerical simulation to estimate hashing cost of balance updates on altair block processing, only for sync committee indexes
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()));
}
[
{
"name": "DAppNodeDAO staked in Unipool rewards contracts multichain",
"strategy": {
"name": "multichain",
"params": {
"strategies": [
{
"name": "unipool-univ2-lp",
"network": 1,
@dapplion
dapplion / lodestar-ssz-oom.ts
Created August 26, 2021 09:58
This code should not OOM, but it does
import {ssz} from "@chainsafe/lodestar-types";
let i = 0;
const heapUsed = process.memoryUsage().heapUsed;
while (true) {
getBigStateTreeBacked();
global.gc();
console.log(i++, (process.memoryUsage().heapUsed - heapUsed) / 1e6, "MB");
}
@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()));
}
@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
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 / 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",
};
@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()