sync

package
v0.8.0-fuji-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: GPL-3.0, LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ParentsToFetch = 256

ParentsToFetch is the number of the block parents the state syncs to. The last 256 block hashes are necessary to support the BLOCKHASH opcode.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockAcceptor

type BlockAcceptor interface {
	PutLastAcceptedID(ids.ID) error
}

type Client

type Client interface {
	// methods that implement the client side of [block.StateSyncableVM]
	StateSyncEnabled(context.Context) (bool, error)
	GetOngoingSyncStateSummary(context.Context) (block.StateSummary, error)
	ParseStateSummary(ctx context.Context, summaryBytes []byte) (block.StateSummary, error)

	// additional methods required by the evm package
	ClearOngoingSummary() error
	Shutdown() error
	Error() error
}

func NewClient

func NewClient(config *ClientConfig) Client

type ClientConfig

type ClientConfig struct {
	Enabled    bool
	SkipResume bool
	// Specifies the number of blocks behind the latest state summary that the chain must be
	// in order to prefer performing state sync over falling back to the normal bootstrapping
	// algorithm.
	MinBlocks   uint64
	RequestSize uint16 // number of key/value pairs to ask peers for per request

	LastAcceptedHeight uint64

	Chain      *eth.Ethereum
	State      *chain.State
	ChaindDB   ethdb.Database
	Acceptor   BlockAcceptor
	VerDB      *versiondb.Database
	MetadataDB database.Database

	// Extension points
	Parser message.SyncableParser
	// Extender is an optional extension point for the state sync process, and can be nil.
	Extender Extender

	Client syncclient.Client

	StateSyncDone chan struct{}
}

ClientConfig defines the options and dependencies needed to construct a Client

type EthBlockWrapper

type EthBlockWrapper interface {
	GetEthBlock() *types.Block
}

EthBlockWrapper can be implemented by a concrete block wrapper type to return *types.Block, which is needed to update chain pointers at the end of the sync operation.

type Extender

type Extender interface {
	// Sync is called to perform any extension-specific state sync logic.
	Sync(ctx context.Context, client syncclient.LeafClient, verdb *versiondb.Database, syncSummary message.Syncable) error
	// OnFinishBeforeCommit is called after the state sync process has completed but before the state sync summary is committed.
	OnFinishBeforeCommit(lastAcceptedHeight uint64, syncSummary message.Syncable) error
	// OnFinishAfterCommit is called after the state sync process has completed and the state sync summary is committed.
	OnFinishAfterCommit(summaryHeight uint64) error
}

Extender is an interface that allows for extending the state sync process.

type Server

type Server interface {
	GetLastStateSummary(context.Context) (block.StateSummary, error)
	GetStateSummary(context.Context, uint64) (block.StateSummary, error)
}

func NewServer

func NewServer(chain *core.BlockChain, provider SummaryProvider, syncableInterval uint64) Server

type SummaryProvider

type SummaryProvider interface {
	StateSummaryAtBlock(ethBlock *types.Block) (block.StateSummary, error)
}

type Syncer

type Syncer interface {
	Start(ctx context.Context) error
	Wait(ctx context.Context) error
}

Syncer represents a step in state sync, along with Start/Done methods to control and monitor progress. Error returns an error if any was encountered.

Jump to

Keyboard shortcuts

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