mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
Add Back Fallback Provider Flag (#11281)
* add it back * remove all references Co-authored-by: terencechain <terence@prysmaticlabs.com>
This commit is contained in:
parent
6957f0637f
commit
eaa2566e90
@ -65,7 +65,6 @@ func (s *Service) pollConnectionStatus(ctx context.Context) {
|
||||
currClient := s.rpcClient
|
||||
if err := s.setupExecutionClientConnections(ctx, s.cfg.currHttpEndpoint); err != nil {
|
||||
errorLogger(err, "Could not connect to execution client endpoint")
|
||||
s.retryExecutionClientConnection(ctx, err)
|
||||
continue
|
||||
}
|
||||
// Close previous client, if connection was successful.
|
||||
|
@ -6,12 +6,6 @@ datadir: /var/lib/prysm/beacon
|
||||
# http-web3provider: ETH1 API endpoint, eg. http://localhost:8545 for a local geth service on the default port
|
||||
http-web3provider: http://localhost:8545
|
||||
|
||||
# fallback-web3provider: List of backup ETH1 API endpoints, used if above is not working
|
||||
# For example:
|
||||
# fallback-web3provider:
|
||||
# - https://mainnet.infura.io/v3/YOUR-PROJECT-ID
|
||||
# - https://eth-mainnet.alchemyapi.io/v2/YOUR-PROJECT-ID
|
||||
|
||||
|
||||
# Optional tuning parameters
|
||||
# For full list, see https://docs.prylabs.network/docs/prysm-usage/parameters
|
||||
|
@ -96,31 +96,3 @@ func ExpandSingleEndpointIfFile(ctx *cli.Context, flag *cli.StringFlag) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExpandWeb3EndpointsIfFile expands the path for --fallback-web3provider if specified as a file.
|
||||
func ExpandWeb3EndpointsIfFile(ctx *cli.Context, flags *cli.StringSliceFlag) error {
|
||||
// Return early if no flag value is set.
|
||||
if !ctx.IsSet(flags.Name) {
|
||||
return nil
|
||||
}
|
||||
rawFlags := ctx.StringSlice(flags.Name)
|
||||
for i, rawValue := range rawFlags {
|
||||
switch {
|
||||
case strings.HasPrefix(rawValue, "http://"):
|
||||
case strings.HasPrefix(rawValue, "https://"):
|
||||
case strings.HasPrefix(rawValue, "ws://"):
|
||||
case strings.HasPrefix(rawValue, "wss://"):
|
||||
default:
|
||||
web3endpoint, err := file.ExpandPath(rawValue)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not expand path for %s", rawValue)
|
||||
}
|
||||
// Given that rawFlags is a pointer this will replace the unexpanded path
|
||||
// with the expanded one. Also there is no easy way to replace the string
|
||||
// slice flag value compared to other flag types. This is why we resort to
|
||||
// replacing it like this.
|
||||
rawFlags[i] = web3endpoint
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -111,43 +111,3 @@ func TestExpandSingleEndpointIfFile(t *testing.T) {
|
||||
require.NoError(t, ExpandSingleEndpointIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.Equal(t, curentdir+"/path.ipc", context.String(HTTPWeb3ProviderFlag.Name))
|
||||
}
|
||||
|
||||
func TestExpandWeb3EndpointsIfFile(t *testing.T) {
|
||||
app := cli.App{}
|
||||
set := flag.NewFlagSet("test", 0)
|
||||
HTTPWeb3ProviderFlag := &cli.StringSliceFlag{Name: "fallback-web3provider", Value: cli.NewStringSlice()}
|
||||
set.Var(cli.NewStringSlice(), HTTPWeb3ProviderFlag.Name, "")
|
||||
context := cli.NewContext(&app, set, nil)
|
||||
// with nothing set
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
|
||||
// with url scheme
|
||||
require.NoError(t, context.Set(HTTPWeb3ProviderFlag.Name, "http://localhost:8545"))
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{"http://localhost:8545"}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
|
||||
// reset context
|
||||
set = flag.NewFlagSet("test", 0)
|
||||
set.Var(cli.NewStringSlice(), HTTPWeb3ProviderFlag.Name, "")
|
||||
context = cli.NewContext(&app, set, nil)
|
||||
|
||||
// relative user home path
|
||||
usr, err := user.Current()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, context.Set(HTTPWeb3ProviderFlag.Name, "~/relative/path.ipc"))
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{usr.HomeDir + "/relative/path.ipc"}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
|
||||
// reset context
|
||||
set = flag.NewFlagSet("test", 0)
|
||||
set.Var(cli.NewStringSlice(), HTTPWeb3ProviderFlag.Name, "")
|
||||
context = cli.NewContext(&app, set, nil)
|
||||
|
||||
// current dir path
|
||||
curentdir, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, context.Set(HTTPWeb3ProviderFlag.Name, "./path.ipc"))
|
||||
require.NoError(t, ExpandWeb3EndpointsIfFile(context, HTTPWeb3ProviderFlag))
|
||||
require.DeepEqual(t, []string{curentdir + "/path.ipc"}, context.StringSlice(HTTPWeb3ProviderFlag.Name))
|
||||
}
|
||||
|
@ -32,6 +32,11 @@ var (
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedFallbackProvider = &cli.StringFlag{
|
||||
Name: "fallback-web3provider",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
)
|
||||
|
||||
// Deprecated flags for both the beacon node and validator client.
|
||||
@ -40,6 +45,7 @@ var deprecatedFlags = []cli.Flag{
|
||||
deprecatedBoltMmapFlag,
|
||||
deprecatedDisableDiscV5Flag,
|
||||
deprecatedDisableAttHistoryCacheFlag,
|
||||
deprecatedFallbackProvider,
|
||||
}
|
||||
|
||||
var deprecatedBeaconFlags = []cli.Flag{
|
||||
|
Loading…
Reference in New Issue
Block a user