Skip to content

Commit

Permalink
Revert "Switch from eth/66 to eth/67 (#4549)" (#4562)
Browse files Browse the repository at this point in the history
This reverts commit 16e57aa.
  • Loading branch information
yperbasis committed Jun 28, 2022
1 parent 16e57aa commit dc5d3ff
Show file tree
Hide file tree
Showing 28 changed files with 232 additions and 179 deletions.
2 changes: 1 addition & 1 deletion DEV_CHAIN.md
Expand Up @@ -70,7 +70,7 @@ Open terminal 3 and navigate to erigon/build/bin folder. Paste in the following

To check if the nodes are connected, you can go to the log of both the nodes and look for the line

``` [p2p] GoodPeers eth67=1 ```
``` [p2p] GoodPeers eth66=1 ```

Note: this might take a while it is not istantaneus, also if you see a 1 on either one of the two the node is fine.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -335,7 +335,7 @@ Detailed explanation: [./docs/programmers_guide/db_faq.md](./docs/programmers_gu

| Port | Protocol | Purpose | Expose |
|:-----:|:---------:|:----------------------:|:-------:|
| 30303 | TCP & UDP | eth/67 peering | Public |
| 30303 | TCP & UDP | eth/66 peering | Public |
| 9090 | TCP | gRPC Connections | Private |
| 42069 | TCP & UDP | Snap sync (Bittorrent) | Public |
| 6060 | TCP | Metrics or Pprof | Private |
Expand All @@ -360,7 +360,7 @@ Typically, 8551 (JWT authenticated) is exposed only internally for the Engine AP
| 30303 | TCP & UDP | Peering | Public |
| 9091 | TCP | gRPC Connections | Private |

Typically, a sentry process will run one eth/xx protocol (e.g. eth/67) and will be exposed to the internet on 30303. Port
Typically, a sentry process will run one eth/xx protocol (e.g. eth/66) and will be exposed to the internet on 30303. Port
9091 is for internal gRCP connections (e.g erigon -> sentry).

#### Other ports
Expand Down
13 changes: 6 additions & 7 deletions cmd/observer/observer/handshake.go
Expand Up @@ -4,11 +4,6 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"math/big"
"net"
"strings"
"time"

"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/forkid"
"github.com/ledgerwatch/erigon/crypto"
Expand All @@ -17,6 +12,10 @@ import (
"github.com/ledgerwatch/erigon/p2p/rlpx"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/rlp"
"math/big"
"net"
"strings"
"time"
)

// https://github.com/ethereum/devp2p/blob/master/rlpx.md#p2p-capability
Expand Down Expand Up @@ -237,10 +236,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: 66},
{Name: eth.ProtocolName, Version: eth.ETH67},
{Name: eth.ProtocolName, Version: eth.ETH66},
}

return HelloMessage{
Expand Down
5 changes: 2 additions & 3 deletions cmd/observer/observer/handshake_test.go
Expand Up @@ -2,14 +2,13 @@ package observer

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"
"testing"
)

func TestHandshake(t *testing.T) {
Expand All @@ -31,6 +30,6 @@ func TestHandshake(t *testing.T) {
assert.Contains(t, hello.ClientID, "erigon")

require.NotNil(t, status)
assert.Equal(t, uint32(eth.ETH67), status.ProtocolVersion)
assert.Equal(t, uint32(eth.ETH66), status.ProtocolVersion)
assert.Equal(t, uint64(1), status.NetworkID)
}
11 changes: 5 additions & 6 deletions cmd/observer/observer/sentry_candidates/log_test.go
Expand Up @@ -2,17 +2,16 @@ package sentry_candidates

import (
"context"
"strings"
"testing"

"github.com/nxadm/tail"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"strings"
"testing"
)

func TestLogRead(t *testing.T) {
line := `
{"capabilities":["eth/67","wit/0"],"clientID":"Nethermind/v1.13.0-0-2e8910b5b-20220520/X64-Linux/6.0.4","lvl":"dbug","msg":"Sentry peer did Connect","nodeURL":"enode://4293b17b897abed4a88d6e760e86a4bb700d62c12a9411fbf9ec0c9df3740c8670b184bd9f24d163cbd9bf05264b3047a69f079209d53d2e0dc05dd678d07cf0@1.2.3.4:45492","peer":"93b17b897abed4a88d6e760e86a4bb700d62c12a9411fbf9ec0c9df3740c8670b184bd9f24d163cbd9bf05264b3047a69f079209d53d2e0dc05dd678d07cf000","t":"2022-05-31T11:10:19.032092272Z"}
{"capabilities":["eth/66","wit/0"],"clientID":"Nethermind/v1.13.0-0-2e8910b5b-20220520/X64-Linux/6.0.4","lvl":"dbug","msg":"Sentry peer did Connect","nodeURL":"enode://4293b17b897abed4a88d6e760e86a4bb700d62c12a9411fbf9ec0c9df3740c8670b184bd9f24d163cbd9bf05264b3047a69f079209d53d2e0dc05dd678d07cf0@1.2.3.4:45492","peer":"93b17b897abed4a88d6e760e86a4bb700d62c12a9411fbf9ec0c9df3740c8670b184bd9f24d163cbd9bf05264b3047a69f079209d53d2e0dc05dd678d07cf000","t":"2022-05-31T11:10:19.032092272Z"}
`
line = strings.TrimLeft(line, "\r\n ")
eventLog := NewLog(NewScannerLineReader(strings.NewReader(line)))
Expand Down Expand Up @@ -55,7 +54,7 @@ func TestLogReadTailSkimFile(t *testing.T) {

func TestLogEventEthVersion(t *testing.T) {
event := LogEvent{}
event.Capabilities = []string{"wit/0", "eth/65", "eth/66", "eth/67"}
event.Capabilities = []string{"wit/0", "eth/64", "eth/65", "eth/66"}
version := event.EthVersion()
assert.Equal(t, uint(67), version)
assert.Equal(t, uint(66), version)
}
7 changes: 3 additions & 4 deletions cmd/observer/observer/server.go
Expand Up @@ -5,9 +5,6 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"net"
"path/filepath"

"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon/core/forkid"
Expand All @@ -20,6 +17,8 @@ import (
"github.com/ledgerwatch/erigon/p2p/netutil"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"
"net"
"path/filepath"
)

type Server struct {
Expand All @@ -33,7 +32,7 @@ type Server struct {
}

func NewServer(flags CommandFlags) (*Server, error) {
nodeDBPath := filepath.Join(flags.DataDir, "nodes", "eth67")
nodeDBPath := filepath.Join(flags.DataDir, "nodes", "eth66")

nodeKeyConfig := p2p.NodeKeyConfig{}
privateKey, err := nodeKeyConfig.LoadOrParseOrGenerateAndSave(flags.NodeKeyFile, flags.NodeKeyHex, flags.DataDir)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_subscribe_test.go
Expand Up @@ -33,7 +33,7 @@ func TestEthSubscribe(t *testing.T) {
require.NoError(err)

m.ReceiveWg.Add(1)
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS_66, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed
Expand Down
6 changes: 3 additions & 3 deletions cmd/rpcdaemon/commands/send_transaction_test.go
Expand Up @@ -42,7 +42,7 @@ func TestSendRawTransaction(t *testing.T) {
})
require.NoError(err)
m.ReceiveWg.Add(1)
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_NEW_BLOCK, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_NEW_BLOCK_66, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
// Send all the headers
Expand All @@ -52,10 +52,10 @@ func TestSendRawTransaction(t *testing.T) {
})
require.NoError(err)
m.ReceiveWg.Add(1)
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS_66, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceed
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed

initialCycle := true
highestSeenHeader := chain.TopBlock.NumberU64()
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon22/commands/eth_subscribe_test.go
Expand Up @@ -32,7 +32,7 @@ func TestEthSubscribe(t *testing.T) {
require.NoError(err)

m.ReceiveWg.Add(1)
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS_66, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed
Expand Down
4 changes: 2 additions & 2 deletions cmd/rpcdaemon22/commands/send_transaction_test.go
Expand Up @@ -42,7 +42,7 @@ func TestSendRawTransaction(t *testing.T) {
})
require.NoError(err)
m.ReceiveWg.Add(1)
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_NEW_BLOCK, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_NEW_BLOCK_66, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
// Send all the headers
Expand All @@ -52,7 +52,7 @@ func TestSendRawTransaction(t *testing.T) {
})
require.NoError(err)
m.ReceiveWg.Add(1)
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS_66, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed
Expand Down
4 changes: 2 additions & 2 deletions cmd/sentry/main.go
Expand Up @@ -45,7 +45,7 @@ func init() {
rootCmd.Flags().StringSliceVar(&trustedPeers, utils.TrustedPeersFlag.Name, []string{}, utils.TrustedPeersFlag.Usage)
rootCmd.Flags().StringSliceVar(&discoveryDNS, utils.DNSDiscoveryFlag.Name, []string{}, utils.DNSDiscoveryFlag.Usage)
rootCmd.Flags().BoolVar(&nodiscover, utils.NoDiscoverFlag.Name, false, utils.NoDiscoverFlag.Usage)
rootCmd.Flags().StringVar(&protocol, "p2p.protocol", "eth67", "eth67")
rootCmd.Flags().StringVar(&protocol, "p2p.protocol", "eth66", "eth66")
rootCmd.Flags().StringVar(&netRestrict, utils.NetrestrictFlag.Name, utils.NetrestrictFlag.Value, utils.NetrestrictFlag.Usage)
rootCmd.Flags().IntVar(&maxPeers, utils.MaxPeersFlag.Name, utils.MaxPeersFlag.Value, utils.MaxPeersFlag.Usage)
rootCmd.Flags().IntVar(&maxPendPeers, utils.MaxPendingPeersFlag.Name, utils.MaxPendingPeersFlag.Value, utils.MaxPendingPeersFlag.Usage)
Expand All @@ -68,7 +68,7 @@ var rootCmd = &cobra.Command{
debug.Exit()
},
RunE: func(cmd *cobra.Command, args []string) error {
p := eth.ETH67
p := eth.ETH66

dirs := datadir.New(datadirCli)
nodeConfig := node2.NewNodeConfig()
Expand Down
65 changes: 33 additions & 32 deletions cmd/sentry/sentry/broadcast.go
Expand Up @@ -41,7 +41,7 @@ func (cs *MultiClient) PropagateNewBlockHashes(ctx context.Context, announces []
log.Error("propagateNewBlockHashes", "err", err)
return
}
var req67 *proto_sentry.OutboundMessageData
var req66 *proto_sentry.OutboundMessageData
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
Expand All @@ -54,14 +54,14 @@ func (cs *MultiClient) PropagateNewBlockHashes(ctx context.Context, announces []

switch sentry.Protocol() {

case eth.ETH67:
if req67 == nil {
req67 = &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_BLOCK_HASHES,
case eth.ETH66:
if req66 == nil {
req66 = &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_BLOCK_HASHES_66,
Data: data,
}

_, err = sentry.SendMessageToAll(ctx, req67, &grpc.EmptyCallOption{})
_, err = sentry.SendMessageToAll(ctx, req66, &grpc.EmptyCallOption{})
if err != nil {
log.Error("propagateNewBlockHashes", "err", err)
}
Expand All @@ -82,7 +82,7 @@ func (cs *MultiClient) BroadcastNewBlock(ctx context.Context, block *types.Block
if err != nil {
log.Error("broadcastNewBlock", "err", err)
}
var req67 *proto_sentry.SendMessageToRandomPeersRequest
var req66 *proto_sentry.SendMessageToRandomPeersRequest
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
Expand All @@ -95,17 +95,17 @@ func (cs *MultiClient) BroadcastNewBlock(ctx context.Context, block *types.Block

switch sentry.Protocol() {

case eth.ETH67:
if req67 == nil {
req67 = &proto_sentry.SendMessageToRandomPeersRequest{
case eth.ETH66:
if req66 == nil {
req66 = &proto_sentry.SendMessageToRandomPeersRequest{
MaxPeers: 1024,
Data: &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_BLOCK,
Id: proto_sentry.MessageId_NEW_BLOCK_66,
Data: data,
},
}
}
if _, err = sentry.SendMessageToRandomPeers(ctx, req67, &grpc.EmptyCallOption{}); err != nil {
if _, err = sentry.SendMessageToRandomPeers(ctx, req66, &grpc.EmptyCallOption{}); err != nil {
if isPeerNotFoundErr(err) || networkTemporaryErr(err) {
log.Debug("broadcastNewBlock", "err", err)
continue
Expand All @@ -124,7 +124,8 @@ func (cs *MultiClient) BroadcastLocalPooledTxs(ctx context.Context, txs []common
cs.lock.RLock()
defer cs.lock.RUnlock()
initialAmount := len(txs)
avgPeersPerSent67 := 0
avgPeersPerSent65 := 0
avgPeersPerSent66 := 0
initialTxs := txs
for len(txs) > 0 {

Expand All @@ -140,7 +141,7 @@ func (cs *MultiClient) BroadcastLocalPooledTxs(ctx context.Context, txs []common
if err != nil {
log.Error("BroadcastLocalPooledTxs", "err", err)
}
var req67 *proto_sentry.OutboundMessageData
var req66 *proto_sentry.OutboundMessageData
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
Expand All @@ -152,29 +153,29 @@ func (cs *MultiClient) BroadcastLocalPooledTxs(ctx context.Context, txs []common
}

switch sentry.Protocol() {
case eth.ETH67:
if req67 == nil {
req67 = &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES,
case eth.ETH66:
if req66 == nil {
req66 = &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES_66,
Data: data,
}
}
peers, err := sentry.SendMessageToAll(ctx, req67, &grpc.EmptyCallOption{})
peers, err := sentry.SendMessageToAll(ctx, req66, &grpc.EmptyCallOption{})
if err != nil {
if isPeerNotFoundErr(err) || networkTemporaryErr(err) {
log.Debug("BroadcastLocalPooledTxs", "err", err)
continue
}
log.Error("BroadcastLocalPooledTxs", "err", err)
}
avgPeersPerSent67 += len(peers.GetPeers())
avgPeersPerSent66 += len(peers.GetPeers())
}
}
}
if initialAmount == 1 {
log.Info("local tx propagated", "to_peers_amount", avgPeersPerSent67, "tx_hash", initialTxs[0].String())
log.Info("local tx propagated", "to_peers_amount", avgPeersPerSent65+avgPeersPerSent66, "tx_hash", initialTxs[0].String())
} else {
log.Info("local txs propagated", "to_peers_amount", avgPeersPerSent67, "txs_amount", initialAmount)
log.Info("local txs propagated", "to_peers_amount", avgPeersPerSent65+avgPeersPerSent66, "txs_amount", initialAmount)
}
}

Expand All @@ -199,7 +200,7 @@ func (cs *MultiClient) BroadcastRemotePooledTxs(ctx context.Context, txs []commo
if err != nil {
log.Error("BroadcastRemotePooledTxs", "err", err)
}
var req67 *proto_sentry.SendMessageToRandomPeersRequest
var req66 *proto_sentry.SendMessageToRandomPeersRequest
// Send the block to a subset of our peers
sendToAmount := int(math.Sqrt(float64(len(cs.sentries))))
for i, sentry := range cs.sentries {
Expand All @@ -212,17 +213,17 @@ func (cs *MultiClient) BroadcastRemotePooledTxs(ctx context.Context, txs []commo

switch sentry.Protocol() {

case eth.ETH67:
if req67 == nil {
req67 = &proto_sentry.SendMessageToRandomPeersRequest{
case eth.ETH66:
if req66 == nil {
req66 = &proto_sentry.SendMessageToRandomPeersRequest{
MaxPeers: 1024,
Data: &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES,
Id: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES_66,
Data: data,
},
}
}
if _, err = sentry.SendMessageToRandomPeers(ctx, req67, &grpc.EmptyCallOption{}); err != nil {
if _, err = sentry.SendMessageToRandomPeers(ctx, req66, &grpc.EmptyCallOption{}); err != nil {
if isPeerNotFoundErr(err) || networkTemporaryErr(err) {
log.Debug("BroadcastRemotePooledTxs", "err", err)
continue
Expand Down Expand Up @@ -263,15 +264,15 @@ func (cs *MultiClient) PropagatePooledTxsToPeersList(ctx context.Context, peers
for _, peer := range peers {
switch sentry.Protocol() {

case eth.ETH67:
req67 := &proto_sentry.SendMessageByIdRequest{
case eth.ETH66:
req66 := &proto_sentry.SendMessageByIdRequest{
PeerId: peer,
Data: &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES,
Id: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES_66,
Data: data,
},
}
if _, err = sentry.SendMessageById(ctx, req67, &grpc.EmptyCallOption{}); err != nil {
if _, err = sentry.SendMessageById(ctx, req66, &grpc.EmptyCallOption{}); err != nil {
if isPeerNotFoundErr(err) || networkTemporaryErr(err) {
log.Debug("PropagatePooledTxsToPeersList", "err", err)
continue
Expand Down

0 comments on commit dc5d3ff

Please sign in to comment.