Skip to content

Instantly share code, notes, and snippets.

@guybrush
Last active May 15, 2020 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guybrush/71d0e043dedc8e64ab158bad36863a9b to your computer and use it in GitHub Desktop.
Save guybrush/71d0e043dedc8e64ab158bad36863a9b to your computer and use it in GitHub Desktop.
prysm node runs with `--enable-new-state-mgmt`
nodeVersion : Prysm/Git commit: 34c02ffd346462f387f3d99eab798cf81f845c8e. Built at: 2020-05-14 03:26:24+00:00
headEpoch : 6156
finalizedEpoch: 6154
justifiedEpoch: 6155
panic: rpc error: code = Internal desc = Could not paginate results: page start 28500 >= list 28500
package main
import (
"context"
"eth2-exporter/utils"
"flag"
"fmt"
ptypes "github.com/gogo/protobuf/types"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"google.golang.org/grpc"
)
func main() {
addrFlag := flag.String("addr", ":4000", "address of beacon-node to connect to")
epochFlag := flag.Uint64("epoch", 0, "epoch to query")
flag.Parse()
dialOpt := grpc.WithInsecure()
conn, err := grpc.Dial(*addrFlag, dialOpt)
if err != nil {
panic(err)
}
nodeClient := ethpb.NewNodeClient(conn)
version, err := nodeClient.GetVersion(context.Background(), &ptypes.Empty{})
if err != nil {
panic(err)
}
chainClient := ethpb.NewBeaconChainClient(conn)
chainHead, err := chainClient.GetChainHead(context.Background(), &ptypes.Empty{})
if err != nil {
panic(err)
}
fmt.Printf("nodeVersion : %v\n", version.Version)
fmt.Printf("headEpoch : %v\n", chainHead.HeadEpoch)
fmt.Printf("finalizedEpoch: %v\n", chainHead.FinalizedEpoch)
fmt.Printf("justifiedEpoch: %v\n", chainHead.JustifiedEpoch)
epoch := *epochFlag
validatorsResponse := &ethpb.Validators{}
validatorsRequest := &ethpb.ListValidatorsRequest{PageSize: utils.PageSize, PageToken: validatorsResponse.NextPageToken, QueryFilter: &ethpb.ListValidatorsRequest_Epoch{Epoch: epoch}}
if epoch == 0 {
validatorsRequest.QueryFilter = &ethpb.ListValidatorsRequest_Genesis{Genesis: true}
}
for {
validatorsRequest.PageToken = validatorsResponse.NextPageToken
validatorsResponse, err = chainClient.ListValidators(context.Background(), validatorsRequest)
if err != nil {
panic(err)
}
if validatorsResponse.TotalSize == 0 {
break
}
if false {
for _, validator := range validatorsResponse.ValidatorList {
fmt.Println(validator.Index, validator.Validator.PublicKey)
}
}
if validatorsResponse.NextPageToken == "" {
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment