Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeDomain(domainType types.DomainType, forkVersionHex string, ...) (domain types.Domain, err error)
- func DeliveredHashKey(bh types.Hash) ds.Key
- func DeliveredKey(slot Slot) ds.Key
- func DeliveredNumKey(bn uint64) ds.Key
- func DeliveredPubkeyKey(pk types.PublicKey) ds.Key
- func HeaderHashKey(bh types.Hash) ds.Key
- func HeaderKey(slot Slot) ds.Key
- func HeaderNumKey(bn uint64) ds.Key
- func Max[T constraints.Ordered](args ...T) T
- func NewBeaconClient(endpoint string, config Config) (*beaconClient, error)
- func PayloadKeyKey(key PayloadKey) ds.Key
- func RegistrationKey(pk PubKey) ds.Key
- func SubmitBlockRequestToSignedBuilderBid(req *types.BuilderSubmitBlockRequest, sk *bls.SecretKey, ...) (*types.SignedBuilderBid, error)
- func ValidatorKey(pk PubKey) ds.Key
- type API
- type AllValidatorsResponse
- type BeaconClient
- type BeaconState
- type BidTraceWithTimestamp
- type BlockBidAndTrace
- type BuilderGetValidatorsResponseEntrySlice
- type Config
- type Datastore
- type DefaultDatastore
- func (s *DefaultDatastore) GetDelivered(ctx context.Context, query Query) (BidTraceWithTimestamp, error)
- func (s *DefaultDatastore) GetDeliveredBatch(ctx context.Context, queries []Query) ([]BidTraceWithTimestamp, error)
- func (s *DefaultDatastore) GetHeaderBatch(ctx context.Context, queries []Query) ([]HeaderAndTrace, error)
- func (s *DefaultDatastore) GetHeaders(ctx context.Context, query Query) ([]HeaderAndTrace, error)
- func (s *DefaultDatastore) GetPayload(ctx context.Context, key PayloadKey) (*BlockBidAndTrace, error)
- func (s *DefaultDatastore) GetRegistration(ctx context.Context, pk PubKey) (types.SignedValidatorRegistration, error)
- func (s *DefaultDatastore) PutDelivered(ctx context.Context, slot Slot, trace DeliveredTrace, ttl time.Duration) error
- func (s *DefaultDatastore) PutHeader(ctx context.Context, slot Slot, header HeaderAndTrace, ttl time.Duration) error
- func (s *DefaultDatastore) PutPayload(ctx context.Context, key PayloadKey, payload *BlockBidAndTrace, ...) error
- func (s *DefaultDatastore) PutRegistration(ctx context.Context, pk PubKey, registration types.SignedValidatorRegistration, ...) error
- type DefaultRelay
- func (rs *DefaultRelay) GetHeader(ctx context.Context, request HeaderRequest, state State) (*types.GetHeaderResponse, error)
- func (rs *DefaultRelay) GetPayload(ctx context.Context, payloadRequest *types.SignedBlindedBeaconBlock, ...) (*types.GetPayloadResponse, error)
- func (rs *DefaultRelay) GetValidators(state State) BuilderGetValidatorsResponseEntrySlice
- func (rs *DefaultRelay) Log() log.Logger
- func (rs *DefaultRelay) RegisterValidator(ctx context.Context, payload []types.SignedValidatorRegistration, state State) error
- func (rs *DefaultRelay) SubmitBlock(ctx context.Context, submitBlockRequest *types.BuilderSubmitBlockRequest, ...) error
- type DefaultService
- func (s *DefaultService) GetBlockReceived(ctx context.Context, query TraceQuery) ([]BidTraceWithTimestamp, error)
- func (s *DefaultService) GetHeader(ctx context.Context, request HeaderRequest) (*types.GetHeaderResponse, error)
- func (s *DefaultService) GetPayload(ctx context.Context, payloadRequest *types.SignedBlindedBeaconBlock) (*types.GetPayloadResponse, error)
- func (s *DefaultService) GetPayloadDelivered(ctx context.Context, query TraceQuery) ([]types.BidTrace, error)
- func (s *DefaultService) GetValidators() BuilderGetValidatorsResponseEntrySlice
- func (s *DefaultService) Ready() <-chan struct{}
- func (s *DefaultService) RegisterValidator(ctx context.Context, payload []types.SignedValidatorRegistration) error
- func (s *DefaultService) Registration(ctx context.Context, pk types.PublicKey) (types.SignedValidatorRegistration, error)
- func (s *DefaultService) Run(ctx context.Context) (err error)
- func (s *DefaultService) SubmitBlock(ctx context.Context, submitBlockRequest *types.BuilderSubmitBlockRequest) error
- type DeliveredTrace
- type Epoch
- type ErrBadProposer
- type GetValidatorRelayResponse
- type HeadEvent
- type HeaderAndTrace
- type HeaderRequest
- type MultiBeaconClient
- func (b *MultiBeaconClient) Endpoint() string
- func (b *MultiBeaconClient) GetProposerDuties(epoch Epoch) (*RegisteredProposersResponse, error)
- func (b *MultiBeaconClient) KnownValidators(headSlot Slot) (AllValidatorsResponse, error)
- func (b *MultiBeaconClient) SubscribeToHeadEvents(ctx context.Context, slotC chan HeadEvent)
- func (b *MultiBeaconClient) SyncStatus() (*SyncStatusPayloadData, error)
- type PayloadKey
- type PubKey
- type Query
- type RegisteredProposersResponse
- type RegisteredProposersResponseData
- type Relay
- type RelayService
- type Slot
- type State
- type SyncStatusPayload
- type SyncStatusPayloadData
- type TTLDatastoreBatcher
- type TTLStorage
- type TraceQuery
- type UserAgent
- type ValidatorResponseEntry
- type ValidatorResponseValidatorData
Constants ¶
const ( // proposer endpoints PathStatus = "/eth/v1/builder/status" PathRegisterValidator = "/eth/v1/builder/validators" PathGetHeader = "/eth/v1/builder/header/{slot:[0-9]+}/{parent_hash:0x[a-fA-F0-9]+}/{pubkey:0x[a-fA-F0-9]+}" PathGetPayload = "/eth/v1/builder/blinded_blocks" // builder endpoints PathGetValidators = "/relay/v1/builder/validators" PathSubmitBlock = "/relay/v1/builder/blocks" // data api PathBuilderBlocksReceived = "/relay/v1/data/bidtraces/builder_blocks_received" PathProposerPayloadsDelivered = "/relay/v1/data/bidtraces/proposer_payload_delivered" PathSpecificRegistration = "/relay/v1/data/validator_registration" // tracing PathPprofIndex = "/debug/pprof/" PathPprofCmdline = "/debug/pprof/cmdline" PathPprofSymbol = "/debug/pprof/symbol" PathPprofTrace = "/debug/pprof/trace" PathPprofProfile = "/debug/pprof/profile" )
Router paths
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" )
const (
Version = "0.1.3"
)
Variables ¶
var ( SlotsPerEpoch Slot = 32 DurationPerSlot = time.Second * 12 DurationPerEpoch = DurationPerSlot * time.Duration(SlotsPerEpoch) ErrHTTPErrorResponse = errors.New("got an HTTP error response") )
var ( ErrNoPayloadFound = errors.New("no payload found") ErrBeaconNodeSyncing = errors.New("beacon node is syncing") ErrMissingRequest = errors.New("req is nil") ErrMissingSecretKey = errors.New("secret key is nil") ErrUnknownValue = errors.New("value is unknown") UnregisteredValidatorMsg = "unregistered validator" )
var (
ErrParamNotFound = errors.New("not found")
)
Functions ¶
func ComputeDomain ¶
func ComputeDomain(domainType types.DomainType, forkVersionHex string, genesisValidatorsRootHex string) (domain types.Domain, err error)
ComputeDomain computes the signing domain
func DeliveredKey ¶
func DeliveredNumKey ¶ added in v0.1.3
func HeaderNumKey ¶
func Max ¶ added in v0.1.5
func Max[T constraints.Ordered](args ...T) T
func NewBeaconClient ¶
func PayloadKeyKey ¶ added in v0.1.2
func PayloadKeyKey(key PayloadKey) ds.Key
func RegistrationKey ¶
func SubmitBlockRequestToSignedBuilderBid ¶
func SubmitBlockRequestToSignedBuilderBid(req *types.BuilderSubmitBlockRequest, sk *bls.SecretKey, pubkey *types.PublicKey, domain types.Domain) (*types.SignedBuilderBid, error)
SubmitBlockRequestToSignedBuilderBid converts a builders block submission to a bid compatible with mev-boost
func ValidatorKey ¶
Types ¶
type API ¶
type API struct { Service RelayService Log log.Logger EnableProfile bool // contains filtered or unexported fields }
type AllValidatorsResponse ¶
type AllValidatorsResponse struct {
Data []ValidatorResponseEntry
}
AllValidatorsResponse is the response for querying active validators
type BeaconClient ¶
type BeaconClient interface { SubscribeToHeadEvents(ctx context.Context, slotC chan HeadEvent) GetProposerDuties(Epoch) (*RegisteredProposersResponse, error) SyncStatus() (*SyncStatusPayloadData, error) KnownValidators(Slot) (AllValidatorsResponse, error) Endpoint() string }
func NewMultiBeaconClient ¶ added in v0.1.2
func NewMultiBeaconClient(l log.Logger, clients []BeaconClient) BeaconClient
type BeaconState ¶ added in v0.1.2
type BidTraceWithTimestamp ¶
type BlockBidAndTrace ¶
type BlockBidAndTrace struct { Trace *types.SignedBidTrace Bid *types.GetHeaderResponse Payload *types.GetPayloadResponse }
func SubmitBlockRequestToBlockBidAndTrace ¶
func SubmitBlockRequestToBlockBidAndTrace(signedBuilderBid *types.SignedBuilderBid, submitBlockRequest *types.BuilderSubmitBlockRequest) BlockBidAndTrace
type BuilderGetValidatorsResponseEntrySlice ¶
type BuilderGetValidatorsResponseEntrySlice []types.BuilderGetValidatorsResponseEntry
func (BuilderGetValidatorsResponseEntrySlice) Loggable ¶
func (b BuilderGetValidatorsResponseEntrySlice) Loggable() map[string]any
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 CheckKnownValidator bool // contains filtered or unexported fields }
Config provides all available options for the default BeaconClient and Relay
type Datastore ¶
type Datastore interface { PutHeader(context.Context, Slot, HeaderAndTrace, time.Duration) error GetHeaders(context.Context, Query) ([]HeaderAndTrace, error) GetHeaderBatch(context.Context, []Query) ([]HeaderAndTrace, error) PutDelivered(context.Context, Slot, DeliveredTrace, time.Duration) error GetDelivered(context.Context, Query) (BidTraceWithTimestamp, error) GetDeliveredBatch(context.Context, []Query) ([]BidTraceWithTimestamp, error) PutPayload(context.Context, PayloadKey, *BlockBidAndTrace, time.Duration) error GetPayload(context.Context, PayloadKey) (*BlockBidAndTrace, error) PutRegistration(context.Context, PubKey, types.SignedValidatorRegistration, time.Duration) error GetRegistration(context.Context, PubKey) (types.SignedValidatorRegistration, error) }
type DefaultDatastore ¶
type DefaultDatastore struct { TTLStorage // contains filtered or unexported fields }
func (*DefaultDatastore) GetDelivered ¶ added in v0.1.3
func (s *DefaultDatastore) GetDelivered(ctx context.Context, query Query) (BidTraceWithTimestamp, error)
func (*DefaultDatastore) GetDeliveredBatch ¶ added in v0.1.3
func (s *DefaultDatastore) GetDeliveredBatch(ctx context.Context, queries []Query) ([]BidTraceWithTimestamp, error)
func (*DefaultDatastore) GetHeaderBatch ¶
func (s *DefaultDatastore) GetHeaderBatch(ctx context.Context, queries []Query) ([]HeaderAndTrace, error)
func (*DefaultDatastore) GetHeaders ¶ added in v0.1.5
func (s *DefaultDatastore) GetHeaders(ctx context.Context, query Query) ([]HeaderAndTrace, error)
func (*DefaultDatastore) GetPayload ¶
func (s *DefaultDatastore) GetPayload(ctx context.Context, key PayloadKey) (*BlockBidAndTrace, error)
func (*DefaultDatastore) GetRegistration ¶
func (s *DefaultDatastore) GetRegistration(ctx context.Context, pk PubKey) (types.SignedValidatorRegistration, error)
func (*DefaultDatastore) PutDelivered ¶
func (s *DefaultDatastore) PutDelivered(ctx context.Context, slot Slot, trace DeliveredTrace, ttl time.Duration) error
func (*DefaultDatastore) PutHeader ¶
func (s *DefaultDatastore) PutHeader(ctx context.Context, slot Slot, header HeaderAndTrace, ttl time.Duration) error
func (*DefaultDatastore) PutPayload ¶
func (s *DefaultDatastore) PutPayload(ctx context.Context, key PayloadKey, payload *BlockBidAndTrace, ttl time.Duration) error
func (*DefaultDatastore) PutRegistration ¶
func (s *DefaultDatastore) PutRegistration(ctx context.Context, pk PubKey, registration types.SignedValidatorRegistration, ttl time.Duration) error
type DefaultRelay ¶
type DefaultRelay struct {
// contains filtered or unexported fields
}
func (*DefaultRelay) GetHeader ¶
func (rs *DefaultRelay) GetHeader(ctx context.Context, request HeaderRequest, state State) (*types.GetHeaderResponse, error)
GetHeader is called by a block proposer communicating through mev-boost and returns a bid along with an execution payload header
func (*DefaultRelay) GetPayload ¶
func (rs *DefaultRelay) GetPayload(ctx context.Context, payloadRequest *types.SignedBlindedBeaconBlock, state State) (*types.GetPayloadResponse, error)
GetPayload is called by a block proposer communicating through mev-boost and reveals execution payload of given signed beacon block if stored
func (*DefaultRelay) GetValidators ¶
func (rs *DefaultRelay) GetValidators(state State) BuilderGetValidatorsResponseEntrySlice
GetValidators returns a list of registered block proposers in current and next epoch
func (*DefaultRelay) Log ¶
func (rs *DefaultRelay) Log() log.Logger
func (*DefaultRelay) RegisterValidator ¶
func (rs *DefaultRelay) RegisterValidator(ctx context.Context, payload []types.SignedValidatorRegistration, state State) error
RegisterValidator is called is called by validators communicating through mev-boost who would like to receive a block from us when their slot is scheduled
func (*DefaultRelay) SubmitBlock ¶
func (rs *DefaultRelay) SubmitBlock(ctx context.Context, submitBlockRequest *types.BuilderSubmitBlockRequest, state State) error
SubmitBlock Accepts block from trusted builder and stores
type DefaultService ¶
type DefaultService struct { Log log.Logger Config Config Relay Relay Storage TTLStorage Datastore Datastore NewBeaconClient func() (BeaconClient, error) // contains filtered or unexported fields }
func (*DefaultService) GetBlockReceived ¶
func (s *DefaultService) GetBlockReceived(ctx context.Context, query TraceQuery) ([]BidTraceWithTimestamp, error)
func (*DefaultService) GetHeader ¶
func (s *DefaultService) GetHeader(ctx context.Context, request HeaderRequest) (*types.GetHeaderResponse, error)
func (*DefaultService) GetPayload ¶
func (s *DefaultService) GetPayload(ctx context.Context, payloadRequest *types.SignedBlindedBeaconBlock) (*types.GetPayloadResponse, error)
func (*DefaultService) GetPayloadDelivered ¶ added in v0.1.5
func (s *DefaultService) GetPayloadDelivered(ctx context.Context, query TraceQuery) ([]types.BidTrace, error)
func (*DefaultService) GetValidators ¶
func (s *DefaultService) GetValidators() BuilderGetValidatorsResponseEntrySlice
func (*DefaultService) Ready ¶
func (s *DefaultService) Ready() <-chan struct{}
func (*DefaultService) RegisterValidator ¶
func (s *DefaultService) RegisterValidator(ctx context.Context, payload []types.SignedValidatorRegistration) error
func (*DefaultService) Registration ¶
func (s *DefaultService) Registration(ctx context.Context, pk types.PublicKey) (types.SignedValidatorRegistration, error)
func (*DefaultService) Run ¶
func (s *DefaultService) Run(ctx context.Context) (err error)
Run creates a relay, datastore and starts the beacon client event loop
func (*DefaultService) SubmitBlock ¶
func (s *DefaultService) SubmitBlock(ctx context.Context, submitBlockRequest *types.BuilderSubmitBlockRequest) error
type DeliveredTrace ¶ added in v0.1.3
type DeliveredTrace struct { Trace BidTraceWithTimestamp BlockNumber uint64 }
type ErrBadProposer ¶
type ErrBadProposer struct {
Want, Got PubKey
}
func (ErrBadProposer) Error ¶
func (ErrBadProposer) Error() string
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
type HeaderAndTrace ¶
type HeaderAndTrace struct { Header *types.ExecutionPayloadHeader Trace *BidTraceWithTimestamp }
type HeaderRequest ¶
func ParseHeaderRequest ¶
func ParseHeaderRequest(r *http.Request) HeaderRequest
func (HeaderRequest) Slot ¶
func (hr HeaderRequest) Slot() (Slot, error)
type MultiBeaconClient ¶ added in v0.1.2
type MultiBeaconClient struct { Log log.Logger Clients []BeaconClient // contains filtered or unexported fields }
func (*MultiBeaconClient) Endpoint ¶ added in v0.1.2
func (b *MultiBeaconClient) Endpoint() string
func (*MultiBeaconClient) GetProposerDuties ¶ added in v0.1.2
func (b *MultiBeaconClient) GetProposerDuties(epoch Epoch) (*RegisteredProposersResponse, error)
func (*MultiBeaconClient) KnownValidators ¶ added in v0.1.2
func (b *MultiBeaconClient) KnownValidators(headSlot Slot) (AllValidatorsResponse, 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 PayloadKey ¶
func SubmissionToKey ¶ added in v0.1.2
func SubmissionToKey(submission *types.BuilderSubmitBlockRequest) PayloadKey
type RegisteredProposersResponse ¶
type RegisteredProposersResponse struct {
Data []RegisteredProposersResponseData
}
RegisteredProposersResponse is the response for querying proposer duties
type Relay ¶
type Relay interface { // Proposer APIs RegisterValidator(context.Context, []types.SignedValidatorRegistration, State) error GetHeader(context.Context, HeaderRequest, State) (*types.GetHeaderResponse, error) GetPayload(context.Context, *types.SignedBlindedBeaconBlock, State) (*types.GetPayloadResponse, error) // Builder APIs SubmitBlock(context.Context, *types.BuilderSubmitBlockRequest, State) error GetValidators(State) BuilderGetValidatorsResponseEntrySlice }
type RelayService ¶
type RelayService interface { // Proposer APIs (builder spec https://github.com/ethereum/builder-specs) RegisterValidator(context.Context, []types.SignedValidatorRegistration) error GetHeader(context.Context, HeaderRequest) (*types.GetHeaderResponse, error) GetPayload(context.Context, *types.SignedBlindedBeaconBlock) (*types.GetPayloadResponse, error) // Builder APIs (relay spec https://flashbots.notion.site/Relay-API-Spec-5fb0819366954962bc02e81cb33840f5) SubmitBlock(context.Context, *types.BuilderSubmitBlockRequest) error GetValidators() BuilderGetValidatorsResponseEntrySlice // Data APIs GetPayloadDelivered(context.Context, TraceQuery) ([]types.BidTrace, error) GetBlockReceived(context.Context, TraceQuery) ([]BidTraceWithTimestamp, error) Registration(context.Context, types.PublicKey) (types.SignedValidatorRegistration, error) }
type State ¶
type State interface { Datastore() Datastore Beacon() BeaconState }
type SyncStatusPayload ¶
type SyncStatusPayload struct {
Data SyncStatusPayloadData
}
SyncStatusPayload is the response payload for /eth/v1/node/syncing
type SyncStatusPayloadData ¶
type TTLDatastoreBatcher ¶
type TTLDatastoreBatcher struct {
ds.TTLDatastore
}
type TTLStorage ¶
type TraceQuery ¶ added in v0.1.5
type TraceQuery struct { Slot Slot BlockHash types.Hash BlockNum uint64 Pubkey types.PublicKey Cursor, Limit uint64 }
func (TraceQuery) HasBlockHash ¶ added in v0.1.5
func (q TraceQuery) HasBlockHash() bool
func (TraceQuery) HasBlockNum ¶ added in v0.1.5
func (q TraceQuery) HasBlockNum() bool
func (TraceQuery) HasCursor ¶ added in v0.1.5
func (q TraceQuery) HasCursor() bool
func (TraceQuery) HasLimit ¶ added in v0.1.5
func (q TraceQuery) HasLimit() bool
func (TraceQuery) HasPubkey ¶ added in v0.1.5
func (q TraceQuery) HasPubkey() bool
func (TraceQuery) HasSlot ¶ added in v0.1.5
func (q TraceQuery) HasSlot() bool
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"`
}