You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a plugin writer, I would like to have the possibility of exposing custom JSON RPC / GraphQL / WebSocket methods (I'll focus only on JSON RPC for the rest of the issue but it should apply to all of those).
Currently, the plugin API is limited by how we can interact with the outside world. Having the possibility of custom JSON RPC commands is immensely useful when you want to extend the capabilities of Besu beyond the default set of exposed methods.
In terms of the API, we can add the following to BesuPlugin interface:
...
/** Called when the plugin wants to expose custom JSON RPC methods.* If not overridden, this method does nothing for convenience.**/defaultMap<String, JsonRpcMethod> createJsonRpcMethods() {
returnCollections.emptyMap();
}
This method would be called once at the Registering phase. The format for each method name could be the following:
<plugin-name-id>_<api-method>
Like this:
plugin-besu-exflo_retrieveTokenBalances
Each plugin is responsible of generating a custom response that can be serialized by Jackson.
We can reuse part of the work that has been done already in the class PluginsJsonRpcMethods. That class receives the list of Plugins, so apart of registering the reload configuration, we can iterate for each plugin and see if they have defined a map of JsonRpcMethods.
Currently, neither of JsonRpcMethod, JsonRpcMethods, JsonRpcRequestContext... are exposed to plugin-api module. So a worthwhile discussion would be what is the best approach to expose those relevant entities to plugins.
Also, probably, I might be forgetting anything that could be crucial to take into account before any attempt of implementation.
Acceptance Criteria
It should not override existing JSON RPC commands (throw an error if the id of the method is one of the native ones).
It should expose custom JSON RPC methods.
It should expose custom GraphQL mutations/queries.
It should allow custom WebSocket subscriptions/methods.
Maybe we can start with just only supporting JSON RPC and later on adding support to GraphQL and WebSockets.
Description
As a plugin writer, I would like to have the possibility of exposing custom JSON RPC / GraphQL / WebSocket methods (I'll focus only on JSON RPC for the rest of the issue but it should apply to all of those).
Currently, the plugin API is limited by how we can interact with the outside world. Having the possibility of custom JSON RPC commands is immensely useful when you want to extend the capabilities of Besu beyond the default set of exposed methods.
In terms of the API, we can add the following to
BesuPlugin
interface:This method would be called once at the
Registering
phase. The format for each method name could be the following:Like this:
Each plugin is responsible of generating a custom response that can be serialized by Jackson.
We can reuse part of the work that has been done already in the class
PluginsJsonRpcMethods
. That class receives the list of Plugins, so apart of registering the reload configuration, we can iterate for each plugin and see if they have defined a map ofJsonRpcMethods
.Currently, neither of
JsonRpcMethod
,JsonRpcMethods
,JsonRpcRequestContext
... are exposed toplugin-api
module. So a worthwhile discussion would be what is the best approach to expose those relevant entities to plugins.Also, probably, I might be forgetting anything that could be crucial to take into account before any attempt of implementation.
Acceptance Criteria
Maybe we can start with just only supporting JSON RPC and later on adding support to GraphQL and WebSockets.
Additional Information
Quorum has implemented a similar feature already.
If an approach is agreed upon, I would be happy to implement it.
The text was updated successfully, but these errors were encountered: