-
Notifications
You must be signed in to change notification settings - Fork 163
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
Test for OpenRPC subscription methods on trace/debug modules #356
Test for OpenRPC subscription methods on trace/debug modules #356
Conversation
Thanks for getting this going! Pub/Sub is not handled well automatically by the reflector; it's a "special" case for the way ethereum/go-ethereum does (or does not) do method reflection and mapping. For example, The current hack-around for I think we may need to either provide a similar kind of mock pattern for TL;DR: I don't think // Exclude methods that handle subscriptions, but do so without adhering to the conventional code pattern.
// Eg. *filters.PublicFiltersAPI.SubscribeNewHeads handles eth_subscribe("newHeads"), but there
// isn't a method called `eth_subscribeNewHeads`. So we blacklist all these methods and use
// the mock subscription receiver type RPCSubscription.
// This pattern matches all strings that start with Subscribe and are suffixed with a non-zero
// number of A-z characters.
if isPubSub(method.Type) {
// This catches MOST of them (except SubscribeSyncStatus)
return false
} |
No I haven't generated the docs. I will. Thanks man |
@@ -329,7 +369,8 @@ var blockNumberOrHashD = fmt.Sprintf(`{ | |||
] | |||
}`, blockNumberD, commonHashD, requireCanonicalD) | |||
|
|||
var rpcSubscriptionParamsNameD = `{ | |||
var rpcEthSubscriptionParamsNameD = `{ | |||
"title": "subscriptionName", |
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.
@meowsbits added this, as it wasn't working for params without it even for eth_subscribe
.
@@ -208,25 +210,59 @@ func newOpenRPCDocument() *go_openrpc_reflect.Document { | |||
} | |||
|
|||
/* | |||
The following struct RPCSubscription and RPCSubscription.Unsubscribe method | |||
The following structs *RPCSubscription and *RPCSubscription.Unsubscribe method |
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.
@meowsbits I want to play a bit in order to find a better way of merging those 3 duplicated implementations where only the subscriptionName type in subscribe
changes.
Let me know if you have an idea.
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.
Have you experimented at all with getting rid of or modifying the general "skip PubSub" case to be more permissive (even if only allowing debug
and trace
receivers through)?
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.
No, I haven't. I will give it a try. Thanks
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.
I have tried it here, which adds the trace_filter
nicely, although it cancan't be used in the way documented, which leads to issues. What do you think? Did you mean something else @meowsbits?
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.
X-linking: #364 (review)
node/openrpc.go
Outdated
var rpcDebugSubscriptionParamsNameD = `{ | ||
"title": "subscriptionName", | ||
"oneOf": [ | ||
{"type": "string", "enum": ["traceFilter"], "description": "Returns traces for the filtered transactions within a range of blocks."} |
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.
I still have to collect all the debug_*
subscription based methods
I want to allow debug and trace API modules through. Taken from @meowsbits d7194b5
@meowsbits I added generating docs for both
|
Per this comment at OpenRPC/spec we could potentially use |
@meowsbits can you review it? To see what's done, check the p.s.: At the moment I haven't enabled the same for the
This is a great addon, but not straightforward to implement. As discussed, let's keep this for later. |
Adapts the canonical list of methods that should be provided by the document to meet what the document says. Date: 2021-04-30 06:13:54-05:00 Signed-off-by: meows <b5c6@protonmail.com>
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.
If this latest commit (ce80270) looks OK to you, everything LGTM!
(I've left the methods commented because that lists serves a duty both as a test case, but also as a "behind-the-scenes" developer reference.)
…well as better examples
…*filters.PublicFilterAPI` methods
Resolves #345 (comment)