threefoldtech / zos

Autonomous operating system
https://threefold.io/host/
Apache License 2.0
84 stars 14 forks source link

openRPC based APIs #2346

Open xmonader opened 6 months ago

xmonader commented 6 months ago

the plan would be exposing zos APIs over mycelium IP, Let's start by creating openRPC documentation, underlying handlers won't need to be changed

KDS is suggesting documenting using this https://pypi.org/project/tabella/

ashraffouda commented 6 months ago

to have openrpc for zos api we need some modification to myceilum for user verification so it would be better if the user starts myceilum with his mnemonics so it has the same identity on the chain and from that we can check the sender ip and using myceilum we can get the key hence we can look up his twin with that key from the chain so we verify that it is the same user. so what needed from myceilum 1- user start myceilum with his chain mnemonics so we can derive the same key 2- from ip we can get the address (pk)

ashraffouda commented 5 months ago

so far I checked those pkgs 1- https://github.com/zchee/go-openrpc this repo doesn't have a working code. all commits seems like initial commits and not maintaind and is like 5 years old

2- https://github.com/gregdhill/go-openrpc this one is working I did a hello world example but also not maintained and is 2 years old also using deprecated pkgs like packr but this is not a big deal we can either use it as it is or maybe later we update it those deprecated stuff is not used alot in the code this one starts from api.json file and it will generate the server stubs, for client generation in go or in any other language we need to use different libraries 3- https://github.com/etclabscore/go-openrpc-reflect I didn't do hands on on it but the difference between it and the second one is this one starts from the code and tries to reflect the server code and generate the json spec file but this one expecting to follow some code styles also not sure if this will be working with all our types in zos or not

p.s all the above pkgs doesn't provide client code generation, so whatever we will choose from the above we will relay on an external openrpc client generation tool

Omarabdul3ziz commented 4 months ago

Update:

to simplify things here is what we need:

as an implementation, i am thinking of:

another quicker approach @ashraffouda suggests is to start from the doc file itself so

Suggestion

both suggestions will take some time, so to finish things quickly we could go with ashraf suggestion and then consider one of the suggestions.

ashraffouda commented 4 months ago

it will be better if we can build the server then generate the spec file out of it, but as u mentioned this is not well supported in golang, but to do this by either create a tool to generate this file or modify one of the existing libs to do this will take much time than expected, my suggestion is to create the spec file manually and use gregdhill/go-openrpc to create server code which I think will be much much faster than doing other suggestions

Omarabdul3ziz commented 4 months ago

work is done on the:

waiting for this https://github.com/threefoldtech/mycelium/issues/341

ashraffouda commented 4 months ago

blocked on https://github.com/threefoldtech/mycelium/issues/341