api

package
v0.34.5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: AGPL-3.0 Imports: 53 Imported by: 3

Documentation

Overview

Package api contains the API webserver for the proposer and block-builder APIs

Index

Constants

View Source
const (
	ErrBlockAlreadyKnown  = "simulation failed: block already known"
	ErrBlockRequiresReorg = "simulation failed: block requires a reorg"
	ErrMissingTrieNode    = "missing trie node"

	HeaderAccept              = "Accept"
	HeaderContentType         = "Content-Type"
	HeaderEthConsensusVersion = "Eth-Consensus-Version"
	HeaderDateMilliseconds    = "Date-Milliseconds"
	HeaderTimeoutMs           = "X-Timeout-Ms"

	HandleGetPayloadVersionV1 HandleGetPayloadVersion = "V1"
	HandleGetPayloadVersionV2 HandleGetPayloadVersion = "V2"
)

Variables

View Source
var (
	ErrRequestClosed    = errors.New("request context closed")
	ErrSimulationFailed = errors.New("simulation failed")
	ErrJSONDecodeFailed = errors.New("json error")
	ErrNoCapellaPayload = errors.New("capella payload is nil")
	ErrNoDenebPayload   = errors.New("deneb payload is nil")
	ErrNoElectraPayload = errors.New("electra payload is nil")
	ErrNoFuluPayload    = errors.New("fulu payload is nil")
)
View Source
var (
	ErrMissingLogOpt              = errors.New("log parameter is nil")
	ErrMissingBeaconClientOpt     = errors.New("beacon-client is nil")
	ErrMissingDatastoreOpt        = errors.New("proposer datastore is nil")
	ErrRelayPubkeyMismatch        = errors.New("relay pubkey does not match existing one")
	ErrServerAlreadyStarted       = errors.New("server was already started")
	ErrBuilderAPIWithoutSecretKey = errors.New("cannot start builder API without secret key")
	ErrInvalidForkVersion         = errors.New("invalid fork version")
)
View Source
var (
	ErrMissingRequest   = errors.New("req is nil")
	ErrMissingSecretKey = errors.New("secret key is nil")
	ErrEmptyPayload     = errors.New("nil payload")

	NilResponse = struct{}{}
	ZeroU256    = boostTypes.IntToU256(0)
)
View Source
var (
	ErrSlotNotFound                    = errors.New("slot not found in payload")
	ErrPayloadTooShortForMessageOffset = errors.New("payload too short to contain message offset")
	ErrPayloadTooShortForSlot          = errors.New("payload too short to contain slot at message offset")
)
View Source
var (
	ErrBlockHashMismatch  = errors.New("blockHash mismatch")
	ErrParentHashMismatch = errors.New("parentHash mismatch")

	ErrUnsupportedPayload   = errors.New("unsupported payload version")
	ErrNoWithdrawals        = errors.New("no withdrawals")
	ErrNoDepositRequests    = errors.New("no deposit receipts")
	ErrNoWithdrawalRequests = errors.New("no execution layer withdrawal requests")
	ErrPayloadMismatch      = errors.New("beacon-block and payload version mismatch")
	ErrHeaderHTRMismatch    = errors.New("beacon-block and payload header mismatch")
	ErrBlobMismatch         = errors.New("beacon-block and payload blob contents mismatch")
	ErrNotAcceptable        = errors.New("not acceptable")
)

Functions

func ComputeWithdrawalsRoot added in v0.20.0

func ComputeWithdrawalsRoot(w []*capella.Withdrawal) (phase0.Root, error)

func CurrentSlot added in v0.34.5

func CurrentSlot(genesisTime uint64, timestampMs int64) uint64

CurrentSlot returns the slot that the given unix millisecond timestamp falls into. Timestamps before genesis return slot 0.

func EqBlindedBlockContentsToBlockContents added in v0.29.0

func EqBlindedBlockContentsToBlockContents(bb *common.VersionedSignedBlindedBeaconBlock, payload *builderApi.VersionedSubmitBlindedBlockResponse) error

func NegotiateRequestResponseType added in v0.30.0

func NegotiateRequestResponseType(req *http.Request) (mimeType string, err error)

NegotiateRequestResponseType returns whether the request accepts JSON (application/json) or SSZ (application/octet-stream) responses. If accepted is false, no mime type could be negotiated and the server should respond with http.StatusNotAcceptable.

func SanityCheckBuilderBlockSubmission added in v0.14.0

func SanityCheckBuilderBlockSubmission(payload *common.VersionedSubmitBlockRequest) error

func SendJSONRPCRequest added in v0.7.0

func SendJSONRPCRequest(client *http.Client, req jsonrpc.JSONRPCRequest, url string, headers http.Header) (res *jsonrpc.JSONRPCResponse, requestErr, validationErr error)

SendJSONRPCRequest sends the request to URL and returns the general JsonRpcResponse, or an error (note: not the JSONRPCError)

Types

type BlockSimulationRateLimiter

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

func NewBlockSimulationRateLimiter

func NewBlockSimulationRateLimiter(blockSimURL string) *BlockSimulationRateLimiter

func (*BlockSimulationRateLimiter) CurrentCounter added in v0.20.0

func (b *BlockSimulationRateLimiter) CurrentCounter() int64

CurrentCounter returns the number of waiting and active requests

func (*BlockSimulationRateLimiter) Send added in v0.20.0

func (b *BlockSimulationRateLimiter) Send(
	context context.Context,
	payload *common.BuilderBlockValidationRequest,
	isHighPrio,
	fastTrack bool,
) (response *common.BuilderBlockValidationResponse, requestErr, validationErr error)

type HTTPErrorResp

type HTTPErrorResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type HTTPMessageResp added in v0.27.1

type HTTPMessageResp struct {
	Message string `json:"message"`
}

type HandleGetPayloadVersion added in v0.32.0

type HandleGetPayloadVersion string

type IBlockSimRateLimiter added in v0.24.0

type IBlockSimRateLimiter interface {
	Send(context context.Context, payload *common.BuilderBlockValidationRequest, isHighPrio, fastTrack bool) (*common.BuilderBlockValidationResponse, error, error)
	CurrentCounter() int64
}

type MockBlockSimulationRateLimiter added in v0.24.0

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

func (*MockBlockSimulationRateLimiter) CurrentCounter added in v0.24.0

func (m *MockBlockSimulationRateLimiter) CurrentCounter() int64

func (*MockBlockSimulationRateLimiter) Send added in v0.24.0

type RelayAPI

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

RelayAPI represents a single Relay instance

func NewRelayAPI

func NewRelayAPI(opts RelayAPIOpts) (api *RelayAPI, err error)

NewRelayAPI creates a new service. if builders is nil, allow any builder

func (*RelayAPI) IsReady added in v0.27.1

func (api *RelayAPI) IsReady() bool

func (*RelayAPI) Respond added in v0.20.0

func (api *RelayAPI) Respond(w http.ResponseWriter, code int, response any)

func (*RelayAPI) RespondError

func (api *RelayAPI) RespondError(w http.ResponseWriter, code int, message string)

func (*RelayAPI) RespondMsg added in v0.24.0

func (api *RelayAPI) RespondMsg(w http.ResponseWriter, code int, msg string)

func (*RelayAPI) RespondOK

func (api *RelayAPI) RespondOK(w http.ResponseWriter, response any)

func (*RelayAPI) StartServer

func (api *RelayAPI) StartServer() (err error)

StartServer starts up this API instance and HTTP server - First it initializes the cache and updates local information - Once that is done, the HTTP server is started

func (*RelayAPI) StopServer added in v0.9.1

func (api *RelayAPI) StopServer() (err error)

StopServer gracefully shuts down the HTTP server: - Stop returning bids - Set ready /readyz to negative status - Wait a bit to allow removal of service from load balancer and draining of requests

func (*RelayAPI) UpdateProposerDutiesWithoutChecks added in v0.30.0

func (api *RelayAPI) UpdateProposerDutiesWithoutChecks(headSlot uint64)

func (*RelayAPI) ValidatorUpdateCh added in v0.30.0

func (api *RelayAPI) ValidatorUpdateCh() chan struct{}

type RelayAPIOpts

type RelayAPIOpts struct {
	Log *logrus.Entry

	ListenAddr  string
	BlockSimURL string

	BeaconClient beaconclient.IMultiBeaconClient
	Datastore    *datastore.Datastore
	Redis        *datastore.RedisCache
	Memcached    *datastore.Memcached
	DB           database.IDatabaseService

	SecretKey *bls.SecretKey // used to sign bids (getHeader responses)

	// Network specific variables
	EthNetDetails common.EthNetworkDetails

	PprofListenAddr string

	// APIs to enable
	ProposerAPI     bool
	BlockBuilderAPI bool
	DataAPI         bool
	InternalAPI     bool
}

RelayAPIOpts contains the options for a relay

Jump to

Keyboard shortcuts

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