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

Switch from eth/66 to eth/67 #4549

Merged
merged 5 commits into from
Jun 28, 2022
Merged
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 DEV_CHAIN.md
Original file line number Diff line number Diff line change
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 eth66=1 ```
``` [p2p] GoodPeers eth67=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
Original file line number Diff line number Diff line change
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/66 peering | Public |
| 30303 | TCP & UDP | eth/67 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/66) and will be exposed to the internet on 30303. Port
Typically, a sentry process will run one eth/xx protocol (e.g. eth/67) 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: 7 additions & 6 deletions cmd/observer/observer/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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 @@ -12,10 +17,6 @@ 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 @@ -236,10 +237,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: 66},
{Name: eth.ProtocolName, Version: eth.ETH67},
}

return HelloMessage{
Expand Down
5 changes: 3 additions & 2 deletions cmd/observer/observer/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ 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 @@ -30,6 +31,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(eth.ETH67), status.ProtocolVersion)
assert.Equal(t, uint64(1), status.NetworkID)
}
11 changes: 6 additions & 5 deletions cmd/observer/observer/sentry_candidates/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ 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/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"}
{"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"}
`
line = strings.TrimLeft(line, "\r\n ")
eventLog := NewLog(NewScannerLineReader(strings.NewReader(line)))
Expand Down Expand Up @@ -54,7 +55,7 @@ func TestLogReadTailSkimFile(t *testing.T) {

func TestLogEventEthVersion(t *testing.T) {
event := LogEvent{}
event.Capabilities = []string{"wit/0", "eth/64", "eth/65", "eth/66"}
event.Capabilities = []string{"wit/0", "eth/65", "eth/66", "eth/67"}
version := event.EthVersion()
assert.Equal(t, uint(66), version)
assert.Equal(t, uint(67), version)
}
7 changes: 4 additions & 3 deletions cmd/observer/observer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ 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 @@ -17,8 +20,6 @@ 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 @@ -32,7 +33,7 @@ type Server struct {
}

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

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
Original file line number Diff line number Diff line change
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_66, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, 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
Original file line number Diff line number Diff line change
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_66, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_NEW_BLOCK, 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_66, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, Data: b, PeerId: m.PeerId}) {
require.NoError(err)
}
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed
m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceed

initialCycle := true
highestSeenHeader := chain.TopBlock.NumberU64()
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon22/commands/eth_subscribe_test.go
Original file line number Diff line number Diff line change
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_66, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, 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
Original file line number Diff line number Diff line change
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_66, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_NEW_BLOCK, 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_66, Data: b, PeerId: m.PeerId}) {
for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_BLOCK_HEADERS, 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
Original file line number Diff line number Diff line change
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", "eth66", "eth66")
rootCmd.Flags().StringVar(&protocol, "p2p.protocol", "eth67", "eth67")
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.ETH66
p := eth.ETH67

dirs := datadir.New(datadirCli)
nodeConfig := node2.NewNodeConfig()
Expand Down
65 changes: 32 additions & 33 deletions cmd/sentry/sentry/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (cs *MultiClient) PropagateNewBlockHashes(ctx context.Context, announces []
log.Error("propagateNewBlockHashes", "err", err)
return
}
var req66 *proto_sentry.OutboundMessageData
var req67 *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.ETH66:
if req66 == nil {
req66 = &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_BLOCK_HASHES_66,
case eth.ETH67:
if req67 == nil {
req67 = &proto_sentry.OutboundMessageData{
Id: proto_sentry.MessageId_NEW_BLOCK_HASHES,
Data: data,
}

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

Expand All @@ -141,7 +140,7 @@ func (cs *MultiClient) BroadcastLocalPooledTxs(ctx context.Context, txs []common
if err != nil {
log.Error("BroadcastLocalPooledTxs", "err", err)
}
var req66 *proto_sentry.OutboundMessageData
var req67 *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 @@ -153,29 +152,29 @@ func (cs *MultiClient) BroadcastLocalPooledTxs(ctx context.Context, txs []common
}

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

Expand All @@ -200,7 +199,7 @@ func (cs *MultiClient) BroadcastRemotePooledTxs(ctx context.Context, txs []commo
if err != nil {
log.Error("BroadcastRemotePooledTxs", "err", err)
}
var req66 *proto_sentry.SendMessageToRandomPeersRequest
var req67 *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 @@ -213,17 +212,17 @@ func (cs *MultiClient) BroadcastRemotePooledTxs(ctx context.Context, txs []commo

switch sentry.Protocol() {

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

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