mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Prioritize eth/68 by default (#7463)
Set `DefaultConfig.ProtocolVersion` to [68, 67, 66] instead of [67, 68]. See https://github.com/ethereum/hive/pull/776
This commit is contained in:
parent
d9abfd826f
commit
cc11462860
@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/core/forkid"
|
||||
@ -239,11 +240,10 @@ func makeOurHelloMessage(myPrivateKey *ecdsa.PrivateKey) HelloMessage {
|
||||
clientID := common.MakeName("observer", version)
|
||||
|
||||
caps := []p2p.Cap{
|
||||
{Name: eth.ProtocolName, Version: 63},
|
||||
{Name: eth.ProtocolName, Version: 64},
|
||||
{Name: eth.ProtocolName, Version: 65},
|
||||
{Name: eth.ProtocolName, Version: eth.ETH66},
|
||||
{Name: eth.ProtocolName, Version: eth.ETH67},
|
||||
{Name: eth.ProtocolName, Version: direct.ETH65},
|
||||
{Name: eth.ProtocolName, Version: direct.ETH66},
|
||||
{Name: eth.ProtocolName, Version: direct.ETH67},
|
||||
{Name: eth.ProtocolName, Version: direct.ETH68},
|
||||
}
|
||||
|
||||
return HelloMessage{
|
||||
|
@ -4,12 +4,14 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/ledgerwatch/erigon/crypto"
|
||||
"github.com/ledgerwatch/erigon/eth/protocols/eth"
|
||||
"github.com/ledgerwatch/erigon/p2p/enode"
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
|
||||
"github.com/ledgerwatch/erigon/crypto"
|
||||
"github.com/ledgerwatch/erigon/p2p/enode"
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
)
|
||||
|
||||
func TestHandshake(t *testing.T) {
|
||||
@ -31,6 +33,6 @@ func TestHandshake(t *testing.T) {
|
||||
assert.Contains(t, hello.ClientID, "erigon")
|
||||
|
||||
require.NotNil(t, status)
|
||||
assert.Equal(t, uint32(eth.ETH66), status.ProtocolVersion)
|
||||
assert.Equal(t, uint32(direct.ETH66), status.ProtocolVersion)
|
||||
assert.Equal(t, uint64(1), status.NetworkID)
|
||||
}
|
||||
|
@ -5,10 +5,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
||||
proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core/forkid"
|
||||
"github.com/ledgerwatch/erigon/eth/protocols/eth"
|
||||
@ -16,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCheckPeerStatusCompatibility(t *testing.T) {
|
||||
var version uint = eth.ETH66
|
||||
var version uint = direct.ETH66
|
||||
networkID := params.MainnetChainConfig.ChainID.Uint64()
|
||||
goodReply := eth.StatusPacket{
|
||||
ProtocolVersion: uint32(version),
|
||||
@ -52,14 +54,14 @@ func TestCheckPeerStatusCompatibility(t *testing.T) {
|
||||
})
|
||||
t.Run("version mismatch min", func(t *testing.T) {
|
||||
reply := goodReply
|
||||
reply.ProtocolVersion = eth.ETH66 - 1
|
||||
reply.ProtocolVersion = direct.ETH66 - 1
|
||||
err := checkPeerStatusCompatibility(&reply, &status, version, version)
|
||||
assert.NotNil(t, err)
|
||||
assert.Contains(t, err.Error(), "version is less")
|
||||
})
|
||||
t.Run("version mismatch max", func(t *testing.T) {
|
||||
reply := goodReply
|
||||
reply.ProtocolVersion = eth.ETH66 + 1
|
||||
reply.ProtocolVersion = direct.ETH66 + 1
|
||||
err := checkPeerStatusCompatibility(&reply, &status, version, version)
|
||||
assert.NotNil(t, err)
|
||||
assert.Contains(t, err.Error(), "version is more")
|
||||
|
@ -18,19 +18,21 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/common/dir"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces/grpcutil"
|
||||
proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
|
||||
proto_types "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/health"
|
||||
"google.golang.org/grpc/health/grpc_health_v1"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/common/dir"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces/grpcutil"
|
||||
proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
|
||||
proto_types "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cmd/utils"
|
||||
"github.com/ledgerwatch/erigon/common/debug"
|
||||
"github.com/ledgerwatch/erigon/core/forkid"
|
||||
@ -414,7 +416,7 @@ func runPeer(
|
||||
}
|
||||
send(eth.ToProto[protocol][msg.Code], peerID, b)
|
||||
case eth.GetNodeDataMsg:
|
||||
if protocol >= eth.ETH67 {
|
||||
if protocol >= direct.ETH67 {
|
||||
msg.Discard()
|
||||
return fmt.Errorf("unexpected GetNodeDataMsg from %s in eth/%d", peerID, protocol)
|
||||
}
|
||||
@ -558,75 +560,67 @@ func NewGrpcServer(ctx context.Context, dialCandidates func() enode.Iterator, re
|
||||
logger: logger,
|
||||
}
|
||||
|
||||
protocols := []uint{protocol}
|
||||
if protocol == eth.ETH67 {
|
||||
protocols = append(protocols, eth.ETH66)
|
||||
var disc enode.Iterator
|
||||
if dialCandidates != nil {
|
||||
disc = dialCandidates()
|
||||
}
|
||||
|
||||
for _, p := range protocols {
|
||||
protocol := p
|
||||
var disc enode.Iterator
|
||||
if dialCandidates != nil {
|
||||
disc = dialCandidates()
|
||||
}
|
||||
ss.Protocols = append(ss.Protocols, p2p.Protocol{
|
||||
Name: eth.ProtocolName,
|
||||
Version: protocol,
|
||||
Length: 17,
|
||||
DialCandidates: disc,
|
||||
Run: func(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||
peerID := peer.Pubkey()
|
||||
printablePeerID := hex.EncodeToString(peerID[:])[:20]
|
||||
if ss.getPeer(peerID) != nil {
|
||||
logger.Trace("[p2p] peer already has connection", "peerId", printablePeerID)
|
||||
return nil
|
||||
}
|
||||
logger.Trace("[p2p] start with peer", "peerId", printablePeerID)
|
||||
|
||||
peerInfo := NewPeerInfo(peer, rw)
|
||||
peerInfo.protocol = protocol
|
||||
defer peerInfo.Close()
|
||||
|
||||
defer ss.GoodPeers.Delete(peerID)
|
||||
err := handShake(ctx, ss.GetStatus(), peerID, rw, protocol, protocol, func(bestHash libcommon.Hash) error {
|
||||
ss.GoodPeers.Store(peerID, peerInfo)
|
||||
ss.sendNewPeerToClients(gointerfaces.ConvertHashToH512(peerID))
|
||||
return ss.startSync(ctx, bestHash, peerID)
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, NetworkIdMissmatchErr) || errors.Is(err, io.EOF) || errors.Is(err, p2p.ErrShuttingDown) {
|
||||
logger.Trace("[p2p] Handshake failure", "peer", printablePeerID, "err", err)
|
||||
} else {
|
||||
logger.Debug("[p2p] Handshake failure", "peer", printablePeerID, "err", err)
|
||||
}
|
||||
return fmt.Errorf("[p2p]handshake to peer %s: %w", printablePeerID, err)
|
||||
}
|
||||
logger.Trace("[p2p] Received status message OK", "peerId", printablePeerID, "name", peer.Name())
|
||||
|
||||
err = runPeer(
|
||||
ctx,
|
||||
peerID,
|
||||
protocol,
|
||||
rw,
|
||||
peerInfo,
|
||||
ss.send,
|
||||
ss.hasSubscribers,
|
||||
logger,
|
||||
) // runPeer never returns a nil error
|
||||
logger.Trace("[p2p] error while running peer", "peerId", printablePeerID, "err", err)
|
||||
ss.sendGonePeerToClients(gointerfaces.ConvertHashToH512(peerID))
|
||||
ss.Protocols = append(ss.Protocols, p2p.Protocol{
|
||||
Name: eth.ProtocolName,
|
||||
Version: protocol,
|
||||
Length: 17,
|
||||
DialCandidates: disc,
|
||||
Run: func(peer *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||
peerID := peer.Pubkey()
|
||||
printablePeerID := hex.EncodeToString(peerID[:])[:20]
|
||||
if ss.getPeer(peerID) != nil {
|
||||
logger.Trace("[p2p] peer already has connection", "peerId", printablePeerID)
|
||||
return nil
|
||||
},
|
||||
NodeInfo: func() interface{} {
|
||||
return readNodeInfo()
|
||||
},
|
||||
PeerInfo: func(peerID [64]byte) interface{} {
|
||||
// TODO: remember handshake reply per peer ID and return eth-related Status info (see ethPeerInfo in geth)
|
||||
return nil
|
||||
},
|
||||
//Attributes: []enr.Entry{eth.CurrentENREntry(chainConfig, genesisHash, headHeight)},
|
||||
})
|
||||
}
|
||||
}
|
||||
logger.Trace("[p2p] start with peer", "peerId", printablePeerID)
|
||||
|
||||
peerInfo := NewPeerInfo(peer, rw)
|
||||
peerInfo.protocol = protocol
|
||||
defer peerInfo.Close()
|
||||
|
||||
defer ss.GoodPeers.Delete(peerID)
|
||||
err := handShake(ctx, ss.GetStatus(), peerID, rw, protocol, protocol, func(bestHash libcommon.Hash) error {
|
||||
ss.GoodPeers.Store(peerID, peerInfo)
|
||||
ss.sendNewPeerToClients(gointerfaces.ConvertHashToH512(peerID))
|
||||
return ss.startSync(ctx, bestHash, peerID)
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, NetworkIdMissmatchErr) || errors.Is(err, io.EOF) || errors.Is(err, p2p.ErrShuttingDown) {
|
||||
logger.Trace("[p2p] Handshake failure", "peer", printablePeerID, "err", err)
|
||||
} else {
|
||||
logger.Debug("[p2p] Handshake failure", "peer", printablePeerID, "err", err)
|
||||
}
|
||||
return fmt.Errorf("[p2p]handshake to peer %s: %w", printablePeerID, err)
|
||||
}
|
||||
logger.Trace("[p2p] Received status message OK", "peerId", printablePeerID, "name", peer.Name())
|
||||
|
||||
err = runPeer(
|
||||
ctx,
|
||||
peerID,
|
||||
protocol,
|
||||
rw,
|
||||
peerInfo,
|
||||
ss.send,
|
||||
ss.hasSubscribers,
|
||||
logger,
|
||||
) // runPeer never returns a nil error
|
||||
logger.Trace("[p2p] error while running peer", "peerId", printablePeerID, "err", err)
|
||||
ss.sendGonePeerToClients(gointerfaces.ConvertHashToH512(peerID))
|
||||
return nil
|
||||
},
|
||||
NodeInfo: func() interface{} {
|
||||
return readNodeInfo()
|
||||
},
|
||||
PeerInfo: func(peerID [64]byte) interface{} {
|
||||
// TODO: remember handshake reply per peer ID and return eth-related Status info (see ethPeerInfo in geth)
|
||||
return nil
|
||||
},
|
||||
//Attributes: []enr.Entry{eth.CurrentENREntry(chainConfig, genesisHash, headHeight)},
|
||||
})
|
||||
|
||||
return ss
|
||||
}
|
||||
@ -934,11 +928,11 @@ func (ss *GrpcServer) SendMessageToAll(ctx context.Context, req *proto_sentry.Ou
|
||||
func (ss *GrpcServer) HandShake(context.Context, *emptypb.Empty) (*proto_sentry.HandShakeReply, error) {
|
||||
reply := &proto_sentry.HandShakeReply{}
|
||||
switch ss.Protocols[0].Version {
|
||||
case eth.ETH66:
|
||||
case direct.ETH66:
|
||||
reply.Protocol = proto_sentry.Protocol_ETH66
|
||||
case eth.ETH67:
|
||||
case direct.ETH67:
|
||||
reply.Protocol = proto_sentry.Protocol_ETH67
|
||||
case eth.ETH68:
|
||||
case direct.ETH68:
|
||||
reply.Protocol = proto_sentry.Protocol_ETH68
|
||||
}
|
||||
return reply, nil
|
||||
|
@ -7,19 +7,20 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
||||
proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/memdb"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/forkid"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
"github.com/ledgerwatch/erigon/eth/protocols/eth"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/ledgerwatch/erigon/p2p"
|
||||
)
|
||||
|
||||
@ -55,7 +56,7 @@ func testSentryServer(db kv.Getter, genesis *types.Genesis, genesisHash libcommo
|
||||
|
||||
// Tests that peers are correctly accepted (or rejected) based on the advertised
|
||||
// fork IDs in the protocol handshake.
|
||||
func TestForkIDSplit66(t *testing.T) { testForkIDSplit(t, eth.ETH66) }
|
||||
func TestForkIDSplit66(t *testing.T) { testForkIDSplit(t, direct.ETH66) }
|
||||
|
||||
func testForkIDSplit(t *testing.T, protocol uint) {
|
||||
var (
|
||||
|
@ -13,6 +13,13 @@ import (
|
||||
|
||||
"github.com/c2h5oh/datasize"
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/dbg"
|
||||
@ -23,12 +30,6 @@ import (
|
||||
proto_types "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/kvcfg"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/ledgerwatch/erigon/consensus"
|
||||
"github.com/ledgerwatch/erigon/core/forkid"
|
||||
@ -68,8 +69,8 @@ func (cs *MultiClient) RecvUploadMessageLoop(
|
||||
wg *sync.WaitGroup,
|
||||
) {
|
||||
ids := []proto_sentry.MessageId{
|
||||
eth.ToProto[eth.ETH66][eth.GetBlockBodiesMsg],
|
||||
eth.ToProto[eth.ETH66][eth.GetReceiptsMsg],
|
||||
eth.ToProto[direct.ETH66][eth.GetBlockBodiesMsg],
|
||||
eth.ToProto[direct.ETH66][eth.GetReceiptsMsg],
|
||||
}
|
||||
streamFactory := func(streamCtx context.Context, sentry direct.SentryClient) (sentryMessageStream, error) {
|
||||
return sentry.Messages(streamCtx, &proto_sentry.MessagesRequest{Ids: ids}, grpc.WaitForReady(true))
|
||||
@ -84,7 +85,7 @@ func (cs *MultiClient) RecvUploadHeadersMessageLoop(
|
||||
wg *sync.WaitGroup,
|
||||
) {
|
||||
ids := []proto_sentry.MessageId{
|
||||
eth.ToProto[eth.ETH66][eth.GetBlockHeadersMsg],
|
||||
eth.ToProto[direct.ETH66][eth.GetBlockHeadersMsg],
|
||||
}
|
||||
streamFactory := func(streamCtx context.Context, sentry direct.SentryClient) (sentryMessageStream, error) {
|
||||
return sentry.Messages(streamCtx, &proto_sentry.MessagesRequest{Ids: ids}, grpc.WaitForReady(true))
|
||||
@ -99,10 +100,10 @@ func (cs *MultiClient) RecvMessageLoop(
|
||||
wg *sync.WaitGroup,
|
||||
) {
|
||||
ids := []proto_sentry.MessageId{
|
||||
eth.ToProto[eth.ETH66][eth.BlockHeadersMsg],
|
||||
eth.ToProto[eth.ETH66][eth.BlockBodiesMsg],
|
||||
eth.ToProto[eth.ETH66][eth.NewBlockHashesMsg],
|
||||
eth.ToProto[eth.ETH66][eth.NewBlockMsg],
|
||||
eth.ToProto[direct.ETH66][eth.BlockHeadersMsg],
|
||||
eth.ToProto[direct.ETH66][eth.BlockBodiesMsg],
|
||||
eth.ToProto[direct.ETH66][eth.NewBlockHashesMsg],
|
||||
eth.ToProto[direct.ETH66][eth.NewBlockMsg],
|
||||
}
|
||||
streamFactory := func(streamCtx context.Context, sentry direct.SentryClient) (sentryMessageStream, error) {
|
||||
return sentry.Messages(streamCtx, &proto_sentry.MessagesRequest{Ids: ids}, grpc.WaitForReady(true))
|
||||
|
@ -27,29 +27,30 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/c2h5oh/datasize"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/cmp"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/common/metrics"
|
||||
downloadercfg2 "github.com/ledgerwatch/erigon-lib/downloader/downloadercfg"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
|
||||
"github.com/ledgerwatch/erigon/cmd/utils/flags"
|
||||
common2 "github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash/ethashcfg"
|
||||
"github.com/ledgerwatch/erigon/eth/gasprice/gaspricecfg"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/cmp"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/common/metrics"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
downloadercfg2 "github.com/ledgerwatch/erigon-lib/downloader/downloadercfg"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cl/clparams"
|
||||
"github.com/ledgerwatch/erigon/cmd/downloader/downloadernat"
|
||||
"github.com/ledgerwatch/erigon/cmd/utils/flags"
|
||||
common2 "github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/common/paths"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash/ethashcfg"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/crypto"
|
||||
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
||||
"github.com/ledgerwatch/erigon/eth/protocols/eth"
|
||||
"github.com/ledgerwatch/erigon/eth/gasprice/gaspricecfg"
|
||||
"github.com/ledgerwatch/erigon/node/nodecfg"
|
||||
"github.com/ledgerwatch/erigon/p2p"
|
||||
"github.com/ledgerwatch/erigon/p2p/enode"
|
||||
@ -912,11 +913,11 @@ func NewP2PConfig(
|
||||
) (*p2p.Config, error) {
|
||||
var enodeDBPath string
|
||||
switch protocol {
|
||||
case eth.ETH66:
|
||||
case direct.ETH66:
|
||||
enodeDBPath = filepath.Join(dirs.Nodes, "eth66")
|
||||
case eth.ETH67:
|
||||
case direct.ETH67:
|
||||
enodeDBPath = filepath.Join(dirs.Nodes, "eth67")
|
||||
case eth.ETH68:
|
||||
case direct.ETH68:
|
||||
enodeDBPath = filepath.Join(dirs.Nodes, "eth68")
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown protocol: %v", protocol)
|
||||
|
@ -21,10 +21,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
@ -113,7 +115,7 @@ func TestGetBlockReceipts(t *testing.T) {
|
||||
|
||||
m.ReceiveWg.Add(1)
|
||||
// Send the hash request and verify the response
|
||||
for _, err = range m.Send(&sentry.InboundMessage{Id: eth.ToProto[eth.ETH66][eth.GetReceiptsMsg], Data: b, PeerId: m.PeerId}) {
|
||||
for _, err = range m.Send(&sentry.InboundMessage{Id: eth.ToProto[direct.ETH66][eth.GetReceiptsMsg], Data: b, PeerId: m.PeerId}) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"math/bits"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
proto_sentry "github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core/forkid"
|
||||
@ -32,17 +33,10 @@ import (
|
||||
"github.com/ledgerwatch/erigon/rlp"
|
||||
)
|
||||
|
||||
// Constants to match up protocol versions and messages
|
||||
const (
|
||||
ETH66 = 66
|
||||
ETH67 = 67
|
||||
ETH68 = 68
|
||||
)
|
||||
|
||||
var ProtocolToString = map[uint]string{
|
||||
ETH66: "eth66",
|
||||
ETH67: "eth67",
|
||||
ETH68: "eth68",
|
||||
direct.ETH66: "eth66",
|
||||
direct.ETH67: "eth67",
|
||||
direct.ETH68: "eth68",
|
||||
}
|
||||
|
||||
// ProtocolName is the official short name of the `eth` protocol used during
|
||||
@ -75,7 +69,7 @@ const (
|
||||
)
|
||||
|
||||
var ToProto = map[uint]map[uint64]proto_sentry.MessageId{
|
||||
ETH66: {
|
||||
direct.ETH66: {
|
||||
GetBlockHeadersMsg: proto_sentry.MessageId_GET_BLOCK_HEADERS_66,
|
||||
BlockHeadersMsg: proto_sentry.MessageId_BLOCK_HEADERS_66,
|
||||
GetBlockBodiesMsg: proto_sentry.MessageId_GET_BLOCK_BODIES_66,
|
||||
@ -91,7 +85,7 @@ var ToProto = map[uint]map[uint64]proto_sentry.MessageId{
|
||||
GetPooledTransactionsMsg: proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66,
|
||||
PooledTransactionsMsg: proto_sentry.MessageId_POOLED_TRANSACTIONS_66,
|
||||
},
|
||||
ETH67: {
|
||||
direct.ETH67: {
|
||||
GetBlockHeadersMsg: proto_sentry.MessageId_GET_BLOCK_HEADERS_66,
|
||||
BlockHeadersMsg: proto_sentry.MessageId_BLOCK_HEADERS_66,
|
||||
GetBlockBodiesMsg: proto_sentry.MessageId_GET_BLOCK_BODIES_66,
|
||||
@ -105,7 +99,7 @@ var ToProto = map[uint]map[uint64]proto_sentry.MessageId{
|
||||
GetPooledTransactionsMsg: proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66,
|
||||
PooledTransactionsMsg: proto_sentry.MessageId_POOLED_TRANSACTIONS_66,
|
||||
},
|
||||
ETH68: {
|
||||
direct.ETH68: {
|
||||
GetBlockHeadersMsg: proto_sentry.MessageId_GET_BLOCK_HEADERS_66,
|
||||
BlockHeadersMsg: proto_sentry.MessageId_BLOCK_HEADERS_66,
|
||||
GetBlockBodiesMsg: proto_sentry.MessageId_GET_BLOCK_BODIES_66,
|
||||
@ -122,7 +116,7 @@ var ToProto = map[uint]map[uint64]proto_sentry.MessageId{
|
||||
}
|
||||
|
||||
var FromProto = map[uint]map[proto_sentry.MessageId]uint64{
|
||||
ETH66: {
|
||||
direct.ETH66: {
|
||||
proto_sentry.MessageId_GET_BLOCK_HEADERS_66: GetBlockHeadersMsg,
|
||||
proto_sentry.MessageId_BLOCK_HEADERS_66: BlockHeadersMsg,
|
||||
proto_sentry.MessageId_GET_BLOCK_BODIES_66: GetBlockBodiesMsg,
|
||||
@ -138,7 +132,7 @@ var FromProto = map[uint]map[proto_sentry.MessageId]uint64{
|
||||
proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66: GetPooledTransactionsMsg,
|
||||
proto_sentry.MessageId_POOLED_TRANSACTIONS_66: PooledTransactionsMsg,
|
||||
},
|
||||
ETH67: {
|
||||
direct.ETH67: {
|
||||
proto_sentry.MessageId_GET_BLOCK_HEADERS_66: GetBlockHeadersMsg,
|
||||
proto_sentry.MessageId_BLOCK_HEADERS_66: BlockHeadersMsg,
|
||||
proto_sentry.MessageId_GET_BLOCK_BODIES_66: GetBlockBodiesMsg,
|
||||
@ -152,7 +146,7 @@ var FromProto = map[uint]map[proto_sentry.MessageId]uint64{
|
||||
proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66: GetPooledTransactionsMsg,
|
||||
proto_sentry.MessageId_POOLED_TRANSACTIONS_66: PooledTransactionsMsg,
|
||||
},
|
||||
ETH68: {
|
||||
direct.ETH68: {
|
||||
proto_sentry.MessageId_GET_BLOCK_HEADERS_66: GetBlockHeadersMsg,
|
||||
proto_sentry.MessageId_BLOCK_HEADERS_66: BlockHeadersMsg,
|
||||
proto_sentry.MessageId_GET_BLOCK_BODIES_66: GetBlockBodiesMsg,
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces"
|
||||
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/gointerfaces/types"
|
||||
@ -190,8 +191,7 @@ func (s *EthBackendServer) Subscribe(r *remote.SubscribeRequest, subscribeServer
|
||||
}
|
||||
|
||||
func (s *EthBackendServer) ProtocolVersion(_ context.Context, _ *remote.ProtocolVersionRequest) (*remote.ProtocolVersionReply, error) {
|
||||
// Hardcoding to avoid import cycle
|
||||
return &remote.ProtocolVersionReply{Id: 66}, nil
|
||||
return &remote.ProtocolVersionReply{Id: direct.ETH66}, nil
|
||||
}
|
||||
|
||||
func (s *EthBackendServer) ClientVersion(_ context.Context, _ *remote.ClientVersionRequest) (*remote.ClientVersionReply, error) {
|
||||
|
@ -18,6 +18,8 @@ package nodecfg
|
||||
|
||||
import (
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/direct"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common/paths"
|
||||
"github.com/ledgerwatch/erigon/p2p"
|
||||
"github.com/ledgerwatch/erigon/p2p/nat"
|
||||
@ -32,7 +34,7 @@ const (
|
||||
DefaultWSPort = 8546 // Default TCP port for the websocket RPC server
|
||||
DefaultGRPCHost = "localhost" // Default host interface for the GRPC server
|
||||
DefaultGRPCPort = 8547 // Default TCP port for the GRPC server
|
||||
DefaultTCPHost = "localhost" // default host interrface for TCP RPC server
|
||||
DefaultTCPHost = "localhost" // default host interface for TCP RPC server
|
||||
DefaultTCPPort = 8548 // default TCP port for TCP RPC server
|
||||
)
|
||||
|
||||
@ -47,7 +49,7 @@ var DefaultConfig = Config{
|
||||
WSModules: []string{"net", "web3"},
|
||||
P2P: p2p.Config{
|
||||
ListenAddr: ":30303",
|
||||
ProtocolVersion: []uint{67, 68},
|
||||
ProtocolVersion: []uint{direct.ETH68, direct.ETH67, direct.ETH66},
|
||||
MaxPeers: 100,
|
||||
MaxPendingPeers: 1000,
|
||||
NAT: nat.Any(),
|
||||
|
@ -11,6 +11,9 @@ import (
|
||||
|
||||
"github.com/c2h5oh/datasize"
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
@ -27,11 +30,6 @@ import (
|
||||
"github.com/ledgerwatch/erigon-lib/txpool"
|
||||
"github.com/ledgerwatch/erigon-lib/txpool/txpoolcfg"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/types"
|
||||
"github.com/ledgerwatch/erigon/turbo/trie"
|
||||
"github.com/ledgerwatch/log/v3"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/ledgerwatch/erigon/turbo/rpchelper"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cmd/sentry/sentry"
|
||||
"github.com/ledgerwatch/erigon/consensus"
|
||||
@ -52,10 +50,12 @@ import (
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
"github.com/ledgerwatch/erigon/rlp"
|
||||
"github.com/ledgerwatch/erigon/turbo/engineapi"
|
||||
"github.com/ledgerwatch/erigon/turbo/rpchelper"
|
||||
"github.com/ledgerwatch/erigon/turbo/shards"
|
||||
"github.com/ledgerwatch/erigon/turbo/snapshotsync"
|
||||
"github.com/ledgerwatch/erigon/turbo/stages/bodydownload"
|
||||
"github.com/ledgerwatch/erigon/turbo/stages/headerdownload"
|
||||
"github.com/ledgerwatch/erigon/turbo/trie"
|
||||
)
|
||||
|
||||
type MockSentry struct {
|
||||
@ -267,7 +267,7 @@ func MockWithEverything(tb testing.TB, gspec *types.Genesis, key *ecdsa.PrivateK
|
||||
propagateNewBlockHashes := func(context.Context, []headerdownload.Announce) {}
|
||||
penalize := func(context.Context, []headerdownload.PenaltyItem) {}
|
||||
|
||||
mock.SentryClient = direct.NewSentryClientDirect(eth.ETH68, mock)
|
||||
mock.SentryClient = direct.NewSentryClientDirect(direct.ETH68, mock)
|
||||
sentries := []direct.SentryClient{mock.SentryClient}
|
||||
|
||||
sendBodyRequest := func(context.Context, *bodydownload.BodyRequest) ([64]byte, bool) { return [64]byte{}, false }
|
||||
|
Loading…
Reference in New Issue
Block a user