Skip to content
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

Refactor RPC part to make it easier to add RPC modules for downstream implementors #1100

Open
clangenb opened this issue Nov 22, 2022 · 0 comments

Comments

@clangenb
Copy link
Contributor

clangenb commented Nov 22, 2022

Example of how to create an aggregated rpc module: https://github.com/paritytech/substrate/blob/eddf888394cba28b048bd79e319e8b27f4b414f3/bin/node-template/node/src/rpc.rs#L49.

Example of how to use the proc_macro to generate client and server: https://github.com/paritytech/jsonrpsee/blob/master/proc-macros/src/lib.rs#L331.

Working Example for encointer-node:

  1. Create Rpc-client/-server: https://github.com/encointer/pallets/blob/master/communities/rpc/src/lib.rs
  2. Add rpc server module at a well-defined place: https://github.com/encointer/encointer-node/blob/9e603970b0aa828497408dcd8554ce2ee9f25cee/node/src/rpc.rs#L86

So instead of the bloat we have here I want to see:

pub fn public_api_rpc_handler<R, G>(top_pool_author: Arc<R>, getter_executor: Arc<G>) -> RpcModule<()> {

    let mut module = RpcModule::new(());
    module.merge(SomeEnclaveRpc::new(some_params).into_rpc())?;

   ...
}

Caveat:
jsonrpsee is not no_std, so we either need to maintain an sgx fork, or we wait until we have migrated to teaclave-v2.0.0. The latter is preferred, as we want to do it soon anyhow: #1102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant