Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go.mod][pubsub][test] Update libp2p, use MaxMessage at p2p level protection, remove dead code #2692

Merged
merged 9 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ go get -u github.com/golang/mock/mockgen; \
go get -u github.com/stamblerre/gocode; \
go get -u golang.org/x/tools/...


RUN eval "$(~/bin/gimme ${GIMME_GO_VERSION})" ; . ~/.bash_profile; \
go get -u honnef.co/go/tools/cmd/staticcheck/...

WORKDIR ${HMY_PATH}/harmony

RUN eval "$(~/bin/gimme ${GIMME_GO_VERSION})" ; scripts/install_build_tools.sh
Expand Down
14 changes: 8 additions & 6 deletions cmd/harmony/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"syscall"
"time"

"github.com/harmony-one/harmony/numeric"

ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/harmony-one/bls/ffi/go/bls"
Expand All @@ -38,12 +36,12 @@ import (
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/multibls"
"github.com/harmony-one/harmony/node"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/p2p"
"github.com/harmony-one/harmony/p2p/p2pimpl"
p2putils "github.com/harmony-one/harmony/p2p/utils"
"github.com/harmony-one/harmony/shard"
"github.com/harmony-one/harmony/webhooks"
golog "github.com/ipfs/go-log"
"github.com/pkg/errors"
gologging "github.com/whyrusleeping/go-logging"
)
Expand Down Expand Up @@ -811,18 +809,22 @@ func main() {
Str("BeaconGroupID", nodeConfig.GetBeaconGroupID().String()).
Str("ClientGroupID", nodeConfig.GetClientGroupID().String()).
Str("Role", currentNode.NodeConfig.Role().String()).
Str("multiaddress", fmt.Sprintf("/ip4/%s/tcp/%s/p2p/%s", *ip, *port, myHost.GetID().Pretty())).
Str("multiaddress",
fmt.Sprintf("/ip4/%s/tcp/%s/p2p/%s", *ip, *port, myHost.GetID().Pretty()),
).
Msg(startMsg)

if *logP2P {
f, err := os.OpenFile(path.Join(*logFolder, "libp2p.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
f, err := os.OpenFile(
path.Join(*logFolder, "libp2p.log"),
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644,
)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to open libp2p.log. %v\n", err)
} else {
defer f.Close()
backend1 := gologging.NewLogBackend(f, "", 0)
gologging.SetBackend(backend1)
golog.SetAllLoggers(gologging.DEBUG) // Change to DEBUG for extra info
}
}

Expand Down
31 changes: 19 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/cespare/cp v1.1.1
github.com/davecgh/go-spew v1.1.1
github.com/davidlazar/go-crypto v0.0.0-20190912175916-7055855a373f // indirect
github.com/deckarep/golang-set v1.7.1
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/ethereum/go-ethereum v1.8.27
Expand All @@ -22,28 +23,32 @@ require (
github.com/golangci/golangci-lint v1.22.2
github.com/gorilla/handlers v1.4.0
github.com/gorilla/mux v1.7.2
github.com/gorilla/websocket v1.4.2 // indirect
github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846
github.com/harmony-one/bls v0.0.6
github.com/harmony-one/taggedrlp v0.1.4
github.com/harmony-one/vdf v0.0.0-20190924175951-620379da8849
github.com/hashicorp/golang-lru v0.5.4
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
github.com/ipfs/go-ds-badger v0.2.1
github.com/ipfs/go-log v0.0.1
github.com/jackpal/gateway v1.0.6 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/karalabe/hid v1.0.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/libp2p/go-libp2p v0.5.2
github.com/libp2p/go-libp2p-core v0.3.0
github.com/libp2p/go-libp2p v0.7.3
github.com/libp2p/go-libp2p-core v0.5.0
github.com/libp2p/go-libp2p-crypto v0.1.0
github.com/libp2p/go-libp2p-discovery v0.2.0
github.com/libp2p/go-libp2p-host v0.1.0
github.com/libp2p/go-libp2p-kad-dht v0.5.0
github.com/libp2p/go-libp2p-net v0.1.0
github.com/libp2p/go-libp2p-peer v0.2.0
github.com/libp2p/go-libp2p-peerstore v0.1.4
github.com/libp2p/go-libp2p-pubsub v0.2.6
github.com/multiformats/go-multiaddr v0.2.0
github.com/multiformats/go-multiaddr-net v0.1.2
github.com/libp2p/go-libp2p-peerstore v0.2.2
github.com/libp2p/go-libp2p-pubsub v0.2.7-0.20200325112436-d3d43e32bef3
github.com/libp2p/go-nat v0.0.5 // indirect
github.com/libp2p/go-reuseport-transport v0.0.3 // indirect
github.com/multiformats/go-multiaddr v0.2.1
github.com/multiformats/go-multiaddr-net v0.1.4
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/pborman/uuid v1.2.0
github.com/pkg/errors v0.9.1
Expand All @@ -61,11 +66,13 @@ require (
github.com/uber/jaeger-client-go v2.20.1+incompatible // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/whyrusleeping/go-logging v0.0.1
go.uber.org/atomic v1.5.1 // indirect
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
golang.org/x/lint v0.0.0-20190930215403-16217165b5de
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/tools v0.0.0-20191113232020-e2727e816f5a
go.uber.org/zap v1.14.1 // indirect
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59
golang.org/x/lint v0.0.0-20200302205851-738671d3881b
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
golang.org/x/tools v0.0.0-20200402223321-bcf690261a44
google.golang.org/grpc v1.22.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
gopkg.in/ini.v1 v1.51.0
Expand Down
19 changes: 14 additions & 5 deletions p2p/host/hostv2/hostv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ import (
"os"
"sync"

"github.com/pkg/errors"
"github.com/rs/zerolog"

nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/p2p"

libp2p "github.com/libp2p/go-libp2p"
libp2p_crypto "github.com/libp2p/go-libp2p-crypto"
libp2p_host "github.com/libp2p/go-libp2p-host"
libp2p_peer "github.com/libp2p/go-libp2p-peer"
libp2p_peerstore "github.com/libp2p/go-libp2p-peerstore"
libp2p_pubsub "github.com/libp2p/go-libp2p-pubsub"
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/rs/zerolog"
)

const (
Expand Down Expand Up @@ -147,6 +145,9 @@ func (r *GroupReceiverImpl) Receive(ctx context.Context) (
msg = m.Data
sender = libp2p_peer.ID(m.From)
}

utils.Logger().Info().Int("size", len(msg)).Msg("receive p2p message")

return msg, sender, err
}

Expand Down Expand Up @@ -227,7 +228,15 @@ func New(self *p2p.Peer, priKey libp2p_crypto.PrivKey) (*HostV2, error) {
return nil, errors.Wrapf(err, "cannot initialize libp2p host")
}
traceFile := os.Getenv("P2P_TRACEFILE")
options := []libp2p_pubsub.Option{libp2p_pubsub.WithPeerOutboundQueueSize(64)}

// TODO first starting with some huge number to see update of libp2p
// and also to dump some values about the p2p message sizes
// 3MB
const MaxSize = 3_145_728
options := []libp2p_pubsub.Option{
libp2p_pubsub.WithPeerOutboundQueueSize(64),
libp2p_pubsub.WithMaxMessageSize(MaxSize),
}
if len(traceFile) > 0 {
tracer, _ := libp2p_pubsub.NewJSONTracer(traceFile)
options = append(options, libp2p_pubsub.WithEventTracer(tracer))
Expand Down
67 changes: 0 additions & 67 deletions test/cal_tps.sh

This file was deleted.

55 changes: 0 additions & 55 deletions test/crypto/bls/main.go

This file was deleted.

25 changes: 0 additions & 25 deletions test/one_address/main.go

This file was deleted.

22 changes: 0 additions & 22 deletions test/p2pchat/LICENSE

This file was deleted.

Loading