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:
Raul Jordan 2022-03-24 20:53:07 +00:00 committed by GitHub
parent 956e7a7563
commit 3579551f15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 36 deletions

View File

@ -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.
func WithExecutionClientJWTSecret(jwtSecret []byte) Option {
return func(s *Service) error {

View File

@ -135,7 +135,6 @@ type config struct {
eth1HeaderReqLimit uint64
beaconNodeStatsUpdater BeaconNodeStatsUpdater
httpEndpoints []network.Endpoint
executionEndpoint string
executionEndpointJWTSecret []byte
currHttpEndpoint network.Endpoint
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 {
return nil, errors.Wrap(err, "unable to validate powchain data")
}
@ -254,6 +246,14 @@ func (s *Service) Start() {
if s.cfg.currHttpEndpoint.Url == "" {
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() {
s.isRunning = true
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.
func (s *Service) initializeEngineAPIClient(ctx context.Context) error {
if s.cfg.executionEndpoint == "" {
return nil
}
opts := []engine.Option{
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 {
return err
}

View File

@ -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",
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
// 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.

View File

@ -33,7 +33,6 @@ import (
var appFlags = []cli.Flag{
flags.DepositContractFlag,
flags.HTTPWeb3ProviderFlag,
flags.ExecutionProviderFlag,
flags.ExecutionJWTSecretFlag,
flags.FallbackWeb3ProviderFlag,
flags.RPCHost,

View File

@ -18,7 +18,6 @@ var log = logrus.WithField("prefix", "cmd-powchain")
// FlagOptions for powchain service flag configurations.
func FlagOptions(c *cli.Context) ([]powchain.Option, error) {
endpoints := parsePowchainEndpoints(c)
executionEndpoint := parseExecutionEndpoint(c)
jwtSecret, err := parseJWTSecretFromFile(c)
if err != nil {
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.WithEth1HeaderRequestLimit(c.Uint64(flags.Eth1HeaderReqLimit.Name)),
}
if executionEndpoint != "" {
opts = append(opts, powchain.WithExecutionEndpoint(executionEndpoint))
}
if len(jwtSecret) > 0 {
opts = append(opts, powchain.WithExecutionClientJWTSecret(jwtSecret))
}
@ -85,7 +81,3 @@ func parsePowchainEndpoints(c *cli.Context) []string {
endpoints = append(endpoints, c.StringSlice(flags.FallbackWeb3ProviderFlag.Name)...)
return endpoints
}
func parseExecutionEndpoint(c *cli.Context) string {
return c.String(flags.ExecutionProviderFlag.Name)
}

View File

@ -107,7 +107,6 @@ var appHelpFlagGroups = []flagGroup{
flags.GRPCGatewayPort,
flags.GPRCGatewayCorsDomain,
flags.HTTPWeb3ProviderFlag,
flags.ExecutionProviderFlag,
flags.ExecutionJWTSecretFlag,
flags.FallbackWeb3ProviderFlag,
flags.SetGCPercent,