Skip to content

Commit

Permalink
update dependency on libp2p to 0.32.1
Browse files Browse the repository at this point in the history
- Fixed code that was not backward compatible due to the interface change.
- Fixed failed unit tests.
- Regenerate mock classes with newer gomock version.
- Improved documents of code generations of mock classes.
  • Loading branch information
hayarobi committed Dec 11, 2023
1 parent b5be8f4 commit ca26f63
Show file tree
Hide file tree
Showing 77 changed files with 1,034 additions and 979 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/full_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
go-version: '1.20'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
go-version: '1.20'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/short_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
go-version: '1.20'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion Docker/Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.0-bullseye as builder
FROM golang:1.20-bullseye as builder
ARG GIT_TAG=master
RUN apt-get -y update && apt-get -y install build-essential git cmake binutils m4 file
RUN git clone --branch ${GIT_TAG} --recursive https://github.com/aergoio/aergo.git \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ MVP based, Forward compatibility, Iteration

### Prerequisites

* Go1.19.1+ - https://golang.org/dl
* Go1.20 - https://golang.org/dl
* Proto Buffers - https://github.com/google/protobuf
* CMake 3.0.0 or higher - https://cmake.org

Expand Down
2 changes: 1 addition & 1 deletion cmd/aergocli/cmd/keygen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/aergoio/aergo/v2/p2p/p2putil"
"github.com/aergoio/aergo/v2/types"
"github.com/btcsuite/btcd/btcec"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/polaris/client/polarisconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/aergoio/aergo/v2/pkg/component"
"github.com/aergoio/aergo/v2/types"
"github.com/aergoio/aergo/v2/types/message"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p/core/network"
)

var ErrTooLowVersion = errors.New("aergosvr version is too low")
Expand Down Expand Up @@ -167,7 +167,7 @@ func (pcs *PolarisConnectSvc) connectAndQuery(mapServerMeta p2pcommon.PeerMeta,

peerID := s.Conn().RemotePeer()
if peerID != mapServerMeta.ID {
return nil, fmt.Errorf("internal error peerid mismatch, exp %s, actual %s", mapServerMeta.ID.Pretty(), peerID.Pretty())
return nil, fmt.Errorf("internal error peerid mismatch, exp %s, actual %s", mapServerMeta.ID.String(), peerID.String())
}
pcs.Logger.Debug().Str("polarisID", peerID.String()).Msg("Sending map query")

Expand Down
2 changes: 1 addition & 1 deletion cmd/polaris/common/polarisprotocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/aergoio/aergo/v2/p2p/p2pcommon"
core "github.com/libp2p/go-libp2p-core"
core "github.com/libp2p/go-libp2p/core"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions cmd/polaris/server/listmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ func Test_polarisListManager_IsBanned(t *testing.T) {
thirdAddr := "222.8.8.8"
thirdID := types.RandomPeerID()

IDOnly, e1 := types.ParseListEntry(`{"peerid":"` + id1.Pretty() + `"}`)
IDOnly, e1 := types.ParseListEntry(`{"peerid":"` + id1.String() + `"}`)
AddrOnly, e2 := types.ParseListEntry(`{"address":"` + addr1 + `"}`)
IDAddr, e3 := types.ParseListEntry(`{"peerid":"` + idother.Pretty() + `", "address":"` + addrother + `"}`)
IDAddr, e3 := types.ParseListEntry(`{"peerid":"` + idother.String() + `", "address":"` + addrother + `"}`)
if e1 != nil || e2 != nil || e3 != nil {
t.Fatalf("Inital entry value failure %v , %v , %v", e1, e2, e3)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/polaris/server/mapservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (pms *PeerMapService) onConnect(s types.Stream) {
pms.Logger.Info().Stringer(p2putil.LogPeerID, types.LogPeerShort(peerID)).Msg("Invalid address information")
return
}
pms.Logger.Info().Str("addr", s.Conn().RemoteMultiaddr().String()).Str(p2putil.LogFullID, peerID.Pretty()).Stringer(p2putil.LogPeerID, types.LogPeerShort(peerID)).Msg("remote peer connected")
pms.Logger.Info().Str("addr", s.Conn().RemoteMultiaddr().String()).Str(p2putil.LogFullID, peerID.String()).Stringer(p2putil.LogPeerID, types.LogPeerShort(peerID)).Msg("remote peer connected")

conn := p2pcommon.RemoteConn{IP: remoteIP, Port: port, Outbound: false}
tempMeta := p2pcommon.PeerMeta{ID: peerID, Addresses: []types.Multiaddr{s.Conn().RemoteMultiaddr()}}
Expand Down
4 changes: 2 additions & 2 deletions cmd/polaris/server/mapservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/aergoio/aergo/v2/pkg/component"
"github.com/aergoio/aergo/v2/types"
"github.com/golang/mock/gomock"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p/core/network"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -197,7 +197,7 @@ func TestPeerMapService_handleQuery(t *testing.T) {
pmapDummyNTC.chainID = &common.ONEMainNet
pmapDummyNTC.nt = mockNT
mockNT.EXPECT().AddStreamHandler(gomock.Any(), gomock.Any())
mockNT.EXPECT().GetOrCreateStreamWithTTL(gomock.Any(), gomock.Any(), common.PolarisPingSub).Return(mockStream, nil).MinTimes(1)
mockNT.EXPECT().GetOrCreateStreamWithTTL(gomock.Any(), gomock.Any(), common.PolarisPingSub).Return(mockStream, nil).Times(0)

pms := NewPolarisService(pmapDummyCfg, pmapDummyNTC)
pms.AfterStart()
Expand Down
2 changes: 1 addition & 1 deletion consensus/impl/dpos/blockfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/aergoio/aergo/v2/state"
"github.com/aergoio/aergo/v2/types"
"github.com/davecgh/go-spew/spew"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p/core/crypto"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion consensus/impl/dpos/bp/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (c *Cluster) BPs() []string {
PeerID string
}{
Index: strconv.FormatUint(uint64(i), 10),
PeerID: bp.id.Pretty(),
PeerID: bp.id.String(),
}

m, err := json.Marshal(p)
Expand Down
2 changes: 1 addition & 1 deletion consensus/impl/dpos/bp/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestNewCluster(t *testing.T) {
assert.Nil(t, err)
b, err := types.IDFromPublicKey(pubKey)
assert.Nil(t, err)
return b.Pretty()
return b.String()
}
genIds := func() []string {
Expand Down
4 changes: 2 additions & 2 deletions consensus/impl/dpos/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/aergoio/aergo/v2/internal/enc/base58"
"github.com/aergoio/aergo/v2/types"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -42,7 +42,7 @@ func newTestChain(clusterSize uint16) (*testChain, error) {
}
}

b, err := bpKey[0].GetPublic().Bytes()
b, err := crypto.MarshalPublicKey(bpKey[0].GetPublic())
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/impl/raftv2/blockfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/aergoio/aergo/v2/pkg/component"
"github.com/aergoio/aergo/v2/state"
"github.com/aergoio/aergo/v2/types"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p/core/crypto"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion consensus/impl/raftv2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ func (cl *Cluster) toConsensusInfo() *types.ConsensusInfo {
bps := make([]string, cl.Size)

for id, m := range cl.Members().MapByID {
bp := &PeerInfo{Name: m.Name, RaftID: EtcdIDToString(m.ID), PeerID: m.GetPeerID().Pretty(), Addr: m.Address}
bp := &PeerInfo{Name: m.Name, RaftID: EtcdIDToString(m.ID), PeerID: m.GetPeerID().String(), Addr: m.Address}
b, err = json.Marshal(bp)
if err != nil {
logger.Error().Err(err).Str("raftid", EtcdIDToString(id)).Msg("failed to marshalEntryData raft consensus bp")
Expand Down
2 changes: 1 addition & 1 deletion contract/system/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/aergoio/aergo/v2/internal/enc/base58"
"github.com/aergoio/aergo/v2/state"
"github.com/aergoio/aergo/v2/types"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/stretchr/testify/assert"
)

Expand Down
Loading

0 comments on commit ca26f63

Please sign in to comment.