mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 16:37:39 +00:00
Use --http-web3provider for Execution Engine Connection (#10307)
* combine endpoints * initialization in the start function instead Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
parent
956e7a7563
commit
3579551f15
@ -32,14 +32,6 @@ func WithHttpEndpoints(endpointStrings []string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithExecutionEndpoint for the execution node JSON-RPC endpoint.
|
|
||||||
func WithExecutionEndpoint(endpoint string) Option {
|
|
||||||
return func(s *Service) error {
|
|
||||||
s.cfg.executionEndpoint = endpoint
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithExecutionClientJWTSecret for authenticating the execution node JSON-RPC endpoint.
|
// WithExecutionClientJWTSecret for authenticating the execution node JSON-RPC endpoint.
|
||||||
func WithExecutionClientJWTSecret(jwtSecret []byte) Option {
|
func WithExecutionClientJWTSecret(jwtSecret []byte) Option {
|
||||||
return func(s *Service) error {
|
return func(s *Service) error {
|
||||||
|
@ -135,7 +135,6 @@ type config struct {
|
|||||||
eth1HeaderReqLimit uint64
|
eth1HeaderReqLimit uint64
|
||||||
beaconNodeStatsUpdater BeaconNodeStatsUpdater
|
beaconNodeStatsUpdater BeaconNodeStatsUpdater
|
||||||
httpEndpoints []network.Endpoint
|
httpEndpoints []network.Endpoint
|
||||||
executionEndpoint string
|
|
||||||
executionEndpointJWTSecret []byte
|
executionEndpointJWTSecret []byte
|
||||||
currHttpEndpoint network.Endpoint
|
currHttpEndpoint network.Endpoint
|
||||||
finalizedStateAtStartup state.BeaconState
|
finalizedStateAtStartup state.BeaconState
|
||||||
@ -213,13 +212,6 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.initializeEngineAPIClient(ctx); err != nil {
|
|
||||||
return nil, errors.Wrap(err, "unable to initialize engine API client")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check transition configuration for the engine API client in the background.
|
|
||||||
go s.checkTransitionConfiguration(ctx)
|
|
||||||
|
|
||||||
if err := s.ensureValidPowchainData(ctx); err != nil {
|
if err := s.ensureValidPowchainData(ctx); err != nil {
|
||||||
return nil, errors.Wrap(err, "unable to validate powchain data")
|
return nil, errors.Wrap(err, "unable to validate powchain data")
|
||||||
}
|
}
|
||||||
@ -254,6 +246,14 @@ func (s *Service) Start() {
|
|||||||
if s.cfg.currHttpEndpoint.Url == "" {
|
if s.cfg.currHttpEndpoint.Url == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := s.initializeEngineAPIClient(s.ctx); err != nil {
|
||||||
|
log.WithError(err).Fatal("unable to initialize engine API client")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check transition configuration for the engine API client in the background.
|
||||||
|
go s.checkTransitionConfiguration(s.ctx)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
s.isRunning = true
|
s.isRunning = true
|
||||||
s.waitForConnection()
|
s.waitForConnection()
|
||||||
@ -1058,13 +1058,10 @@ func (s *Service) ensureValidPowchainData(ctx context.Context) error {
|
|||||||
|
|
||||||
// Initializes a connection to the engine API if an execution provider endpoint is set.
|
// Initializes a connection to the engine API if an execution provider endpoint is set.
|
||||||
func (s *Service) initializeEngineAPIClient(ctx context.Context) error {
|
func (s *Service) initializeEngineAPIClient(ctx context.Context) error {
|
||||||
if s.cfg.executionEndpoint == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
opts := []engine.Option{
|
opts := []engine.Option{
|
||||||
engine.WithJWTSecret(s.cfg.executionEndpointJWTSecret),
|
engine.WithJWTSecret(s.cfg.executionEndpointJWTSecret),
|
||||||
}
|
}
|
||||||
client, err := engine.New(ctx, s.cfg.executionEndpoint, opts...)
|
client, err := engine.New(ctx, s.cfg.currHttpEndpoint.Url, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,6 @@ var (
|
|||||||
Usage: "A mainchain web3 provider string http endpoint. Can contain auth header as well in the format --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Basic xxx\" for project secret (base64 encoded) and --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Bearer xxx\" for jwt use",
|
Usage: "A mainchain web3 provider string http endpoint. Can contain auth header as well in the format --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Basic xxx\" for project secret (base64 encoded) and --http-web3provider=\"https://goerli.infura.io/v3/xxxx,Bearer xxx\" for jwt use",
|
||||||
Value: "",
|
Value: "",
|
||||||
}
|
}
|
||||||
// ExecutionProvider provides an HTTP or IPC access endpoint to an ETH execution node.
|
|
||||||
ExecutionProviderFlag = &cli.StringFlag{
|
|
||||||
Name: "execution-provider",
|
|
||||||
Usage: "An http endpoint for an Ethereum execution node",
|
|
||||||
Value: "",
|
|
||||||
}
|
|
||||||
// ExecutionJWTSecretFlag provides a path to a file containing a hex-encoded string representing a 32 byte secret
|
// ExecutionJWTSecretFlag provides a path to a file containing a hex-encoded string representing a 32 byte secret
|
||||||
// used to authenticate with an execution node via HTTP. This is required if using an HTTP connection, otherwise all requests
|
// used to authenticate with an execution node via HTTP. This is required if using an HTTP connection, otherwise all requests
|
||||||
// to execution nodes for consensus-related calls will fail. This is not required if using an IPC connection.
|
// to execution nodes for consensus-related calls will fail. This is not required if using an IPC connection.
|
||||||
|
@ -33,7 +33,6 @@ import (
|
|||||||
var appFlags = []cli.Flag{
|
var appFlags = []cli.Flag{
|
||||||
flags.DepositContractFlag,
|
flags.DepositContractFlag,
|
||||||
flags.HTTPWeb3ProviderFlag,
|
flags.HTTPWeb3ProviderFlag,
|
||||||
flags.ExecutionProviderFlag,
|
|
||||||
flags.ExecutionJWTSecretFlag,
|
flags.ExecutionJWTSecretFlag,
|
||||||
flags.FallbackWeb3ProviderFlag,
|
flags.FallbackWeb3ProviderFlag,
|
||||||
flags.RPCHost,
|
flags.RPCHost,
|
||||||
|
@ -18,7 +18,6 @@ var log = logrus.WithField("prefix", "cmd-powchain")
|
|||||||
// FlagOptions for powchain service flag configurations.
|
// FlagOptions for powchain service flag configurations.
|
||||||
func FlagOptions(c *cli.Context) ([]powchain.Option, error) {
|
func FlagOptions(c *cli.Context) ([]powchain.Option, error) {
|
||||||
endpoints := parsePowchainEndpoints(c)
|
endpoints := parsePowchainEndpoints(c)
|
||||||
executionEndpoint := parseExecutionEndpoint(c)
|
|
||||||
jwtSecret, err := parseJWTSecretFromFile(c)
|
jwtSecret, err := parseJWTSecretFromFile(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not read JWT secret file for authenticating execution API")
|
return nil, errors.Wrap(err, "could not read JWT secret file for authenticating execution API")
|
||||||
@ -27,9 +26,6 @@ func FlagOptions(c *cli.Context) ([]powchain.Option, error) {
|
|||||||
powchain.WithHttpEndpoints(endpoints),
|
powchain.WithHttpEndpoints(endpoints),
|
||||||
powchain.WithEth1HeaderRequestLimit(c.Uint64(flags.Eth1HeaderReqLimit.Name)),
|
powchain.WithEth1HeaderRequestLimit(c.Uint64(flags.Eth1HeaderReqLimit.Name)),
|
||||||
}
|
}
|
||||||
if executionEndpoint != "" {
|
|
||||||
opts = append(opts, powchain.WithExecutionEndpoint(executionEndpoint))
|
|
||||||
}
|
|
||||||
if len(jwtSecret) > 0 {
|
if len(jwtSecret) > 0 {
|
||||||
opts = append(opts, powchain.WithExecutionClientJWTSecret(jwtSecret))
|
opts = append(opts, powchain.WithExecutionClientJWTSecret(jwtSecret))
|
||||||
}
|
}
|
||||||
@ -85,7 +81,3 @@ func parsePowchainEndpoints(c *cli.Context) []string {
|
|||||||
endpoints = append(endpoints, c.StringSlice(flags.FallbackWeb3ProviderFlag.Name)...)
|
endpoints = append(endpoints, c.StringSlice(flags.FallbackWeb3ProviderFlag.Name)...)
|
||||||
return endpoints
|
return endpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseExecutionEndpoint(c *cli.Context) string {
|
|
||||||
return c.String(flags.ExecutionProviderFlag.Name)
|
|
||||||
}
|
|
||||||
|
@ -107,7 +107,6 @@ var appHelpFlagGroups = []flagGroup{
|
|||||||
flags.GRPCGatewayPort,
|
flags.GRPCGatewayPort,
|
||||||
flags.GPRCGatewayCorsDomain,
|
flags.GPRCGatewayCorsDomain,
|
||||||
flags.HTTPWeb3ProviderFlag,
|
flags.HTTPWeb3ProviderFlag,
|
||||||
flags.ExecutionProviderFlag,
|
|
||||||
flags.ExecutionJWTSecretFlag,
|
flags.ExecutionJWTSecretFlag,
|
||||||
flags.FallbackWeb3ProviderFlag,
|
flags.FallbackWeb3ProviderFlag,
|
||||||
flags.SetGCPercent,
|
flags.SetGCPercent,
|
||||||
|
Loading…
Reference in New Issue
Block a user