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

eth: implement eth66 #22241

Merged
merged 20 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7999e70
eth/protocols/eth: split up the eth protocol handlers
holiman Nov 24, 2020
5f0af8b
eth/protocols/eth: define eth-66 protocol messages
holiman Jan 26, 2021
d139b26
eth/protocols/eth: poc implement getblockheaders on eth/66
holiman Jan 26, 2021
114e366
eth/protocols/eth: implement remaining eth-66 handlers
holiman Jan 26, 2021
80f0f95
eth/protocols: define handler map for eth 66
holiman Jan 26, 2021
2b1477b
eth/downloader: use protocol constants from eth package
holiman Jan 26, 2021
9e8116f
eth/protocols/eth: add ETH66 capability
holiman Jan 26, 2021
ad57ef8
eth/downloader: tests for eth66
holiman Jan 26, 2021
e7858d7
eth/downloader: fix error in tests
holiman Jan 26, 2021
6e1bfe4
eth/protocols/eth: use eth66 for outgoing requests
holiman Jan 26, 2021
30f9649
eth/protocols/eth: remove unused error type
holiman Jan 26, 2021
bc10f94
eth/protocols/eth: define protocol length
holiman Jan 26, 2021
b7e8558
eth/protocols/eth: fix pooled tx over eth66
holiman Jan 27, 2021
0c03abc
protocols/eth/handlers: revert behavioural change which caused tests …
holiman Jan 27, 2021
0a83e81
eth/downloader: fix failing test
holiman Jan 27, 2021
5f62d2e
eth/protocols/eth: add testcases + fix flaw with header requests
holiman Jan 28, 2021
fb7c0d8
eth/protocols: change comments
holiman Jan 28, 2021
4ac8b82
eth/protocols/eth: review fixes + fixed flaw in RequestOneHeader
holiman Feb 8, 2021
7a1b727
eth/protocols: documentation
holiman Feb 18, 2021
c41ffe6
eth/protocols/eth: review concerns about types
holiman Feb 18, 2021
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
Prev Previous commit
Next Next commit
eth/protocols: change comments
  • Loading branch information
holiman committed Feb 18, 2021
commit fb7c0d8b571c6901d73ac88a0e284cd880f26c64
2 changes: 1 addition & 1 deletion eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func handleGetBlockHeaders(backend Backend, msg Decoder, peer *Peer) error {
return peer.SendBlockHeaders(response)
}

// handleGetBlockHeaders66 is the ETH-66 version of handleGetBlockHeaders
// handleGetBlockHeaders66 is the eth/66 version of handleGetBlockHeaders
func handleGetBlockHeaders66(backend Backend, msg Decoder, peer *Peer) error {
// Decode the complex header query
var query GetBlockHeadersPacket66
Expand Down
6 changes: 3 additions & 3 deletions eth/protocols/eth/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (p *Peer) SendPooledTransactionsRLP(hashes []common.Hash, txs PooledTransac
return p2p.Send(p.rw, PooledTransactionsMsg, txs) // Not packed into PooledTransactionsPacket to avoid RLP decoding
}

// ReplyPooledTransactionsRLP is the ETH-66 version of SendPooledTransactionsRLP
// ReplyPooledTransactionsRLP is the eth/66 version of SendPooledTransactionsRLP
func (p *Peer) ReplyPooledTransactionsRLP(id uint64, hashes []common.Hash, txs PooledTransactionsRLPPacket) error {
// Mark all the transactions as known, but ensure we don't overflow our limits
for p.knownTxs.Cardinality() > max(0, maxKnownTxs-len(hashes)) {
Expand Down Expand Up @@ -363,7 +363,7 @@ func (p *Peer) SendNodeData(data NodeDataPacket) error {
return p2p.Send(p.rw, NodeDataMsg, data)
}

// ReplyNodeData is the ETH-66 response to GetNodeData
// ReplyNodeData is the eth/66 response to GetNodeData
func (p *Peer) ReplyNodeData(id uint64, data NodeDataPacket) error {
return p2p.Send(p.rw, NodeDataMsg, NodeDataPacket66{id, data})
}
Expand All @@ -374,7 +374,7 @@ func (p *Peer) SendReceiptsRLP(receipts ReceiptsRLPPacket) error {
return p2p.Send(p.rw, ReceiptsMsg, receipts) // Not packed into ReceiptsPacket to avoid RLP decoding
}

// ReplyReceiptsRLP is the ETH-66 response to GetReceipts
// ReplyReceiptsRLP is the eth/66 response to GetReceipts
func (p *Peer) ReplyReceiptsRLP(id uint64, receipts ReceiptsRLPPacket) error {
return p2p.Send(p.rw, ReceiptsMsg, ReceiptsRLPPacket66{id, receipts})
}
Expand Down
22 changes: 11 additions & 11 deletions eth/protocols/eth/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ type GetBlockHeadersPacket struct {
Reverse bool // Query direction (false = rising towards latest, true = falling towards genesis)
}

// GetBlockHeadersPacket represents a block header query over ETH-66
// GetBlockHeadersPacket represents a block header query over eth/66
type GetBlockHeadersPacket66 struct {
RequestId uint64
*GetBlockHeadersPacket
Expand Down Expand Up @@ -174,7 +174,7 @@ func (hn *HashOrNumber) DecodeRLP(s *rlp.Stream) error {
// BlockHeadersPacket represents a block header response.
type BlockHeadersPacket []*types.Header

// BlockHeadersPacket represents a block header response over ETH-66.
// BlockHeadersPacket represents a block header response over eth/66.
type BlockHeadersPacket66 struct {
RequestId uint64
BlockHeadersPacket
Expand Down Expand Up @@ -202,7 +202,7 @@ func (request *NewBlockPacket) sanityCheck() error {
// GetBlockBodiesPacket represents a block body query.
type GetBlockBodiesPacket []common.Hash

// GetBlockBodiesPacket represents a block body query over ETH-66.
// GetBlockBodiesPacket represents a block body query over eth/66.
type GetBlockBodiesPacket66 struct {
RequestId uint64
GetBlockBodiesPacket
Expand All @@ -216,13 +216,13 @@ type BlockBodiesPacket []*BlockBody
// roundtrip.
type BlockBodiesRLPPacket []rlp.RawValue

// BlockBodiesRLPPacket66 is the BlockBodiesRLPPacket over ETH-66
// BlockBodiesRLPPacket66 is the BlockBodiesRLPPacket over eth/66
type BlockBodiesRLPPacket66 struct {
RequestId uint64
BlockBodiesRLPPacket
}

// BlockBodiesPacket is the network packet for block content distribution over ETH-66.
// BlockBodiesPacket is the network packet for block content distribution over eth/66.
type BlockBodiesPacket66 struct {
RequestId uint64
BlockBodiesPacket
Expand Down Expand Up @@ -250,7 +250,7 @@ func (p *BlockBodiesPacket) Unpack() ([][]*types.Transaction, [][]*types.Header)
// GetNodeDataPacket represents a trie node data query.
type GetNodeDataPacket []common.Hash

// GetNodeDataPacket represents a trie node data query over ETH-66.
// GetNodeDataPacket represents a trie node data query over eth/66.
type GetNodeDataPacket66 struct {
RequestId uint64
GetNodeDataPacket
Expand All @@ -259,7 +259,7 @@ type GetNodeDataPacket66 struct {
// 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.
// NodeDataPacket is the network packet for trie node data distribution over eth/66.
type NodeDataPacket66 struct {
RequestId uint64
NodeDataPacket
Expand All @@ -268,7 +268,7 @@ type NodeDataPacket66 struct {
// GetReceiptsPacket represents a block receipts query.
type GetReceiptsPacket []common.Hash

// GetReceiptsPacket represents a block receipts query over ETH-66.
// GetReceiptsPacket represents a block receipts query over eth/66.
type GetReceiptsPacket66 struct {
RequestId uint64
GetReceiptsPacket
Expand All @@ -277,7 +277,7 @@ type GetReceiptsPacket66 struct {
// ReceiptsPacket is the network packet for block receipts distribution.
type ReceiptsPacket [][]*types.Receipt

// ReceiptsPacket is the network packet for block receipts distribution over ETH-66.
// ReceiptsPacket is the network packet for block receipts distribution over eth/66.
type ReceiptsPacket66 struct {
RequestId uint64
ReceiptsPacket
Expand Down Expand Up @@ -306,7 +306,7 @@ type GetPooledTransactionsPacket66 struct {
// PooledTransactionsPacket is the network packet for transaction distribution.
type PooledTransactionsPacket []*types.Transaction

// PooledTransactionsPacket is the network packet for transaction distribution over ETH-66.
// PooledTransactionsPacket is the network packet for transaction distribution over eth/66.
type PooledTransactionsPacket66 struct {
RequestId uint64
PooledTransactionsPacket
Expand All @@ -316,7 +316,7 @@ type PooledTransactionsPacket66 struct {
// in the cases we already have them in rlp-encoded form
type PooledTransactionsRLPPacket []rlp.RawValue

// PooledTransactionsRLPPacket66 is the ETH-66 form of PooledTransactionsRLPPacket
// PooledTransactionsRLPPacket66 is the eth/66 form of PooledTransactionsRLPPacket
type PooledTransactionsRLPPacket66 struct {
RequestId uint64
PooledTransactionsRLPPacket
Expand Down
3 changes: 1 addition & 2 deletions eth/protocols/eth/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ package eth

import (
"bytes"
"fmt"
"github.com/ethereum/go-ethereum/core/types"
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
)

Expand Down