api

package
v0.11.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRequestClosed    = errors.New("request context closed")
	ErrSimulationFailed = errors.New("simulation failed")
)
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")
)
View Source
var (
	ErrMissingRequest   = errors.New("req is nil")
	ErrMissingSecretKey = errors.New("secret key is nil")
)
View Source
var (
	ErrBlockHashMismatch  = errors.New("blockHash mismatch")
	ErrParentHashMismatch = errors.New("parentHash mismatch")
)
View Source
var NilResponse = struct{}{}
View Source
var VersionBellatrix types.VersionString = "bellatrix"
View Source
var ZeroU256 = types.IntToU256(0)

Functions

func BuilderSubmitBlockRequestToSignedBuilderBid

func BuilderSubmitBlockRequestToSignedBuilderBid(req *types.BuilderSubmitBlockRequest, sk *bls.SecretKey, pubkey *types.PublicKey, domain types.Domain) (*types.SignedBuilderBid, error)

func SendJSONRPCRequest added in v0.7.0

func SendJSONRPCRequest(req jsonrpc.JSONRPCRequest, url string, isHighPrio bool) (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 added in v0.6.0

func SignedBlindedBeaconBlockToBeaconBlock(signedBlindedBeaconBlock *types.SignedBlindedBeaconBlock, executionPayload *types.ExecutionPayload) *types.SignedBeaconBlock

func VerifyBuilderBlockSubmission

func VerifyBuilderBlockSubmission(payload *types.BuilderSubmitBlockRequest) error

Types

type BlockSimulationRateLimiter

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

func NewBlockSimulationRateLimiter

func NewBlockSimulationRateLimiter(blockSimURL string) *BlockSimulationRateLimiter

type HTTPErrorResp

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

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) RespondError

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

func (*RelayAPI) RespondOK

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

func (*RelayAPI) StartServer

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

StartServer starts the HTTP server for this instance

func (*RelayAPI) StopServer added in v0.9.1

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

StopServer disables sending any bids on getHeader calls, waits a few seconds to catch any remaining getPayload call, and then shuts down the webserver

type RelayAPIOpts

type RelayAPIOpts struct {
	Log *logrus.Entry

	ListenAddr  string
	BlockSimURL string

	BeaconClient beaconclient.IMultiBeaconClient
	Datastore    *datastore.Datastore
	Redis        *datastore.RedisCache
	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

Jump to

Keyboard shortcuts

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