Documentation ¶
Index ¶
- Constants
- Variables
- func CheckKnownValidator(m *BoostService) mux.MiddlewareFunc
- func ComputeDomain(domainType types.DomainType, forkVersionHex string, ...) (domain types.Domain, err error)
- func ComputeWithdrawalsRoot(w []*capella.Withdrawal) (phase0.Root, error)
- func InitLogger(consoleLevelFlag, fileLevelFlag, fluentdHost, nodeID string, ...)
- func LogRequestID(m *BoostService) mux.MiddlewareFunc
- func NewLog(consoleLevelFlag, fileLevelFlag string, ...) (*logger.Config, error)
- func ReadAuthMetadata(ctx context.Context) (string, error)
- func SendHTTPRequest(ctx context.Context, client http.Client, method, url string, ...) (code int, err error)
- func SendJSONRPCRequest(ctx context.Context, req jsonrpc.JSONRPCRequest, url string) (res *jsonrpc.JSONRPCResponse, err error)
- func SignedBlindedBeaconBlockToBeaconBlock(signedBlindedBeaconBlock *capellaapi.SignedBlindedBeaconBlock, ...) *capella.SignedBeaconBlock
- type Auth
- type BestBlockFromRelay
- type BidTraceJSON
- type BidTraceWithTimestampJSON
- type BoostService
- func (m *BoostService) CheckRelays() bool
- func (m *BoostService) FetchKnownValidators() error
- func (m *BoostService) FetchPreviousData(slot uint64) error
- func (m *BoostService) GRPCAuthentication(ctx context.Context) (context.Context, error)
- func (m *BoostService) GetGenesis() (genesisInfo *GetGenesisResponse, err error)
- func (m *BoostService) GetPayloadResponseToBlockSubmission(payload *common.GetPayloadResponse) (*common.BuilderSubmitBlockRequest, error)
- func (m *BoostService) HandleSocketConnection(w http.ResponseWriter, r *http.Request)
- func (m *BoostService) SendCloudServicesHTTPRequest(ctx context.Context, client http.Client, payload any, dst any) (code int, err error)
- func (m *BoostService) StartActivityLogger(parent context.Context)
- func (m *BoostService) StartConfigFilesLoading()
- func (m *BoostService) StartFetchValidators()
- func (m *BoostService) StartHTTPServer() error
- func (m *BoostService) StartSaveBlocksPubSub()
- func (m *BoostService) StartSendNextSlotProposerDuties()
- func (m *BoostService) StartStats(fluentdHost, nodeID string)
- func (m *BoostService) SubmitBlock(ctx context.Context, block *relaygrpc.SubmitBlockRequest) (*relaygrpc.SubmitBlockResponse, error)
- func (m *BoostService) SubscribeToBlocks()
- func (m *BoostService) SubscribeToPayloadAttributes()
- func (m *BoostService) UpdateActiveValidators()
- type BoostServiceOpts
- type DeleteBidPayload
- type EndpointStats
- type GetGenesisResponse
- type Hash
- type HeaderResponse
- type HighPriorityBuilderData
- type PerformanceStats
- type PerformanceStatsRecord
- type ProvidedHeaders
- type PutRelayPayload
- type RPCRequestType
- type RelayEntry
- type RelayType
- type TrustedValidatorData
- type UserAgent
- type Validator
- type ValidatorData
- type ValidatorsResponse
Constants ¶
const (
AuthHeaderPrefix = "bearer "
)
const DateFormat = "2006-01-02T15:04:05.000000"
DateFormat is an example to date time string format
Variables ¶
var ( ErrRequestClosed = errors.New("request context closed") ErrSimulationFailed = errors.New("simulation failed") )
var AuthToken = "B71S@$742bS*$128#ldf1"
AuthToken used for authenticated endpoints
var ErrHTTPErrorResponse = errors.New("got an HTTP error response")
var ( // ErrMissingRelayPubkey is returned if a new RelayEntry URL has no public key ErrMissingRelayPubkey = fmt.Errorf("missing relay public key") )
var Version = "dev"
Version is used to get the version of the backend. It is set by the cli
Functions ¶
func CheckKnownValidator ¶
func CheckKnownValidator(m *BoostService) mux.MiddlewareFunc
CheckKnownValidator is a middleware function that checks the endpoint and service config to ensure whoever is requesting the endpoint is a known validator
func ComputeDomain ¶
func ComputeDomain(domainType types.DomainType, forkVersionHex string, genesisValidatorsRootHex string) (domain types.Domain, err error)
ComputeDomain computes the signing domain
func ComputeWithdrawalsRoot ¶
func ComputeWithdrawalsRoot(w []*capella.Withdrawal) (phase0.Root, error)
func InitLogger ¶
func InitLogger(consoleLevelFlag, fileLevelFlag, fluentdHost, nodeID string, fluentdEnabled bool, fileMaxSize, fileMaxAge, fileMaxBackups int)
InitLogger initializes a new bloxroute logger using logrus
func LogRequestID ¶
func LogRequestID(m *BoostService) mux.MiddlewareFunc
LogRequestID adds logging to the requests on the id parameter for the relay
func NewLog ¶
func NewLog(consoleLevelFlag, fileLevelFlag string, fileMaxSize, fileMaxAge, fileMaxBackups int) (*logger.Config, error)
NewLog builds new log configuration from the CLI context
func ReadAuthMetadata ¶
ReadAuthMetadata reads auth info from the RPC connection context
func SendHTTPRequest ¶
func SendHTTPRequest(ctx context.Context, client http.Client, method, url string, userAgent UserAgent, payload any, dst any) (code int, err error)
SendHTTPRequest - prepare and send HTTP request, marshaling the payload if any, and decoding the response if dst is set
func SendJSONRPCRequest ¶
func SendJSONRPCRequest(ctx context.Context, req jsonrpc.JSONRPCRequest, url string) (res *jsonrpc.JSONRPCResponse, err error)
SendJSONRPCRequest sends the request to URL and returns the general JsonRpcResponse, or an error (note: not the JSONRPCError)
func SignedBlindedBeaconBlockToBeaconBlock ¶
func SignedBlindedBeaconBlockToBeaconBlock(signedBlindedBeaconBlock *capellaapi.SignedBlindedBeaconBlock, executionPayload *capella.ExecutionPayload) *capella.SignedBeaconBlock
Types ¶
type BestBlockFromRelay ¶
type BidTraceJSON ¶
type BidTraceJSON struct { Slot uint64 `json:"slot,string"` ParentHash string `json:"parent_hash"` BlockHash string `json:"block_hash"` BuilderPubkey string `json:"builder_pubkey"` ProposerPubkey string `json:"proposer_pubkey"` ProposerFeeRecipient string `json:"proposer_fee_recipient"` GasLimit uint64 `json:"gas_limit,string"` GasUsed uint64 `json:"gas_used,string"` Value string `json:"value"` NumTx uint64 `json:"num_tx,string"` BlockNumber uint64 `json:"block_number,string"` }
BidTraceJSON is a struct used for the relay api
type BidTraceWithTimestampJSON ¶
type BidTraceWithTimestampJSON struct { BidTraceJSON TimestampMs int64 `json:"timestamp_ms,string,omitempty"` Timestamp int64 `json:"timestamp,string,omitempty"` }
BidTraceWithTimestampJSON is a struct used for the relay api
type BoostService ¶
type BoostService struct {
// contains filtered or unexported fields
}
BoostService TODO
func NewBoostService ¶
func NewBoostService(opts BoostServiceOpts) (*BoostService, error)
NewBoostService created a new BoostService
func (*BoostService) CheckRelays ¶
func (m *BoostService) CheckRelays() bool
CheckRelays sends a request to each one of the relays previously registered to get their status
func (*BoostService) FetchKnownValidators ¶
func (m *BoostService) FetchKnownValidators() error
FetchKnownValidators requests the validators from the provided beacon node and stores them in the knownValidators variable
func (*BoostService) FetchPreviousData ¶
func (m *BoostService) FetchPreviousData(slot uint64) error
func (*BoostService) GRPCAuthentication ¶
func (*BoostService) GetGenesis ¶
func (m *BoostService) GetGenesis() (genesisInfo *GetGenesisResponse, err error)
GetGenesis returns the genesis info - https://ethereum.github.io/beacon-APIs/#/Beacon/getGenesis
func (*BoostService) GetPayloadResponseToBlockSubmission ¶
func (m *BoostService) GetPayloadResponseToBlockSubmission(payload *common.GetPayloadResponse) (*common.BuilderSubmitBlockRequest, error)
func (*BoostService) HandleSocketConnection ¶
func (m *BoostService) HandleSocketConnection(w http.ResponseWriter, r *http.Request)
func (*BoostService) SendCloudServicesHTTPRequest ¶
func (m *BoostService) SendCloudServicesHTTPRequest(ctx context.Context, client http.Client, payload any, dst any) (code int, err error)
SendCloudServicesHTTPRequest - prepare and send HTTP request, marshaling the payload if any, and decoding the response if dst is set
func (*BoostService) StartActivityLogger ¶
func (m *BoostService) StartActivityLogger(parent context.Context)
StartActivityLogger starts a loop that outputs validator request logs every 30 minutes and relay general performance every 1 minute
func (*BoostService) StartConfigFilesLoading ¶
func (m *BoostService) StartConfigFilesLoading()
StartConfigFilesLoading loads data from config files continuously based on 'configFilesUpdateInterval'
func (*BoostService) StartFetchValidators ¶
func (m *BoostService) StartFetchValidators()
StartFetchValidators runs a loop to fetch all validators every 60 minutes
func (*BoostService) StartHTTPServer ¶
func (m *BoostService) StartHTTPServer() error
StartHTTPServer starts the HTTP server for this boost service instance
func (*BoostService) StartSaveBlocksPubSub ¶
func (m *BoostService) StartSaveBlocksPubSub()
func (*BoostService) StartSendNextSlotProposerDuties ¶
func (m *BoostService) StartSendNextSlotProposerDuties()
StartSendNextSlotProposerDuties runs a loop to send next slot proposer duties to cloud services on slot start time
func (*BoostService) StartStats ¶
func (m *BoostService) StartStats(fluentdHost, nodeID string)
StartStats adds the fluentDStats data to the service
func (*BoostService) SubmitBlock ¶
func (m *BoostService) SubmitBlock(ctx context.Context, block *relaygrpc.SubmitBlockRequest) (*relaygrpc.SubmitBlockResponse, error)
func (*BoostService) SubscribeToBlocks ¶
func (m *BoostService) SubscribeToBlocks()
SubscribeToBlocks subscribes to new block events from the beacon node
func (*BoostService) SubscribeToPayloadAttributes ¶
func (m *BoostService) SubscribeToPayloadAttributes()
SubscribeToPayloadAttributes subscribes to new block events from the beacon node
func (*BoostService) UpdateActiveValidators ¶
func (m *BoostService) UpdateActiveValidators()
type BoostServiceOpts ¶
type BoostServiceOpts struct { Log *logrus.Entry ListenAddr string Relays []RelayEntry GenesisForkVersionHex string BellatrixForkVersionHex string CapellaForkVersionHex string GenesisValidatorRootHex string RelayRequestTimeout time.Duration RelayCheck bool MaxHeaderBytes int IsRelay bool SecretKey *blst.SecretKey PubKey types.PublicKey BeaconNode string ExecutionNode url.URL BeaconChain url.URL Etherscan url.URL KnownValidators string CheckKnownValidators bool BuilderIPs string HighPriorityBuilderPubkeys *syncmap.SyncMap[string, bool] HighPerfSimBuilderPubkeys *syncmap.SyncMap[string, bool] DB database.IDatabaseService RedisURI string RedisPrefix string SDNURL string CertificatesPath string SimulationNodes string SimulationNodeHighPerf string CloudServicesEndpoint string CloudServicesAuthHeader string SendSlotProposerDuties bool RelayType RelayType RedisPoolSize int TopBlockLimit int ExternalRelaysForComparison []string GetPayloadRequestCutoffMs int GetHeaderRequestCutoffMs int CapellaForkEpoch int64 EnableBidSaveCancellation bool Tracer trace.Tracer TrustedValidatorBearerTokens *syncmap.SyncMap[string, struct{}] }
BoostServiceOpts provides all available options for use with NewBoostService
type DeleteBidPayload ¶
type DeleteBidPayload struct { Slot uint64 `json:"slot"` Pubkey string `json:"pubkey"` BlockHashes []string `json:"blockHashes"` ParentHash string `json:"parentHash"` }
DeleteBidPayload models the request payload used to delete bids from the datastore
type EndpointStats ¶
type EndpointStats struct { CountSuccesses int `json:"count_successes"` CountFails int `json:"count_fails"` TotalDuration uint64 `json:"total_duration"` MaxDuration uint64 `json:"max_duration"` }
EndpointStats has statistics on an endpoint
type GetGenesisResponse ¶
type GetGenesisResponse struct { Data struct { GenesisTime uint64 `json:"genesis_time,string"` GenesisValidatorsRoot string `json:"genesis_validators_root"` GenesisForkVersion string `json:"genesis_fork_version"` } }
func GetGenesis ¶
func GetGenesis(url string) (*GetGenesisResponse, error)
GetGenesis returns the genesis info - https://ethereum.github.io/beacon-APIs/#/Beacon/getGenesis
type Hash ¶
type Hash interface { // Write (via the embedded io.Writer interface) adds more data to the running hash. // It never returns an error. io.Writer // Sum appends the current hash to b and returns the resulting slice. // It does not change the underlying hash state. Sum(b []byte) []byte // Reset resets the Hash to its initial state. Reset() // Size returns the number of bytes Sum will return. Size() int // BlockSize returns the hash's underlying block size. // The Write method must be able to accept any amount // of data, but it may operate more efficiently if all writes // are a multiple of the block size. BlockSize() int }
type HeaderResponse ¶
type HeaderResponse struct {
Data []headerData `json:"data"`
}
HeaderResponse models the header response
type HighPriorityBuilderData ¶
type HighPriorityBuilderData struct { Pubkeys map[string]bool `json:"high_priority_builder_pubkeys"` AccountIds map[string]bool `json:"high_priority_builder_account_ids"` PubkeysToSkipSimulationThreshold map[string]float64 `json:"high_priority_builder_pubkeys_to_skip_simulation_threshold"` AccountIdsToSkipSimulationThreshold map[string]float64 `json:"high_priority_builder_account_ids_to_skip_simulation_threshold"` UltraTierAccIDs map[string]bool `json:"ultra_tier_builder_account_ids"` NoRateLimitAccIDs map[string]bool `json:"no_rate_limit_builder_account_ids"` }
type PerformanceStats ¶
type PerformanceStats struct {
// contains filtered or unexported fields
}
PerformanceStats has statistics in an interval on selected endpoints
func NewPerformanceStats ¶
func NewPerformanceStats() PerformanceStats
NewPerformanceStats creates the PerformanceStats
func (*PerformanceStats) CloseInterval ¶
func (p *PerformanceStats) CloseInterval(endTime time.Time) PerformanceStatsRecord
CloseInterval closes an interval and return the bloxroute stats record
func (*PerformanceStats) SetEndpointStats ¶
func (p *PerformanceStats) SetEndpointStats(endpoint string, duration uint64, success bool)
SetEndpointStats updates usage statistics of an endpoint
type PerformanceStatsRecord ¶
type PerformanceStatsRecord struct { StartTime string `json:"start_timestamp"` EndTime string `json:"end_timestamp"` EndpointsStats map[string]*EndpointStats `json:"endpoints_stats"` }
PerformanceStatsRecord has the bloxroute stats record
type ProvidedHeaders ¶
type ProvidedHeaders struct { Headers []*common.GetHeaderResponse ProposerPublicKey string }
type PutRelayPayload ¶
type PutRelayPayload struct {
URL string `json:"url"`
}
PutRelayPayload models the payload for the PUT request
type RPCRequestType ¶
type RPCRequestType string
RPCRequestType represents the JSON-RPC methods that are callable
const ( RPCMEVBlock RPCRequestType = "mev_block" RPCProposerSlot RPCRequestType = "proposer_slot" )
RPCRequestType enumeration
type RelayEntry ¶
RelayEntry represents a relay that mev-boost connects to.
func NewRelayEntry ¶
func NewRelayEntry(relayURL string) (entry RelayEntry, err error)
NewRelayEntry creates a new instance based on an input string relayURL can be IP@PORT, PUBKEY@IP:PORT, https://IP, etc.
func (*RelayEntry) GetURI ¶
func (r *RelayEntry) GetURI(path string) string
GetURI returns the full request URI with scheme, host, path and args.
func (*RelayEntry) String ¶
func (r *RelayEntry) String() string
type TrustedValidatorData ¶
type TrustedValidatorData struct {
TrustedValidatorBearerTokens map[string]struct{} `json:"trusted_validator_bearer_tokens"`
}
type UserAgent ¶
type UserAgent string
UserAgent is a custom string type to avoid confusing url + userAgent parameters in SendHTTPRequest
type Validator ¶
type Validator struct { Pubkey string `json:"pubkey"` WithdrawalCredentials string `json:"withdrawal_credentials"` EffectiveBalance string `json:"effective_balance"` Slashed bool `json:"slashed"` ActivationEligibilityEpoch string `json:"activation_eligibility_epoch"` ActivationEpoch string `json:"activation_epoch"` ExitEpoch string `json:"exit_epoch"` WithdrawableEpoch string `json:"withdrawable_epoch"` }
Validator models the validator data
type ValidatorData ¶
type ValidatorData struct { Index string `json:"index"` Balance string `json:"balance"` Status string `json:"status"` Validator Validator `json:"validator"` }
ValidatorData represents the data returned from beacon's validator endpoint
type ValidatorsResponse ¶
type ValidatorsResponse struct {
Data []ValidatorData `json:"data"`
}
ValidatorsResponse models the response from the beacon node when fetching validators