Remove Execution Client Fallback and Make Providing an Execution Client Required (#10921)

* Starting

* Done

* Fix more tests

* Fix test

* Fix test

* fix up

* building

* requirement

* gaz

* builds

* rem deadcode

* fix

* fix up

* removed checked method

* Update service_test.go

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
terencechain
2022-08-16 10:22:34 -07:00
committed by GitHub
parent e0eee87bf4
commit 2728b83f6a
27 changed files with 127 additions and 431 deletions

View File

@@ -13,7 +13,6 @@ go_library(
"//cmd/beacon-chain/flags:go_default_library",
"//io/file:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library",
],
)
@@ -28,7 +27,6 @@ go_test(
"//io/file:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library",
],
)

View File

@@ -9,25 +9,25 @@ import (
"github.com/prysmaticlabs/prysm/v3/beacon-chain/execution"
"github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags"
"github.com/prysmaticlabs/prysm/v3/io/file"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
var log = logrus.WithField("prefix", "cmd-execution-chain")
// FlagOptions for execution service flag configurations.
func FlagOptions(c *cli.Context) ([]execution.Option, error) {
endpoints := parseExecutionChainEndpoint(c)
endpoint, err := parseExecutionChainEndpoint(c)
if err != nil {
return nil, err
}
jwtSecret, err := parseJWTSecretFromFile(c)
if err != nil {
return nil, errors.Wrap(err, "could not read JWT secret file for authenticating execution API")
}
opts := []execution.Option{
execution.WithHttpEndpoints(endpoints),
execution.WithHttpEndpoint(endpoint),
execution.WithEth1HeaderRequestLimit(c.Uint64(flags.Eth1HeaderReqLimit.Name)),
}
if len(jwtSecret) > 0 {
opts = append(opts, execution.WithHttpEndpointsAndJWTSecret(endpoints, jwtSecret))
opts = append(opts, execution.WithHttpEndpointAndJWTSecret(endpoint, jwtSecret))
}
return opts, nil
}
@@ -63,15 +63,15 @@ func parseJWTSecretFromFile(c *cli.Context) ([]byte, error) {
return secret, nil
}
func parseExecutionChainEndpoint(c *cli.Context) []string {
if c.String(flags.ExecutionEngineEndpoint.Name) == "" && len(c.StringSlice(flags.FallbackWeb3ProviderFlag.Name)) == 0 {
log.Error(
"No execution engine specified to run with the beacon node. " +
"You must specified an execution client in order to participate. Visit " +
"https://docs.prylabs.network/docs/prysm-usage/setup-eth1 for more information",
func parseExecutionChainEndpoint(c *cli.Context) (string, error) {
if c.String(flags.ExecutionEngineEndpoint.Name) == "" {
return "", fmt.Errorf(
"you need to specify %s to provide a connection endpoint to an Ethereum execution client "+
"for your Prysm beacon node. This is a requirement for running a node. You can read more about "+
"how to configure this execution client connection in our docs here "+
"https://docs.prylabs.network/docs/install/install-with-script",
flags.ExecutionEngineEndpoint.Name,
)
}
endpoints := []string{c.String(flags.ExecutionEngineEndpoint.Name)}
endpoints = append(endpoints, c.StringSlice(flags.FallbackWeb3ProviderFlag.Name)...)
return endpoints
return c.String(flags.ExecutionEngineEndpoint.Name), nil
}

View File

@@ -11,7 +11,6 @@ import (
"github.com/prysmaticlabs/prysm/v3/io/file"
"github.com/prysmaticlabs/prysm/v3/testing/assert"
"github.com/prysmaticlabs/prysm/v3/testing/require"
logTest "github.com/sirupsen/logrus/hooks/test"
"github.com/urfave/cli/v2"
)
@@ -19,16 +18,11 @@ func TestExecutionchainCmd(t *testing.T) {
app := cli.App{}
set := flag.NewFlagSet("test", 0)
set.String(flags.ExecutionEngineEndpoint.Name, "primary", "")
fallback := cli.StringSlice{}
err := fallback.Set("fallback1")
require.NoError(t, err)
err = fallback.Set("fallback2")
require.NoError(t, err)
set.Var(&fallback, flags.FallbackWeb3ProviderFlag.Name, "")
ctx := cli.NewContext(&app, set, nil)
endpoints := parseExecutionChainEndpoint(ctx)
assert.DeepEqual(t, []string{"primary", "fallback1", "fallback2"}, endpoints)
endpoints, err := parseExecutionChainEndpoint(ctx)
require.NoError(t, err)
assert.Equal(t, "primary", endpoints)
}
func Test_parseJWTSecretFromFile(t *testing.T) {
@@ -98,13 +92,10 @@ func Test_parseJWTSecretFromFile(t *testing.T) {
}
func TestPowchainPreregistration_EmptyWeb3Provider(t *testing.T) {
hook := logTest.NewGlobal()
app := cli.App{}
set := flag.NewFlagSet("test", 0)
set.String(flags.ExecutionEngineEndpoint.Name, "", "")
fallback := cli.StringSlice{}
set.Var(&fallback, flags.FallbackWeb3ProviderFlag.Name, "")
ctx := cli.NewContext(&app, set, nil)
parseExecutionChainEndpoint(ctx)
assert.LogsContain(t, hook, "No execution engine specified to run with the beacon node. You must specified an execution client in order to participate")
_, err := parseExecutionChainEndpoint(ctx)
assert.ErrorContains(t, "you need to specify", err)
}

View File

@@ -44,11 +44,6 @@ var (
"This is not required if using an IPC connection.",
Value: "",
}
// FallbackWeb3ProviderFlag provides a fallback endpoint to an ETH 1.0 RPC.
FallbackWeb3ProviderFlag = &cli.StringSliceFlag{
Name: "fallback-web3provider",
Usage: "A mainchain web3 provider string http endpoint. This is our fallback web3 provider, this flag may be used multiple times.",
}
// DepositContractFlag defines a flag for the deposit contract address.
DepositContractFlag = &cli.StringFlag{
Name: "deposit-contract",

View File

@@ -39,7 +39,6 @@ var appFlags = []cli.Flag{
flags.DepositContractFlag,
flags.ExecutionEngineEndpoint,
flags.ExecutionJWTSecretFlag,
flags.FallbackWeb3ProviderFlag,
flags.RPCHost,
flags.RPCPort,
flags.CertFlag,
@@ -189,9 +188,6 @@ func main() {
if err := cmd.ExpandSingleEndpointIfFile(ctx, flags.ExecutionEngineEndpoint); err != nil {
return err
}
if err := cmd.ExpandWeb3EndpointsIfFile(ctx, flags.FallbackWeb3ProviderFlag); err != nil {
return err
}
if ctx.IsSet(flags.SetGCPercent.Name) {
runtimeDebug.SetGCPercent(ctx.Int(flags.SetGCPercent.Name))
}

View File

@@ -110,7 +110,6 @@ var appHelpFlagGroups = []flagGroup{
flags.GPRCGatewayCorsDomain,
flags.ExecutionEngineEndpoint,
flags.ExecutionJWTSecretFlag,
flags.FallbackWeb3ProviderFlag,
flags.SetGCPercent,
flags.SlotsPerArchivedPoint,
flags.DisableDiscv5,