> loading_
# ---------------------------------------------------------------------------
# Walkthrough: Detecting eth/72 capability during devp2p handshake
# ---------------------------------------------------------------------------
# When EIP-8070 (eth/72) is adopted, nodes will advertise the new version
# during the RLPx capability exchange. Below is a minimal Python sketch
# showing how you might extend an existing handshake parser to handle it.
#
# Tested against the py-devp2p patterns; adapt for your own client.
# ---------------------------------------------------------------------------
import rlp
# Step 1 — Define the capability tuple for eth/72.
# Each capability is (name: str, version: int). Nodes exchange a list of
# these during the HELLO message.
ETH_72_CAP = ("eth", 72)
# Step 2 — Parse incoming HELLO capabilities and check for eth/72 support.
def parse_capabilities(hello_payload: bytes) -> list:
"""Decode the capabilities list from a HELLO RLP payload."""
decoded = rlp.decode(hello_payload) # top-level HELLO fields
# Capabilities live at index 4 in the HELLO message structure
raw_caps = decoded[4] # list of [name, version]
caps = [(c[0].decode(), int.from_bytes(c[1], 'big')) for c in raw_caps]
return caps
def supports_eth72(caps: list) -> bool:
"""Return True if the peer advertises eth/72."""
return ETH_72_CAP in caps
# Step 3 — Example: handle the new `value` field from EIP-8141 frames.
# The updated frame now carries an additional `value` field at the end.
# Before EIP-8141 update: [request_id, code, data]
# After EIP-8141 update: [request_id, code, data, value]
def decode_frame(raw_frame: bytes) -> dict:
"""Decode an EIP-8141 frame, tolerating the new value field."""
parts = rlp.decode(raw_frame)
frame = {
"request_id": parts[0],
"code": parts[1],
"data": parts[2],
}
# EIP-8141 update: value field is optional during transition
if len(parts) >= 4:
frame["value"] = parts[3] # <-- new field
else:
frame["value"] = b"\x00" # default to zero
return frame
# Step 4 — Putting it together in a connection handler.
def on_peer_connected(hello_payload: bytes, first_frame: bytes):
caps = parse_capabilities(hello_payload)
if supports_eth72(caps):
print("Peer supports eth/72 — using EIP-8070 message set")
frame = decode_frame(first_frame)
print(f"Frame value field: {frame['value'].hex()}")
else:
print("Peer on older eth version — falling back")
# ---------------------------------------------------------------------------
# Next steps:
# • Review EIP-8070 for the full eth/72 message catalogue.
# • Review EIP-8141 for the authoritative frame schema with `value`.
# • Track the EVMification EIP (commit f78f8fa) for architectural changes
# that may affect opcode dispatch and contract execution internals.
# ---------------------------------------------------------------------------