diff --git a/DEV_CHAIN.md b/DEV_CHAIN.md index d3510aea3df..cbff468d1a8 100644 --- a/DEV_CHAIN.md +++ b/DEV_CHAIN.md @@ -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. diff --git a/README.md b/README.md index 83de5de31b1..2ed20281c4f 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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 diff --git a/cmd/observer/observer/handshake.go b/cmd/observer/observer/handshake.go index 6fdcd3414ab..785a97a5762 100644 --- a/cmd/observer/observer/handshake.go +++ b/cmd/observer/observer/handshake.go @@ -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" @@ -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 @@ -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{ diff --git a/cmd/observer/observer/handshake_test.go b/cmd/observer/observer/handshake_test.go index 2691cd24006..19dd35ada3c 100644 --- a/cmd/observer/observer/handshake_test.go +++ b/cmd/observer/observer/handshake_test.go @@ -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) { @@ -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) } diff --git a/cmd/observer/observer/sentry_candidates/log_test.go b/cmd/observer/observer/sentry_candidates/log_test.go index e1ac9c391c7..3e75a1a5647 100644 --- a/cmd/observer/observer/sentry_candidates/log_test.go +++ b/cmd/observer/observer/sentry_candidates/log_test.go @@ -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))) @@ -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) } diff --git a/cmd/observer/observer/server.go b/cmd/observer/observer/server.go index 907b7c709a6..24e3a8899d8 100644 --- a/cmd/observer/observer/server.go +++ b/cmd/observer/observer/server.go @@ -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" @@ -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 { @@ -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) diff --git a/cmd/rpcdaemon/commands/eth_subscribe_test.go b/cmd/rpcdaemon/commands/eth_subscribe_test.go index a997495bd99..337a8df9049 100644 --- a/cmd/rpcdaemon/commands/eth_subscribe_test.go +++ b/cmd/rpcdaemon/commands/eth_subscribe_test.go @@ -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 diff --git a/cmd/rpcdaemon/commands/send_transaction_test.go b/cmd/rpcdaemon/commands/send_transaction_test.go index 0e848258126..719064f6eb9 100644 --- a/cmd/rpcdaemon/commands/send_transaction_test.go +++ b/cmd/rpcdaemon/commands/send_transaction_test.go @@ -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 @@ -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() diff --git a/cmd/rpcdaemon22/commands/eth_subscribe_test.go b/cmd/rpcdaemon22/commands/eth_subscribe_test.go index 875b7a2456a..180137a9722 100644 --- a/cmd/rpcdaemon22/commands/eth_subscribe_test.go +++ b/cmd/rpcdaemon22/commands/eth_subscribe_test.go @@ -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 diff --git a/cmd/rpcdaemon22/commands/send_transaction_test.go b/cmd/rpcdaemon22/commands/send_transaction_test.go index 87c6ef411b3..634c265d99d 100644 --- a/cmd/rpcdaemon22/commands/send_transaction_test.go +++ b/cmd/rpcdaemon22/commands/send_transaction_test.go @@ -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 @@ -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 diff --git a/cmd/sentry/main.go b/cmd/sentry/main.go index 80ed49d8522..1b75579a0f0 100644 --- a/cmd/sentry/main.go +++ b/cmd/sentry/main.go @@ -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) @@ -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() diff --git a/cmd/sentry/sentry/broadcast.go b/cmd/sentry/sentry/broadcast.go index 869fede9555..32b9f694f50 100644 --- a/cmd/sentry/sentry/broadcast.go +++ b/cmd/sentry/sentry/broadcast.go @@ -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 { @@ -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) } @@ -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 { @@ -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 @@ -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 { @@ -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 { @@ -153,14 +152,14 @@ 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) @@ -168,14 +167,14 @@ func (cs *MultiClient) BroadcastLocalPooledTxs(ctx context.Context, txs []common } 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) } } @@ -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 { @@ -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 @@ -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 diff --git a/cmd/sentry/sentry/eth_handshake_test.go b/cmd/sentry/sentry/eth_handshake_test.go index eeec146f3f9..ba32d8b770f 100644 --- a/cmd/sentry/sentry/eth_handshake_test.go +++ b/cmd/sentry/sentry/eth_handshake_test.go @@ -15,7 +15,7 @@ import ( ) func TestCheckPeerStatusCompatibility(t *testing.T) { - var version uint = eth.ETH66 + var version uint = eth.ETH67 networkID := params.MainnetChainConfig.ChainID.Uint64() goodReply := eth.StatusPacket{ ProtocolVersion: uint32(version), @@ -49,14 +49,14 @@ func TestCheckPeerStatusCompatibility(t *testing.T) { }) t.Run("version mismatch min", func(t *testing.T) { reply := goodReply - reply.ProtocolVersion = eth.ETH66 - 1 + reply.ProtocolVersion = eth.ETH67 - 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 = eth.ETH67 + 1 err := checkPeerStatusCompatibility(&reply, &status, version, version) assert.NotNil(t, err) assert.Contains(t, err.Error(), "version is more") diff --git a/cmd/sentry/sentry/sentry_api.go b/cmd/sentry/sentry/sentry_api.go index fbb1ed814d9..11b548eeb8d 100644 --- a/cmd/sentry/sentry/sentry_api.go +++ b/cmd/sentry/sentry/sentry_api.go @@ -44,7 +44,7 @@ func (cs *MultiClient) SendBodyRequest(ctx context.Context, req *bodydownload.Bo } switch cs.sentries[i].Protocol() { - case eth.ETH66: + case eth.ETH67: //log.Info(fmt.Sprintf("Sending body request for %v", req.BlockNums)) var bytes []byte var err error @@ -59,7 +59,7 @@ func (cs *MultiClient) SendBodyRequest(ctx context.Context, req *bodydownload.Bo outreq := proto_sentry.SendMessageByMinBlockRequest{ MinBlock: req.BlockNums[len(req.BlockNums)-1], Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_GET_BLOCK_BODIES_66, + Id: proto_sentry.MessageId_GET_BLOCK_BODIES, Data: bytes, }, } @@ -85,7 +85,7 @@ func (cs *MultiClient) SendHeaderRequest(ctx context.Context, req *headerdownloa continue } switch cs.sentries[i].Protocol() { - case eth.ETH66: + case eth.ETH67: //log.Info(fmt.Sprintf("Sending header request {hash: %x, height: %d, length: %d}", req.Hash, req.Number, req.Length)) reqData := ð.GetBlockHeadersPacket66{ RequestId: rand.Uint64(), @@ -109,7 +109,7 @@ func (cs *MultiClient) SendHeaderRequest(ctx context.Context, req *headerdownloa outreq := proto_sentry.SendMessageByMinBlockRequest{ MinBlock: minBlock, Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_GET_BLOCK_HEADERS_66, + Id: proto_sentry.MessageId_GET_BLOCK_HEADERS, Data: bytes, }, } diff --git a/cmd/sentry/sentry/sentry_grpc_server.go b/cmd/sentry/sentry/sentry_grpc_server.go index 098c77693b6..539385d2cba 100644 --- a/cmd/sentry/sentry/sentry_grpc_server.go +++ b/cmd/sentry/sentry/sentry_grpc_server.go @@ -356,16 +356,6 @@ func runPeer( log.Error(fmt.Sprintf("%s: reading msg into bytes: %v", peerID, err)) } send(eth.ToProto[protocol][msg.Code], peerID, b) - case eth.GetNodeDataMsg: - if !hasSubscribers(eth.ToProto[protocol][msg.Code]) { - continue - } - b := make([]byte, msg.Size) - if _, err := io.ReadFull(msg.Payload, b); err != nil { - log.Error(fmt.Sprintf("%s: reading msg into bytes: %v", peerID, err)) - } - send(eth.ToProto[protocol][msg.Code], peerID, b) - //log.Info(fmt.Sprintf("[%s] GetNodeData", peerID)) case eth.GetReceiptsMsg: if !hasSubscribers(eth.ToProto[protocol][msg.Code]) { continue @@ -491,7 +481,7 @@ func NewGrpcServer(ctx context.Context, dialCandidates enode.Iterator, readNodeI peersStreams: NewPeersStreams(), } - if protocol != eth.ETH66 { + if protocol != eth.ETH67 { panic(fmt.Errorf("unexpected p2p protocol: %d", protocol)) } @@ -631,7 +621,7 @@ func (ss *GrpcServer) writePeer(logPrefix string, peerInfo *PeerInfo, msgcode ui func (ss *GrpcServer) startSync(ctx context.Context, bestHash common.Hash, peerID [64]byte) error { switch ss.Protocol.Version { - case eth.ETH66: + case eth.ETH67: b, err := rlp.EncodeToBytes(ð.GetBlockHeadersPacket66{ RequestId: rand.Uint64(), GetBlockHeadersPacket: ð.GetBlockHeadersPacket{ @@ -647,7 +637,7 @@ func (ss *GrpcServer) startSync(ctx context.Context, bestHash common.Hash, peerI if _, err := ss.SendMessageById(ctx, &proto_sentry.SendMessageByIdRequest{ PeerId: gointerfaces.ConvertHashToH512(peerID), Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_GET_BLOCK_HEADERS_66, + Id: proto_sentry.MessageId_GET_BLOCK_HEADERS, Data: b, }, }); err != nil { @@ -803,8 +793,8 @@ 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.Protocol.Version { - case eth.ETH66: - reply.Protocol = proto_sentry.Protocol_ETH66 + case eth.ETH67: + reply.Protocol = proto_sentry.Protocol_ETH67 } return reply, nil } diff --git a/cmd/sentry/sentry/sentry_grpc_server_test.go b/cmd/sentry/sentry/sentry_grpc_server_test.go index 8cbd567a9e2..281216624de 100644 --- a/cmd/sentry/sentry/sentry_grpc_server_test.go +++ b/cmd/sentry/sentry/sentry_grpc_server_test.go @@ -50,7 +50,7 @@ func testSentryServer(db kv.Getter, genesis *core.Genesis, genesisHash common.Ha // 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 TestForkIDSplit67(t *testing.T) { testForkIDSplit(t, eth.ETH67) } func testForkIDSplit(t *testing.T, protocol uint) { var ( diff --git a/cmd/sentry/sentry/sentry_multi_client.go b/cmd/sentry/sentry/sentry_multi_client.go index 1359398c43c..0434ea51aa7 100644 --- a/cmd/sentry/sentry/sentry_multi_client.go +++ b/cmd/sentry/sentry/sentry_multi_client.go @@ -64,8 +64,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[eth.ETH67][eth.GetBlockBodiesMsg], + eth.ToProto[eth.ETH67][eth.GetReceiptsMsg], } streamFactory := func(streamCtx context.Context, sentry direct.SentryClient) (sentryMessageStream, error) { return sentry.Messages(streamCtx, &proto_sentry.MessagesRequest{Ids: ids}, grpc.WaitForReady(true)) @@ -80,7 +80,7 @@ func (cs *MultiClient) RecvUploadHeadersMessageLoop( wg *sync.WaitGroup, ) { ids := []proto_sentry.MessageId{ - eth.ToProto[eth.ETH66][eth.GetBlockHeadersMsg], + eth.ToProto[eth.ETH67][eth.GetBlockHeadersMsg], } streamFactory := func(streamCtx context.Context, sentry direct.SentryClient) (sentryMessageStream, error) { return sentry.Messages(streamCtx, &proto_sentry.MessagesRequest{Ids: ids}, grpc.WaitForReady(true)) @@ -95,10 +95,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[eth.ETH67][eth.BlockHeadersMsg], + eth.ToProto[eth.ETH67][eth.BlockBodiesMsg], + eth.ToProto[eth.ETH67][eth.NewBlockHashesMsg], + eth.ToProto[eth.ETH67][eth.NewBlockMsg], } streamFactory := func(streamCtx context.Context, sentry direct.SentryClient) (sentryMessageStream, error) { return sentry.Messages(streamCtx, &proto_sentry.MessagesRequest{Ids: ids}, grpc.WaitForReady(true)) @@ -336,7 +336,7 @@ func (cs *MultiClient) newBlockHashes66(ctx context.Context, req *proto_sentry.I outreq := proto_sentry.SendMessageByIdRequest{ PeerId: req.PeerId, Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_GET_BLOCK_HEADERS_66, + Id: proto_sentry.MessageId_GET_BLOCK_HEADERS, Data: b, }, } @@ -534,7 +534,7 @@ func (cs *MultiClient) getBlockHeaders66(ctx context.Context, inreq *proto_sentr outreq := proto_sentry.SendMessageByIdRequest{ PeerId: inreq.PeerId, Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_BLOCK_HEADERS_66, + Id: proto_sentry.MessageId_BLOCK_HEADERS, Data: b, }, } @@ -571,7 +571,7 @@ func (cs *MultiClient) getBlockBodies66(ctx context.Context, inreq *proto_sentry outreq := proto_sentry.SendMessageByIdRequest{ PeerId: inreq.PeerId, Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_BLOCK_BODIES_66, + Id: proto_sentry.MessageId_BLOCK_BODIES, Data: b, }, } @@ -611,7 +611,7 @@ func (cs *MultiClient) getReceipts66(ctx context.Context, inreq *proto_sentry.In outreq := proto_sentry.SendMessageByIdRequest{ PeerId: inreq.PeerId, Data: &proto_sentry.OutboundMessageData{ - Id: proto_sentry.MessageId_RECEIPTS_66, + Id: proto_sentry.MessageId_RECEIPTS, Data: b, }, } @@ -655,23 +655,23 @@ func (cs *MultiClient) HandleInboundMessage(ctx context.Context, message *proto_ func (cs *MultiClient) handleInboundMessage(ctx context.Context, inreq *proto_sentry.InboundMessage, sentry direct.SentryClient) error { switch inreq.Id { - // ========= eth 66 ========== + // ========= eth 67 ========== - case proto_sentry.MessageId_NEW_BLOCK_HASHES_66: + case proto_sentry.MessageId_NEW_BLOCK_HASHES: return cs.newBlockHashes66(ctx, inreq, sentry) - case proto_sentry.MessageId_BLOCK_HEADERS_66: + case proto_sentry.MessageId_BLOCK_HEADERS: return cs.blockHeaders66(ctx, inreq, sentry) - case proto_sentry.MessageId_NEW_BLOCK_66: + case proto_sentry.MessageId_NEW_BLOCK: return cs.newBlock66(ctx, inreq, sentry) - case proto_sentry.MessageId_BLOCK_BODIES_66: + case proto_sentry.MessageId_BLOCK_BODIES: return cs.blockBodies66(inreq, sentry) - case proto_sentry.MessageId_GET_BLOCK_HEADERS_66: + case proto_sentry.MessageId_GET_BLOCK_HEADERS: return cs.getBlockHeaders66(ctx, inreq, sentry) - case proto_sentry.MessageId_GET_BLOCK_BODIES_66: + case proto_sentry.MessageId_GET_BLOCK_BODIES: return cs.getBlockBodies66(ctx, inreq, sentry) - case proto_sentry.MessageId_RECEIPTS_66: + case proto_sentry.MessageId_RECEIPTS: return cs.receipts66(ctx, inreq, sentry) - case proto_sentry.MessageId_GET_RECEIPTS_66: + case proto_sentry.MessageId_GET_RECEIPTS: return cs.getReceipts66(ctx, inreq, sentry) default: return fmt.Errorf("not implemented for message Id: %s", inreq.Id) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ff39c1e4367..7b91de08b43 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -841,8 +841,8 @@ func NewP2PConfig( ) (*p2p.Config, error) { var enodeDBPath string switch protocol { - case eth.ETH66: - enodeDBPath = filepath.Join(dirs.Nodes, "eth66") + case eth.ETH67: + enodeDBPath = filepath.Join(dirs.Nodes, "eth67") default: return nil, fmt.Errorf("unknown protocol: %v", protocol) } diff --git a/eth/backend.go b/eth/backend.go index d85647cde94..d704058fe1a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -235,16 +235,16 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere return res } - d66, err := setupDiscovery(backend.config.EthDiscoveryURLs) + d67, err := setupDiscovery(backend.config.EthDiscoveryURLs) if err != nil { return nil, err } - cfg66 := stack.Config().P2P - cfg66.NodeDatabase = filepath.Join(stack.Config().Dirs.Nodes, "eth66") - server66 := sentry.NewGrpcServer(backend.sentryCtx, d66, readNodeInfo, &cfg66, eth.ETH66) - backend.sentryServers = append(backend.sentryServers, server66) - sentries = []direct.SentryClient{direct.NewSentryClientDirect(eth.ETH66, server66)} + cfg67 := stack.Config().P2P + cfg67.NodeDatabase = filepath.Join(stack.Config().Dirs.Nodes, "eth67") + server67 := sentry.NewGrpcServer(backend.sentryCtx, d67, readNodeInfo, &cfg67, eth.ETH67) + backend.sentryServers = append(backend.sentryServers, server67) + sentries = []direct.SentryClient{direct.NewSentryClientDirect(eth.ETH67, server67)} go func() { logEvery := time.NewTicker(120 * time.Second) diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index 76a08335ec0..d718c0888f0 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -112,7 +112,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[eth.ETH67][eth.GetReceiptsMsg], Data: b, PeerId: m.PeerId}) { require.NoError(t, err) } diff --git a/eth/protocols/eth/protocol.go b/eth/protocols/eth/protocol.go index 37569605b82..bb9ed2012d0 100644 --- a/eth/protocols/eth/protocol.go +++ b/eth/protocols/eth/protocol.go @@ -33,11 +33,11 @@ import ( // Constants to match up protocol versions and messages const ( - ETH66 = 66 + ETH67 = 67 ) var ProtocolToString = map[uint]string{ - ETH66: "eth66", + ETH67: "eth67", } // ProtocolName is the official short name of the `eth` protocol used during @@ -58,10 +58,10 @@ const ( GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 NewBlockMsg = 0x07 - GetNodeDataMsg = 0x0d - NodeDataMsg = 0x0e - GetReceiptsMsg = 0x0f - ReceiptsMsg = 0x10 + // GetNodeDataMsg = 0x0d // removed in eth/67 + // NodeDataMsg = 0x0e // removed in eth/67 + GetReceiptsMsg = 0x0f + ReceiptsMsg = 0x10 // Protocol messages overloaded in eth/65 NewPooledTransactionHashesMsg = 0x08 @@ -70,40 +70,36 @@ const ( ) var ToProto = map[uint]map[uint64]proto_sentry.MessageId{ - ETH66: { - GetBlockHeadersMsg: proto_sentry.MessageId_GET_BLOCK_HEADERS_66, - BlockHeadersMsg: proto_sentry.MessageId_BLOCK_HEADERS_66, - GetBlockBodiesMsg: proto_sentry.MessageId_GET_BLOCK_BODIES_66, - BlockBodiesMsg: proto_sentry.MessageId_BLOCK_BODIES_66, - GetNodeDataMsg: proto_sentry.MessageId_GET_NODE_DATA_66, - NodeDataMsg: proto_sentry.MessageId_NODE_DATA_66, - GetReceiptsMsg: proto_sentry.MessageId_GET_RECEIPTS_66, - ReceiptsMsg: proto_sentry.MessageId_RECEIPTS_66, - NewBlockHashesMsg: proto_sentry.MessageId_NEW_BLOCK_HASHES_66, - NewBlockMsg: proto_sentry.MessageId_NEW_BLOCK_66, - TransactionsMsg: proto_sentry.MessageId_TRANSACTIONS_66, - NewPooledTransactionHashesMsg: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES_66, - GetPooledTransactionsMsg: proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66, - PooledTransactionsMsg: proto_sentry.MessageId_POOLED_TRANSACTIONS_66, + ETH67: { + GetBlockHeadersMsg: proto_sentry.MessageId_GET_BLOCK_HEADERS, + BlockHeadersMsg: proto_sentry.MessageId_BLOCK_HEADERS, + GetBlockBodiesMsg: proto_sentry.MessageId_GET_BLOCK_BODIES, + BlockBodiesMsg: proto_sentry.MessageId_BLOCK_BODIES, + GetReceiptsMsg: proto_sentry.MessageId_GET_RECEIPTS, + ReceiptsMsg: proto_sentry.MessageId_RECEIPTS, + NewBlockHashesMsg: proto_sentry.MessageId_NEW_BLOCK_HASHES, + NewBlockMsg: proto_sentry.MessageId_NEW_BLOCK, + TransactionsMsg: proto_sentry.MessageId_TRANSACTIONS, + NewPooledTransactionHashesMsg: proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES, + GetPooledTransactionsMsg: proto_sentry.MessageId_GET_POOLED_TRANSACTIONS, + PooledTransactionsMsg: proto_sentry.MessageId_POOLED_TRANSACTIONS, }, } var FromProto = map[uint]map[proto_sentry.MessageId]uint64{ - ETH66: { - proto_sentry.MessageId_GET_BLOCK_HEADERS_66: GetBlockHeadersMsg, - proto_sentry.MessageId_BLOCK_HEADERS_66: BlockHeadersMsg, - proto_sentry.MessageId_GET_BLOCK_BODIES_66: GetBlockBodiesMsg, - proto_sentry.MessageId_BLOCK_BODIES_66: BlockBodiesMsg, - proto_sentry.MessageId_GET_NODE_DATA_66: GetNodeDataMsg, - proto_sentry.MessageId_NODE_DATA_66: NodeDataMsg, - proto_sentry.MessageId_GET_RECEIPTS_66: GetReceiptsMsg, - proto_sentry.MessageId_RECEIPTS_66: ReceiptsMsg, - proto_sentry.MessageId_NEW_BLOCK_HASHES_66: NewBlockHashesMsg, - proto_sentry.MessageId_NEW_BLOCK_66: NewBlockMsg, - proto_sentry.MessageId_TRANSACTIONS_66: TransactionsMsg, - proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES_66: NewPooledTransactionHashesMsg, - proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66: GetPooledTransactionsMsg, - proto_sentry.MessageId_POOLED_TRANSACTIONS_66: PooledTransactionsMsg, + ETH67: { + proto_sentry.MessageId_GET_BLOCK_HEADERS: GetBlockHeadersMsg, + proto_sentry.MessageId_BLOCK_HEADERS: BlockHeadersMsg, + proto_sentry.MessageId_GET_BLOCK_BODIES: GetBlockBodiesMsg, + proto_sentry.MessageId_BLOCK_BODIES: BlockBodiesMsg, + proto_sentry.MessageId_GET_RECEIPTS: GetReceiptsMsg, + proto_sentry.MessageId_RECEIPTS: ReceiptsMsg, + proto_sentry.MessageId_NEW_BLOCK_HASHES: NewBlockHashesMsg, + proto_sentry.MessageId_NEW_BLOCK: NewBlockMsg, + proto_sentry.MessageId_TRANSACTIONS: TransactionsMsg, + proto_sentry.MessageId_NEW_POOLED_TRANSACTION_HASHES: NewPooledTransactionHashesMsg, + proto_sentry.MessageId_GET_POOLED_TRANSACTIONS: GetPooledTransactionsMsg, + proto_sentry.MessageId_POOLED_TRANSACTIONS: PooledTransactionsMsg, }, } @@ -654,24 +650,6 @@ func (p *BlockRawBodiesPacket) Unpack() ([][][]byte, [][]*types.Header) { return txset, uncleset } -// GetNodeDataPacket represents a trie node data query. -type GetNodeDataPacket []common.Hash - -// GetNodeDataPacket represents a trie node data query over eth/66. -type GetNodeDataPacket66 struct { - RequestId uint64 - GetNodeDataPacket -} - -// NodeDataPacket is the network packet for trie node data distribution. -type NodeDataPacket [][]byte - -// NodeDataPacket is the network packet for trie node data distribution over eth/66. -type NodeDataPacket66 struct { - RequestId uint64 - NodeDataPacket -} - // GetReceiptsPacket represents a block receipts query. type GetReceiptsPacket []common.Hash @@ -914,12 +892,6 @@ func (*BlockBodiesPacket) Kind() byte { return BlockBodiesMsg } func (*NewBlockPacket) Name() string { return "NewBlock" } func (*NewBlockPacket) Kind() byte { return NewBlockMsg } -func (*GetNodeDataPacket) Name() string { return "GetNodeData" } -func (*GetNodeDataPacket) Kind() byte { return GetNodeDataMsg } - -func (*NodeDataPacket) Name() string { return "NodeData" } -func (*NodeDataPacket) Kind() byte { return NodeDataMsg } - func (*GetReceiptsPacket) Name() string { return "GetReceipts" } func (*GetReceiptsPacket) Kind() byte { return GetReceiptsMsg } diff --git a/eth/protocols/eth/protocol_test.go b/eth/protocols/eth/protocol_test.go index 592dcbdf0c0..5bae0706887 100644 --- a/eth/protocols/eth/protocol_test.go +++ b/eth/protocols/eth/protocol_test.go @@ -71,8 +71,8 @@ func TestGetBlockHeadersDataEncodeDecode(t *testing.T) { } } -// TestEth66EmptyMessages tests encoding of empty eth66 messages -func TestEth66EmptyMessages(t *testing.T) { +// TestEth67EmptyMessages tests encoding of empty eth67 messages +func TestEth67EmptyMessages(t *testing.T) { // All empty messages encodes to the same format want := common.FromHex("c4820457c0") @@ -84,9 +84,6 @@ func TestEth66EmptyMessages(t *testing.T) { GetBlockBodiesPacket66{1111, nil}, BlockBodiesPacket66{1111, nil}, BlockBodiesRLPPacket66{1111, nil}, - // Node data - GetNodeDataPacket66{1111, nil}, - NodeDataPacket66{1111, nil}, // Receipts GetReceiptsPacket66{1111, nil}, ReceiptsPacket66{1111, nil}, @@ -101,9 +98,6 @@ func TestEth66EmptyMessages(t *testing.T) { GetBlockBodiesPacket66{1111, GetBlockBodiesPacket([]common.Hash{})}, BlockBodiesPacket66{1111, BlockBodiesPacket([]*BlockBody{})}, BlockBodiesRLPPacket66{1111, BlockBodiesRLPPacket([]rlp.RawValue{})}, - // Node data - GetNodeDataPacket66{1111, GetNodeDataPacket([]common.Hash{})}, - NodeDataPacket66{1111, NodeDataPacket([][]byte{})}, // Receipts GetReceiptsPacket66{1111, GetReceiptsPacket([]common.Hash{})}, ReceiptsPacket66{1111, ReceiptsPacket([][]*types.Receipt{})}, @@ -119,8 +113,8 @@ func TestEth66EmptyMessages(t *testing.T) { } -// TestEth66Messages tests the encoding of all redefined eth66 messages -func TestEth66Messages(t *testing.T) { +// TestEth67Messages tests the encoding of all redefined eth67 messages +func TestEth67Messages(t *testing.T) { // Some basic structs used during testing var ( @@ -173,10 +167,6 @@ func TestEth66Messages(t *testing.T) { common.HexToHash("deadc0de"), common.HexToHash("feedbeef"), } - byteSlices := [][]byte{ - common.FromHex("deadc0de"), - common.FromHex("feedbeef"), - } // init the receipts { receipts = []*types.Receipt{ @@ -230,14 +220,6 @@ func TestEth66Messages(t *testing.T) { BlockBodiesRLPPacket66{1111, BlockBodiesRLPPacket([]rlp.RawValue{blockBodyRlp})}, common.FromHex("f902dc820457f902d6f902d3f8d2f867088504a817c8088302e2489435353535353535353535353535353535353535358202008025a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c12a064b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10f867098504a817c809830334509435353535353535353535353535353535353535358202d98025a052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afba052f8f61201b2b11a78d6e866abc9c3db2ae8631fa656bfe5cb53668255367afbf901fcf901f9a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000940000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008208ae820d0582115c8215b3821a0a827788a00000000000000000000000000000000000000000000000000000000000000000880000000000000000"), }, - { - GetNodeDataPacket66{1111, GetNodeDataPacket(hashes)}, - common.FromHex("f847820457f842a000000000000000000000000000000000000000000000000000000000deadc0dea000000000000000000000000000000000000000000000000000000000feedbeef"), - }, - { - NodeDataPacket66{1111, NodeDataPacket(byteSlices)}, - common.FromHex("ce820457ca84deadc0de84feedbeef"), - }, { GetReceiptsPacket66{1111, GetReceiptsPacket(hashes)}, common.FromHex("f847820457f842a000000000000000000000000000000000000000000000000000000000deadc0dea000000000000000000000000000000000000000000000000000000000feedbeef"), diff --git a/ethdb/privateapi/ethbackend.go b/ethdb/privateapi/ethbackend.go index 4719d6c78e6..46e0fa49f01 100644 --- a/ethdb/privateapi/ethbackend.go +++ b/ethdb/privateapi/ethbackend.go @@ -197,7 +197,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: 67}, nil } func (s *EthBackendServer) ClientVersion(_ context.Context, _ *remote.ClientVersionRequest) (*remote.ClientVersionReply, error) { diff --git a/go.mod b/go.mod index ecea7d44e68..7eab08c2969 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/ledgerwatch/erigon-lib v0.0.0-20220625091153-e7b09db04531 + github.com/ledgerwatch/erigon-lib v0.0.0-20220628075812-eac8c1fa590b github.com/ledgerwatch/log/v3 v3.4.1 github.com/ledgerwatch/secp256k1 v1.0.0 github.com/nxadm/tail v1.4.9-0.20211216163028-4472660a31a6 diff --git a/go.sum b/go.sum index b7a39052902..3e38c0a8807 100644 --- a/go.sum +++ b/go.sum @@ -386,8 +386,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20220625091153-e7b09db04531 h1:UKQC0chFY2s0wXOMDOyPEuUTwymsQRUpNHm7/5isnUo= -github.com/ledgerwatch/erigon-lib v0.0.0-20220625091153-e7b09db04531/go.mod h1:7sQ5B5m54zoo7RVRVukH3YZCYVrCC+BmwDBD+9KyTrE= +github.com/ledgerwatch/erigon-lib v0.0.0-20220628075812-eac8c1fa590b h1:9SnS7lnKnl4PtXB0tYZjnK/wJIl/wHbx9ByXp2wDUNQ= +github.com/ledgerwatch/erigon-lib v0.0.0-20220628075812-eac8c1fa590b/go.mod h1:7sQ5B5m54zoo7RVRVukH3YZCYVrCC+BmwDBD+9KyTrE= github.com/ledgerwatch/log/v3 v3.4.1 h1:/xGwlVulXnsO9Uq+tzaExc8OWmXXHU0dnLalpbnY5Bc= github.com/ledgerwatch/log/v3 v3.4.1/go.mod h1:VXcz6Ssn6XEeU92dCMc39/g1F0OYAjw1Mt+dGP5DjXY= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ= diff --git a/p2p/dial_test.go b/p2p/dial_test.go index 9bafb293fc7..185a71a401e 100644 --- a/p2p/dial_test.go +++ b/p2p/dial_test.go @@ -410,7 +410,7 @@ func runDialTest(t *testing.T, config dialConfig, rounds []dialTestRound) { setupCh <- conn return nil } - dialsched = newDialScheduler(config, iterator, setup, 66) + dialsched = newDialScheduler(config, iterator, setup, 67) defer dialsched.stop() for i, round := range rounds { diff --git a/turbo/stages/mock_sentry.go b/turbo/stages/mock_sentry.go index 5ba56a2fad5..2caf0cfa040 100644 --- a/turbo/stages/mock_sentry.go +++ b/turbo/stages/mock_sentry.go @@ -117,7 +117,7 @@ func (ms *MockSentry) PeerMinBlock(context.Context, *proto_sentry.PeerMinBlockRe } func (ms *MockSentry) HandShake(ctx context.Context, in *emptypb.Empty) (*proto_sentry.HandShakeReply, error) { - return &proto_sentry.HandShakeReply{Protocol: proto_sentry.Protocol_ETH66}, nil + return &proto_sentry.HandShakeReply{Protocol: proto_sentry.Protocol_ETH67}, nil } func (ms *MockSentry) SendMessageByMinBlock(_ context.Context, r *proto_sentry.SendMessageByMinBlockRequest) (*proto_sentry.SentPeers, error) { ms.sentMessages = append(ms.sentMessages, r.Data) @@ -234,7 +234,7 @@ func MockWithEverything(t *testing.T, gspec *core.Genesis, key *ecdsa.PrivateKey cfg.DeprecatedTxPool.Disable = !withTxPool cfg.DeprecatedTxPool.StartOnInit = true - mock.SentryClient = direct.NewSentryClientDirect(eth.ETH66, mock) + mock.SentryClient = direct.NewSentryClientDirect(eth.ETH67, mock) sentries := []direct.SentryClient{mock.SentryClient} sendBodyRequest := func(context.Context, *bodydownload.BodyRequest) ([64]byte, bool) { return [64]byte{}, false } @@ -450,7 +450,7 @@ func (ms *MockSentry) InsertChain(chain *core.ChainPack) error { return err } ms.ReceiveWg.Add(1) - for _, err = range ms.Send(&proto_sentry.InboundMessage{Id: proto_sentry.MessageId_NEW_BLOCK_66, Data: b, PeerId: ms.PeerId}) { + for _, err = range ms.Send(&proto_sentry.InboundMessage{Id: proto_sentry.MessageId_NEW_BLOCK, Data: b, PeerId: ms.PeerId}) { if err != nil { return err } @@ -464,7 +464,7 @@ func (ms *MockSentry) InsertChain(chain *core.ChainPack) error { return err } ms.ReceiveWg.Add(1) - for _, err = range ms.Send(&proto_sentry.InboundMessage{Id: proto_sentry.MessageId_BLOCK_HEADERS_66, Data: b, PeerId: ms.PeerId}) { + for _, err = range ms.Send(&proto_sentry.InboundMessage{Id: proto_sentry.MessageId_BLOCK_HEADERS, Data: b, PeerId: ms.PeerId}) { if err != nil { return err } @@ -482,7 +482,7 @@ func (ms *MockSentry) InsertChain(chain *core.ChainPack) error { return err } ms.ReceiveWg.Add(1) - for _, err = range ms.Send(&proto_sentry.InboundMessage{Id: proto_sentry.MessageId_BLOCK_BODIES_66, Data: b, PeerId: ms.PeerId}) { + for _, err = range ms.Send(&proto_sentry.InboundMessage{Id: proto_sentry.MessageId_BLOCK_BODIES, Data: b, PeerId: ms.PeerId}) { if err != nil { return err } diff --git a/turbo/stages/sentry_mock_test.go b/turbo/stages/sentry_mock_test.go index f0a9c136efa..df2c6329478 100644 --- a/turbo/stages/sentry_mock_test.go +++ b/turbo/stages/sentry_mock_test.go @@ -40,7 +40,7 @@ func TestHeaderStep(t *testing.T) { }) require.NoError(t, 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(t, err) } // Send all the headers @@ -50,7 +50,7 @@ func TestHeaderStep(t *testing.T) { }) require.NoError(t, 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(t, err) } m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceed @@ -79,7 +79,7 @@ func TestMineBlockWith1Tx(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 @@ -89,7 +89,7 @@ func TestMineBlockWith1Tx(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 @@ -113,7 +113,7 @@ func TestMineBlockWith1Tx(t *testing.T) { b, err := rlp.EncodeToBytes(chain.TopBlock.Transactions()) require.NoError(err) m.ReceiveWg.Add(1) - for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_TRANSACTIONS_66, Data: b, PeerId: m.PeerId}) { + for _, err = range m.Send(&sentry.InboundMessage{Id: sentry.MessageId_TRANSACTIONS, Data: b, PeerId: m.PeerId}) { require.NoError(err) } m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed @@ -145,7 +145,7 @@ func TestReorg(t *testing.T) { t.Fatal(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(t, err) } @@ -158,7 +158,7 @@ func TestReorg(t *testing.T) { t.Fatal(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(t, err) } m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed @@ -199,7 +199,7 @@ func TestReorg(t *testing.T) { t.Fatal(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(t, err) } @@ -212,7 +212,7 @@ func TestReorg(t *testing.T) { t.Fatal(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(t, err) } m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed @@ -232,7 +232,7 @@ func TestReorg(t *testing.T) { t.Fatal(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(t, err) } @@ -245,7 +245,7 @@ func TestReorg(t *testing.T) { t.Fatal(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(t, err) } @@ -256,7 +256,7 @@ func TestReorg(t *testing.T) { }) require.NoError(t, 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(t, err) } m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed @@ -283,7 +283,7 @@ func TestReorg(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -294,7 +294,7 @@ func TestReorg(t *testing.T) { }) require.NoError(t, 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(t, err) } m.ReceiveWg.Wait() // Wait for all messages to be processed before we proceeed @@ -342,7 +342,7 @@ func TestAnchorReplace(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -353,7 +353,7 @@ func TestAnchorReplace(t *testing.T) { }) require.NoError(t, 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(t, err) } require.NoError(t, err) @@ -365,7 +365,7 @@ func TestAnchorReplace(t *testing.T) { }) require.NoError(t, 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(t, err) } require.NoError(t, err) @@ -377,7 +377,7 @@ func TestAnchorReplace(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -390,7 +390,7 @@ func TestAnchorReplace(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -438,7 +438,7 @@ func TestAnchorReplace2(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -449,7 +449,7 @@ func TestAnchorReplace2(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -460,7 +460,7 @@ func TestAnchorReplace2(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -471,7 +471,7 @@ func TestAnchorReplace2(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -482,7 +482,7 @@ func TestAnchorReplace2(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -495,7 +495,7 @@ func TestAnchorReplace2(t *testing.T) { }) require.NoError(t, 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(t, err) } @@ -591,7 +591,7 @@ func TestPoSDownloader(t *testing.T) { }) require.NoError(t, 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(t, err) } m.ReceiveWg.Wait() @@ -657,7 +657,7 @@ func TestPoSSyncWithInvalidHeader(t *testing.T) { }) require.NoError(t, 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(t, err) } m.ReceiveWg.Wait()