diff --git a/cmd/exit.go b/cmd/exit.go index 59d8155f9..2f933aa4c 100644 --- a/cmd/exit.go +++ b/cmd/exit.go @@ -13,6 +13,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/eth2wrap" "github.com/obolnetwork/charon/app/log" + "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/eth2util/signing" "github.com/obolnetwork/charon/tbls" ) @@ -36,6 +37,7 @@ type exitConfig struct { ExitFromFileDir string Log log.Config All bool + testnetConfig eth2util.Network } func newExitCmd(cmds ...*cobra.Command) *cobra.Command { @@ -67,6 +69,11 @@ const ( publishTimeout validatorIndex all + testnetName + testnetForkVersion + testnetChainID + testnetGenesisTimestamp + testnetCapellaHardFork ) func (ef exitFlag) String() string { @@ -99,6 +106,16 @@ func (ef exitFlag) String() string { return "validator-index" case all: return "all" + case testnetName: + return "testnet-name" + case testnetForkVersion: + return "testnet-fork-version" + case testnetChainID: + return "testnet-chain-id" + case testnetGenesisTimestamp: + return "testnet-genesis-timestamp" + case testnetCapellaHardFork: + return "testnet-capella-hard-fork" default: return "unknown" } @@ -150,6 +167,16 @@ func bindExitFlags(cmd *cobra.Command, config *exitConfig, flags []exitCLIFlag) cmd.Flags().Uint64Var(&config.ValidatorIndex, validatorIndex.String(), 0, "Validator index of the validator to exit, the associated public key must be present in the cluster lock manifest. If --validator-public-key is also provided, validator existence won't be checked on the beacon chain.") case all: cmd.Flags().BoolVar(&config.All, all.String(), false, "Exit all currently active validators in the cluster.") + case testnetName: + cmd.Flags().StringVar(&config.testnetConfig.Name, testnetName.String(), "", "Name of the custom test network.") + case testnetForkVersion: + cmd.Flags().StringVar(&config.testnetConfig.GenesisForkVersionHex, testnetForkVersion.String(), "", "Genesis fork version of the custom test network (in hex).") + case testnetChainID: + cmd.Flags().Uint64Var(&config.testnetConfig.ChainID, "testnet-chain-id", 0, "Chain ID of the custom test network.") + case testnetGenesisTimestamp: + cmd.Flags().Int64Var(&config.testnetConfig.GenesisTimestamp, "testnet-genesis-timestamp", 0, "Genesis timestamp of the custom test network.") + case testnetCapellaHardFork: + cmd.Flags().StringVar(&config.testnetConfig.CapellaHardFork, "testnet-capella-hard-fork", "", "Capella hard fork version of the custom test network.") } if f.required { diff --git a/cmd/exit_broadcast.go b/cmd/exit_broadcast.go index 6f28ac01a..b32079c00 100644 --- a/cmd/exit_broadcast.go +++ b/cmd/exit_broadcast.go @@ -25,6 +25,7 @@ import ( "github.com/obolnetwork/charon/app/z" manifestpb "github.com/obolnetwork/charon/cluster/manifestpb/v1" "github.com/obolnetwork/charon/core" + "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/eth2util/keystore" "github.com/obolnetwork/charon/tbls" "github.com/obolnetwork/charon/tbls/tblsconv" @@ -62,6 +63,12 @@ func newBcastFullExitCmd(runFunc func(context.Context, exitConfig) error) *cobra {exitFromDir, false}, {beaconNodeTimeout, false}, {publishTimeout, false}, + {all, false}, + {testnetName, false}, + {testnetForkVersion, false}, + {testnetChainID, false}, + {testnetGenesisTimestamp, false}, + {testnetCapellaHardFork, false}, }) bindLogFlags(cmd.Flags(), &config.Log) @@ -98,6 +105,12 @@ func newBcastFullExitCmd(runFunc func(context.Context, exitConfig) error) *cobra } func runBcastFullExit(ctx context.Context, config exitConfig) error { + // Check if custom testnet configuration is provided. + if config.testnetConfig.IsNonZero() { + // Add testnet config to supported networks. + eth2util.AddTestNetwork(config.testnetConfig) + } + identityKey, err := k1util.Load(config.PrivateKeyPath) if err != nil { return errors.Wrap(err, "could not load identity key") diff --git a/cmd/exit_fetch.go b/cmd/exit_fetch.go index 0a3e25119..7dd7296ec 100644 --- a/cmd/exit_fetch.go +++ b/cmd/exit_fetch.go @@ -18,6 +18,7 @@ import ( "github.com/obolnetwork/charon/app/obolapi" "github.com/obolnetwork/charon/app/z" "github.com/obolnetwork/charon/core" + "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/eth2util/keystore" ) @@ -49,6 +50,11 @@ func newFetchExitCmd(runFunc func(context.Context, exitConfig) error) *cobra.Com {all, false}, {fetchedExitPath, false}, {publishTimeout, false}, + {testnetName, false}, + {testnetForkVersion, false}, + {testnetChainID, false}, + {testnetGenesisTimestamp, false}, + {testnetCapellaHardFork, false}, }) bindLogFlags(cmd.Flags(), &config.Log) @@ -73,6 +79,12 @@ func newFetchExitCmd(runFunc func(context.Context, exitConfig) error) *cobra.Com } func runFetchExit(ctx context.Context, config exitConfig) error { + // Check if custom testnet configuration is provided. + if config.testnetConfig.IsNonZero() { + // Add testnet config to supported networks. + eth2util.AddTestNetwork(config.testnetConfig) + } + if _, err := os.Stat(config.FetchedExitPath); err != nil { return errors.Wrap(err, "store exit path") } diff --git a/cmd/exit_list.go b/cmd/exit_list.go index 79c753df4..ef263f7ec 100644 --- a/cmd/exit_list.go +++ b/cmd/exit_list.go @@ -15,6 +15,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/log" "github.com/obolnetwork/charon/app/z" + "github.com/obolnetwork/charon/eth2util" ) func newListActiveValidatorsCmd(runFunc func(context.Context, exitConfig) error) *cobra.Command { @@ -43,6 +44,11 @@ func newListActiveValidatorsCmd(runFunc func(context.Context, exitConfig) error) {lockFilePath, false}, {beaconNodeEndpoints, true}, {beaconNodeTimeout, false}, + {testnetName, false}, + {testnetForkVersion, false}, + {testnetChainID, false}, + {testnetGenesisTimestamp, false}, + {testnetCapellaHardFork, false}, }) bindLogFlags(cmd.Flags(), &config.Log) @@ -51,6 +57,12 @@ func newListActiveValidatorsCmd(runFunc func(context.Context, exitConfig) error) } func runListActiveValidatorsCmd(ctx context.Context, config exitConfig) error { + // Check if custom testnet configuration is provided. + if config.testnetConfig.IsNonZero() { + // Add testnet config to supported networks. + eth2util.AddTestNetwork(config.testnetConfig) + } + valList, err := listActiveVals(ctx, config) if err != nil { return err diff --git a/cmd/exit_sign.go b/cmd/exit_sign.go index 3b5f3b7e8..9aac498f5 100644 --- a/cmd/exit_sign.go +++ b/cmd/exit_sign.go @@ -19,6 +19,7 @@ import ( "github.com/obolnetwork/charon/app/obolapi" "github.com/obolnetwork/charon/app/z" "github.com/obolnetwork/charon/core" + "github.com/obolnetwork/charon/eth2util" "github.com/obolnetwork/charon/eth2util/keystore" ) @@ -54,6 +55,11 @@ func newSubmitPartialExitCmd(runFunc func(context.Context, exitConfig) error) *c {beaconNodeTimeout, false}, {publishTimeout, false}, {all, false}, + {testnetName, false}, + {testnetForkVersion, false}, + {testnetChainID, false}, + {testnetGenesisTimestamp, false}, + {testnetCapellaHardFork, false}, }) bindLogFlags(cmd.Flags(), &config.Log) @@ -82,6 +88,12 @@ func newSubmitPartialExitCmd(runFunc func(context.Context, exitConfig) error) *c } func runSignPartialExit(ctx context.Context, config exitConfig) error { + // Check if custom testnet configuration is provided. + if config.testnetConfig.IsNonZero() { + // Add testnet config to supported networks. + eth2util.AddTestNetwork(config.testnetConfig) + } + identityKey, err := k1util.Load(config.PrivateKeyPath) if err != nil { return errors.Wrap(err, "could not load identity key")