metachain icon indicating copy to clipboard operation
metachain copied to clipboard

JSON-RPC communication between Native Chain and Meta Chain

Open DieHard073055 opened this issue 3 years ago • 10 comments

What would you like to be added:

JSON-RPC communication between Native Chain and Meta Chain.

This includes creating *.proto definitions on the NativeChain side that auto-generate client code for DMC to call.

Why is this needed:

For the JSON RPC client generator to generate code for the RPC calls.

related

  • https://github.com/DeFiCh/metachain/pull/10
  • https://github.com/DeFiCh/metachain/issues/45

PR

https://github.com/DeFiCh/libain-rs/pull/19

DieHard073055 avatar Sep 08 '22 09:09 DieHard073055

@DieHard073055: There are no 'area' labels on this issue. Adding an appropriate label will greatly expedite the process for us. You can add as many area as you see fit. If you are unsure what to do you can ignore this!

You can add area labels by leaving a /area comment.

Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

defichain-bot avatar Sep 08 '22 09:09 defichain-bot

Why protobuf instead of simple JSON-RPC?

fuxingloh avatar Sep 08 '22 09:09 fuxingloh

@wafflespeanut

Why protobuf instead of simple JSON-RPC?

DieHard073055 avatar Sep 08 '22 09:09 DieHard073055

Protobuf offers strict typing and aids versioning for various messages used in RPC calls, so we decided to have a protobuf spec which represents the existing JSON RPC implementation and support both gRPC and JSON RPC endpoints (JSON schema is autogenerated from protobuf types and is meant to be backward-compatible). If defid needs to invoke an RPC endpoint, then it's easier to add the protobuf spec and use the generated client code directly (which will provide the necessary types and functions to perform that call). Long-term goal is to segregate the RPC handling (both server and client) out of ain.

wafflespeanut avatar Sep 08 '22 10:09 wafflespeanut

It should be noted that this doesn't change anything in metachain (the incoming RPC request will still be JSON) - it's only a matter of how we decided to go about RPC implementation in ain.

wafflespeanut avatar Sep 08 '22 10:09 wafflespeanut

Protobuf offers strict typing and aids versioning for various messages used in RPC calls, so we decided to have a protobuf spec which represents the existing JSON RPC implementation and support both gRPC and JSON RPC endpoints (JSON schema is autogenerated from protobuf types and is meant to be backward-compatible). If defid needs to invoke an RPC endpoint, then it's easier to add the protobuf spec and use the generated client code directly (which will provide the necessary types and functions to perform that call). Long-term goal is to segregate the RPC handling (both server and client) out of ain.

Sounds good! Do we have an integration timeline for this?

fuxingloh avatar Sep 12 '22 08:09 fuxingloh

It should be noted that this doesn't change anything in metachain (the incoming RPC request will still be JSON) - it's only a matter of how we decided to go about RPC implementation in ain.

For the avoidance of doubt, is this what you mean?

graph LR

nb --JSON RPC---> ma

subgraph DeFiCh/metachain
ma[RPC Server] --> mb[MetaChain Consensus]
end

subgraph DeFiCh/ain
na[NativeChain Consensus]
nb["NativeChain 'RPC Client'"]
nc["*.proto Defintions"]

na --> nb
nb --> nc
end

fuxingloh avatar Sep 12 '22 08:09 fuxingloh

Sounds good! Do we have an integration timeline for this?

As for the protobuf-based RPC client code, the work is already in place, it's just a matter of fixing library linkage on different platforms. Hopefully will be able to merge it today or tomorrow.

For the avoidance of doubt, is this what you mean?

That's accurate.

wafflespeanut avatar Sep 14 '22 08:09 wafflespeanut

Sounds good! Do we have an integration timeline for this?

As for the protobuf-based RPC client code, the work is already in place, it's just a matter of fixing library linkage on different platforms. Hopefully will be able to merge it today or tomorrow.

For the avoidance of doubt, is this what you mean?

That's accurate.

Awesome thanks!

fuxingloh avatar Sep 14 '22 09:09 fuxingloh

/assign @wafflespeanut let me assign this to you since you're working on #106 /area ain meta

fuxingloh avatar Oct 03 '22 04:10 fuxingloh