Skip to content

Instantly share code, notes, and snippets.

View rauljordan's full-sized avatar
💭
building ethereum

Raul Jordan rauljordan

💭
building ethereum
View GitHub Profile
@rauljordan
rauljordan / main.rs
Created July 10, 2024 20:17
Semaphore gas / sec rate limited pool
use rand::Rng;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use tokio::sync::Semaphore;
use tokio::task;
const MAX_GAS_PER_SECOND: usize = 7_000_000;
pub async fn rate_limited_pool(num_workers: usize, num_tasks: usize, rate_limit: Option<usize>) {
let limit = rate_limit.unwrap_or(MAX_GAS_PER_SECOND);
@rauljordan
rauljordan / SSZ.hs
Created August 16, 2022 18:19
SSZ serialize FP
module SSZ (
SSZItem(..),
zeroVal,
serialize,
) where
import Data.Word (Word8,Word16,Word32,Word64)
import Data.Serialize (Serialize,encode,decode)
import qualified Data.ByteString as B
import Data.ByteString (ByteString)
@rauljordan
rauljordan / main.go
Created March 20, 2022 17:40
BTreeMap Go Generics
package main
import (
"fmt"
"runtime"
"strings"
"sync"
)
// Map is an ordered map.
@rauljordan
rauljordan / main.go
Created March 7, 2022 05:53
SSZ Generic Iterables Go 1.18 Beta
package main
import (
"encoding/binary"
"fmt"
)
const BYTES_PER_LENGTH_OFFSET = uint64(4)
type Marshaler interface {
@rauljordan
rauljordan / forkchoice_updated_request.json
Last active February 8, 2022 23:03
New Engine API Spec Tests, Informal
{
"forkchoiceState": {
"headBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a",
"safeBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a",
"finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
"payloadAttributes": {
"timestamp": "0x5",
"random": "0x0000000000000000000000000000000000000000000000000000000000000000",
"suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"
@rauljordan
rauljordan / go.mod
Created February 2, 2022 02:38
Prysm gRPC Indexed Attestation Parsing
module github.com/rauljordan/attestation-parse
go 1.17
require (
github.com/golang/protobuf v1.5.2
github.com/prysmaticlabs/prysm/v2 v2.0.1
google.golang.org/grpc v1.37.0
)

mkdir catalyst-devnet && cd catalyst-devnet

git clone https://github.com/ethereum/go-ethereum.git && cd go-ethereum go build -o ./build/bin/catalyst ./cmd/geth cd ../

mkdir -p data/catalyst ./build/bin/catalyst --datadir "./data/catalyst" init "./eth1_config.json"

block proposal rewards/fees go to the below 'etherbase', change it if you like to spend them

@rauljordan
rauljordan / main.go
Created July 29, 2021 14:39
In-Progress Cache
package main
import (
"fmt"
"sync"
"time"
)
var stopper chan bool // Semaphore.
var listeners []chan int
@rauljordan
rauljordan / main.go
Created July 21, 2021 14:29
inprogcache
package main
import (
"fmt"
"sync"
"time"
)
var stopper chan bool // Semaphore.
var listeners []chan int
#[test]
fn check_against_prysm() {
let mut tree = DepositDataTree::create(&[], 0, DEPOSIT_TREE_DEPTH);
let mut deposit_count = 0;
if let Ok(lines) = read_lines("/tmp/temp.txt") {
for line in lines {
if let Ok(raw_line_string) = line {
let deposit_line: Vec<&str> = raw_line_string.split(",").collect();
let deposit_data_root = deposit_line[0];
let deposit_index = deposit_line[1];