Skip to content

Instantly share code, notes, and snippets.

View arnetheduck's full-sized avatar

Jacek Sieka arnetheduck

View GitHub Profile
SignedBeaconBlock: 1125899911395480
message: 1125899911395380
slot: 8
proposer_index: 8
parent_root: 32
state_root: 32
body: 1125899911395296
randao_reveal: 96
eth1_data: 72
graffiti: 32
import chronos, chronos/threadsync
import stew/ptrops
import std/locks
import std/typetraits
const Numbers = 1000
const Threads = 100
type
Node = object
@arnetheduck
arnetheduck / carnot.nim
Created March 15, 2023 12:37
Carnot implemenation
# Based on https://github.com/logos-co/nomos-research/blob/98e2a20bbda525cad6e38035c806b374ca5352b2/consensus-engine/docs/carnot-spec.md
import std/[sets, tables]
type
View = uint
Block = ref object
view: View
qc: Qc
@arnetheduck
arnetheduck / control-messages.txt
Created April 27, 2021 09:27
lots of empty control messages
This file has been truncated, but you can view the full file.
DBG 2021-04-27 11:05:07.477+02:00 sending control message topics="libp2p gossipsub" tid=480061 file=gossipsub.nim:273 msg="(ihave: @[], iwant: @[(messageIDs: @[])], graft: @[], prune: @[])" peer=16U*F8XUwG
DBG 2021-04-27 11:05:08.344+02:00 sending control message topics="libp2p gossipsub" tid=480061 file=gossipsub.nim:273 msg="(ihave: @[], iwant: @[(messageIDs: @[])], graft: @[], prune: @[])" peer=16U*F8XUwG
DBG 2021-04-27 11:05:08.551+02:00 sending control message topics="libp2p gossipsub" tid=480061 file=gossipsub.nim:273 msg="(ihave: @[], iwant: @[(messageIDs: @[])], graft: @[], prune: @[])" peer=16U*F8XUwG
DBG 2021-04-27 11:05:08.551+02:00 sending control message topics="libp2p gossipsub" tid=480061 file=gossipsub.nim:273 msg="(ihave: @[], iwant: @[(messageIDs: @[])], graft: @[], prune: @[])" peer=16U*F8XUwG
DBG 2021-04-27 11:05:08.552+02:00 sending control message topics="libp2p gossipsub" tid=480061 file=gossi
@arnetheduck
arnetheduck / leb128.nim
Created March 1, 2020 16:03
work in progress varint codec
# Little-endian base 128 variable length integer utilities, as seen in
# https://en.wikipedia.org/wiki/LEB128
#
# Used in formats like DWARF, WASM - unsigned variant identical to protobuf/go
# varint. Exception/Defect free for WASM use
import
stew/[bitops2, result]
const
@arnetheduck
arnetheduck / wrc20.wat
Created April 11, 2019 19:54
wrc20 challenge, nlvm
(module
(type (;0;) (func (result i32)))
(type (;1;) (func (param i32 i32)))
(type (;2;) (func (param i32 i32 i32)))
(type (;3;) (func (param i32)))
(type (;4;) (func))
(type (;5;) (func (param i32 i32) (result i32)))
(import "env" "getCallDataSize" (func $getCallDataSize (type 0)))
(import "env" "revert" (func $revert (type 1)))
(import "env" "callDataCopy" (func $callDataCopy (type 2)))
@arnetheduck
arnetheduck / beacon_clock.nim
Created March 21, 2019 13:40
starting point, beacon clock
import
chronos,
spec/[datatypes]
type
ChronosTime* = uint64
## Unix epoch timestamp in millisecond resolution
# TODO fetch from chronos and make distinct
ChronosClock* = object
@arnetheduck
arnetheduck / datatypes.fbs
Last active March 15, 2019 21:10
beacon block, flatbuffers style
struct Bytes8 {
v0: ubyte;
v1: ubyte;
v2: ubyte;
v3: ubyte;
v4: ubyte;
v5: ubyte;
v6: ubyte;
v7: ubyte;
v8: ubyte;