Documentation ¶
Overview ¶
Package api contains the API webserver for the proposer and block-builder APIs
Index ¶
- Constants
- Variables
- func ComputeWithdrawalsRoot(w []*capella.Withdrawal) (phase0.Root, error)
- func EqBlindedBlockContentsToBlockContents(bb *common.VersionedSignedBlindedBlockRequest, ...) error
- func SanityCheckBuilderBlockSubmission(payload *common.VersionedSubmitBlockRequest) error
- func SendJSONRPCRequest(client *http.Client, req jsonrpc.JSONRPCRequest, url string, ...) (res *jsonrpc.JSONRPCResponse, requestErr, validationErr error)
- type BlockSimulationRateLimiter
- type HTTPErrorResp
- type HTTPMessageResp
- type IBlockSimRateLimiter
- type MockBlockSimulationRateLimiter
- type RelayAPI
- func (api *RelayAPI) IsReady() bool
- func (api *RelayAPI) Respond(w http.ResponseWriter, code int, response any)
- func (api *RelayAPI) RespondError(w http.ResponseWriter, code int, message string)
- func (api *RelayAPI) RespondMsg(w http.ResponseWriter, code int, msg string)
- func (api *RelayAPI) RespondOK(w http.ResponseWriter, response any)
- func (api *RelayAPI) StartServer() (err error)
- func (api *RelayAPI) StopServer() (err error)
- type RelayAPIOpts
Constants ¶
const ( ErrBlockAlreadyKnown = "simulation failed: block already known" ErrBlockRequiresReorg = "simulation failed: block requires a reorg" ErrMissingTrieNode = "missing trie node" )
Variables ¶
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") )
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") ErrNegativeTimestamp = errors.New("timestamp cannot be negative") )
var ( ErrMissingRequest = errors.New("req is nil") ErrMissingSecretKey = errors.New("secret key is nil") ErrEmptyPayload = errors.New("nil payload") ErrInvalidTransaction = errors.New("invalid transaction") NilResponse = struct{}{} ZeroU256 = boostTypes.IntToU256(0) )
var ( ErrBlockHashMismatch = errors.New("blockHash mismatch") ErrParentHashMismatch = errors.New("parentHash mismatch") ErrUnsupportedPayload = errors.New("unsupported payload version") ErrNoWithdrawals = errors.New("no withdrawals") 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") )
Functions ¶
func ComputeWithdrawalsRoot ¶ added in v0.20.0
func ComputeWithdrawalsRoot(w []*capella.Withdrawal) (phase0.Root, error)
func EqBlindedBlockContentsToBlockContents ¶ added in v0.29.0
func EqBlindedBlockContentsToBlockContents(bb *common.VersionedSignedBlindedBlockRequest, payload *builderApi.VersionedSubmitBlindedBlockResponse) error
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) (requestErr, validationErr error)
type HTTPErrorResp ¶
type HTTPMessageResp ¶ added in v0.27.1
type HTTPMessageResp struct {
Message string `json:"message"`
}
type IBlockSimRateLimiter ¶ added in v0.24.0
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
func (m *MockBlockSimulationRateLimiter) Send(context context.Context, payload *common.BuilderBlockValidationRequest, isHighPrio, fastTrack bool) (error, error)
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) 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) StartServer ¶
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
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
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 // APIs to enable ProposerAPI bool BlockBuilderAPI bool DataAPI bool PprofAPI bool InternalAPI bool }
RelayAPIOpts contains the options for a relay