Documentation
¶
Index ¶
- Constants
- Variables
- func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket, blockReader services.FullBlockReader) []rlp.RawValue
- func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, ...) ([]*types.Header, error)
- func AnswerGetReceiptsQuery(ctx context.Context, cfg *chain.Config, receiptsGetter ReceiptsGetter, ...) ([]rlp.RawValue, error)
- func AnswerGetReceiptsQueryCacheOnly(ctx context.Context, receiptsGetter ReceiptsGetter, query GetReceiptsPacket) (*cachedReceipts, bool, 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 GetReceiptsPacket
- type GetReceiptsPacket66
- type HashOrNumber
- type NewBlockHashesPacket
- type NewBlockPacket
- type NodeInfo
- type Packet
- type ReceiptsGetter
- type ReceiptsPacket
- type ReceiptsPacket66
- type ReceiptsRLPPacket
- type ReceiptsRLPPacket66
- type StatusPacket
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 ( // Protocol messages in eth/64 StatusMsg = 0x00 NewBlockHashesMsg = 0x01 TransactionsMsg = 0x02 GetBlockHeadersMsg = 0x03 BlockHeadersMsg = 0x04 GetBlockBodiesMsg = 0x05 BlockBodiesMsg = 0x06 NewBlockMsg = 0x07 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{ direct.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, }, direct.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 ToProto = map[uint]map[uint64]proto_sentry.MessageId{ direct.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, }, direct.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, blockReader services.FullBlockReader) []rlp.RawValue
func AnswerGetBlockHeadersQuery ¶
func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, blockReader services.HeaderAndCanonicalReader) ([]*types.Header, error)
func AnswerGetReceiptsQuery ¶
func AnswerGetReceiptsQuery(ctx context.Context, cfg *chain.Config, receiptsGetter ReceiptsGetter, br services.FullBlockReader, db kv.TemporalTx, query GetReceiptsPacket, cachedReceipts *cachedReceipts) ([]rlp.RawValue, error)
func AnswerGetReceiptsQueryCacheOnly ¶
func AnswerGetReceiptsQueryCacheOnly(ctx context.Context, receiptsGetter ReceiptsGetter, query GetReceiptsPacket) (*cachedReceipts, bool, error)
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 }
BlockBodiesPacket66 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 }
BlockHeadersPacket66 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, 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 }
BlockRawBodiesPacket66 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 }
GetBlockHeadersPacket66 represents a block header query over eth/66
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 }
GetReceiptsPacket66 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 NodeInfo ¶
type NodeInfo struct { Network uint64 `json:"network"` // Ethereum network ID (1=mainnet, 11155111=Sepolia) 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 ReceiptsGetter ¶
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 }
ReceiptsPacket66 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 }
ReceiptsRLPPacket66 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