Skip to content

Instantly share code, notes, and snippets.

View jmcph4's full-sized avatar

Jack McPherson jmcph4

View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
contract Foo {
function bar() public pure {
assembly {
mstore(0x08, 0x01000000000000000000000000000000000000000000000000000000000000FF)
}
}
}
{
"peer_id": "16Uiu2HAkzG8D5PVPfZZBq3hvjKX2QyFfpVjCR2y5Te4Dff2xLckp",
"addresses": [
"/ip4/83.150.19.30/tcp/9001/p2p/16Uiu2HAkzG8D5PVPfZZBq3hvjKX2QyFfpVjCR2y5Te4Dff2xLckp"
],
"client_info": {
"kind": "Unknown",
"version": "unknown",
"os_version": "unknown",
"protocol_version": "unknown",
use std::io::{stdin, BufRead};
type Number = i64;
fn main() {
let mut nums: Vec<Number> = vec![];
loop {
if let Some(Ok(line)) = stdin().lock().lines().next() {
if let Ok(num) = line.parse::<Number>() {
@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,