Skip to content

Commit

Permalink
Replace libp2p transport by GRPC (#539)
Browse files Browse the repository at this point in the history
* Replace libp2p transport by grpc

Remove everything libp2p-related from the repository.
The the libp2p transport module is replaced by a very similar one
based on GRPC instead, making also the old and rudimentary GRPC module
obsolete (and thus removed).

* Clean up go.mod (from libp2p)
* Bump golang.org/x/crypto from 0.14.0 to 0.17.0
* Fix GRPC transport tests

Signed-off-by: Matej Pavlovic <[email protected]>
  • Loading branch information
matejpavlovic authored Feb 5, 2024
1 parent d45c300 commit 92a1b70
Show file tree
Hide file tree
Showing 34 changed files with 1,103 additions and 3,268 deletions.
29 changes: 7 additions & 22 deletions cmd/bench/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,26 @@ import (
"fmt"
"net"
"os"
"strconv"
"time"

es "github.com/go-errors/errors"
"github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr/net"
"github.com/spf13/cobra"

"github.com/filecoin-project/mir/stdtypes"

"github.com/filecoin-project/mir"
"github.com/filecoin-project/mir/cmd/bench/localtxgenerator"
"github.com/filecoin-project/mir/cmd/bench/stats"
"github.com/filecoin-project/mir/pkg/deploytest"
"github.com/filecoin-project/mir/pkg/logging"
"github.com/filecoin-project/mir/pkg/membership"
libp2p2 "github.com/filecoin-project/mir/pkg/net/libp2p"
"github.com/filecoin-project/mir/pkg/net/grpc"
"github.com/filecoin-project/mir/pkg/rendezvous"
"github.com/filecoin-project/mir/pkg/trantor"
"github.com/filecoin-project/mir/pkg/trantor/appmodule"
tt "github.com/filecoin-project/mir/pkg/trantor/types"
"github.com/filecoin-project/mir/pkg/util/libp2p"
"github.com/filecoin-project/mir/pkg/util/maputil"
"github.com/filecoin-project/mir/stdtypes"
)

const (
Expand Down Expand Up @@ -97,12 +94,6 @@ func runNode() error {
return es.Errorf("could not load parameters from file '%s': %w", configFileName, err)
}

// Parse own ID.
ownNumericID, err := strconv.Atoi(id)
if err != nil {
return es.Errorf("unable to convert node ID: %w", err)
}

// Check if own id is in the membership
initialMembership := params.Trantor.Iss.InitialMembership
if _, ok := initialMembership.Nodes[stdtypes.NodeID(id)]; !ok {
Expand All @@ -122,20 +113,14 @@ func runNode() error {
return es.Errorf("could not create listen address: %w", err)
}

// Create libp2p host
h, err := libp2p.NewDummyHostWithPrivKey(
stdtypes.NodeAddress(libp2p.NewDummyMultiaddr(ownNumericID, listenAddr)),
libp2p.NewDummyHostKey(ownNumericID),
)
if err != nil {
return es.Errorf("failed to create libp2p host: %w", err)
}

// Initialize tracking of networking statistics.
netStats := stats.NewNetStats(time.Second)

// Initialize the libp2p transport subsystem.
transport := libp2p2.NewTransport(params.Trantor.Net, ownID, h, logger, netStats)
// Initialize the grpc transport subsystem.
transport, err := grpc.NewTransport(params.Trantor.Net, ownID, listenAddr.String(), logger, netStats)
if err != nil {
return es.Errorf("failed to create grpc transport: %w", err)
}

// Instantiate the crypto module.
localCryptoSystem, err := deploytest.NewLocalCryptoSystem("pseudo", membership.GetIDs(initialMembership), logger)
Expand Down
3 changes: 1 addition & 2 deletions cmd/mircat/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/filecoin-project/mir/pkg/pb/recordingpb"
trantorpbtypes "github.com/filecoin-project/mir/pkg/pb/trantorpb/types"
"github.com/filecoin-project/mir/pkg/trantor/appmodule"
"github.com/filecoin-project/mir/pkg/util/libp2p"
"github.com/filecoin-project/mir/stdmodules/timer"
"github.com/filecoin-project/mir/stdtypes"
)
Expand All @@ -40,7 +39,7 @@ func debug(args *arguments) error {
for _, nID := range args.membership {
membership.Nodes[nID] = &trantorpbtypes.NodeIdentity{
Id: nID,
Addr: libp2p.NewDummyHostAddr(0, 0).String(),
Addr: "", // TODO: THIS EMPTY ADDRESS MIGHT BREAK STUFF!!! Make sure the code still works.
Key: nil,
Weight: "1",
}
Expand Down
76 changes: 7 additions & 69 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ require (
github.com/AlecAivazis/survey/v2 v2.3.2
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/libp2p/go-libp2p v0.27.8
github.com/otiai10/copy v1.7.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.2
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3
google.golang.org/protobuf v1.30.0
Expand All @@ -29,113 +28,52 @@ require (
github.com/drand/kyber-bls12381 v0.3.0
github.com/fxamacker/cbor/v2 v2.4.0
github.com/go-errors/errors v1.4.2
github.com/ipfs/go-cid v0.4.1
github.com/libp2p/go-yamux/v4 v4.0.0
github.com/mattn/go-sqlite3 v1.14.16
github.com/multiformats/go-multiaddr v0.9.0
github.com/reactivex/rxgo/v2 v2.5.0
github.com/spf13/cobra v1.5.0
github.com/tidwall/gjson v1.14.2
github.com/tidwall/sjson v1.2.5
github.com/whyrusleeping/cbor-gen v0.0.0-20220514204315-f29c37e9c44c
go.uber.org/goleak v1.1.12
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f
gopkg.in/yaml.v3 v3.0.1
)

require (
filippo.io/bigmod v0.0.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/huin/goupnp v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/koron/go-ssdp v0.0.4 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.3.0 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.1 // indirect
github.com/libp2p/go-reuseport v0.3.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/miekg/dns v1.1.54 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multicodec v0.9.0 // indirect
github.com/multiformats/go-multihash v0.2.2 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onsi/ginkgo/v2 v2.9.7 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.3 // indirect
github.com/quic-go/qtls-go1-20 v0.2.3 // indirect
github.com/quic-go/quic-go v0.33.0 // indirect
github.com/quic-go/webtransport-go v0.5.3 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/teivah/onecontext v0.0.0-20200513185103-40f981bfd775 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/dig v1.17.0 // indirect
go.uber.org/fx v1.19.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.9.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
lukechampine.com/blake3 v1.2.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect
)
Loading

0 comments on commit 92a1b70

Please sign in to comment.