relay

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenesisForkVersionMainnet = "0x00000000"
	GenesisForkVersionKiln    = "0x70000069" // https://github.com/eth-clients/merge-testnets/blob/main/kiln/config.yaml#L10
	GenesisForkVersionRopsten = "0x80000069"
	GenesisForkVersionSepolia = "0x90000069"
	GenesisForkVersionGoerli  = "0x00001020" // https://github.com/eth-clients/merge-testnets/blob/main/goerli-shadow-fork-5/config.yaml#L11

	GenesisValidatorsRootMainnet = "0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"
	GenesisValidatorsRootKiln    = "0x99b09fcd43e5905236c370f184056bec6e6638cfc31a323b304fc4aa789cb4ad"
	GenesisValidatorsRootRopsten = "0x44f1e56283ca88b35c789f7f449e52339bc1fefe3a45913a43a6d16edcd33cf1"
	GenesisValidatorsRootSepolia = "0xd8ea171f3c94aea21ebc42a1ed61052acf3f9209c00e4efbaaddac09ed9b8078"
	GenesisValidatorsRootGoerli  = "0x043db0d9a83813551ee2f33450d23797757d430911a9320530ad8a0eabc43efb"

	BellatrixForkVersionMainnet = "0x02000000"
	BellatrixForkVersionKiln    = "0x70000071"
	BellatrixForkVersionRopsten = "0x80000071"
	BellatrixForkVersionSepolia = "0x90000071"
	BellatrixForkVersionGoerli  = "0x02001020"
)
View Source
const (
	Version = "0.3.6"
)

Variables

View Source
var (
	DurationPerSlot  = time.Second * 12
	DurationPerEpoch = DurationPerSlot * time.Duration(structs.SlotsPerEpoch)

	ErrHTTPErrorResponse = errors.New("got an HTTP error response")
	ErrNodesUnavailable  = errors.New("beacon nodes are unavailable")
)
View Source
var (
	ErrBeaconNodeSyncing = errors.New("beacon node is syncing")
)

Functions

func ComputeDomain

func ComputeDomain(domainType types.DomainType, forkVersionHex string, genesisValidatorsRootHex string) (domain types.Domain, err error)

ComputeDomain computes the signing domain

func Max added in v0.1.5

func Max[T constraints.Ordered](args ...T) T

func NewBeaconClient

func NewBeaconClient(endpoint string, config Config) (*beaconClient, error)

Types

type AllValidatorsResponse

type AllValidatorsResponse struct {
	Data []ValidatorResponseEntry
}

AllValidatorsResponse is the response for querying active validators

type AtomicState added in v0.3.0

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

func (*AtomicState) Beacon added in v0.3.0

func (as *AtomicState) Beacon() *structs.BeaconState

type BeaconClient

type BeaconClient interface {
	SubscribeToHeadEvents(ctx context.Context, slotC chan HeadEvent)
	GetProposerDuties(structs.Epoch) (*RegisteredProposersResponse, error)
	SyncStatus() (*SyncStatusPayloadData, error)
	KnownValidators(structs.Slot) (AllValidatorsResponse, error)
	Genesis() (structs.GenesisInfo, error)
	PublishBlock(block *types.SignedBeaconBlock) error
	Endpoint() string

	AttachMetrics(m *metrics.Metrics)
}

func NewMultiBeaconClient added in v0.1.2

func NewMultiBeaconClient(l log.Logger, clients []BeaconClient) BeaconClient

type BeaconMetrics added in v0.3.9

type BeaconMetrics struct {
	Timing *prometheus.HistogramVec
}

type Config

type Config struct {
	Log                      log.Logger
	BuilderURLs              []string
	Network                  string
	RelayRequestTimeout      time.Duration
	BuilderCheck             bool
	BeaconEndpoints          []string
	PubKey                   types.PublicKey
	SecretKey                *bls.SecretKey
	Datadir                  string
	TTL                      time.Duration
	RelayQueueProcessingSize uint64

	RelayHeaderMemorySlotLag       uint64
	RelayHeaderMemorySlotTimeLag   time.Duration
	RelayHeaderMemoryPurgeInterval time.Duration

	GenesisForkVersion    string
	GenesisValidatorsRoot string
	BellatrixForkVersion  string
	// contains filtered or unexported fields
}

Config provides all available options for the default BeaconClient and Relay

func (*Config) Validate added in v0.3.0

func (c *Config) Validate() error

type Datastore

type Datastore interface {
	GetRegistration(context.Context, structs.PubKey) (types.SignedValidatorRegistration, error)
}

type ErrBadProposer

type ErrBadProposer struct {
	Want, Got structs.PubKey
}

func (ErrBadProposer) Error

func (ErrBadProposer) Error() string

type GenesisResponse added in v0.2.7

type GenesisResponse struct {
	Data structs.GenesisInfo
}

type GetValidatorRelayResponse

type GetValidatorRelayResponse []struct {
	Slot  uint64 `json:"slot,string"`
	Entry struct {
		Message struct {
			FeeRecipient string `json:"fee_recipient"`
			GasLimit     uint64 `json:"gas_limit,string"`
			Timestamp    uint64 `json:"timestamp,string"`
			PubKey       string `json:"pubkey"`
		} `json:"message"`
		Signature string `json:"signature"`
	} `json:"entry"`
}

type HeadEvent

type HeadEvent struct {
	Slot  uint64 `json:"slot,string"`
	Block string `json:"block"`
	State string `json:"state"`
}

HeadEvent is emitted when subscribing to head events

func (HeadEvent) Loggable

func (h HeadEvent) Loggable() map[string]any

type MultiBeaconClient added in v0.1.2

type MultiBeaconClient struct {
	Log     log.Logger
	Clients []BeaconClient
	// contains filtered or unexported fields
}

func (*MultiBeaconClient) AttachMetrics added in v0.3.9

func (b *MultiBeaconClient) AttachMetrics(m *metrics.Metrics)

func (*MultiBeaconClient) Endpoint added in v0.1.2

func (b *MultiBeaconClient) Endpoint() string

func (*MultiBeaconClient) Genesis added in v0.2.7

func (b *MultiBeaconClient) Genesis() (genesisInfo structs.GenesisInfo, err error)

func (*MultiBeaconClient) GetProposerDuties added in v0.1.2

func (b *MultiBeaconClient) GetProposerDuties(epoch structs.Epoch) (*RegisteredProposersResponse, error)

func (*MultiBeaconClient) KnownValidators added in v0.1.2

func (b *MultiBeaconClient) KnownValidators(headSlot structs.Slot) (AllValidatorsResponse, error)

func (*MultiBeaconClient) PublishBlock added in v0.3.9

func (b *MultiBeaconClient) PublishBlock(block *types.SignedBeaconBlock) (err error)

func (*MultiBeaconClient) SubscribeToHeadEvents added in v0.1.2

func (b *MultiBeaconClient) SubscribeToHeadEvents(ctx context.Context, slotC chan HeadEvent)

func (*MultiBeaconClient) SyncStatus added in v0.1.2

func (b *MultiBeaconClient) SyncStatus() (*SyncStatusPayloadData, error)

type Network added in v0.2.4

type Network struct {
	GenesisForkVersion    string `json:"GenesisForkVersion"`
	GenesisValidatorsRoot string `json:"GenesisValidatorsRoot"`
	BellatrixForkVersion  string `json:"BellatrixForkVersion"`
}

type RegisteredProposersResponse

type RegisteredProposersResponse struct {
	Data []RegisteredProposersResponseData
}

RegisteredProposersResponse is the response for querying proposer duties

type RegisteredProposersResponseData

type RegisteredProposersResponseData struct {
	PubKey structs.PubKey `json:"pubkey"`
	Slot   uint64         `json:"slot,string"`
}

type Service added in v0.3.0

type Service struct {
	Log             log.Logger
	Config          Config
	Datastore       Datastore
	NewBeaconClient func() (BeaconClient, error)
	// contains filtered or unexported fields
}

func NewService added in v0.3.0

func NewService(l log.Logger, c Config, d Datastore, as *AtomicState) *Service

func (*Service) Ready added in v0.3.0

func (s *Service) Ready() <-chan struct{}

func (*Service) RunBeacon added in v0.3.0

func (s *Service) RunBeacon(ctx context.Context, client BeaconClient) error

type SyncStatusPayload

type SyncStatusPayload struct {
	Data SyncStatusPayloadData
}

SyncStatusPayload is the response payload for /eth/v1/node/syncing

type SyncStatusPayloadData

type SyncStatusPayloadData struct {
	HeadSlot  uint64 `json:"head_slot,string"`
	IsSyncing bool   `json:"is_syncing"`
}

type UserAgent

type UserAgent string

type ValidatorResponseEntry

type ValidatorResponseEntry struct {
	Index     uint64                         `json:"index,string"` // Index of validator in validator registry.
	Balance   string                         `json:"balance"`      // Current validator balance in gwei.
	Status    string                         `json:"status"`
	Validator ValidatorResponseValidatorData `json:"validator"`
}

type ValidatorResponseValidatorData

type ValidatorResponseValidatorData struct {
	Pubkey string `json:"pubkey"`
}

Directories

Path Synopsis
api
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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