Documentation ¶
Index ¶
- Constants
- Variables
- func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket) []rlp.RawValue
- func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, ...) ([]*types.Header, error)
- func AnswerGetReceiptsQuery(db kv.Tx, query GetReceiptsPacket) ([]rlp.RawValue, error)
- func CurrentENREntryFromForks(heightForks, timeForks []uint64, genesisHash libcommon.Hash, ...) *enrEntry
- func LoadENRForkID(r *enr.Record) (*forkid.ID, error)
- type BlockBodiesPacket
- type BlockBodiesPacket66
- type BlockBodiesRLPPacket
- type BlockBodiesRLPPacket66
- type BlockHeadersPacket
- type BlockHeadersPacket66
- type BlockRawBodiesPacket
- type BlockRawBodiesPacket66
- type GetBlockBodiesPacket
- type GetBlockBodiesPacket66
- type GetBlockHeadersPacket
- type GetBlockHeadersPacket66
- type GetNodeDataPacket
- type GetNodeDataPacket66
- type GetPooledTransactionsPacket
- type GetPooledTransactionsPacket66
- type GetReceiptsPacket
- type GetReceiptsPacket66
- type HashOrNumber
- type NewBlockHashesPacket
- type NewBlockPacket
- type NewPooledTransactionHashesPacket
- type NodeDataPacket
- type NodeDataPacket66
- type NodeInfo
- type Packet
- type PooledTransactionsPacket
- type PooledTransactionsPacket66
- type PooledTransactionsRLPPacket
- type PooledTransactionsRLPPacket66
- type ReceiptsPacket
- type ReceiptsPacket66
- type ReceiptsRLPPacket
- type ReceiptsRLPPacket66
- type StatusPacket
- type TransactionsPacket
Constants ¶
const ( // maxHeadersServe is the maximum number of block headers to serve. This number // is there to limit the number of disk lookups. MaxHeadersServe = 1024 // maxBodiesServe is the maximum number of block bodies to serve. This number // is mostly there to limit the number of disk lookups. With 24KB block sizes // nowadays, the practical limit will always be softResponseLimit. MaxBodiesServe = 1024 )
const ( ETH66 = 66 ETH67 = 67 ETH68 = 68 )
Constants to match up protocol versions and messages
const ( // Protocol messages in eth/64 StatusMsg = 0x00 NewBlockHashesMsg = 0x01 TransactionsMsg = 0x02 GetBlockHeadersMsg = 0x03 BlockHeadersMsg = 0x04 GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 NewBlockMsg = 0x07 GetNodeDataMsg = 0x0d NodeDataMsg = 0x0e GetReceiptsMsg = 0x0f ReceiptsMsg = 0x10 // Protocol messages overloaded in eth/65 NewPooledTransactionHashesMsg = 0x08 GetPooledTransactionsMsg = 0x09 PooledTransactionsMsg = 0x0a )
const ProtocolMaxMsgSize = maxMessageSize
const ProtocolName = "eth"
ProtocolName is the official short name of the `eth` protocol used during devp2p capability negotiation.
Variables ¶
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_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_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, }, ETH68: { 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_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_68: NewPooledTransactionHashesMsg, proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66: GetPooledTransactionsMsg, proto_sentry.MessageId_POOLED_TRANSACTIONS_66: PooledTransactionsMsg, }, }
var ProtocolToString = map[uint]string{ ETH66: "eth66", ETH67: "eth67", ETH68: "eth68", }
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_66, BlockHeadersMsg: proto_sentry.MessageId_BLOCK_HEADERS_66, GetBlockBodiesMsg: proto_sentry.MessageId_GET_BLOCK_BODIES_66, BlockBodiesMsg: proto_sentry.MessageId_BLOCK_BODIES_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, }, ETH68: { 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, 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_68, GetPooledTransactionsMsg: proto_sentry.MessageId_GET_POOLED_TRANSACTIONS_66, PooledTransactionsMsg: proto_sentry.MessageId_POOLED_TRANSACTIONS_66, }, }
Functions ¶
func AnswerGetBlockBodiesQuery ¶
func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket) []rlp.RawValue
func AnswerGetBlockHeadersQuery ¶
func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, blockReader services.HeaderAndCanonicalReader) ([]*types.Header, error)
func AnswerGetReceiptsQuery ¶
Types ¶
type BlockBodiesPacket ¶
BlockBodiesPacket is the network packet for block content distribution.
func (*BlockBodiesPacket) Kind ¶
func (*BlockBodiesPacket) Kind() byte
func (*BlockBodiesPacket) Name ¶
func (*BlockBodiesPacket) Name() string
type BlockBodiesPacket66 ¶
type BlockBodiesPacket66 struct { RequestId uint64 BlockBodiesPacket }
BlockBodiesPacket is the network packet for block content distribution over eth/66.
type BlockBodiesRLPPacket ¶
BlockBodiesRLPPacket is used for replying to block body requests, in cases where we already have them RLP-encoded, and thus can avoid the decode-encode roundtrip.
type BlockBodiesRLPPacket66 ¶
type BlockBodiesRLPPacket66 struct { RequestId uint64 BlockBodiesRLPPacket }
BlockBodiesRLPPacket66 is the BlockBodiesRLPPacket over eth/66
type BlockHeadersPacket ¶
BlockHeadersPacket represents a block header response.
func (*BlockHeadersPacket) Kind ¶
func (*BlockHeadersPacket) Kind() byte
func (*BlockHeadersPacket) Name ¶
func (*BlockHeadersPacket) Name() string
type BlockHeadersPacket66 ¶
type BlockHeadersPacket66 struct { RequestId uint64 BlockHeadersPacket }
BlockHeadersPacket represents a block header response over eth/66.
type BlockRawBodiesPacket ¶
BlockRawBodiesPacket is the network packet for block content distribution.
func (*BlockRawBodiesPacket) Unpack ¶
func (p *BlockRawBodiesPacket) Unpack() ([][][]byte, [][]*types.Header, []types.Withdrawals)
Unpack retrieves the transactions, uncles, and withdrawals from the range packet and returns them in a split flat format that's more consistent with the internal data structures.
type BlockRawBodiesPacket66 ¶
type BlockRawBodiesPacket66 struct { RequestId uint64 BlockRawBodiesPacket }
BlockBodiesPacket is the network packet for block content distribution over eth/66.
type GetBlockBodiesPacket ¶
GetBlockBodiesPacket represents a block body query.
func (*GetBlockBodiesPacket) Kind ¶
func (*GetBlockBodiesPacket) Kind() byte
func (*GetBlockBodiesPacket) Name ¶
func (*GetBlockBodiesPacket) Name() string
type GetBlockBodiesPacket66 ¶
type GetBlockBodiesPacket66 struct { RequestId uint64 GetBlockBodiesPacket }
GetBlockBodiesPacket represents a block body query over eth/66.
type GetBlockHeadersPacket ¶
type GetBlockHeadersPacket struct { Origin HashOrNumber // Block from which to retrieve headers Amount uint64 // Maximum number of headers to retrieve Skip uint64 // Blocks to skip between consecutive headers Reverse bool // Query direction (false = rising towards latest, true = falling towards genesis) }
GetBlockHeadersPacket represents a block header query.
func (*GetBlockHeadersPacket) Kind ¶
func (*GetBlockHeadersPacket) Kind() byte
func (*GetBlockHeadersPacket) Name ¶
func (*GetBlockHeadersPacket) Name() string
type GetBlockHeadersPacket66 ¶
type GetBlockHeadersPacket66 struct { RequestId uint64 *GetBlockHeadersPacket }
GetBlockHeadersPacket represents a block header query over eth/66
type GetNodeDataPacket ¶
GetNodeDataPacket represents a trie node data query.
func (*GetNodeDataPacket) Kind ¶
func (*GetNodeDataPacket) Kind() byte
func (*GetNodeDataPacket) Name ¶
func (*GetNodeDataPacket) Name() string
type GetNodeDataPacket66 ¶
type GetNodeDataPacket66 struct { RequestId uint64 GetNodeDataPacket }
GetNodeDataPacket represents a trie node data query over eth/66.
type GetPooledTransactionsPacket ¶
GetPooledTransactionsPacket represents a transaction query.
func (*GetPooledTransactionsPacket) Kind ¶
func (*GetPooledTransactionsPacket) Kind() byte
func (*GetPooledTransactionsPacket) Name ¶
func (*GetPooledTransactionsPacket) Name() string
type GetPooledTransactionsPacket66 ¶
type GetPooledTransactionsPacket66 struct { RequestId uint64 GetPooledTransactionsPacket }
type GetReceiptsPacket ¶
GetReceiptsPacket represents a block receipts query.
func (*GetReceiptsPacket) Kind ¶
func (*GetReceiptsPacket) Kind() byte
func (*GetReceiptsPacket) Name ¶
func (*GetReceiptsPacket) Name() string
type GetReceiptsPacket66 ¶
type GetReceiptsPacket66 struct { RequestId uint64 GetReceiptsPacket }
GetReceiptsPacket represents a block receipts query over eth/66.
type HashOrNumber ¶
type HashOrNumber struct { Hash libcommon.Hash // Block hash from which to retrieve headers (excludes Number) Number uint64 // Block hash from which to retrieve headers (excludes Hash) }
HashOrNumber is a combined field for specifying an origin block.
type NewBlockHashesPacket ¶
type NewBlockHashesPacket []struct { Hash libcommon.Hash // Hash of one particular block being announced Number uint64 // Number of one particular block being announced }
NewBlockHashesPacket is the network packet for the block announcements.
func (*NewBlockHashesPacket) Kind ¶
func (*NewBlockHashesPacket) Kind() byte
func (*NewBlockHashesPacket) Name ¶
func (*NewBlockHashesPacket) Name() string
type NewBlockPacket ¶
NewBlockPacket is the network packet for the block propagation message.
func (*NewBlockPacket) Kind ¶
func (*NewBlockPacket) Kind() byte
func (*NewBlockPacket) Name ¶
func (*NewBlockPacket) Name() string
func (*NewBlockPacket) SanityCheck ¶
func (request *NewBlockPacket) SanityCheck() error
SanityCheck verifies that the values are reasonable, as a DoS protection
type NewPooledTransactionHashesPacket ¶
NewPooledTransactionHashesPacket represents a transaction announcement packet.
func (*NewPooledTransactionHashesPacket) Kind ¶
func (*NewPooledTransactionHashesPacket) Kind() byte
func (*NewPooledTransactionHashesPacket) Name ¶
func (*NewPooledTransactionHashesPacket) Name() string
type NodeDataPacket ¶
type NodeDataPacket [][]byte
NodeDataPacket is the network packet for trie node data distribution.
func (*NodeDataPacket) Kind ¶
func (*NodeDataPacket) Kind() byte
func (*NodeDataPacket) Name ¶
func (*NodeDataPacket) Name() string
type NodeDataPacket66 ¶
type NodeDataPacket66 struct { RequestId uint64 NodeDataPacket }
NodeDataPacket is the network packet for trie node data distribution over eth/66.
type NodeInfo ¶
type NodeInfo struct { Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, Rinkeby=4, Görli=5) Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain Genesis libcommon.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *chain.Config `json:"config"` // ChainDB configuration for the fork rules Head libcommon.Hash `json:"head"` // Hex hash of the host's best owned block }
NodeInfo represents a short summary of the `eth` sub-protocol metadata known about the host peer.
type Packet ¶
type Packet interface { Name() string // Name returns a string corresponding to the message type. Kind() byte // Kind returns the message type. }
Packet represents a p2p message in the `eth` protocol.
type PooledTransactionsPacket ¶
type PooledTransactionsPacket []types.Transaction
PooledTransactionsPacket is the network packet for transaction distribution.
func (*PooledTransactionsPacket) DecodeRLP ¶
func (ptp *PooledTransactionsPacket) DecodeRLP(s *rlp.Stream) error
func (PooledTransactionsPacket) EncodeRLP ¶
func (ptp PooledTransactionsPacket) EncodeRLP(w io.Writer) error
func (*PooledTransactionsPacket) Kind ¶
func (*PooledTransactionsPacket) Kind() byte
func (*PooledTransactionsPacket) Name ¶
func (*PooledTransactionsPacket) Name() string
type PooledTransactionsPacket66 ¶
type PooledTransactionsPacket66 struct { RequestId uint64 PooledTransactionsPacket }
PooledTransactionsPacket is the network packet for transaction distribution over eth/66.
type PooledTransactionsRLPPacket ¶
PooledTransactionsPacket is the network packet for transaction distribution, used in the cases we already have them in rlp-encoded form
type PooledTransactionsRLPPacket66 ¶
type PooledTransactionsRLPPacket66 struct { RequestId uint64 PooledTransactionsRLPPacket }
PooledTransactionsRLPPacket66 is the eth/66 form of PooledTransactionsRLPPacket
type ReceiptsPacket ¶
ReceiptsPacket is the network packet for block receipts distribution.
func (*ReceiptsPacket) Kind ¶
func (*ReceiptsPacket) Kind() byte
func (*ReceiptsPacket) Name ¶
func (*ReceiptsPacket) Name() string
type ReceiptsPacket66 ¶
type ReceiptsPacket66 struct { RequestId uint64 ReceiptsPacket }
ReceiptsPacket is the network packet for block receipts distribution over eth/66.
type ReceiptsRLPPacket ¶
ReceiptsRLPPacket is used for receipts, when we already have it encoded
type ReceiptsRLPPacket66 ¶
type ReceiptsRLPPacket66 struct { RequestId uint64 ReceiptsRLPPacket }
ReceiptsPacket66 is the eth-66 version of ReceiptsRLPPacket
type StatusPacket ¶
type StatusPacket struct { ProtocolVersion uint32 NetworkID uint64 TD *big.Int Head libcommon.Hash Genesis libcommon.Hash ForkID forkid.ID }
StatusPacket is the network packet for the status message for eth/64 and later.
func (*StatusPacket) Kind ¶
func (*StatusPacket) Kind() byte
func (*StatusPacket) Name ¶
func (*StatusPacket) Name() string
type TransactionsPacket ¶
type TransactionsPacket []types.Transaction
TransactionsPacket is the network packet for broadcasting new transactions.
func (*TransactionsPacket) Kind ¶
func (*TransactionsPacket) Kind() byte
func (*TransactionsPacket) Name ¶
func (*TransactionsPacket) Name() string