info_tfgrid/collections/tfgrid4specs/openrpc.md
2024-10-03 17:29:42 +03:00

2.0 KiB

OpenRPC

we use OpenRPC on the Registrar and other services.

The OpenRPC is exposed over rest (and later over other protocols).

  • rpc_in
    • rpc_id (string) : a unique id for the rpc call
    • method_name
    • params (json as text, encrypted with the mycelium pubkey of the rpc server)
    • pubkey (string) : the pubkey of the caller mycelium agent
    • signature (rpc_id+method_name+params+return_url+returl_topic signed with Mycelium Agent Priv key of the sender)
    • async (bool) : if the call should be async, if async will send as message back over mycelium to source, if return url will use that one
    • return_url (string) : the url to return the result, optional to async return the result to sender (source)
    • return_topic (string): for the sender to know what the return is for
  • rpc_return (for async return)
    • rpc_id (string) : a unique id for the rpc call needs to correspond to the rpc_in and source caller
    • method_name
    • pubkey (string) : the pubkey of the rpc server
    • signature (the result is signed with Mycelium Agent of the server for: rpc_id+method_name+params+result)
    • topic (string)
    • result (json as text, encrypted with the mycelium pubkey of the source caller)
  • rpc_check returns the status of the rpc call which is done, error, running or pending
    • rpc_id
    • signature (of rpc_id from the caller)
  • rpc_kill stop the rpc if it is running and would e.g. take too long
    • rpc_id
    • signature (of rpc_id from the caller)

Because of signatures on the caller can stop a call or check status

if return_url is provided:

  • the server will process and if async send result back as json over mycelium to the source or over http to the return_url

the rpc_return is called by an rpc_server to return results to the caller

see openrpc_openapi_spec for the OpenRPC spec on top of Rest.

Implementation Details

  • the state of the calls on server is kept in redis
  • timeouts need to be implemented on the server
  • the encryption & signing is used to provide security