Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type EngineClient
- func (s *EngineClient) ExchangeCapabilities(ctx context.Context) ([]string, error)
- func (s *EngineClient) ForkchoiceUpdated(ctx context.Context, state *engine.ForkchoiceState, ...) (*engine.PayloadID, *primitives.ExecutionHash, error)
- func (s *EngineClient) GetLogs(ctx context.Context, blockHash primitives.ExecutionHash, ...) ([]coretypes.Log, error)
- func (s *EngineClient) GetPayload(ctx context.Context, payloadID engine.PayloadID, forkVersion uint32) (enginetypes.ExecutionPayload, *engine.BlobsBundleV1, bool, error)
- func (s *EngineClient) HeaderByHash(ctx context.Context, hash primitives.ExecutionHash) (*primitives.ExecutionHeader, error)
- func (s *EngineClient) HeaderByNumber(ctx context.Context, number *big.Int) (*primitives.ExecutionHeader, error)
- func (s *EngineClient) NewPayload(ctx context.Context, payload enginetypes.ExecutionPayload, ...) (*primitives.ExecutionHash, error)
- func (s *EngineClient) Start(ctx context.Context)
- func (s *EngineClient) Status() error
- func (s *EngineClient) VerifyChainID(ctx context.Context) error
- func (s *EngineClient) WaitForHealthy(ctx context.Context)
- type Option
Constants ¶
const ( // MetricBaseKey is the base key for all metrics. MetricBaseKey = "beacon-kit.engine.client." // MetricKeyParseErrorCount represents the metric key // for counting parse errors. MetricKeyParseErrorCount = MetricBaseKey + "parse_error_count" // MetricKeyInvalidRequestCount represents the metric key // for counting invalid requests. MetricKeyInvalidRequestCount = MetricBaseKey + "invalid_request_count" // MetricKeyMethodNotFoundCount represents the metric key // for counting instances // where a method is not found. MetricKeyMethodNotFoundCount = MetricBaseKey + "method_not_found_count" // MetricKeyInvalidParamsCount represents the metric key // for counting instances of // invalid parameters. MetricKeyInvalidParamsCount = MetricBaseKey + "invalid_params_count" // MetricKeyInternalErrorCount represents the metric key // for counting internal errors. MetricKeyInternalErrorCount = MetricBaseKey + "internal_error_count" // MetricKeyUnknownPayloadErrorCount represents the metric key // for counting unknown payload errors. MetricKeyUnknownPayloadErrorCount = MetricBaseKey + "unknown_payload_error_count" // MetricKeyInvalidForkchoiceStateCount represents the metric key // for counting invalid fork choice state errors. MetricKeyInvalidForkchoiceStateCount = MetricBaseKey + "invalid_forkchoice_state_count" // MetricKeyInvalidPayloadAttributesCount represents the metric key // for counting invalid payload attribute errors. MetricKeyInvalidPayloadAttributesCount = MetricBaseKey + "invalid_payload_attributes_count" // MetricKeyRequestTooLargeCount represents the metric key // for counting instances where a request is too large. MetricKeyRequestTooLargeCount = MetricBaseKey + "request_too_large_count" // MetricKeyInternalServerErrorCount represents the metric key // for counting internal server errors. MetricKeyInternalServerErrorCount = MetricBaseKey + "internal_server_error_count" )
const UnauthenticatedConnectionErrorStr = `` /* 175-byte string literal not displayed */
ErrUnauthenticatedConnection indicates that the connection is not authenticated.
Variables ¶
var ( // ErrNotStarted indicates that the execution client is not started. ErrNotStarted = errors.New("engine client is not started") // ErrInvalidJWTSecretLength indicates incorrect JWT secret length. ErrInvalidJWTSecretLength = errors.New("invalid JWT secret length") // ErrHTTPTimeout indicates a timeout error from http.Client. ErrHTTPTimeout = errors.New("timeout from http.Client") // ErrEmptyBlockHash indicates an empty block hash scenario. ErrEmptyBlockHash = errors.New("block hash is empty 0x0000...000") // ErrNilResponse indicates a nil response from the execution client. ErrNilResponse = errors.New("nil response from execution client") // ErrParse indicates a parsing error // (JSON-RPC code -32700). ErrParse = errors.New("invalid JSON was received by the server") // ErrInvalidRequest indicates an invalid request object // (JSON-RPC code -32600). ErrInvalidRequest = errors.New("JSON sent is not valid request object") // ErrMethodNotFound indicates a non-existent method call // (JSON-RPC code -32601). ErrMethodNotFound = errors.New("method not found") // ErrInvalidParams indicates invalid method parameters // (JSON-RPC code -32602). ErrInvalidParams = errors.New("invalid method parameter(s)") // ErrInternal indicates an internal JSON-RPC error // (JSON-RPC code -32603). ErrInternal = errors.New("internal JSON-RPC error") // ErrServer indicates a client-side error during request processing // (JSON-RPC code -32000). ErrServer = errors.New( "client error while processing request") // ErrUnknownPayload indicates an unavailable or non-existent payload // (JSON-RPC code -38001). ErrUnknownPayload = errors.New( "payload does not exist or is not available") // ErrInvalidForkchoiceState indicates an invalid fork choice state // (JSON-RPC code -38002). ErrInvalidForkchoiceState = errors.New( "invalid forkchoice state") // ErrInvalidPayloadAttributes indicates invalid or inconsistent payload // attributes // (JSON-RPC code -38003). ErrInvalidPayloadAttributes = errors.New( "payload attributes are invalid / inconsistent") // ErrUnknownPayloadStatus indicates an unknown payload status. ErrUnknownPayloadStatus = errors.New( "unknown payload status") // ErrAcceptedSyncingPayloadStatus indicates a payload status of SYNCING or // ACCEPTED. ErrAcceptedSyncingPayloadStatus = errors.New( "payload status is SYNCING or ACCEPTED") // ErrInvalidPayloadStatus indicates an invalid payload status. ErrInvalidPayloadStatus = errors.New( "payload status is INVALID") // ErrInvalidBlockHashPayloadStatus indicates a failure in validating the // block hash for the payload. ErrInvalidBlockHashPayloadStatus = errors.New( "payload status is INVALID_BLOCK_HASH") // ErrNilForkchoiceResponse indicates a nil forkchoice response. ErrNilForkchoiceResponse = errors.New( "nil forkchoice response", ) // ErrNilPayloadStatus indicates a nil payload status. ErrNilPayloadStatus = errors.New( "nil payload status", ) // ErrRequestTooLarge indicates that the request size exceeded the limit. ErrRequestTooLarge = errors.New( "request too large") // ErrUnsupportedVersion indicates a request for a block type with an // unknown ExecutionPayload schema. ErrUnsupportedVersion = errors.New( "unknown ExecutionPayload schema for block version") // ErrNilJWTSecret indicates that the JWT secret is nil. ErrNilJWTSecret = errors.New("nil JWT secret") // ErrNilAttributesPassedToClient is returned when nil attributes are // passed to the client. ErrNilAttributesPassedToClient = errors.New( "nil attributes passed to client") // ErrNilExecutionPayloadEnvelope is returned when nil execution payload // envelope is received. ErrNilExecutionPayloadEnvelope = errors.New( "nil execution payload envelope received from execution client") // ErrNilExecutionPayload is returned when nil execution payload // envelope is received. ErrNilExecutionPayload = errors.New( "nil execution payload received from execution client") /// ErrNilBlobsBundle is returned when nil blobs bundle is received. ErrNilBlobsBundle = errors.New( "nil blobs bundle received from execution client") // ErrInvalidPayloadAttributeVersion indicates an invalid version of payload // attributes was provided. ErrInvalidPayloadAttributeVersion = errors.New( "invalid payload attribute version") // ErrInvalidPayloadType indicates an invalid payload type // was provided for an RPC call. ErrInvalidPayloadType = errors.New("invalid payload type for RPC call") // ErrInvalidGetPayloadVersion indicates that an unknown fork version was // provided for getting a payload. ErrInvalidGetPayloadVersion = errors.New("unknown fork for get payload") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // RPCDialURL is the HTTP url of the execution client JSON-RPC endpoint. RPCDialURL *url.URL `mapstructure:"rpc-dial-url"` // RPCRetries is the number of retries before shutting down consensus // client. RPCRetries uint64 `mapstructure:"rpc-retries"` // RPCTimeout is the RPC timeout for execution client calls. RPCTimeout time.Duration `mapstructure:"rpc-timeout"` // RPCStartupCheckInterval is the Interval for the startup check. RPCStartupCheckInterval time.Duration `mapstructure:"rpc-startup-check-interval"` // JWTRefreshInterval is the Interval for the JWT refresh. RPCJWTRefreshInterval time.Duration `mapstructure:"rpc-jwt-refresh-interval"` // JWTSecretPath is the path to the JWT secret. JWTSecretPath string `mapstructure:"jwt-secret-path"` // RequiredChainID is the chain id that the consensus client must be // connected to. RequiredChainID uint64 `mapstructure:"required-chain-id"` }
Config is the configuration struct for the execution client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig is the default configuration for the engine client.
type EngineClient ¶
type EngineClient struct { *eth.Eth1Client // contains filtered or unexported fields }
EngineClient is a struct that holds a pointer to an Eth1Client.
func New ¶
func New(opts ...Option) *EngineClient
New creates a new engine client EngineClient. It takes an Eth1Client as an argument and returns a pointer to an EngineClient.
func (*EngineClient) ExchangeCapabilities ¶
func (s *EngineClient) ExchangeCapabilities( ctx context.Context, ) ([]string, error)
ExchangeCapabilities calls the engine_exchangeCapabilities method via JSON-RPC.
func (*EngineClient) ForkchoiceUpdated ¶
func (s *EngineClient) ForkchoiceUpdated( ctx context.Context, state *engine.ForkchoiceState, attrs enginetypes.PayloadAttributer, forkVersion uint32, ) (*engine.PayloadID, *primitives.ExecutionHash, error)
ForkchoiceUpdated calls the engine_forkchoiceUpdatedV1 method via JSON-RPC.
func (*EngineClient) GetLogs ¶
func (s *EngineClient) GetLogs( ctx context.Context, blockHash primitives.ExecutionHash, addresses []primitives.ExecutionAddress, ) ([]coretypes.Log, error)
GetLogs retrieves the logs from the Ethereum execution client. It calls the eth_getLogs method via JSON-RPC.
func (*EngineClient) GetPayload ¶
func (s *EngineClient) GetPayload( ctx context.Context, payloadID engine.PayloadID, forkVersion uint32, ) (enginetypes.ExecutionPayload, *engine.BlobsBundleV1, bool, error)
GetPayload calls the engine_getPayloadVX method via JSON-RPC. It returns the execution data as well as the blobs bundle.
func (*EngineClient) HeaderByHash ¶
func (s *EngineClient) HeaderByHash( ctx context.Context, hash primitives.ExecutionHash, ) (*primitives.ExecutionHeader, error)
HeaderByHash retrieves the block header by its hash.
func (*EngineClient) HeaderByNumber ¶
func (s *EngineClient) HeaderByNumber( ctx context.Context, number *big.Int, ) (*primitives.ExecutionHeader, error)
HeaderByNumber retrieves the block header by its number.
func (*EngineClient) NewPayload ¶
func (s *EngineClient) NewPayload( ctx context.Context, payload enginetypes.ExecutionPayload, versionedHashes []primitives.ExecutionHash, parentBlockRoot *[32]byte, ) (*primitives.ExecutionHash, error)
NewPayload calls the engine_newPayloadVX method via JSON-RPC.
func (*EngineClient) Start ¶
func (s *EngineClient) Start(ctx context.Context)
Start starts the engine client.
func (*EngineClient) Status ¶
func (s *EngineClient) Status() error
Status verifies the chain ID via JSON-RPC. By proxy we will also verify the connection to the execution client.
func (*EngineClient) VerifyChainID ¶
func (s *EngineClient) VerifyChainID(ctx context.Context) error
Checks the chain ID of the execution client to ensure it matches local parameters of what Prysm expects.
func (*EngineClient) WaitForHealthy ¶
func (s *EngineClient) WaitForHealthy(ctx context.Context)
WaitForHealthy waits for the engine client to be healthy.
type Option ¶
type Option func(*EngineClient) error
Option is a function type that takes a pointer to an engineClient and returns an error.
func WithCacheConfig ¶
WithCacheConfig is an option to create a new cache with the given config for the EngineClient.
func WithEngineConfig ¶
WithEngineConfig is a function that returns an Option.
func WithEth1Client ¶
func WithEth1Client(eth1Client *eth.Eth1Client) Option
WithEth1Client is a function that returns an Option.
func WithJWTSecret ¶
WithJWTSecret is a function that returns an Option.
func WithLogger ¶
WithLogger is an option to set the logger for the EngineClient.