chore(autonatv2): utilize protobuf_serialization#2612
Open
vladopajic wants to merge 6 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## protobuf-improvements #2612 +/- ##
========================================================
Coverage ? 85.10%
========================================================
Files ? 165
Lines ? 28103
Branches ? 7
========================================================
Hits ? 23916
Misses ? 4187
Partials ? 0
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates AutoNAT v2 protobuf encoding/decoding from minprotobuf to protobuf_serialization, updating the AutoNAT v2 message types and their usage across client/server/mock/test code paths.
Changes:
- Replaced manual
minprotobufencode/decode implementations withprotobuf_serialization-generatedencode()/decode()for AutoNAT v2 types. - Updated AutoNAT v2 client/server/test logic to construct and interpret messages via
Opt[...]fields instead of amsgTypecase object. - Removed now-unneeded
protobuf/minprotobufimports where applicable.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/libp2p/protocols/test_autonat_v2.nim | Updates AutoNAT v2 encode/decode tests to use Opt[...] fields and new serialization. |
| tests/libp2p/protocols/test_autonat_v2_service.nim | Updates service tests for new DialResponse.status representation. |
| libp2p/protocols/pubsub/rpc/message.nim | Removes unused minprotobuf import. |
| libp2p/protocols/connectivity/autonatv2/utils.nim | Adjusts reachability logic for Opt[ResponseStatus]. |
| libp2p/protocols/connectivity/autonatv2/types.nim | Replaces manual protobuf with protobuf_serialization schemas + generated serializers. |
| libp2p/protocols/connectivity/autonatv2/service.nim | Removes minprotobuf import. |
| libp2p/protocols/connectivity/autonatv2/server.nim | Updates message IO to use new encode/decode and Opt[...]-based message selection. |
| libp2p/protocols/connectivity/autonatv2/mockserver.nim | Updates mock to write raw bytes; message validation logic needs correction. |
| libp2p/protocols/connectivity/autonatv2/mock.nim | Updates decode call but still references removed msgType/MsgType and uses ProtoBuffer. |
| libp2p/protocols/connectivity/autonatv2/client.nim | Updates client message handling to the new serialization and Opt[...] fields. |
Comments suppressed due to low confidence (2)
libp2p/protocols/connectivity/autonatv2/client.nim:190
- In
sendDialRequest,LPStreamRemoteClosedErroris caught and only logged, but execution continues and the function returnsdialResp.get(). If the stream was reset beforedialRespis set, this will raise due todialRespbeingnone. Either re-raise asAutonatV2Erroror return an explicit failure value.
except LPStreamRemoteClosedError as exc:
error "Stream reset by server", description = exc.msg, peer = pid
finally:
# rollback any changes
self.expectedNonces.del(nonce)
return dialResp.get().asAutonatV2Response(testAddrs)
libp2p/protocols/connectivity/autonatv2/mock.nim:33
- This mock still uses the removed
msgType/MsgTypediscriminator and storesresponseasProtoBuffer, but AutonatV2 messages now decode based on whichOpt[...]field is set andencode()returnsseq[byte]. As-is this will not compile (noMsgType, noProtoBufferin scope) and won't interoperate with the new encode/decode API.
let msg = AutonatV2Msg.decode(await stream.readLp(AutonatV2MsgLpSize)).valueOr:
return
if msg.msgType != MsgType.DialRequest:
return
except LPStreamError:
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.
No description provided.