From ae36630ccdcb67a3075b01d95bca96813cfc9609 Mon Sep 17 00:00:00 2001 From: kasey <489222+kasey@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:08:19 -0500 Subject: [PATCH] Raise http body limit for fetching genesis state on Holesky (#14689) * use larger limit when fetching genesis * changelog --------- Co-authored-by: Kasey Kirkham --- CHANGELOG.md | 1 + api/client/client.go | 5 +++-- beacon-chain/sync/checkpoint/api.go | 4 +--- beacon-chain/sync/genesis/BUILD.bazel | 1 + beacon-chain/sync/genesis/api.go | 3 ++- cmd/prysmctl/checkpointsync/download.go | 4 +--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b1a8acfbb..c276da32e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -105,6 +105,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Diverse log improvements and comment additions. - P2P: Avoid infinite loop when looking for peers in small networks. - Fixed another rollback bug due to a context deadline. +- Fix checkpoint sync bug on holesky. [pr](https://github.com/prysmaticlabs/prysm/pull/14689) ### Security diff --git a/api/client/client.go b/api/client/client.go index fa39d32606..60bf6f5b33 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -11,8 +11,9 @@ import ( ) const ( - MaxBodySize int64 = 1 << 23 // 8MB default, WithMaxBodySize can override - MaxErrBodySize int64 = 1 << 17 // 128KB + MaxBodySize int64 = 1 << 23 // 8MB default, WithMaxBodySize can override + MaxBodySizeState int64 = 1 << 29 // 512MB + MaxErrBodySize int64 = 1 << 17 // 128KB ) // Client is a wrapper object around the HTTP client. diff --git a/beacon-chain/sync/checkpoint/api.go b/beacon-chain/sync/checkpoint/api.go index 7924b1671a..44a6fb2456 100644 --- a/beacon-chain/sync/checkpoint/api.go +++ b/beacon-chain/sync/checkpoint/api.go @@ -10,8 +10,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/config/params" ) -const stateSizeLimit int64 = 1 << 29 // 512MB - // APIInitializer manages initializing the beacon node using checkpoint sync, retrieving the checkpoint state and root // from the remote beacon node api. type APIInitializer struct { @@ -21,7 +19,7 @@ type APIInitializer struct { // NewAPIInitializer creates an APIInitializer, handling the set up of a beacon node api client // using the provided host string. func NewAPIInitializer(beaconNodeHost string) (*APIInitializer, error) { - c, err := beacon.NewClient(beaconNodeHost, client.WithMaxBodySize(stateSizeLimit)) + c, err := beacon.NewClient(beaconNodeHost, client.WithMaxBodySize(client.MaxBodySizeState)) if err != nil { return nil, errors.Wrapf(err, "unable to parse beacon node url or hostname - %s", beaconNodeHost) } diff --git a/beacon-chain/sync/genesis/BUILD.bazel b/beacon-chain/sync/genesis/BUILD.bazel index 22a55a88e5..5f6ae48409 100644 --- a/beacon-chain/sync/genesis/BUILD.bazel +++ b/beacon-chain/sync/genesis/BUILD.bazel @@ -10,6 +10,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/genesis", visibility = ["//visibility:public"], deps = [ + "//api/client:go_default_library", "//api/client/beacon:go_default_library", "//beacon-chain/db:go_default_library", "//crypto/hash:go_default_library", diff --git a/beacon-chain/sync/genesis/api.go b/beacon-chain/sync/genesis/api.go index 643f857dba..d34e18ef92 100644 --- a/beacon-chain/sync/genesis/api.go +++ b/beacon-chain/sync/genesis/api.go @@ -4,6 +4,7 @@ import ( "context" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v5/api/client" "github.com/prysmaticlabs/prysm/v5/api/client/beacon" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db" ) @@ -17,7 +18,7 @@ type APIInitializer struct { // NewAPIInitializer creates an APIInitializer, handling the set up of a beacon node api client // using the provided host string. func NewAPIInitializer(beaconNodeHost string) (*APIInitializer, error) { - c, err := beacon.NewClient(beaconNodeHost) + c, err := beacon.NewClient(beaconNodeHost, client.WithMaxBodySize(client.MaxBodySizeState)) if err != nil { return nil, errors.Wrapf(err, "unable to parse beacon node url or hostname - %s", beaconNodeHost) } diff --git a/cmd/prysmctl/checkpointsync/download.go b/cmd/prysmctl/checkpointsync/download.go index b8415a8d60..65954b66af 100644 --- a/cmd/prysmctl/checkpointsync/download.go +++ b/cmd/prysmctl/checkpointsync/download.go @@ -42,13 +42,11 @@ var downloadCmd = &cli.Command{ }, } -const stateSizeLimit int64 = 1 << 29 // 512MB to accommodate future state growth - func cliActionDownload(_ *cli.Context) error { ctx := context.Background() f := downloadFlags - opts := []client.ClientOpt{client.WithTimeout(f.Timeout), client.WithMaxBodySize(stateSizeLimit)} + opts := []client.ClientOpt{client.WithTimeout(f.Timeout), client.WithMaxBodySize(client.MaxBodySizeState)} client, err := beacon.NewClient(downloadFlags.BeaconNodeHost, opts...) if err != nil { return err