consensus

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBlockBody added in v0.0.10

func GetBlockBody(v *spec.VersionedSignedBeaconBlock) any

func GetExecutionExtraData added in v0.0.9

func GetExecutionExtraData(v *spec.VersionedSignedBeaconBlock) ([]byte, error)

Types

type Block

type Block struct {
	Root phase0.Root
	Slot phase0.Slot
	// contains filtered or unexported fields
}

func (*Block) AwaitBlock

func (block *Block) AwaitBlock(ctx context.Context, timeout time.Duration) *spec.VersionedSignedBeaconBlock

func (*Block) AwaitHeader

func (block *Block) AwaitHeader(ctx context.Context, timeout time.Duration) *phase0.SignedBeaconBlockHeader

func (*Block) EnsureBlock

func (block *Block) EnsureBlock(loadBlock func() (*spec.VersionedSignedBeaconBlock, error)) (bool, error)

func (*Block) EnsureHeader

func (block *Block) EnsureHeader(loadHeader func() (*phase0.SignedBeaconBlockHeader, error)) error

func (*Block) GetBlock

func (block *Block) GetBlock() *spec.VersionedSignedBeaconBlock

func (*Block) GetHeader

func (block *Block) GetHeader() *phase0.SignedBeaconBlockHeader

func (*Block) GetParentRoot

func (block *Block) GetParentRoot() *phase0.Root

func (*Block) GetSeenBy

func (block *Block) GetSeenBy() []*Client

func (*Block) SetHeader

func (block *Block) SetHeader(header *phase0.SignedBeaconBlockHeader)

func (*Block) SetSeenBy

func (block *Block) SetSeenBy(client *Client)

type BlockCache

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

func NewBlockCache

func NewBlockCache(ctx context.Context, logger logrus.FieldLogger, followDistance uint64) (*BlockCache, error)

func (*BlockCache) AddBlock

func (cache *BlockCache) AddBlock(root phase0.Root, slot phase0.Slot) (*Block, bool)

func (*BlockCache) GetBlockDistance

func (cache *BlockCache) GetBlockDistance(blockRoot, headRoot phase0.Root) (linked bool, distance uint64)

func (*BlockCache) GetCachedBlockByRoot

func (cache *BlockCache) GetCachedBlockByRoot(root phase0.Root) *Block

func (*BlockCache) GetCachedBlocks

func (cache *BlockCache) GetCachedBlocks() []*Block

func (*BlockCache) GetCachedBlocksBySlot

func (cache *BlockCache) GetCachedBlocksBySlot(slot phase0.Slot) []*Block

func (*BlockCache) GetFinalizedCheckpoint

func (cache *BlockCache) GetFinalizedCheckpoint() (phase0.Epoch, phase0.Root)

func (*BlockCache) GetGenesis

func (cache *BlockCache) GetGenesis() *v1.Genesis

func (*BlockCache) GetSpecValues added in v0.0.11

func (cache *BlockCache) GetSpecValues() map[string]interface{}

func (*BlockCache) GetSpecs

func (cache *BlockCache) GetSpecs() *ChainSpec

func (*BlockCache) GetWallclock

func (cache *BlockCache) GetWallclock() *ethwallclock.EthereumBeaconChain

func (*BlockCache) InitWallclock

func (cache *BlockCache) InitWallclock()

func (*BlockCache) IsCanonicalBlock

func (cache *BlockCache) IsCanonicalBlock(blockRoot, headRoot phase0.Root) bool

func (*BlockCache) SetClientSpecs

func (cache *BlockCache) SetClientSpecs(specValues map[string]interface{}) error

func (*BlockCache) SetFinalizedCheckpoint

func (cache *BlockCache) SetFinalizedCheckpoint(finalizedEpoch phase0.Epoch, finalizedRoot phase0.Root)

func (*BlockCache) SetGenesis

func (cache *BlockCache) SetGenesis(genesis *v1.Genesis) error

func (*BlockCache) SetMinFollowDistance

func (cache *BlockCache) SetMinFollowDistance(followDistance uint64)

func (*BlockCache) SubscribeBlockEvent

func (cache *BlockCache) SubscribeBlockEvent(capacity int) *Subscription[*Block]

func (*BlockCache) SubscribeFinalizedEvent

func (cache *BlockCache) SubscribeFinalizedEvent(capacity int) *Subscription[*FinalizedCheckpoint]

func (*BlockCache) SubscribeWallclockEpochEvent

func (cache *BlockCache) SubscribeWallclockEpochEvent(capacity int) *Subscription[*ethwallclock.Epoch]

func (*BlockCache) SubscribeWallclockSlotEvent

func (cache *BlockCache) SubscribeWallclockSlotEvent(capacity int) *Subscription[*ethwallclock.Slot]

type ChainSpec

type ChainSpec struct {
	PresetBase           string         `yaml:"PRESET_BASE"`
	ConfigName           string         `yaml:"CONFIG_NAME"`
	MinGenesisTime       time.Time      `yaml:"MIN_GENESIS_TIME"`
	GenesisForkVersion   phase0.Version `yaml:"GENESIS_FORK_VERSION"`
	AltairForkVersion    phase0.Version `yaml:"ALTAIR_FORK_VERSION"`
	AltairForkEpoch      uint64         `yaml:"ALTAIR_FORK_EPOCH"`
	BellatrixForkVersion phase0.Version `yaml:"BELLATRIX_FORK_VERSION"`
	BellatrixForkEpoch   uint64         `yaml:"BELLATRIX_FORK_EPOCH"`
	CappellaForkVersion  phase0.Version `yaml:"CAPELLA_FORK_VERSION"`
	CappellaForkEpoch    uint64         `yaml:"CAPELLA_FORK_EPOCH"`
	SecondsPerSlot       time.Duration  `yaml:"SECONDS_PER_SLOT"`
	SlotsPerEpoch        uint64         `yaml:"SLOTS_PER_EPOCH"`
	MaxCommitteesPerSlot uint64         `yaml:"MAX_COMMITTEES_PER_SLOT"`
}

https://github.com/ethereum/consensus-specs/blob/dev/configs/mainnet.yaml

func (*ChainSpec) CheckMismatch

func (chain *ChainSpec) CheckMismatch(chain2 *ChainSpec) []string

type Client

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

func (*Client) GetClientType

func (client *Client) GetClientType() ClientType

func (*Client) GetEndpointConfig

func (client *Client) GetEndpointConfig() *ClientConfig

func (*Client) GetIndex

func (client *Client) GetIndex() uint16

func (*Client) GetLastError

func (client *Client) GetLastError() error

func (*Client) GetLastEventTime

func (client *Client) GetLastEventTime() time.Time

func (*Client) GetLastHead

func (client *Client) GetLastHead() (phase0.Slot, phase0.Root)

func (*Client) GetName

func (client *Client) GetName() string

func (*Client) GetRPCClient

func (client *Client) GetRPCClient() *rpc.BeaconClient

func (*Client) GetStatus

func (client *Client) GetStatus() ClientStatus

func (*Client) GetVersion

func (client *Client) GetVersion() string

func (*Client) SubscribeBlockEvent

func (client *Client) SubscribeBlockEvent(capacity int) *Subscription[*Block]

func (*Client) SubscribeFinalizedEvent

func (client *Client) SubscribeFinalizedEvent(capacity int) *Subscription[*FinalizedCheckpoint]

func (*Client) UnsubscribeBlockEvent

func (client *Client) UnsubscribeBlockEvent(subscription *Subscription[*Block])

func (*Client) UnsubscribeFinalizedEvent

func (client *Client) UnsubscribeFinalizedEvent(subscription *Subscription[*FinalizedCheckpoint])

type ClientConfig

type ClientConfig struct {
	URL     string
	Name    string
	Headers map[string]string
}

type ClientStatus

type ClientStatus uint8
var (
	ClientStatusOnline        ClientStatus = 1
	ClientStatusOffline       ClientStatus = 2
	ClientStatusSynchronizing ClientStatus = 3
	ClientStatusOptimistic    ClientStatus = 4
)

type ClientType

type ClientType int8
var (
	AnyClient        ClientType
	UnknownClient    ClientType = -1
	LighthouseClient ClientType = 1
	LodestarClient   ClientType = 2
	NimbusClient     ClientType = 3
	PrysmClient      ClientType = 4
	TekuClient       ClientType = 5
	GrandineClient   ClientType = 6
	CaplinClient     ClientType = 7
)

func ParseClientType

func ParseClientType(name string) ClientType

func (ClientType) String

func (clientType ClientType) String() string

type Dispatcher

type Dispatcher[T interface{}] struct {
	// contains filtered or unexported fields
}

func (*Dispatcher[T]) Fire

func (d *Dispatcher[T]) Fire(data T)

func (*Dispatcher[T]) Subscribe

func (d *Dispatcher[T]) Subscribe(capacity int) *Subscription[T]

func (*Dispatcher[T]) Unsubscribe

func (d *Dispatcher[T]) Unsubscribe(subscription *Subscription[T])

type FinalizedCheckpoint

type FinalizedCheckpoint struct {
	Epoch phase0.Epoch
	Root  phase0.Root
}

type ForkVersion

type ForkVersion struct {
	Epoch           uint64
	CurrentVersion  []byte
	PreviousVersion []byte
}

type HeadFork

type HeadFork struct {
	Slot         phase0.Slot
	Root         phase0.Root
	ReadyClients []*Client
	AllClients   []*Client
}

func (*HeadFork) IsClientReady

func (fork *HeadFork) IsClientReady(client *Client) bool

type Pool

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

func NewPool

func NewPool(ctx context.Context, config *PoolConfig, logger logrus.FieldLogger) (*Pool, error)

func (*Pool) AddEndpoint

func (pool *Pool) AddEndpoint(endpoint *ClientConfig) (*Client, error)

func (*Pool) AwaitReadyEndpoint added in v0.0.6

func (pool *Pool) AwaitReadyEndpoint(ctx context.Context, clientType ClientType) *Client

func (*Pool) GetAllEndpoints

func (pool *Pool) GetAllEndpoints() []*Client

func (*Pool) GetBlockCache

func (pool *Pool) GetBlockCache() *BlockCache

func (*Pool) GetCanonicalFork

func (pool *Pool) GetCanonicalFork(forkDistance int64) *HeadFork

func (*Pool) GetHeadForks

func (pool *Pool) GetHeadForks(forkDistance int64) []*HeadFork

func (*Pool) GetReadyEndpoint

func (pool *Pool) GetReadyEndpoint(clientType ClientType) *Client

func (*Pool) GetValidatorSet added in v0.0.5

func (pool *Pool) GetValidatorSet() map[phase0.ValidatorIndex]*v1.Validator

func (*Pool) IsClientReady

func (pool *Pool) IsClientReady(client *Client) bool

type PoolConfig

type PoolConfig struct {
	FollowDistance uint64 `yaml:"followDistance" envconfig:"CONSENSUS_POOL_FOLLOW_DISTANCE"`
	ForkDistance   uint64 `yaml:"forkDistance" envconfig:"CONSENSUS_POOL_FORK_DISTANCE"`
	SchedulerMode  string `yaml:"schedulerMode" envconfig:"CONSENSUS_POOL_SCHEDULER_MODE"`
}

type SchedulerMode

type SchedulerMode uint8
var (
	RoundRobinScheduler SchedulerMode = 1
)

type Subscription

type Subscription[T interface{}] struct {
	// contains filtered or unexported fields
}

func (*Subscription[T]) Channel

func (s *Subscription[T]) Channel() <-chan T

func (*Subscription[T]) Unsubscribe

func (s *Subscription[T]) Unsubscribe()

Directories

Path Synopsis
rpc

Jump to

Keyboard shortcuts

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