Skip to content

Commit

Permalink
Revert "Enable NOISE Handshake by Default v0.11 (#5272)" (#5381)
Browse files Browse the repository at this point in the history
This reverts commit a8d32d5.
  • Loading branch information
prestonvanloon authored Apr 10, 2020
1 parent 9f9c679 commit 2aa8f4c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/p2p/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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",
Expand Down Expand Up @@ -126,7 +127,6 @@ 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",
Expand Down
8 changes: 5 additions & 3 deletions beacon-chain/p2p/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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.
Expand All @@ -28,9 +29,10 @@ 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)),
// Enable NOISE handshakes by default in the beacon node.
libp2p.Security(noise.ID, noise.New),
libp2p.DefaultSecurity,
}
if featureconfig.Get().EnableNoise {
// Enable NOISE for the beacon node
options = append(options, libp2p.Security(noise.ID, noise.New))
}
if cfg.EnableUPnP {
options = append(options, libp2p.NATPortMap()) //Allow to use UPnP
Expand Down
9 changes: 1 addition & 8 deletions beacon-chain/p2p/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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"
logTest "github.com/sirupsen/logrus/hooks/test"
mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
Expand Down Expand Up @@ -68,13 +67,7 @@ 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),
libp2p.Security(noise.ID, noise.New),
}...)
h, err := libp2p.New(context.Background(), []libp2p.Option{privKeyOption(pkey), libp2p.ListenAddrs(listen)}...)
if err != nil {
t.Fatal(err)
}
Expand Down
5 changes: 5 additions & 0 deletions shared/featureconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ 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.
DisableNewStateMgmt bool // NewStateMgmt disables the new state mgmt service.
DisableInitSyncQueue bool // DisableInitSyncQueue disables the new initial sync implementation.
Expand Down Expand Up @@ -161,6 +162,10 @@ 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
Expand Down
13 changes: 7 additions & 6 deletions shared/featureconfig/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ 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",
Expand Down Expand Up @@ -143,11 +148,6 @@ var (
Usage: deprecatedUsage,
Hidden: true,
}
deprecatedEnableNoiseHandshake = &cli.BoolFlag{
Name: "enable-noise",
Usage: deprecatedUsage,
Hidden: true,
}
deprecatedEnableInitSyncQueue = &cli.BoolFlag{
Name: "enable-initial-sync-queue",
Usage: deprecatedUsage,
Expand Down Expand Up @@ -198,6 +198,7 @@ var (
Usage: deprecatedUsage,
Hidden: true,
}

deprecatedEnableCustomStateSSZFlag = &cli.BoolFlag{
Name: "enable-custom-state-ssz",
Usage: deprecatedUsage,
Expand Down Expand Up @@ -282,7 +283,6 @@ var (

var deprecatedFlags = []cli.Flag{
deprecatedNoCustomConfigFlag,
deprecatedEnableNoiseHandshake,
deprecatedEnableInitSyncQueue,
deprecatedEnableFinalizedBlockRootIndexFlag,
deprecatedScatterFlag,
Expand Down Expand Up @@ -344,6 +344,7 @@ var BeaconChainFlags = append(deprecatedFlags, []cli.Flag{
enableByteMempool,
enableStateGenSigVerify,
checkHeadState,
enableNoiseHandshake,
dontPruneStateStartUp,
broadcastSlashingFlag,
disableNewStateMgmt,
Expand Down

0 comments on commit 2aa8f4c

Please sign in to comment.