mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-07 20:43:57 -05:00
Enable NOISE Handshake by Default v0.11 (#5272)
* noise handshakes by default * fix build * noisy noise everywhere * deprecated noisy noise flag with more noise * add secio as fallback Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: nisdas <nishdas93@gmail.com>
This commit is contained in:
@@ -39,7 +39,6 @@ go_library(
|
||||
"//beacon-chain/p2p/peers:go_default_library",
|
||||
"//proto/beacon/p2p/v1:go_default_library",
|
||||
"//shared:go_default_library",
|
||||
"//shared/featureconfig:go_default_library",
|
||||
"//shared/hashutil:go_default_library",
|
||||
"//shared/iputils:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
@@ -121,6 +120,7 @@ go_test(
|
||||
"@com_github_libp2p_go_libp2p_core//host:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_core//network:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_core//peer:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_noise//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_pubsub//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_swarm//testing:go_default_library",
|
||||
"@com_github_multiformats_go_multiaddr//:go_default_library",
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/connmgr"
|
||||
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||||
)
|
||||
|
||||
// buildOptions for the libp2p host.
|
||||
@@ -29,10 +28,9 @@ func buildOptions(cfg *Config, ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt
|
||||
// Add one for the boot node and another for the relay, otherwise when we are close to maxPeers we will be above the high
|
||||
// water mark and continually trigger pruning.
|
||||
libp2p.ConnectionManager(connmgr.NewConnManager(int(cfg.MaxPeers+2), int(cfg.MaxPeers+2), 1*time.Second)),
|
||||
}
|
||||
if featureconfig.Get().EnableNoise {
|
||||
// Enable NOISE for the beacon node
|
||||
options = append(options, libp2p.Security(noise.ID, noise.New))
|
||||
// Enable NOISE handshakes by default in the beacon node.
|
||||
libp2p.Security(noise.ID, noise.New),
|
||||
libp2p.DefaultSecurity,
|
||||
}
|
||||
if cfg.EnableUPnP {
|
||||
options = append(options, libp2p.NATPortMap()) //Allow to use UPnP
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
libp2p "github.com/libp2p/go-libp2p"
|
||||
"github.com/libp2p/go-libp2p-core/host"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
noise "github.com/libp2p/go-libp2p-noise"
|
||||
multiaddr "github.com/multiformats/go-multiaddr"
|
||||
testDB "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||
@@ -64,7 +65,13 @@ func createHost(t *testing.T, port int) (host.Host, *ecdsa.PrivateKey, net.IP) {
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to p2p listen: %v", err)
|
||||
}
|
||||
h, err := libp2p.New(context.Background(), []libp2p.Option{privKeyOption(pkey), libp2p.ListenAddrs(listen)}...)
|
||||
h, err := libp2p.New(
|
||||
context.Background(),
|
||||
[]libp2p.Option{
|
||||
privKeyOption(pkey),
|
||||
libp2p.ListenAddrs(listen),
|
||||
libp2p.Security(noise.ID, noise.New),
|
||||
}...)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ type Flags struct {
|
||||
EnableDomainDataCache bool // EnableDomainDataCache caches validator calls to DomainData per epoch.
|
||||
EnableStateGenSigVerify bool // EnableStateGenSigVerify verifies proposer and randao signatures during state gen.
|
||||
CheckHeadState bool // CheckHeadState checks the current headstate before retrieving the desired state from the db.
|
||||
EnableNoise bool // EnableNoise enables the beacon node to use NOISE instead of SECIO when performing a handshake with another peer.
|
||||
DontPruneStateStartUp bool // DontPruneStateStartUp disables pruning state upon beacon node start up.
|
||||
NewStateMgmt bool // NewStateMgmt enables the new experimental state mgmt service.
|
||||
EnableInitSyncQueue bool // EnableInitSyncQueue enables the new initial sync implementation.
|
||||
@@ -162,10 +161,6 @@ func ConfigureBeaconChain(ctx *cli.Context) {
|
||||
log.Warn("Enabling check head state for chainservice")
|
||||
cfg.CheckHeadState = true
|
||||
}
|
||||
if ctx.Bool(enableNoiseHandshake.Name) {
|
||||
log.Warn("Enabling noise handshake for peer")
|
||||
cfg.EnableNoise = true
|
||||
}
|
||||
if ctx.Bool(dontPruneStateStartUp.Name) {
|
||||
log.Warn("Not enabling state pruning upon start up")
|
||||
cfg.DontPruneStateStartUp = true
|
||||
|
||||
@@ -112,11 +112,6 @@ var (
|
||||
Name: "check-head-state",
|
||||
Usage: "Enables the checking of head state in chainservice first before retrieving the desired state from the db.",
|
||||
}
|
||||
enableNoiseHandshake = &cli.BoolFlag{
|
||||
Name: "enable-noise",
|
||||
Usage: "This enables the beacon node to use NOISE instead of SECIO for performing handshakes between peers and " +
|
||||
"securing transports between peers",
|
||||
}
|
||||
dontPruneStateStartUp = &cli.BoolFlag{
|
||||
Name: "dont-prune-state-start-up",
|
||||
Usage: "Don't prune historical states upon start up",
|
||||
@@ -148,6 +143,11 @@ var (
|
||||
const deprecatedUsage = "DEPRECATED. DO NOT USE."
|
||||
|
||||
var (
|
||||
deprecatedEnableNoiseHandshake = &cli.BoolFlag{
|
||||
Name: "enable-noise",
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
deprecatedEnableFinalizedBlockRootIndexFlag = &cli.BoolFlag{
|
||||
Name: "enable-finalized-block-root-index",
|
||||
Usage: deprecatedUsage,
|
||||
@@ -193,7 +193,6 @@ var (
|
||||
Usage: deprecatedUsage,
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
deprecatedEnableCustomStateSSZFlag = &cli.BoolFlag{
|
||||
Name: "enable-custom-state-ssz",
|
||||
Usage: deprecatedUsage,
|
||||
@@ -272,6 +271,7 @@ var (
|
||||
)
|
||||
|
||||
var deprecatedFlags = []cli.Flag{
|
||||
deprecatedEnableNoiseHandshake,
|
||||
deprecatedEnableFinalizedBlockRootIndexFlag,
|
||||
deprecatedScatterFlag,
|
||||
deprecatedPruneFinalizedStatesFlag,
|
||||
@@ -332,7 +332,6 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
|
||||
enableByteMempool,
|
||||
enableStateGenSigVerify,
|
||||
checkHeadState,
|
||||
enableNoiseHandshake,
|
||||
dontPruneStateStartUp,
|
||||
broadcastSlashingFlag,
|
||||
newStateMgmt,
|
||||
|
||||
Reference in New Issue
Block a user