snapshot

package
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxConcurrentFlushers int = 16
View Source
var (
	ZstdDecoderConcurrency = runtime.NumCPU()
)

Functions

func CleanAccountsDbDir

func CleanAccountsDbDir(accountsDbDir string)

CleanAccountsDbDir removes all artifacts from a previous incomplete snapshot run. This prevents corruption from Ctrl+C or partial downloads. Exported so it can be called early in startup before any failures.

func CleanSnapshotDownloadDir

func CleanSnapshotDownloadDir(downloadPath string, maxSnapshots int)

CleanSnapshotDownloadDir removes old snapshot files based on retention settings. maxSnapshots controls how many snapshots to keep:

  • 0 = delete all snapshots (stream-only mode, used by new-snapshot bootstrap)
  • N > 0 = keep N newest snapshots, delete the rest

func LoadStakePubkeyIndex

func LoadStakePubkeyIndex(path string) ([]solana.PublicKey, error)

LoadStakePubkeyIndex reads stake pubkeys from a binary index file.

func NewBufMonReader

func NewBufMonReader(name string, r io.ReadCloser, totalSize int64) *bufmonreader

func NewBufMonReaderFromFile

func NewBufMonReaderFromFile(file *os.File) (*bufmonreader, error)

func NewBufMonReaderHTTP

func NewBufMonReaderHTTP(ctx context.Context, url string) (*bufmonreader, error)

func NewBufMonReaderHTTPWithSave

func NewBufMonReaderHTTPWithSave(ctx context.Context, url string, savePath string) (*bufmonreader, error)

NewBufMonReaderHTTPWithSave streams from HTTP URL and optionally saves to disk. If savePath is non-empty, the data will be written to disk while streaming. Returns: (*bufmonreader, error)

func WriteStakePubkeyIndex

func WriteStakePubkeyIndex(path string, pubkeys []solana.PublicKey) error

WriteStakePubkeyIndex writes stake pubkeys to a binary index file. Format: 32-byte pubkeys appended sequentially, no header.

Types

type AccountsDbFields

type AccountsDbFields struct {
	//Storages                []SlotAcctVecs
	Storages                map[uint64]SlotAcctVecs
	Version                 uint64
	Slot                    uint64
	BankHashInfo            BankHashInfo
	HistoricalRoots         []uint64
	HistoricalRootsWithHash []SlotMapPair
}

func (*AccountsDbFields) UnmarshalWithDecoder

func (acctDbFields *AccountsDbFields) UnmarshalWithDecoder(decoder *bin.Decoder) error

type AcctVec

type AcctVec struct {
	Id       uint64
	FileSize uint64
}

func (*AcctVec) UnmarshalWithDecoder

func (acctVec *AcctVec) UnmarshalWithDecoder(decoder *bin.Decoder) error

type BankHashInfo

type BankHashInfo struct {
	Hash         [32]byte
	SnapshotHash [32]byte
	Stats        BankHashStats
}

func (*BankHashInfo) UnmarshalWithDecoder

func (info *BankHashInfo) UnmarshalWithDecoder(decoder *bin.Decoder) error

type BankHashStats

type BankHashStats struct {
	NumUpdatedAccts    uint64
	NumRemovedAccts    uint64
	NumLamportsStored  uint64
	TotalDataLen       uint64
	NumExecutableAccts uint64
}

func (*BankHashStats) UnmarshalWithDecoder

func (stats *BankHashStats) UnmarshalWithDecoder(decoder *bin.Decoder) error

type BankIncrementalSnapshotPersistence

type BankIncrementalSnapshotPersistence struct {
	FullSlot                  uint64
	FullHash                  [32]byte
	FullCapitalization        uint64
	IncrementalHash           [32]byte
	IncrementalCapitalization uint64
}

func (*BankIncrementalSnapshotPersistence) UnmarshalWithDecoder

func (bankIncrSnapshotPersistence *BankIncrementalSnapshotPersistence) UnmarshalWithDecoder(decoder *bin.Decoder) error

type BlockHashVec

type BlockHashVec struct {
	LastHashIndex uint64
	LastHash      *[32]byte
	HashAndAge    []HashAgePair
	MaxAge        uint64
}

func (*BlockHashVec) UnmarshalWithDecoder

func (bhv *BlockHashVec) UnmarshalWithDecoder(decoder *bin.Decoder) error

type Delegation

type Delegation struct {
	VoterPubkey        solana.PublicKey
	Stake              uint64
	ActivationEpoch    uint64
	DeactivationEpoch  uint64
	WarmupCooldownRate float64
}

func (*Delegation) UnmarshalWithDecoder

func (delegation *Delegation) UnmarshalWithDecoder(decoder *bin.Decoder) error

type DelegationPair

type DelegationPair struct {
	Account    solana.PublicKey
	Delegation Delegation
}

func (*DelegationPair) UnmarshalWithDecoder

func (delegationPair *DelegationPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type DeserializableVersionedBank

type DeserializableVersionedBank struct {
	BlockhashQueue      BlockHashVec
	Ancestors           []SlotPair
	Hash                [32]byte
	ParentHash          [32]byte
	ParentSlot          uint64
	HardForks           []SlotPair
	TransactionCount    uint64
	TickHeight          uint64
	SignatureCount      uint64
	Capitalization      uint64
	MaxTickHeight       uint64
	HashesPerTick       *uint64 `bin:"optional"`
	TicksPerSlot        uint64
	NsPerSlot           bin.Uint128
	GenesisCreationTime uint64
	SlotsPerYear        float64
	AccountsDataLen     uint64
	Slot                uint64
	Epoch               uint64
	BlockHeight         uint64
	CollectorId         solana.PublicKey
	CollectorFees       uint64
	FeeCalculator       sealevel.FeeCalculator
	FeeRateGovernor     sealevel.FeeRateGovernor
	CollectedRent       uint64
	RentCollector       RentCollector
	EpochSchedule       sealevel.SysvarEpochSchedule
	Inflation           rewards.Inflation
	Stakes              Stakes
	UnusedAccounts      UnusedAccounts
	EpochStakes         []EpochStakesPair
	IsDelta             bool
}

func (*DeserializableVersionedBank) UnmarshalWithDecoder

func (dsv *DeserializableVersionedBank) UnmarshalWithDecoder(decoder *bin.Decoder) error

type EpochStakes

type EpochStakes struct {
	Stakes                Stakes
	TotalStake            uint64
	NodeIdToVoteAccounts  []NodeVoteAccountsPair
	EpochAuthorizedVoters []PubkeyPair
}

func (*EpochStakes) UnmarshalWithDecoder

func (epochStakes *EpochStakes) UnmarshalWithDecoder(decoder *bin.Decoder) error

type EpochStakesPair

type EpochStakesPair struct {
	Key uint64
	Val EpochStakes
}

func (*EpochStakesPair) UnmarshalWithDecoder

func (epochStakesPair *EpochStakesPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type HashAge

type HashAge struct {
	FeeCalculator sealevel.FeeCalculator
	HashIndex     uint64
	Timestamp     uint64
}

func (*HashAge) UnmarshalWithDecoder

func (age *HashAge) UnmarshalWithDecoder(decoder *bin.Decoder) error

type HashAgePair

type HashAgePair struct {
	Key [32]byte
	Val HashAge
}

func (*HashAgePair) UnmarshalWithDecoder

func (hashAgePair *HashAgePair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type NodeVoteAccounts

type NodeVoteAccounts struct {
	VoteAccounts []solana.PublicKey
	TotalStake   uint64
}

func (*NodeVoteAccounts) UnmarshalWithDecoder

func (nodeVoteAccts *NodeVoteAccounts) UnmarshalWithDecoder(decoder *bin.Decoder) error

type NodeVoteAccountsPair

type NodeVoteAccountsPair struct {
	Key solana.PublicKey
	Val NodeVoteAccounts
}

func (*NodeVoteAccountsPair) UnmarshalWithDecoder

func (pair *NodeVoteAccountsPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type ProgressCallback

type ProgressCallback func(bytesRead, totalBytes int64)

ProgressCallback is called with (bytesRead, totalBytes) to report download progress

type PubkeyPair

type PubkeyPair struct {
	Key solana.PublicKey
	Val solana.PublicKey
}

func (*PubkeyPair) UnmarshalWithDecoder

func (pubkeyPair *PubkeyPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type RentCollector

type RentCollector struct {
	Epoch         uint64
	EpochSchedule sealevel.SysvarEpochSchedule
	SlotsPerYear  float64
	Rent          sealevel.SysvarRent
}

func (*RentCollector) UnmarshalWithDecoder

func (rentCollector *RentCollector) UnmarshalWithDecoder(decoder *bin.Decoder) error

type RewardInfo

type RewardInfo struct {
	RewardType         uint32
	Lamports           uint64
	StakerRewards      uint64
	NewCreditsObserved uint64
	PostBalance        uint64
	Commission         uint64
}

func (*RewardInfo) UnmarshalWithDecoder

func (rewardInfo *RewardInfo) UnmarshalWithDecoder(decoder *bin.Decoder) error

type SerializableEpochRewardStatus

type SerializableEpochRewardStatus struct {
	Type   uint32
	Active StartBlockHeightAndRewards
}

func (*SerializableEpochRewardStatus) UnmarshalWithDecoder

func (epochRewardStatus *SerializableEpochRewardStatus) UnmarshalWithDecoder(decoder *bin.Decoder) error

type SerializableStakeRewards

type SerializableStakeRewards struct {
	StakePubkey solana.PublicKey
	RewardInfo  RewardInfo
}

func (*SerializableStakeRewards) UnmarshalWithDecoder

func (stakeRewards *SerializableStakeRewards) UnmarshalWithDecoder(decoder *bin.Decoder) error

type ShardLogger

type ShardLogger struct {
	// contains filtered or unexported fields
}

ShardLogger manages multiple sharded log files

func NewShardLogger

func NewShardLogger(numShards int, filePrefix string) *ShardLogger

NewShardLogger creates a new ShardLogger with the specified number of shards for logging entries. Entries are flushed to shardedSetter when log reaches a certain size or on shard closure.

func (*ShardLogger) BytesDone

func (sl *ShardLogger) BytesDone() int64

BytesDone returns the bytes that have been flushed to cache

func (*ShardLogger) Close

func (sl *ShardLogger) Close(ctx context.Context) error

Close closes all shards and their files

func (*ShardLogger) CloseWithProgress

func (sl *ShardLogger) CloseWithProgress(ctx context.Context, onProgress func(completed, total int)) error

CloseWithProgress closes all shards with optional progress callback. The callback is called after each shard flush completes with (completed, total) counts.

func (*ShardLogger) EnqueueRequest

func (sl *ShardLogger) EnqueueRequest(k solana.PublicKey, v accountsdb.AccountIndexEntry)

EnqueueRequest adds a request to the appropriate shard

func (*ShardLogger) SetProgressCallback

func (sl *ShardLogger) SetProgressCallback(cb ShardProgressCallback)

SetProgressCallback sets a callback to receive progress updates during shard flushes. The callback receives (bytesDone, totalBytes) and is called as bytes are flushed to cache.

func (*ShardLogger) TotalBytes

func (sl *ShardLogger) TotalBytes() int64

TotalBytes returns the total bytes written to shard logs

type ShardProgressCallback

type ShardProgressCallback func(bytesDone, totalBytes int64)

ShardProgressCallback is called with (bytesDone, totalBytes) to report shard flush progress

type SlotAcctVecs

type SlotAcctVecs struct {
	Slot     uint64
	AcctVecs []AcctVec
}

func (*SlotAcctVecs) UnmarshalWithDecoder

func (slotAcctVecs *SlotAcctVecs) UnmarshalWithDecoder(decoder *bin.Decoder) error

type SlotMapPair

type SlotMapPair struct {
	Slot uint64
	Hash [32]byte
}

func (*SlotMapPair) UnmarshalWithDecoder

func (pair *SlotMapPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type SlotPair

type SlotPair struct {
	Slot uint64
	Val  uint64
}

func (*SlotPair) UnmarshalWithDecoder

func (slotPair *SlotPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type SnapshotManifest

type SnapshotManifest struct {
	Bank                               DeserializableVersionedBank
	AccountsDb                         AccountsDbFields
	LamportsPerSignature               uint64
	BankIncrementalSnapshotPersistence BankIncrementalSnapshotPersistence
	EpochAccountHash                   [32]byte
	VersionedEpochStakes               []VersionedEpochStakesPair
	LtHash                             *lthash.LtHash
}

func BuildAccountsDbAuto

func BuildAccountsDbAuto(
	ctx context.Context,
	fullSnapshotFile string,
	snapshotDownloadPath string,
	fullSnapshotSlot int,
	referenceSlot int,
	accountsDbDir string,
	rpcEndpoints []string,
	blockDir string,
	snapCfg snapshotdl.SnapshotConfig,
	dp *progress.DualProgress,
) (*accountsdb.AccountsDb, *SnapshotManifest, error)

BuildAccountsDbAuto builds the accounts database from full + incremental snapshots.

func BuildAccountsDbPaths

func BuildAccountsDbPaths(
	ctx context.Context,
	snapshotFile string,
	incrementalSnapshotFile string,
	accountsDbDir string,
	dp *progress.DualProgress,
) (*accountsdb.AccountsDb, *SnapshotManifest, error)

func LoadManifestFromFile

func LoadManifestFromFile(filename string) (*SnapshotManifest, error)

func UnmarshalManifestFromSnapshot

func UnmarshalManifestFromSnapshot(ctx context.Context, filename string, accountsDbDir string) (*SnapshotManifest, error)

func (*SnapshotManifest) UnmarshalWithDecoder

func (snapshot *SnapshotManifest) UnmarshalWithDecoder(decoder *bin.Decoder) error

type Stake

type Stake struct {
	VoteAccounts     []VoteAccountsPair
	StakeDelegations map[solana.PublicKey]StakePair
	Unused           uint64
	Epoch            uint64
	StakeHistory     sealevel.SysvarStakeHistory
}

func (*Stake) UnmarshalWithDecoder

func (stakes *Stake) UnmarshalWithDecoder(decoder *bin.Decoder) error

type StakeInner

type StakeInner struct {
	Delegation      Delegation
	CreditsObserved uint64
}

func (*StakeInner) UnmarshalWithDecoder

func (stakeInner *StakeInner) UnmarshalWithDecoder(decoder *bin.Decoder) error

type StakePair

type StakePair struct {
	Account [32]byte
	Stake   StakeInner
}

func (*StakePair) UnmarshalWithDecoder

func (stakePair *StakePair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type Stakes

type Stakes struct {
	VoteAccounts []VoteAccountsPair
	Delegations  []DelegationPair
	Unused       uint64
	Epoch        uint64
	StakeHistory sealevel.SysvarStakeHistory
}

func (*Stakes) UnmarshalWithDecoder

func (stakes *Stakes) UnmarshalWithDecoder(decoder *bin.Decoder) error

type StartBlockHeightAndRewards

type StartBlockHeightAndRewards struct {
	StartBlockHeight        uint64
	StakeRewardsByPartition map[solana.PublicKey]SerializableStakeRewards
}

func (*StartBlockHeightAndRewards) UnmarshalWithDecoder

func (startBlockHeightAndRewards *StartBlockHeightAndRewards) UnmarshalWithDecoder(decoder *bin.Decoder) error

type UnusedAccounts

type UnusedAccounts struct {
	Unused1 []solana.PublicKey
	Unused2 []solana.PublicKey
	Unused3 []UnusedAccountsU64Pair
}

func (*UnusedAccounts) UnmarshalWithDecoder

func (unusedAccts *UnusedAccounts) UnmarshalWithDecoder(decoder *bin.Decoder) error

type UnusedAccountsU64Pair

type UnusedAccountsU64Pair struct {
	// contains filtered or unexported fields
}

func (*UnusedAccountsU64Pair) UnmarshalWithDecoder

func (pair *UnusedAccountsU64Pair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type VersionedEpochStakes

type VersionedEpochStakes struct {
	Stakes                Stake
	TotalStake            uint64
	NodeIdToVoteAccounts  []NodeVoteAccountsPair
	EpochAuthorizedVoters []PubkeyPair
}

func (*VersionedEpochStakes) UnmarshalWithDecoder

func (versionedEpochStakes *VersionedEpochStakes) UnmarshalWithDecoder(decoder *bin.Decoder) error

type VersionedEpochStakesPair

type VersionedEpochStakesPair struct {
	Epoch uint64
	Val   VersionedEpochStakes
}

func (*VersionedEpochStakesPair) UnmarshalWithDecoder

func (epochStakesPair *VersionedEpochStakesPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

type VoteAccount

type VoteAccount struct {
	Lamports          uint64
	NodePubkey        solana.PublicKey
	LastTimestampTs   int64
	LastTimestampSlot uint64
	Owner             solana.PublicKey
	Executable        byte
	RentEpoch         uint64
}

func (*VoteAccount) UnmarshalWithDecoder

func (voteAcct *VoteAccount) UnmarshalWithDecoder(decoder *bin.Decoder) error

type VoteAccountsPair

type VoteAccountsPair struct {
	Key   solana.PublicKey
	Stake uint64
	Value VoteAccount
}

func (*VoteAccountsPair) UnmarshalWithDecoder

func (voteAcctsPair *VoteAccountsPair) UnmarshalWithDecoder(decoder *bin.Decoder) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL