api

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 44 Imported by: 0

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

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")
)
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")
	ErrNegativeTimestamp          = errors.New("timestamp cannot be negative")
)
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 (
	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.VersionedSignedBlindedBeaconBlock, 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 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 IBlockSimRateLimiter added in v0.24.0

type IBlockSimRateLimiter interface {
	Send(context context.Context, payload *common.BuilderBlockValidationRequest, isHighPrio, fastTrack bool) (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

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

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

Jump to

Keyboard shortcuts

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