diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 9b00505bd..6ed282db9 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -55,6 +55,7 @@ go_library( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/startup:go_default_library", "//cmd/beacon-chain/flags:go_default_library", + "//config/features:go_default_library", "//config/params:go_default_library", "//consensus-types/primitives:go_default_library", "//consensus-types/wrapper:go_default_library", diff --git a/beacon-chain/p2p/options.go b/beacon-chain/p2p/options.go index 8301f5c34..031017a08 100644 --- a/beacon-chain/p2p/options.go +++ b/beacon-chain/p2p/options.go @@ -6,12 +6,14 @@ import ( "net" "github.com/libp2p/go-libp2p" + "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/p2p/muxer/mplex" "github.com/libp2p/go-libp2p/p2p/security/noise" "github.com/libp2p/go-libp2p/p2p/transport/tcp" ma "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" + "github.com/prysmaticlabs/prysm/v4/config/features" ecdsaprysm "github.com/prysmaticlabs/prysm/v4/crypto/ecdsa" "github.com/prysmaticlabs/prysm/v4/runtime/version" ) @@ -99,6 +101,9 @@ func (s *Service) buildOptions(ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt } // Disable Ping Service. options = append(options, libp2p.Ping(false)) + if features.Get().DisableResourceManager { + options = append(options, libp2p.ResourceManager(&network.NullResourceManager{})) + } return options } diff --git a/config/features/config.go b/config/features/config.go index 166de6f85..ee8489047 100644 --- a/config/features/config.go +++ b/config/features/config.go @@ -60,6 +60,7 @@ type Flags struct { SaveFullExecutionPayloads bool // Save full beacon blocks with execution payloads in the database. EnableStartOptimistic bool // EnableStartOptimistic treats every block as optimistic at startup. + DisableResourceManager bool // Disables running the node with libp2p's resource manager. DisableStakinContractCheck bool // Disables check for deposit contract when proposing blocks EnableVerboseSigVerification bool // EnableVerboseSigVerification specifies whether to verify individual signature if batch verification fails @@ -222,6 +223,10 @@ func ConfigureBeaconChain(ctx *cli.Context) error { logEnabled(disableBuildBlockParallel) cfg.BuildBlockParallel = false } + if ctx.IsSet(disableResourceManager.Name) { + logEnabled(disableResourceManager) + cfg.DisableResourceManager = true + } cfg.AggregateIntervals = [3]time.Duration{aggregateFirstInterval.Value, aggregateSecondInterval.Value, aggregateThirdInterval.Value} Init(cfg) return nil diff --git a/config/features/flags.go b/config/features/flags.go index cb0aacd1a..b7f09b387 100644 --- a/config/features/flags.go +++ b/config/features/flags.go @@ -140,6 +140,10 @@ var ( Name: "disable-build-block-parallel", Usage: "Disables building a beacon block in parallel for consensus and execution", } + disableResourceManager = &cli.BoolFlag{ + Name: "disable-resource-manager", + Usage: "Disables running the libp2p resource manager", + } ) // devModeFlags holds list of flags that are set when development mode is on. @@ -190,6 +194,7 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c aggregateFirstInterval, aggregateSecondInterval, aggregateThirdInterval, + disableResourceManager, }...)...) // E2EBeaconChainFlags contains a list of the beacon chain feature flags to be tested in E2E.