Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeDomain(domainType types.DomainType, forkVersionHex string, ...) (domain types.Domain, err error)
- func DeliveredKey(key ds.Key) ds.Key
- func HeaderHashKey(bh types.Hash) ds.Key
- func HeaderKey(slot Slot) ds.Key
- func HeaderNumKey(bn uint64) ds.Key
- func HeaderPubkeyKey(pk types.PublicKey) ds.Key
- func PayloadKey(h types.Hash) 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 BidTraceWithTimestamp
- type BlockBidAndTrace
- type BuilderGetValidatorsResponseEntrySlice
- type Config
- type Datastore
- type DefaultDatastore
- func (s DefaultDatastore) GetHeader(ctx context.Context, slot Slot, delivered bool) (HeaderAndTrace, error)
- func (s DefaultDatastore) GetHeaderBatch(ctx context.Context, slots []Slot, delivered bool) ([]HeaderAndTrace, error)
- func (s DefaultDatastore) GetHeaderByBlockHash(ctx context.Context, bh types.Hash, delivered bool) (HeaderAndTrace, error)
- func (s DefaultDatastore) GetHeaderByBlockNum(ctx context.Context, bn uint64, delivered bool) (HeaderAndTrace, error)
- func (s DefaultDatastore) GetHeaderByPubkey(ctx context.Context, pk types.PublicKey, delivered bool) (HeaderAndTrace, error)
- func (s DefaultDatastore) GetPayload(ctx context.Context, h types.Hash) (*BlockBidAndTrace, error)
- func (s DefaultDatastore) GetRegistration(ctx context.Context, pk PubKey) (types.SignedValidatorRegistration, error)
- func (s DefaultDatastore) PutDelivered(ctx context.Context, slot Slot, 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, h types.Hash, 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, slot Slot) ([]BidTraceWithTimestamp, error)
- func (s *DefaultService) GetBlockReceivedByHash(ctx context.Context, bh types.Hash) ([]BidTraceWithTimestamp, error)
- func (s *DefaultService) GetBlockReceivedByNum(ctx context.Context, bn uint64) ([]BidTraceWithTimestamp, error)
- func (s *DefaultService) GetDelivered(ctx context.Context, slot Slot) ([]types.BidTrace, error)
- func (s *DefaultService) GetDeliveredByHash(ctx context.Context, bh types.Hash) ([]types.BidTrace, error)
- func (s *DefaultService) GetDeliveredByNum(ctx context.Context, bn uint64) ([]types.BidTrace, error)
- func (s *DefaultService) GetDeliveredByPubKey(ctx context.Context, pk types.PublicKey) ([]types.BidTrace, 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) GetTailBlockReceived(ctx context.Context, limit uint64) ([]BidTraceWithTimestamp, error)
- func (s *DefaultService) GetTailDelivered(ctx context.Context, limit uint64) ([]types.BidTrace, error)
- func (s *DefaultService) GetTailDeliveredCursor(ctx context.Context, limit, cursor uint64) ([]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 Epoch
- type ErrBadProposer
- type GetValidatorRelayResponse
- type HeadEvent
- type HeaderAndTrace
- type HeaderRequest
- type PubKey
- type RegisteredProposersResponse
- type RegisteredProposersResponseData
- type Relay
- type RelayService
- type Slot
- type State
- type SyncStatusPayload
- type SyncStatusPayloadData
- type TTLDatastoreBatcher
- type TTLStorage
- type UserAgent
- type ValidatorData
- 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.0"
)
Variables ¶
var ( SlotsPerEpoch Slot = 32 DurationPerSlot = time.Second * 12 DurationPerEpoch = DurationPerSlot * time.Duration(SlotsPerEpoch) ErrOldSlot = errors.New("old slot") )
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") UnregisteredValidatorMsg = "unregistered validator" )
var ErrHTTPErrorResponse = errors.New("got an HTTP error response")
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 HeaderNumKey ¶
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 received when querying the active validators
type BeaconClient ¶
type BeaconClient interface {
SubscribeToHeadEvents(context.Context) <-chan HeadEvent
GetProposerDuties(Epoch) (*RegisteredProposersResponse, error)
SyncStatus() (*SyncStatusPayloadData, error)
UpdateProposerDuties(context.Context, Slot, Datastore) error
ProcessNewSlot(context.Context, Slot, Datastore) error
GetProposerByIndex(uint64) (types.PubkeyHex, error)
GetValidatorsMap() BuilderGetValidatorsResponseEntrySlice
IsValidator(PubKey) bool
HeadSlot() Slot
}
func NewBeaconClient ¶
func NewBeaconClient(config Config) (BeaconClient, error)
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
BeaconEndpoint 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
PutDelivered(context.Context, Slot, time.Duration) error
GetHeader(context.Context, Slot, bool) (HeaderAndTrace, error)
GetHeaderBatch(context.Context, []Slot, bool) ([]HeaderAndTrace, error)
GetHeaderByBlockHash(context.Context, types.Hash, bool) (HeaderAndTrace, error)
GetHeaderByBlockNum(context.Context, uint64, bool) (HeaderAndTrace, error)
GetHeaderByPubkey(context.Context, types.PublicKey, bool) (HeaderAndTrace, error)
PutPayload(context.Context, types.Hash, *BlockBidAndTrace, time.Duration) error
GetPayload(context.Context, types.Hash) (*BlockBidAndTrace, error)
PutRegistration(context.Context, PubKey, types.SignedValidatorRegistration, time.Duration) error
GetRegistration(context.Context, PubKey) (types.SignedValidatorRegistration, error)
}
type DefaultDatastore ¶
type DefaultDatastore struct {
Storage TTLStorage
}
func (DefaultDatastore) GetHeader ¶
func (s DefaultDatastore) GetHeader(ctx context.Context, slot Slot, delivered bool) (HeaderAndTrace, error)
func (DefaultDatastore) GetHeaderBatch ¶
func (s DefaultDatastore) GetHeaderBatch(ctx context.Context, slots []Slot, delivered bool) ([]HeaderAndTrace, error)
func (DefaultDatastore) GetHeaderByBlockHash ¶
func (s DefaultDatastore) GetHeaderByBlockHash(ctx context.Context, bh types.Hash, delivered bool) (HeaderAndTrace, error)
func (DefaultDatastore) GetHeaderByBlockNum ¶
func (s DefaultDatastore) GetHeaderByBlockNum(ctx context.Context, bn uint64, delivered bool) (HeaderAndTrace, error)
func (DefaultDatastore) GetHeaderByPubkey ¶
func (s DefaultDatastore) GetHeaderByPubkey(ctx context.Context, pk types.PublicKey, delivered bool) (HeaderAndTrace, error)
func (DefaultDatastore) GetPayload ¶
func (s DefaultDatastore) GetPayload(ctx context.Context, h types.Hash) (*BlockBidAndTrace, error)
func (DefaultDatastore) GetRegistration ¶
func (s DefaultDatastore) GetRegistration(ctx context.Context, pk PubKey) (types.SignedValidatorRegistration, error)
func (DefaultDatastore) PutDelivered ¶
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, h types.Hash, 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, slot Slot) ([]BidTraceWithTimestamp, error)
func (*DefaultService) GetBlockReceivedByHash ¶
func (s *DefaultService) GetBlockReceivedByHash(ctx context.Context, bh types.Hash) ([]BidTraceWithTimestamp, error)
func (*DefaultService) GetBlockReceivedByNum ¶
func (s *DefaultService) GetBlockReceivedByNum(ctx context.Context, bn uint64) ([]BidTraceWithTimestamp, error)
func (*DefaultService) GetDelivered ¶
func (*DefaultService) GetDeliveredByHash ¶
func (*DefaultService) GetDeliveredByNum ¶
func (*DefaultService) GetDeliveredByPubKey ¶
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) GetTailBlockReceived ¶
func (s *DefaultService) GetTailBlockReceived(ctx context.Context, limit uint64) ([]BidTraceWithTimestamp, error)
func (*DefaultService) GetTailDelivered ¶
func (*DefaultService) GetTailDeliveredCursor ¶
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 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 on new slots in beacon client
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 RegisteredProposersResponse ¶
type RegisteredProposersResponse struct {
Data []RegisteredProposersResponseData
}
RegisteredProposersResponse is received when 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
GetDelivered(context.Context, Slot) ([]types.BidTrace, error)
GetDeliveredByHash(context.Context, types.Hash) ([]types.BidTrace, error)
GetDeliveredByNum(context.Context, uint64) ([]types.BidTrace, error)
GetDeliveredByPubKey(context.Context, types.PublicKey) ([]types.BidTrace, error)
GetTailDelivered(context.Context, uint64) ([]types.BidTrace, error)
GetTailDeliveredCursor(context.Context, uint64, uint64) ([]types.BidTrace, error)
GetBlockReceived(context.Context, Slot) ([]BidTraceWithTimestamp, error)
GetBlockReceivedByHash(context.Context, types.Hash) ([]BidTraceWithTimestamp, error)
GetBlockReceivedByNum(context.Context, uint64) ([]BidTraceWithTimestamp, error)
GetTailBlockReceived(context.Context, uint64) ([]BidTraceWithTimestamp, error)
Registration(context.Context, types.PublicKey) (types.SignedValidatorRegistration, error)
}
type State ¶
type State interface {
Datastore() Datastore
Beacon() BeaconClient
}
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 ValidatorData ¶
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"`
}