Skip to content

Commit

Permalink
Add activation timestamp to validator info.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Aug 22, 2023
1 parent 9191cac commit 9d50a72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dev:
- add "slot" to "proposer duties" command
- add activation epoch and time to "validator info" command where applicable

1.33.0:
- show all slots with 'synccommittee inclusion'
Expand Down
17 changes: 16 additions & 1 deletion cmd/validatorinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
standardchaintime "github.com/wealdtech/ethdo/services/chaintime/standard"
"github.com/wealdtech/ethdo/util"
string2eth "github.com/wealdtech/go-string2eth"
)
Expand All @@ -53,6 +54,14 @@ In quiet mode this will return 0 if the validator information can be obtained, o
})
errCheck(err, "Failed to connect to Ethereum 2 beacon node")

chainTime, err := standardchaintime.New(ctx,
standardchaintime.WithSpecProvider(eth2Client.(eth2client.SpecProvider)),
standardchaintime.WithGenesisTimeProvider(eth2Client.(eth2client.GenesisTimeProvider)),
)
if err != nil {
errCheck(err, "failed to set up chaintime service")
}

if viper.GetString("validator") == "" {
fmt.Println("validator is required")
os.Exit(_exitFailure)
Expand Down Expand Up @@ -84,7 +93,13 @@ In quiet mode this will return 0 if the validator information can be obtained, o
}
if viper.GetBool("verbose") {
if validator.Status.IsPending() {
fmt.Printf("Activation eligibility epoch: %d\n", validator.Validator.ActivationEligibilityEpoch)
if validator.Validator.ActivationEpoch == 0xffffffffffffffff {
fmt.Printf("Activation eligibility epoch: %d\n", validator.Validator.ActivationEligibilityEpoch)
fmt.Printf("Activation eligibility timestamp: %v\n", chainTime.StartOfEpoch(validator.Validator.ActivationEligibilityEpoch))
} else {
fmt.Printf("Activation epoch: %d\n", validator.Validator.ActivationEpoch)
fmt.Printf("Activation timestamp: %v\n", chainTime.StartOfEpoch(validator.Validator.ActivationEpoch))
}
}
if validator.Status.HasActivated() {
fmt.Printf("Activation epoch: %d\n", validator.Validator.ActivationEpoch)
Expand Down

0 comments on commit 9d50a72

Please sign in to comment.