Documentation
¶
Overview ¶
Package bundler defines account bundling schemes
Index ¶
Constants ¶
const KeyFlagBundlerTipUpdate uint8 = 201
KeyFlagBundlerTipUpdate is the shared, cross-strategy stdin key flag (Go->bot) carrying a TipUpdate -- must match catscope-rust-bot's src/bundler_message.rs COMMON_KEY_FLAG_BUNDLER_TIP_UPDATE exactly, and must never collide with any per-strategy key (every per-strategy scheme in this codebase stays below 100).
Variables ¶
var Schema string
Functions ¶
func DoBundlerTipUpdate ¶
DoBundlerTipUpdate builds the wire message for a TipUpdate: [bundler u8][up u8][n_addrs u16][addr0 32B]...[addrN-1 32B][p25 u64][p50 u64][p75 u64][p95 u64][p99 u64], all little-endian. Mirrors catscope-rust-bot's bundler_message::BundlerTipUpdate::parse exactly.
func RecordTipUpdate ¶
RecordTipUpdate persists update into bundler_tip as the latest known-good tip state for update.Bundler -- only called for a real, live update (Up == true, both Tip() and Distribution() succeeded), so a later LoadTipUpdate always returns the most recent value the network actually reported, never a synthetic "down" state.
func RunTipBroadcaster ¶
func RunTipBroadcaster(ctx context.Context, entry *slog.Logger, db *sql.DB, bundlers []Bundler, send func(TipUpdate) error)
RunTipBroadcaster polls each of bundlers' Tip()/Distribution() every tipBroadcastInterval and pushes a TipUpdate to the running bot via send. Every successful (Up: true) poll is also persisted to db via RecordTipUpdate, so a freshly-started bot doesn't have to wait through however long it takes a bundler's own live feed (e.g. Astralane's tip websocket) to deliver a first real snapshot: whenever a poll fails (Tip() or Distribution() returns an error), the last db-persisted TipUpdate for that bundler is sent instead of an immediate Up: false -- only bundlers that have NEVER produced a real update are marked down. db may be nil (persistence/fallback disabled, e.g. in tests). Blocks until ctx is cancelled; callers should run it in its own goroutine. send failures (e.g. the bot hasn't connected yet) are logged and retried on the next tick rather than treated as fatal.
Types ¶
type Bundler ¶
type Bundler interface {
Base
// specify the code needed to tell the bot runtime which bundler to use
Code() uint8
// Tip returns an array of tipping accounts. Make sure to strategically pick the tip account with the least chance of writes
// A tip is rust is specified with:
// let tip_ix = system_instruction::transfer(&signer.pubkey(), &TIP, MIN_TIP_AMOUNT);
// ixs.push(tip_ix);
Tip() ([]sgo.PublicKey, error)
// Distribution specified the 25th, 50th, 75th, 95th, 99th percentile required types to get a transaction into the block
Distribution() ([5]graph.Lamports, error)
}
type BundlerCode ¶
type BundlerCode = uint8
const ( BundlerDefault BundlerCode = 0 BundlerAstralane BundlerCode = 1 BundlerJito BundlerCode = 2 )
type TipUpdate ¶
type TipUpdate struct {
// Bundler is the same code Bundler.Code() returns (see
// BundlerAstralane/BundlerJito).
Bundler BundlerCode
// Up is false whenever Tip() (or Distribution()) returned an error --
// Addresses/Distribution are meaningless in that case and the bot
// should treat this bundler as unusable until the next Up==true
// update.
Up bool
Addresses []sgo.PublicKey
Distribution [5]graph.Lamports
}
TipUpdate is the payload broadcast to a running bot via CustomStdin whenever a registered Bundler's tip state changes (see RunTipBroadcaster).
func LoadTipUpdate ¶
LoadTipUpdate returns the last real tip update RecordTipUpdate persisted for bundlerCode, if any -- the fallback RunTipBroadcaster uses whenever a live Tip()/Distribution() poll fails (no websocket snapshot yet, or the bundler is otherwise unreachable this cycle). ok is false if nothing has ever been recorded for this bundler.
Source Files
¶
- bundler.go
- message.go
- schema.go
- store.go