Unverified Commit 30602163 authored by rjl493456442's avatar rjl493456442 Committed by GitHub

eth: introduce eth67 protocol (#24093)

The new protocol version removes support for GetNodeData.
See https://eips.ethereum.org/EIPS/eip-4938 for more information.
Co-authored-by: 's avatarFelix Lange <fjl@twurst.com>
Co-authored-by: 's avatarMartin Holst Swende <martin@swende.se>
parent 3273ad1a
This diff is collapsed.
......@@ -181,6 +181,21 @@ var eth66 = map[uint64]msgHandler{
PooledTransactionsMsg: handlePooledTransactions66,
}
var eth67 = map[uint64]msgHandler{
NewBlockHashesMsg: handleNewBlockhashes,
NewBlockMsg: handleNewBlock,
TransactionsMsg: handleTransactions,
NewPooledTransactionHashesMsg: handleNewPooledTransactionHashes,
GetBlockHeadersMsg: handleGetBlockHeaders66,
BlockHeadersMsg: handleBlockHeaders66,
GetBlockBodiesMsg: handleGetBlockBodies66,
BlockBodiesMsg: handleBlockBodies66,
GetReceiptsMsg: handleGetReceipts66,
ReceiptsMsg: handleReceipts66,
GetPooledTransactionsMsg: handleGetPooledTransactions66,
PooledTransactionsMsg: handlePooledTransactions66,
}
// handleMessage is invoked whenever an inbound message is received from a remote
// peer. The remote connection is torn down upon returning any error.
func handleMessage(backend Backend, peer *Peer) error {
......@@ -195,9 +210,9 @@ func handleMessage(backend Backend, peer *Peer) error {
defer msg.Discard()
var handlers = eth66
//if peer.Version() >= ETH67 { // Left in as a sample when new protocol is added
// handlers = eth67
//}
if peer.Version() >= ETH67 {
handlers = eth67
}
// Track the amount of time it takes to serve the request and run the handler
if metrics.Enabled {
......
......@@ -31,6 +31,7 @@ import (
// Constants to match up protocol versions and messages
const (
ETH66 = 66
ETH67 = 67
)
// ProtocolName is the official short name of the `eth` protocol used during
......@@ -39,11 +40,11 @@ const ProtocolName = "eth"
// ProtocolVersions are the supported versions of the `eth` protocol (first
// is primary).
var ProtocolVersions = []uint{ETH66}
var ProtocolVersions = []uint{ETH67, ETH66}
// protocolLengths are the number of implemented message corresponding to
// different protocol versions.
var protocolLengths = map[uint]uint64{ETH66: 17}
var protocolLengths = map[uint]uint64{ETH67: 17, ETH66: 17}
// maxMessageSize is the maximum cap on the size of a protocol message.
const maxMessageSize = 10 * 1024 * 1024
......
......@@ -30,6 +30,7 @@ import (
// Tests that snap sync is disabled after a successful sync cycle.
func TestSnapSyncDisabling66(t *testing.T) { testSnapSyncDisabling(t, eth.ETH66, snap.SNAP1) }
func TestSnapSyncDisabling67(t *testing.T) { testSnapSyncDisabling(t, eth.ETH67, snap.SNAP1) }
// Tests that snap sync gets disabled as soon as a real block is successfully
// imported into the blockchain.
......
......@@ -413,7 +413,7 @@ func (ps *peerSet) HeaderIdlePeers() ([]*peerConnection, int) {
throughput := func(p *peerConnection) int {
return p.rates.Capacity(eth.BlockHeadersMsg, time.Second)
}
return ps.idlePeers(eth.ETH66, eth.ETH66, idle, throughput)
return ps.idlePeers(eth.ETH66, eth.ETH67, idle, throughput)
}
// BodyIdlePeers retrieves a flat list of all the currently body-idle peers within
......@@ -425,7 +425,7 @@ func (ps *peerSet) BodyIdlePeers() ([]*peerConnection, int) {
throughput := func(p *peerConnection) int {
return p.rates.Capacity(eth.BlockBodiesMsg, time.Second)
}
return ps.idlePeers(eth.ETH66, eth.ETH66, idle, throughput)
return ps.idlePeers(eth.ETH66, eth.ETH67, idle, throughput)
}
// ReceiptIdlePeers retrieves a flat list of all the currently receipt-idle peers
......@@ -437,7 +437,7 @@ func (ps *peerSet) ReceiptIdlePeers() ([]*peerConnection, int) {
throughput := func(p *peerConnection) int {
return p.rates.Capacity(eth.ReceiptsMsg, time.Second)
}
return ps.idlePeers(eth.ETH66, eth.ETH66, idle, throughput)
return ps.idlePeers(eth.ETH66, eth.ETH67, idle, throughput)
}
// NodeDataIdlePeers retrieves a flat list of all the currently node-data-idle
......@@ -449,7 +449,7 @@ func (ps *peerSet) NodeDataIdlePeers() ([]*peerConnection, int) {
throughput := func(p *peerConnection) int {
return p.rates.Capacity(eth.NodeDataMsg, time.Second)
}
return ps.idlePeers(eth.ETH66, eth.ETH66, idle, throughput)
return ps.idlePeers(eth.ETH66, eth.ETH67, idle, throughput)
}
// idlePeers retrieves a flat list of all currently idle peers satisfying the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment