Repository navigation
fix: support IPv6 enode URLs - #20
Open
iamomm-hack wants to merge 1 commit into
Open
iamomm-hack wants to merge 1 commit into
iamomm-hack wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
enode://endpoints returned by Ethereum clientsProblem
ClientEnode.from_string()split the endpoint on every colon:That works for IPv4, but a valid client response such as:
contains multiple colons and raises
ValueError: too many values to unpack. This matters because Hive obtains the client P2P endpoint fromenode.sh; IPv6-only or dual-stack test environments can therefore fail before a simulator can connect to the client.The serializer had the inverse problem: it emitted
...@2001:db8::1:30303, where the address/port boundary is ambiguous. go-ethereum's canonicalNode.URLv4()representation uses the standard bracketed host form for IPv6.Implementation
The parser now splits the port from the right once, removes the brackets before passing the host to
ip_address(), and limits the node-id split to one separator.ClientEnode.__str__()bracketsIPv6Addressvalues while leaving IPv4 output unchanged.Keeping the parsed field as
IPv4Address | IPv6Addressretains the existing API and validation behavior; this is only a correction to endpoint parsing and serialization.Validation
uv run pytest src/hive/tests/test_client.py src/hive/tests/test_session.py— 7 passeduv run black --check src— passeduv run isort --check-only src— passeduv run mypy src— passeduv run pytestreaches 9 tests; the 7 self-contained tests pass and the 2 existing Hive sanity tests require a live Hive API on127.0.0.1:3000Compatibility
No public types or method signatures change. Existing IPv4 enode strings serialize exactly as before; IPv6 strings now round-trip in the canonical form accepted and produced by Ethereum clients.