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

update dependency on libp2p from 0.4.0 to 0.32.1 #327

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
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
30 changes: 23 additions & 7 deletions 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 Expand Up @@ -105,7 +105,7 @@ func generateKeyFiles(prefix string) error {
pkFile := prefix + ".key"

// Write private key file
err := saveKeyFile(pkFile, priv)
err := savePrivKeyFile(pkFile, priv)
if err != nil {
return err
}
Expand All @@ -117,7 +117,7 @@ func saveFilesFromKeys(priv crypto.PrivKey, pub crypto.PubKey, prefix string) er
pubFile := prefix + ".pub"
idFile := prefix + ".id"
// Write public key file
err := saveKeyFile(pubFile, pub)
err := savePubKeyFile(pubFile, pub)
if err != nil {
return err
}
Expand All @@ -128,7 +128,7 @@ func saveFilesFromKeys(priv crypto.PrivKey, pub crypto.PubKey, prefix string) er
saveBytesToFile(idFile, idBytes)

if genAddress {
pkBytes, err := priv.Bytes()
pkBytes, err := crypto.MarshalPrivateKey(priv)
if err != nil {
return err
}
Expand All @@ -149,12 +149,28 @@ func saveFilesFromKeys(priv crypto.PrivKey, pub crypto.PubKey, prefix string) er
return nil
}

func saveKeyFile(pkFile string, priv crypto.Key) error {
func savePrivKeyFile(pkFile string, priv crypto.PrivKey) error {
pkf, err := os.Create(pkFile)
if err != nil {
return err
}
pkBytes, err := priv.Bytes()
pkBytes, err := crypto.MarshalPrivateKey(priv)
if err != nil {
return err
}
_, err = pkf.Write(pkBytes)
if err != nil {
return err
}
return pkf.Sync()
}

func savePubKeyFile(pkFile string, pub crypto.PubKey) error {
pkf, err := os.Create(pkFile)
if err != nil {
return err
}
pkBytes, err := crypto.MarshalPublicKey(pub)
if err != nil {
return err
}
Expand All @@ -179,7 +195,7 @@ func saveBytesToFile(fileName string, bytes []byte) error {
func generateKeyJson(priv crypto.PrivKey, pub crypto.PubKey) error {
btcPK := p2putil.ConvertPKToBTCEC(priv)
pkBytes := btcPK.Serialize()
pubBytes, err := pub.Bytes()
pubBytes, err := crypto.MarshalPublicKey(pub)
pid, _ := types.IDFromPublicKey(pub)
if err != nil {
return err
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
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (ctx *ServerContext) GetDefaultP2PConfig() *P2PConfig {
NPUsePolaris: true,
NPExposeSelf: true,
PeerRole: "",
AllowLegacy: true,
}
}

Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package config

import (
"io/ioutil"
"os"
"path"
"testing"

Expand All @@ -14,7 +14,7 @@ import (

func TestSetParamConfPath(t *testing.T) {
// create a temporary directory
tmpDir, err := ioutil.TempDir("", "test")
tmpDir, err := os.MkdirTemp("", "test")
if err != nil {
assert.Fail(t, err.Error())
}
Expand Down
2 changes: 2 additions & 0 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type P2PConfig struct {
Producers []string `mapstructure:"producers" description:"List of peer ids of block producers, only meaningful when peer is agent"`
InternalZones []string `mapstructure:"internalzones" description:"List of address ranges that are recognised as inner zone of agent. defined by CIDR notation."`
Agent string `mapstructure:"agent" description:"Peer id of agent that delegates this producer, only available when local peer is producer"`
AllowLegacy bool `mapstructure:"allowlegacy" description:"Whether to allow legacy security protocols"`
}

// AuthConfig defines configuration for auditing
Expand Down Expand Up @@ -218,6 +219,7 @@ npaddpolarises = [{{range .P2P.NPAddPolarises}}
"{{.}}", {{end}}
]
peerrole = "{{.P2P.PeerRole}}"
allowlegacy = "{{.P2P.AllowLegacy}}"

[polaris]
allowprivate = {{.Polaris.AllowPrivate}}
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
6 changes: 3 additions & 3 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 Expand Up @@ -74,7 +74,7 @@ func (tc *testChain) setGenesis(block *types.Block) {

func (tc *testChain) addBlock(i types.BlockNo) error {
pk := tc.getBpKey(i % types.BlockNo(tc.bpClusterSize))
b, err := pk.Bytes()
b, err := crypto.MarshalPrivateKey(pk)
if err != nil {
return 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