mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
6672d1499a
* wip proposer settings * WIP validator client APIs * adding proposer settings output * adding unit tests * fixing linting * fixing deepsource issues * fixing e2e * fixing deep source issue * updating naming to not stutter * updating bazel * fixing linting error * reverting comment * adding builder settings * gaz * Update validator/client/validator.go Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> * adding comments * adding some tests * gaz * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/errors.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/options.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/validator/client.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/cmd.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/validator/client.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/validator/client.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update cmd/prysmctl/validator/proposer_settings.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * Update api/client/errors.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * fixing feedback * fixing unit test * addressign comments --------- Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com> Co-authored-by: Radosław Kapka <rkapka@wp.pl>
79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
package checkpointsync
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/api/client"
|
|
"github.com/prysmaticlabs/prysm/v4/api/client/beacon"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
var downloadFlags = struct {
|
|
BeaconNodeHost string
|
|
Timeout time.Duration
|
|
}{}
|
|
|
|
var downloadCmd = &cli.Command{
|
|
Name: "download",
|
|
Aliases: []string{"dl"},
|
|
Usage: "Download the latest finalized state and the most recent block it integrates. To be used for checkpoint sync.",
|
|
Action: func(cliCtx *cli.Context) error {
|
|
if err := cliActionDownload(cliCtx); err != nil {
|
|
log.WithError(err).Fatal("Could not download checkpoint-sync data")
|
|
}
|
|
return nil
|
|
},
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "beacon-node-host",
|
|
Usage: "host:port for beacon node connection",
|
|
Destination: &downloadFlags.BeaconNodeHost,
|
|
Value: "localhost:3500",
|
|
},
|
|
&cli.DurationFlag{
|
|
Name: "http-timeout",
|
|
Usage: "timeout for http requests made to beacon-node-url (uses duration format, ex: 2m31s). default: 4m",
|
|
Destination: &downloadFlags.Timeout,
|
|
Value: time.Minute * 4,
|
|
},
|
|
},
|
|
}
|
|
|
|
func cliActionDownload(_ *cli.Context) error {
|
|
ctx := context.Background()
|
|
f := downloadFlags
|
|
|
|
opts := []client.ClientOpt{client.WithTimeout(f.Timeout)}
|
|
client, err := beacon.NewClient(downloadFlags.BeaconNodeHost, opts...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
cwd, err := os.Getwd()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
od, err := beacon.DownloadFinalizedData(ctx, client)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
blockPath, err := od.SaveBlock(cwd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Printf("saved ssz-encoded block to %s", blockPath)
|
|
|
|
statePath, err := od.SaveState(cwd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log.Printf("saved ssz-encoded state to %s", statePath)
|
|
|
|
return nil
|
|
}
|