Skip to content

Instantly share code, notes, and snippets.

@ochaloup
ochaloup / buildkite-test.yml
Created April 28, 2024 06:05
Buildkite script managing upload artifacts and failures
agents:
queue: "snapshots"
steps:
- label: ":mega: Notification setup"
commands:
- 'notification_color="8388863"'
- 'buildkite-agent meta-data set notification_color "$$notification_color"'
- |
epoch=333
echo "$$DISCORD_WEBHOOK_VALIDATOR_BONDS" -H "Content-Type: application/json" -d '{
@ochaloup
ochaloup / #search_solana_vote_and_stake_account
Last active May 7, 2024 13:01
Solana search for VoteAccount - by validator identity (node_pubkey) and StakeAcccount - by staker/withdrawer/voter
Changing name:
https://stackoverflow.com/questions/19896900/how-to-change-the-name-of-a-gist-in-github/62398008#62398008
@ochaloup
ochaloup / generate-keypairs-solana.sh
Created March 25, 2024 12:53
SH script generating keypairs for Solana for testing purposes
#!/bin/bash
is_valid_directory() {
if [ -d "$1" ]; then
echo "$1 is a valid directory."
return 0
else
echo "$1 is not a valid directory."
return 1
fi
@ochaloup
ochaloup / Cargo.toml
Created February 29, 2024 11:20
Marinade state verification onchain program
[package]
name = "test"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"
[lib]
crate-type = ["cdylib", "lib"]
name = "test"
@ochaloup
ochaloup / fixture-change.sh
Last active February 13, 2024 11:28
fixture account change script
# solana account -um vbMaRfmTCg92HWGzmd53APkMNpPnGVGZTUHwUJQkXAU --output json -o fixtures/solana-accounts/vbMaRfmTCg92HWGzmd53APkMNpPnGVGZTUHwUJQkXAU.json
function to_bash_arr() {
ARR="$@"
echo $ARR | sed 's/[,]/ /g' | sed 's/\[\|\]/ /g'
}
EXPECTED_LEN=260
@ochaloup
ochaloup / snapshot-ledger-error-investigation.sh
Last active February 20, 2024 17:14
solana snapshot parsing ledger tool
# --- Working with etl snapshot DB ---
# speed up queries with index creation
create index token_account_mint on token_account(mint);
create index token_account_owner on token_account(owner);
# loading token accounts without system account from sqlite DB
SELECT sum(token_account.amount) FROM token_account
LEFT JOIN account ON token_account.owner = account.pubkey
#!/usr/bin/env bash
BINDIR=./target/debug
TESTDIR=./gen-ledger
FAUCET_KEYPAIR="$TESTDIR"/bootstrap/faucet-keypair.json
CONFIG="$TESTDIR"/config.yml
VALIDATOR_CNT=4
BOOTSTRAP_RPC="http://127.0.0.1:8899"
BOOTSTRAP_GOSSIP="127.0.0.1:8000"
WARMUP_SLOT=20
@ochaloup
ochaloup / snapshots.md
Created January 19, 2024 13:42 — forked from ripatel-fd/snapshots.md
Informal Guide to Solana Snapshots

Consider this an informal guide to reading the Solana snapshot format. This guide is written for Solana Labs versions v1.14 through v1.17.

You are probably reading this because you want to read the accounts in a snapshot without going through the pain of interfacing with the Solana Labs codebase.

Terminology

We assume general familiarity with the Solana ledger.

@ochaloup
ochaloup / jq-msol.sh
Last active January 30, 2024 10:56
jq fighting notes
# sqlite no account data
# this can be of owner system program but of owner of any other program as well (e.g., Defi)
# squirrel: seesion properties -> SQL -> SQL results - Limit rows -> uncheck
SELECT *
FROM token_account
LEFT JOIN account ON token_account.owner = account.pubkey
WHERE account.pubkey IS NULL AND token_account.mint = 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'
token_account.amount > 0;
# token_account.amount > 1000000000;
@ochaloup
ochaloup / list-vote-records-curl.sh
Last active January 17, 2024 09:25
Listing Solana SPL Governance VoteRecords for a proposal
# first want to check what is the VoteRecord account type in SPL Gov
# https://github.com/solana-labs/solana-program-library/blob/governance-v3.1.1/governance/program/src/state/enums.rs#L7
# within solana-program-library governance#state/enums.rs we can see VoteRecordV2 is at 13rd position in enum GovernanceAccountType, i.e., index 12
# tobase58.py: https://gist.github.com/ochaloup/58ceee3ed436766ba7c444bf3fbc8545
~/scripts/tobase58.py [12]
# D
# ---
# marinade SPL Gov program id deployment is: GovMaiHfpVPw8BAM1mbdzgmSZYDw2tdP32J2fapoQoYs
# https://explorer.solana.com/address/899YG3yk4F66ZgbNWLHriZHTXSKk9e1kvsKEquW7L6Mo
# ---