Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit: add custom testnet flags for exits #3317

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cmd/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"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"
)
Expand All @@ -36,6 +37,7 @@
ExitFromFileDir string
Log log.Config
All bool
testnetConfig eth2util.Network
}

func newExitCmd(cmds ...*cobra.Command) *cobra.Command {
Expand Down Expand Up @@ -67,6 +69,11 @@
publishTimeout
validatorIndex
all
testnetName
testnetForkVersion
testnetChainID
testnetGenesisTimestamp
testnetCapellaHardFork
)

func (ef exitFlag) String() string {
Expand Down Expand Up @@ -99,6 +106,16 @@
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"

Check warning on line 118 in cmd/exit.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit.go#L109-L118

Added lines #L109 - L118 were not covered by tests
default:
return "unknown"
}
Expand Down Expand Up @@ -150,6 +167,16 @@
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.")

Check warning on line 179 in cmd/exit.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit.go#L170-L179

Added lines #L170 - L179 were not covered by tests
}

if f.required {
Expand Down
13 changes: 13 additions & 0 deletions cmd/exit_broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"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"
Expand Down Expand Up @@ -62,6 +63,12 @@
{exitFromDir, false},
{beaconNodeTimeout, false},
{publishTimeout, false},
{all, false},
{testnetName, false},
{testnetForkVersion, false},
{testnetChainID, false},
{testnetGenesisTimestamp, false},
{testnetCapellaHardFork, false},

Check warning on line 71 in cmd/exit_broadcast.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_broadcast.go#L66-L71

Added lines #L66 - L71 were not covered by tests
})

bindLogFlags(cmd.Flags(), &config.Log)
Expand Down Expand Up @@ -98,6 +105,12 @@
}

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)
}

Check warning on line 112 in cmd/exit_broadcast.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_broadcast.go#L110-L112

Added lines #L110 - L112 were not covered by tests

identityKey, err := k1util.Load(config.PrivateKeyPath)
if err != nil {
return errors.Wrap(err, "could not load identity key")
Expand Down
12 changes: 12 additions & 0 deletions cmd/exit_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"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"
)

Expand Down Expand Up @@ -49,6 +50,11 @@
{all, false},
{fetchedExitPath, false},
{publishTimeout, false},
{testnetName, false},
{testnetForkVersion, false},
{testnetChainID, false},
{testnetGenesisTimestamp, false},
{testnetCapellaHardFork, false},

Check warning on line 57 in cmd/exit_fetch.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_fetch.go#L53-L57

Added lines #L53 - L57 were not covered by tests
})

bindLogFlags(cmd.Flags(), &config.Log)
Expand All @@ -73,6 +79,12 @@
}

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)
}

Check warning on line 86 in cmd/exit_fetch.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_fetch.go#L84-L86

Added lines #L84 - L86 were not covered by tests

if _, err := os.Stat(config.FetchedExitPath); err != nil {
return errors.Wrap(err, "store exit path")
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/exit_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"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 {
Expand Down Expand Up @@ -43,6 +44,11 @@
{lockFilePath, false},
{beaconNodeEndpoints, true},
{beaconNodeTimeout, false},
{testnetName, false},
{testnetForkVersion, false},
{testnetChainID, false},
{testnetGenesisTimestamp, false},
{testnetCapellaHardFork, false},

Check warning on line 51 in cmd/exit_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_list.go#L47-L51

Added lines #L47 - L51 were not covered by tests
})

bindLogFlags(cmd.Flags(), &config.Log)
Expand All @@ -51,6 +57,12 @@
}

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)
}

Check warning on line 64 in cmd/exit_list.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_list.go#L62-L64

Added lines #L62 - L64 were not covered by tests

valList, err := listActiveVals(ctx, config)
if err != nil {
return err
Expand Down
12 changes: 12 additions & 0 deletions cmd/exit_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"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"
)

Expand Down Expand Up @@ -54,6 +55,11 @@
{beaconNodeTimeout, false},
{publishTimeout, false},
{all, false},
{testnetName, false},
{testnetForkVersion, false},
{testnetChainID, false},
{testnetGenesisTimestamp, false},
{testnetCapellaHardFork, false},

Check warning on line 62 in cmd/exit_sign.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_sign.go#L58-L62

Added lines #L58 - L62 were not covered by tests
})

bindLogFlags(cmd.Flags(), &config.Log)
Expand Down Expand Up @@ -82,6 +88,12 @@
}

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)
}

Check warning on line 95 in cmd/exit_sign.go

View check run for this annotation

Codecov / codecov/patch

cmd/exit_sign.go#L93-L95

Added lines #L93 - L95 were not covered by tests

identityKey, err := k1util.Load(config.PrivateKeyPath)
if err != nil {
return errors.Wrap(err, "could not load identity key")
Expand Down
Loading