Skip to content

Instantly share code, notes, and snippets.

View deanmlittle's full-sized avatar

Dean 利迪恩 deanmlittle

View GitHub Profile
. . . . . .
: - - - . . . . . . * * * * + + +
- - - - : : : - - . . * * * * * + +
. - - - - - - - : . . * * * * * + +
. - - - - - - : : . . * * * * * * *
. - - - - - : : : . . * * * * * * *
. - - - - : : : : . . * * * * * * * .
. - - - : : : : : . . * * * * * * * .
: - - : : : : : : . . . . . . . * * * * * * * : .
# - : : : : : : : # + + + + * * * . . & [ & [ & [ u 8 ] ] ] * * # # :
@deanmlittle
deanmlittle / merkle_proof.rs
Created August 19, 2025 09:16
Rust merkle proof POC
use core::{mem::MaybeUninit, ptr};
pub trait MerkleHash<const N: usize> {
fn hash(bytes: &[u8]) -> [u8;N];
fn merkle_hashv(l: &[u8], r: &[u8], swap: bool) -> [u8;N];
}
#[inline(always)]
unsafe fn trunc32_to_n<const N: usize>(src32: *const u8) -> [u8; N] {

Feature Gate Activation Guide

Below is a guide to feature gate activations, outlining the requirements and expectations for those holding the feature gate activation keypair.

Expectations

Holding the keypair for a feature gate isn’t just “having the magic button.” It comes with both technical and process responsibilities, along with a tiny bit of ceremonial paranoia, to make sure the activation goes smoothly and safely.

Here’s what’s expected of you:

1. Be Part of the Audit Process

You’re expected to participate in the audit process for any change related to the gated feature.

@deanmlittle
deanmlittle / fib-so-teardown.md
Last active July 9, 2025 17:50
fib.so teardown

Deconstructing fib.so, a minimal sBPF program

For this deconstruction, we will be researching fib.so, a hand-rolled sBPF assembly program that calculates the fibonacci number based upon a u8 input.

Structure of an sBPF program

The structure of an sBPF program has 4 sections:

1. ELF Header

The starting point of the file, describing the overall file format, target environment, and offsets for program and section headers.

2. Program Headers

Define the memory segments and their attributes (readable, writable, executable) for runtime execution.

@deanmlittle
deanmlittle / fib.md
Last active October 3, 2025 12:37
fib.so teardown

Deconstructing fib.so, a minimal sBPF program

For this deconstruction, we will be researching fib.so, a hand-rolled sBPF assembly program that calculates the fibonacci number based upon a u8 input.

Structure of an sBPF program

The structure of an sBPF program has 4 sections:

1. ELF Header

The starting point of the file, describing the overall file format, target environment, and offsets for program and section headers.

2. Program Headers

Define the memory segments and their attributes (readable, writable, executable) for runtime execution.

@deanmlittle
deanmlittle / bitcoin_winternitz_vault.s
Last active January 9, 2025 10:28
Bitcoin Winternitz Vault
/*******************
* UNLOCKING SCRIPT *
*******************/
// Reverse-ordered Winternitz signature scalar and hash offset pairs
<0x6a1e8e25ac52d4073e6e6792deae3dd16d12580130e8fb1338629cf09cde415f> <0x08>
<0x171582236c86aacab7a0bdfde1d841bed34a4c712748b46a141bd9a743cb965a> <0x0a>
<0xc42ebffb891ff91b5cd75c0b2cfa1b1658eb3586bad9a4aaea05a34846765491> <0xf0>
<0x7faa84fe7faa005ebc37f02b15aa8db41c9ed7c63d8480573471533a0c942096> <0xb0>
<0xe7bbce18cacf2dbc2ae36122365462a07850e873e961ec4ea318dc6506498790> <0x15>
@deanmlittle
deanmlittle / mollusk_generate.sh
Last active October 30, 2024 07:22
Generate a Mollusk SDK for a mainnet-beta program
#!/bin/bash
# Check if program ID and name are provided
if [ "$#" -ne 2 ]; then
echo "Usage: ./mollusk_generate.sh <ProgramID> <name>"
exit 1
fi
PROGRAM_ID="$1"
NAME="$2"
@deanmlittle
deanmlittle / target_os_solana.md
Last active September 23, 2024 14:15
Make Rust Analyzer recognize target_os="solana"

To make Rust analyzer target target_os="solana" try the following:

  1. Find active_release_dir from your config file with cat ~/.config/solana/install/config.yml (or whatever your config directory is)
  2. Create a .vscode/settings.json file in your project workspace and add the following:
{
    "rust-analyzer.cargo.target": "sbf-solana-solana",
    "rust-analyzer.cargo.extraEnv": {
        "CARGO": "<your_active_release_directory>/bin/sdk/sbf/dependencies/platform-tools/rust/bin/cargo",
 "RUSTC": "/bin/sdk/sbf/dependencies/platform-tools/rust/bin/rustc"
@deanmlittle
deanmlittle / anchor-fix-m3-mac.md
Created April 30, 2024 01:52
Fix Anchor build on Mac M3

Fix Anchor build on Mac M3

  1. Make sure you have installed XCode from the App store
  2. Select xcode version from appstore: sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
  3. Confirm by running xcodebuild -version
  4. Install GCC 12 brew install gcc@12
  5. Create a symlink to your usr/local/include folder to make includes discoverable: sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
@deanmlittle
deanmlittle / jupiter.rs
Created January 17, 2024 01:52
Jupiter swap lib
use anchor_lang::{prelude::*, Discriminator};
pub mod jupiter {
use super::*;
declare_id!("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
#[derive(AnchorDeserialize, AnchorSerialize)]
pub struct SharedAccountsRoute {
pub id: u8,
pub route_plan: Vec<RoutePlanStep>,
pub in_amount: u64,