-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement portal_*Ping rpc with ping extension support #64
base: main
Are you sure you want to change the base?
Conversation
I am doing this request, with
getting the erro:
but I guess it should generate the default payload, according to specs my trace:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements support for payload extension in portal_*Ping RPC calls. Key changes include:
- Adding new payload conversion and error handling logic in the ping_ext/rpc.go package.
- Updating the API interfaces in portalwire/api.go, beacon/api.go, state/api.go, and history/api.go to accept new payload parameters.
- Refactoring the ping functionality in portal_protocol.go to use the new payload processing functions.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
portalwire/ping_ext/rpc.go | Introduces payload JSON-to-SSZ conversion and error types. |
portalwire/api.go | Updates Ping signature and payload processing logic. |
portalwire/portal_protocol.go | Refactors ping functions to support payloads via pingInnerWithPayload. |
beacon/api.go, state/api.go, history/api.go | Updates API functions to pass the new payload parameters. |
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dereferencing payloadType without confirming it is non-nil can lead to a runtime panic. Consider checking if payloadType is nil and handling that case (e.g. by applying a default value or returning an explicit error).
if payloadType == nil { | |
return nil, errors.New("payloadType is required") | |
} |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements support for ping extensions in the portal protocols by adding new RPC handlers, error types, and JSON/SSZ conversion functions. Key changes include:
- Introducing new payload types and conversions in ping_ext/rpc.go.
- Updating the API endpoints (in portalwire/api.go, beacon/api.go, history/api.go, and state/api.go) to accept optional payloadType and payload parameters.
- Refactoring ping logic in portal_protocol.go to work with various payload types.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
portalwire/ping_ext/rpc.go | New file defining JSON structures, custom error types, and SSZ conversion functions. |
portalwire/api.go | Updated Ping API signature and logic for handling ping payload conversion. |
portalwire/portal_protocol.go | Refactored ping logic with payload support and genPayloadByType function added. |
beacon/api.go, history/api.go, state/api.go | Updated API methods to include payload parameters. |
@@ -448,6 +452,37 @@ func (p *PortalProtocol) pingInner(node *enode.Node) (*Pong, []byte, error) { | |||
return p.processPong(node, talkResp) | |||
} | |||
|
|||
func (p *PortalProtocol) genPayloadByType(payloadType uint16) ([]byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The switch in genPayloadByType lacks a default case to handle unsupported payload types, which may lead to silent failures with a nil payload. Consider adding a default branch that returns an appropriate error (e.g., ErrPayloadTypeIsNotSupported).
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements ping RPC extensions by adding support for payload types and their JSON/SSZ conversions.
- Added new payload types (ClientInfo, BasicRadius, HistoryRadius) with associated error types and conversion functions.
- Updated API endpoints (in portalwire, beacon, state, and history) to accept optional payload parameters and to utilize the new ping extension functions.
- Refactored ping-related functions in PortalProtocol to leverage payload type support and streamline payload processing.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
portalwire/ping_ext/rpc.go | Introduces new payload types, error types, and JSON/SSZ conversion support for ping extensions. |
portalwire/api.go | Updates the Ping API to accept optional payloadType and payload parameters and returns extended response data. |
portalwire/portal_protocol.go | Refactors ping logic by extracting payload-based functions and updating processPong accordingly. |
beacon/api.go, state/api.go, history/api.go | Adjusts the API endpoints to pass along the new payload parameters to Ping. |
return nil, err | ||
} | ||
} | ||
return data, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The switch statement in the genPayloadByType function does not include a default branch. Adding a default case that returns an error (e.g., ErrPayloadTypeIsNotSupported) would improve robustness in case an unsupported payload type is passed.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements ping extension support by enabling the portal ping RPC to accept an optional payload type and payload along with the conversion functions between JSON and SSZ formats. Key changes include:
- Adding new helper functions in the ping_ext package for JSON↔SSZ conversion.
- Updating the PortalProtocolAPI Ping endpoint to optionally accept payloadType and payload.
- Adjusting related API endpoints across beacon, state, and history modules to support the new payload parameters.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
File | Description |
---|---|
portalwire/ping_ext/rpc.go | New functions for JSON and SSZ payload conversion & error definitions. |
portalwire/api.go | Updated Ping signature and response structure with payload support. |
portalwire/portal_protocol.go | Refactored pingInnerWithPayload and genPayloadByType for payload handling. |
beacon/api.go, state/api.go, history/api.go | Updated Ping endpoints to pass the new payload parameters. |
Comments suppressed due to low confidence (2)
portalwire/api.go:346
- [nitpick] Consider replacing the literal 0 with an explicit constant (e.g., pingext.ClientInfo) to clarify the intended default payload type.
var defaultType uint16 = 0
portalwire/portal_protocol.go:483
- [nitpick] For consistency with the rest of the codebase, consider returning pingext.ErrPayloadTypeIsNotSupported{} instead of a custom error message.
return nil, fmt.Errorf("payload type %d is not supported", payloadType)
fixed #53