Skip to content

discv4/discv4_constants.hpp

Namespaces

Name
discv4

Attributes

Name
constexpr size_t kWireHashSize
Outer Keccak-256 hash.
constexpr size_t kWireSigSize
Recoverable ECDSA signature.
constexpr size_t kWirePacketTypeSize
Single packet-type byte.
constexpr size_t kWireRecoveryIdSize
Recoverable ECDSA recovery id.
constexpr size_t kWireCompactSigSize
constexpr size_t kWireHeaderSize
constexpr size_t kWirePacketTypeOffset
constexpr size_t kNodeIdSize
Node identity.
constexpr size_t kNodeIdHexSize
constexpr size_t kUncompressedPubKeySize
0x04 prefix + 64 bytes
constexpr size_t kIPv4Size
Network.
constexpr size_t kUdpBufferSize
constexpr uint8_t kPacketTypePing
Packet type identifiers.
constexpr uint8_t kPacketTypePong
constexpr uint8_t kPacketTypeFindNode
constexpr uint8_t kPacketTypeNeighbours
constexpr uint8_t kPacketTypeEnrRequest
constexpr uint8_t kPacketTypeEnrResponse
constexpr uint8_t kProtocolVersion
Protocol version advertised in PING packets.
constexpr uint32_t kPacketExpirySeconds
Default packet expiry window (seconds)
constexpr auto kDefaultPingTimeout
Default networking timers.
constexpr auto kDefaultPeerExpiry
constexpr auto kDefaultDialHistoryExpiry
constexpr size_t kEnrSeqSize
ENR sequence number field size in PONG (optional, 6-byte big-endian uint48)

Attributes Documentation

variable kWireHashSize

static constexpr size_t kWireHashSize = 32;

Outer Keccak-256 hash.

discv4 wire-packet layout constants Layout: hash(32) || signature(65) || packet-type(1) || RLP(payload)

variable kWireSigSize

static constexpr size_t kWireSigSize = 65;

Recoverable ECDSA signature.

variable kWirePacketTypeSize

static constexpr size_t kWirePacketTypeSize = 1;

Single packet-type byte.

variable kWireRecoveryIdSize

static constexpr size_t kWireRecoveryIdSize = 1;

Recoverable ECDSA recovery id.

variable kWireCompactSigSize

static constexpr size_t kWireCompactSigSize = kWireSigSize - kWireRecoveryIdSize;

variable kWireHeaderSize

static constexpr size_t kWireHeaderSize = kWireHashSize + kWireSigSize + kWirePacketTypeSize;

variable kWirePacketTypeOffset

static constexpr size_t kWirePacketTypeOffset = kWireHashSize + kWireSigSize;

variable kNodeIdSize

static constexpr size_t kNodeIdSize = 64;

Node identity.

Uncompressed secp256k1 pubkey without 0x04 prefix

variable kNodeIdHexSize

static constexpr size_t kNodeIdHexSize = kNodeIdSize * 2;

variable kUncompressedPubKeySize

static constexpr size_t kUncompressedPubKeySize = kNodeIdSize + kWirePacketTypeSize;

0x04 prefix + 64 bytes

variable kIPv4Size

static constexpr size_t kIPv4Size = 4;

Network.

variable kUdpBufferSize

static constexpr size_t kUdpBufferSize = 2048;

variable kPacketTypePing

static constexpr uint8_t kPacketTypePing = 0x01U;

Packet type identifiers.

variable kPacketTypePong

static constexpr uint8_t kPacketTypePong = 0x02U;

variable kPacketTypeFindNode

static constexpr uint8_t kPacketTypeFindNode = 0x03U;

variable kPacketTypeNeighbours

static constexpr uint8_t kPacketTypeNeighbours = 0x04U;

variable kPacketTypeEnrRequest

static constexpr uint8_t kPacketTypeEnrRequest = 0x05U;

variable kPacketTypeEnrResponse

static constexpr uint8_t kPacketTypeEnrResponse = 0x06U;

variable kProtocolVersion

static constexpr uint8_t kProtocolVersion = 0x04U;

Protocol version advertised in PING packets.

variable kPacketExpirySeconds

static constexpr uint32_t kPacketExpirySeconds = 60U;

Default packet expiry window (seconds)

variable kDefaultPingTimeout

constexpr auto kDefaultPingTimeout = std::chrono::milliseconds(5000);

Default networking timers.

variable kDefaultPeerExpiry

constexpr auto kDefaultPeerExpiry = std::chrono::seconds(300);

variable kDefaultDialHistoryExpiry

constexpr auto kDefaultDialHistoryExpiry = std::chrono::seconds(35);

variable kEnrSeqSize

static constexpr size_t kEnrSeqSize = 6;

ENR sequence number field size in PONG (optional, 6-byte big-endian uint48)

Source code

// Copyright 2026 Genius Ventures, Inc.
// SPDX-License-Identifier: MIT

#ifndef EVMRELAY_INCLUDE_DISCV4_DISCV4_CONSTANTS_HPP
#define EVMRELAY_INCLUDE_DISCV4_DISCV4_CONSTANTS_HPP

#include <chrono>
#include <cstddef>
#include <cstdint>

namespace discv4 {

static constexpr size_t  kWireHashSize           = 32;   
static constexpr size_t  kWireSigSize            = 65;   
static constexpr size_t  kWirePacketTypeSize     = 1;    
static constexpr size_t  kWireRecoveryIdSize     = 1;    
static constexpr size_t  kWireCompactSigSize     = kWireSigSize - kWireRecoveryIdSize;
static constexpr size_t  kWireHeaderSize         = kWireHashSize + kWireSigSize + kWirePacketTypeSize;
static constexpr size_t  kWirePacketTypeOffset   = kWireHashSize + kWireSigSize;

static constexpr size_t  kNodeIdSize             = 64;   
static constexpr size_t  kNodeIdHexSize          = kNodeIdSize * 2;
static constexpr size_t  kUncompressedPubKeySize = kNodeIdSize + kWirePacketTypeSize; 

static constexpr size_t  kIPv4Size               = 4;
static constexpr size_t  kUdpBufferSize          = 2048;

static constexpr uint8_t kPacketTypePing         = 0x01U;
static constexpr uint8_t kPacketTypePong         = 0x02U;
static constexpr uint8_t kPacketTypeFindNode     = 0x03U;
static constexpr uint8_t kPacketTypeNeighbours   = 0x04U;
static constexpr uint8_t kPacketTypeEnrRequest   = 0x05U;
static constexpr uint8_t kPacketTypeEnrResponse  = 0x06U;

static constexpr uint8_t kProtocolVersion        = 0x04U;

static constexpr uint32_t kPacketExpirySeconds   = 60U;

inline constexpr auto kDefaultPingTimeout        = std::chrono::milliseconds(5000);
inline constexpr auto kDefaultPeerExpiry         = std::chrono::seconds(300);
inline constexpr auto kDefaultDialHistoryExpiry  = std::chrono::seconds(35);

static constexpr size_t kEnrSeqSize              = 6;

} // namespace discv4


#endif // EVMRELAY_INCLUDE_DISCV4_DISCV4_CONSTANTS_HPP

Updated on 2026-08-06 at 13:59:18 +0000