Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/lean_spec/subspecs/containers/state/state.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""State Container for the Lean Ethereum consensus specification."""

from __future__ import annotations

from typing import AbstractSet, Iterable

from lean_spec.subspecs.ssz.hash import hash_tree_root
Expand Down
12 changes: 0 additions & 12 deletions src/lean_spec/subspecs/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,26 @@

from .registry import (
REGISTRY,
attestations_invalid,
attestations_produced,
attestations_received,
attestations_valid,
block_processing_time,
blocks_processed,
blocks_proposed,
current_slot,
finalized_slot,
generate_metrics,
head_slot,
justified_slot,
peers_connected,
reorgs,
validators_count,
)

__all__ = [
"REGISTRY",
"attestations_invalid",
"attestations_produced",
"attestations_received",
"attestations_valid",
"block_processing_time",
"blocks_processed",
"blocks_proposed",
"current_slot",
"finalized_slot",
"generate_metrics",
"head_slot",
"justified_slot",
"peers_connected",
"reorgs",
"validators_count",
]
48 changes: 0 additions & 48 deletions src/lean_spec/subspecs/metrics/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
registry=REGISTRY,
)

current_slot = Gauge(
"lean_current_slot",
"Current time slot",
registry=REGISTRY,
)

justified_slot = Gauge(
"lean_justified_slot",
"Latest justified slot",
Expand Down Expand Up @@ -71,48 +65,6 @@
registry=REGISTRY,
)

# -----------------------------------------------------------------------------
# Attestations
# -----------------------------------------------------------------------------

attestations_received = Counter(
"lean_attestations_received_total",
"Total attestations received",
registry=REGISTRY,
)

attestations_valid = Counter(
"lean_attestations_valid_total",
"Valid attestations",
registry=REGISTRY,
)

attestations_invalid = Counter(
"lean_attestations_invalid_total",
"Invalid attestations",
registry=REGISTRY,
)

# -----------------------------------------------------------------------------
# Network
# -----------------------------------------------------------------------------

peers_connected = Gauge(
"lean_peers_connected",
"Connected peers",
registry=REGISTRY,
)

# -----------------------------------------------------------------------------
# Consensus Events
# -----------------------------------------------------------------------------

reorgs = Counter(
"lean_reorgs_total",
"Chain reorganizations",
registry=REGISTRY,
)

# -----------------------------------------------------------------------------
# Validator Production
# -----------------------------------------------------------------------------
Expand Down
178 changes: 21 additions & 157 deletions src/lean_spec/subspecs/networking/discovery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,192 +18,56 @@

from .codec import (
DiscoveryMessage,
MessageDecodingError,
MessageEncodingError,
decode_message,
encode_message,
generate_request_id,
)
from .config import DiscoveryConfig
from .crypto import (
AES_KEY_SIZE,
COMPRESSED_PUBKEY_SIZE,
CTR_IV_SIZE,
GCM_NONCE_SIZE,
GCM_TAG_SIZE,
ID_SIGNATURE_SIZE,
UNCOMPRESSED_PUBKEY_SIZE,
aes_ctr_decrypt,
aes_ctr_encrypt,
aes_gcm_decrypt,
aes_gcm_encrypt,
ecdh_agree,
generate_secp256k1_keypair,
pubkey_to_compressed,
pubkey_to_uncompressed,
sign_id_nonce,
verify_id_nonce_signature,
)
from .handshake import (
HandshakeError,
HandshakeManager,
HandshakeResult,
HandshakeState,
PendingHandshake,
)
from .keys import (
DISCV5_KEY_AGREEMENT_INFO,
SESSION_KEY_SIZE,
compute_node_id,
derive_keys,
derive_keys_from_pubkey,
)
from .messages import (
MAX_REQUEST_ID_LENGTH,
PROTOCOL_ID,
PROTOCOL_VERSION,
Distance,
FindNode,
IdNonce,
IPv4,
IPv6,
MessageType,
Nodes,
Nonce,
PacketFlag,
Ping,
Pong,
Port,
RequestId,
StaticHeader,
TalkReq,
TalkResp,
WhoAreYouAuthdata,
)
from .packet import (
HANDSHAKE_HEADER_SIZE,
MESSAGE_AUTHDATA_SIZE,
STATIC_HEADER_SIZE,
WHOAREYOU_AUTHDATA_SIZE,
HandshakeAuthdata,
MessageAuthdata,
PacketHeader,
PacketType,
decode_handshake_authdata,
decode_message_authdata,
decode_packet_header,
decode_whoareyou_authdata,
decrypt_message,
encode_handshake_authdata,
encode_message_authdata,
encode_packet,
encode_whoareyou_authdata,
generate_id_nonce,
generate_nonce,
)
from .packet import (
WhoAreYouAuthdata as WhoAreYouAuthdataDecoded,
)
from .routing import KBucket, NodeEntry, RoutingTable, log2_distance, xor_distance
from .routing import NodeEntry, RoutingTable
from .service import DiscoveryService, LookupResult
from .session import BondCache, Session, SessionCache
from .transport import DiscoveryTransport

__all__ = [
# Config
# High-level service
"DiscoveryService",
"DiscoveryConfig",
# Messages
"MAX_REQUEST_ID_LENGTH",
"LookupResult",
# Message types (for protocol interaction)
"DiscoveryMessage",
"encode_message",
"decode_message",
# Routing
"NodeEntry",
"RoutingTable",
# Message types (commonly needed)
"Ping",
"Pong",
"FindNode",
"Nodes",
"TalkReq",
"TalkResp",
# Constants (commonly needed)
"PROTOCOL_ID",
"PROTOCOL_VERSION",
"MAX_REQUEST_ID_LENGTH",
# Types
"Distance",
"IdNonce",
"IPv4",
"IPv6",
"Nonce",
"Port",
"RequestId",
"MessageType",
"PacketFlag",
"FindNode",
"Nodes",
"Ping",
"Pong",
"TalkReq",
"TalkResp",
"StaticHeader",
"WhoAreYouAuthdata",
# Routing
"KBucket",
"NodeEntry",
"RoutingTable",
"log2_distance",
"xor_distance",
# Crypto
"AES_KEY_SIZE",
"COMPRESSED_PUBKEY_SIZE",
"CTR_IV_SIZE",
"GCM_NONCE_SIZE",
"GCM_TAG_SIZE",
"ID_SIGNATURE_SIZE",
"UNCOMPRESSED_PUBKEY_SIZE",
"aes_ctr_encrypt",
"aes_ctr_decrypt",
"aes_gcm_encrypt",
"aes_gcm_decrypt",
"ecdh_agree",
"generate_secp256k1_keypair",
"pubkey_to_compressed",
"pubkey_to_uncompressed",
"sign_id_nonce",
"verify_id_nonce_signature",
# Keys
"DISCV5_KEY_AGREEMENT_INFO",
"SESSION_KEY_SIZE",
"compute_node_id",
"derive_keys",
"derive_keys_from_pubkey",
# Codec
"DiscoveryMessage",
"MessageDecodingError",
"MessageEncodingError",
"encode_message",
"decode_message",
"generate_request_id",
# Packet
"STATIC_HEADER_SIZE",
"MESSAGE_AUTHDATA_SIZE",
"WHOAREYOU_AUTHDATA_SIZE",
"HANDSHAKE_HEADER_SIZE",
"PacketType",
"PacketHeader",
"MessageAuthdata",
"WhoAreYouAuthdataDecoded",
"HandshakeAuthdata",
"encode_packet",
"decode_packet_header",
"encode_message_authdata",
"decode_message_authdata",
"encode_whoareyou_authdata",
"decode_whoareyou_authdata",
"encode_handshake_authdata",
"decode_handshake_authdata",
"decrypt_message",
"generate_nonce",
"generate_id_nonce",
# Session
"Session",
"SessionCache",
"BondCache",
# Handshake
"HandshakeState",
"PendingHandshake",
"HandshakeResult",
"HandshakeError",
"HandshakeManager",
# Transport
"DiscoveryTransport",
# Service
"DiscoveryService",
"LookupResult",
]
Loading
Loading