Skip to content

Instantly share code, notes, and snippets.

View jmcph4's full-sized avatar

Jack McPherson jmcph4

View GitHub Profile
@jmcph4
jmcph4 / serialise_multiaddr.rs
Created October 13, 2023 00:18
Serialise a Multiaddr to bytes
use std::{
io::{stdout, Write},
str::FromStr,
};
use clap::Parser;
use multiaddr::Multiaddr;
fn print_bytes(bytes: Vec<u8>) {
stdout()
@jmcph4
jmcph4 / uvibench.zig
Created October 11, 2023 03:55
Basic benchmark of encoding unsigned-varints in Zig. I estimate this can achieve ~20M `u64`s per second on a modern laptop
pub fn main() void {
if (std.os.argv.len < 2) { // usage
std.os.exit(1);
}
var rnd = RndGen.init(0);
const n: usize = std.fmt.parseInt(usize, std.mem.sliceTo(std.os.argv[1], 0), 10) catch @panic("Invalid integer");
var alloc: Allocator = Allocator{
.ptr = undefined,
diff --git a/beacon_node/lighthouse_network/src/config.rs b/beacon_node/lighthouse_network/src/config.rs
index d8c3f619d..22ee558c0 100644
--- a/beacon_node/lighthouse_network/src/config.rs
+++ b/beacon_node/lighthouse_network/src/config.rs
@@ -16,6 +16,11 @@ use std::sync::Arc;
use std::time::Duration;
use types::{ForkContext, ForkName};
+pub const DEFAULT_IPV4_ADDRESS: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
+pub const DEFAULT_UDP_DISC_PORT: u16 = 9000;
@jmcph4
jmcph4 / holesky.txt
Last active September 15, 2023 06:47
$ cargo run --bin lighthouse -- beacon_node --execution-endpoint http://localhost:8551 --execution-jwt ~/.local/share/reth/mainnet/jwt.hex --http --http-address 0.0.0.0 --http-port 8080 --network holesky
Finished dev [unoptimized + debuginfo] target(s) in 0.49s
Running `target/debug/lighthouse beacon_node --execution-endpoint 'http://localhost:8551' --execution-jwt /home/jmcph4/.local/share/reth/mainnet/jwt.hex --http --http-address 0.0.0.0 --http-port 8080 --network holesky`
Sep 15 06:09:44.253 INFO Logging to file path: "/home/jmcph4/.lighthouse/holesky/beacon/logs/beacon.log"
Sep 15 06:09:44.255 INFO Lighthouse started version: Lighthouse/v4.4.1-e4ed317
Sep 15 06:09:44.255 INFO Configured for network name: holesky
Sep 15 06:09:44.255 INFO Data directory initialised datadir: /home/jmcph4/.lighthouse/holesky
Sep 15 06:09:44.255 INFO Deposit contract address: 0x4242424242424242424242424242424242424242, d
@jmcph4
jmcph4 / expansion.rs
Last active September 12, 2023 04:39
loop {
{
#[doc(hidden)]
mod __tokio_select_util {
pub(super) enum Out<_0, _1> {
_0(_0),
_1(_1),
Disabled,
}
pub(super) type Mask = u8;
@jmcph4
jmcph4 / checkbuf.diff
Last active September 10, 2023 23:35
diff --git a/beacon_node/network/src/sync/manager.rs b/beacon_node/network/src/sync/manager.rs
index b910f7b33..731809043 100644
--- a/beacon_node/network/src/sync/manager.rs
+++ b/beacon_node/network/src/sync/manager.rs
@@ -359,6 +359,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
/// - If there is no range sync and no required backfill and we have synced up to the currently
/// known peers, we consider ourselves synced.
fn update_sync_state(&mut self) {
+ self.range_sync.any_over();
let new_state: SyncState = match self.range_sync.state() {
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const expect = std.testing.expect;
const PATH_SEPARATOR: c_char = '/';
const Protocol = enum {
dccp,
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const expect = std.testing.expect;
const Protocol = enum {
P2p,
};

Description

Due to the ordering of various operations during initialisation of Lighthouse's networking stack, we are currently unable to defer port selection to the OS (i.e., bind to the 0 port). The ability to do so is desirable for a few reasons; namely that it would avoid racing on bound port numbers which are currently causing some instability in our tests and subsequently CI jobs.

Currently, the following procedure describes the initialisation of the network service:

  1. Parse relevant CLI flags
  2. Produce a network service configuration from these flags
  3. Initialise the UPnP service
#[macro_use]
extern crate honggfuzz;
const MIN_LEN: usize = 8000;
const SPECIAL_LOC: usize = MIN_LEN - 200;
const SPECIAL_CHAR: u8 = b'A';
fn parse(s: &str) -> bool {
if s.len() >= MIN_LEN {
if s.as_bytes()[SPECIAL_LOC] == SPECIAL_CHAR {