-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[JSON-RPC] Generate openrpc.json spec and rpc.discover endpoint #1588
Conversation
cf0e66b
to
09739f4
Compare
Hi Patrick, I started my edits in a direct commit here but ran into this error when attempting to update and get the
If you tell me the correct way to update via Include this new file in site navigation: And announce it in [siteconfig.json](https://github.com/MystenLabs/sui/blob/main/doc/src/siteconfig.json)
I can take care of all of this. In fact, I just documented the process: Please just help me get this up and running. Thanks! |
@Clay-Mysten , we should update the command from
to
. However, the latter command will also fail due to another issue, which should be fixed soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
@@ -0,0 +1,2087 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping that we can generate ts typing from this schema(so that we can automate the syncing) and tried loading this file with https://github.com/open-rpc/typings, unfortunately I got an out of memory error
npx open-rpc-typings --output-ts .
<--- Last few GCs --->
[45334:0x160008000] 40122 ms: Mark-sweep 4042.4 (4128.9) -> 4031.2 (4133.9) MB, 4860.8 / 0.1 ms (average mu = 0.185, current mu = 0.054) allocation failure scavenge might not succeed
[45334:0x160008000] 45056 ms: Mark-sweep 4047.5 (4133.9) -> 4034.2 (4136.7) MB, 4902.3 / 0.0 ms (average mu = 0.098, current mu = 0.006) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x102c0a104 node::Abort() [/opt/homebrew/Cellar/node/17.5.0/bin/node]
2: 0x102c0b104 node::OnFatalError(char const*, char const*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
3: 0x102d6243c v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
4: 0x102d623d0 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
5: 0x102eb21d0 v8::internal::Heap::EnsureFillerObjectAtTop() [/opt/homebrew/Cellar/node/17.5.0/bin/node]
6: 0x102eb43a0 v8::internal::Heap::ComputeMutatorUtilization(char const*, double, double) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
7: 0x102eb2a04 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
8: 0x102eb0c74 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
9: 0x102ebdbbc v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
10: 0x102ebdc3c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
11: 0x102e956d4 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
12: 0x10314a96c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
13: 0x102a7d5ec Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/opt/homebrew/Cellar/node/17.5.0/bin/node]
14: 0x1093cbd50
15: 0x1093c9fe8
16: 0x10959b3e4
17: 0x1095b9c1c
18: 0x10935e304
19: 0x102ac56f8 Builtins_PromiseFulfillReactionJob [/opt/homebrew/Cellar/node/17.5.0/bin/node]
20: 0x102a32c54 Builtins_RunMicrotasks [/opt/homebrew/Cellar/node/17.5.0/bin/node]
21: 0x102a0fe84 Builtins_JSRunMicrotasksEntry [/opt/homebrew/Cellar/node/17.5.0/bin/node]
22: 0x102e4e668 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
23: 0x102e4e9d4 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
24: 0x102e6faf4 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
25: 0x102e6f920 v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
26: 0x102b41ab4 node::InternalCallbackScope::Close() [/opt/homebrew/Cellar/node/17.5.0/bin/node]
27: 0x102b423fc node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
28: 0x102b5cc9c node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
29: 0x102c0f620 node::fs::FSReqCallback::Resolve(v8::Local<v8::Value>) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
30: 0x102c1094c node::fs::AfterNoArgs(uv_fs_s*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
31: 0x104f338c0 uv__work_done [/opt/homebrew/Cellar/libuv/1.43.0/lib/libuv.1.dylib]
32: 0x104f36c38 uv__async_io [/opt/homebrew/Cellar/libuv/1.43.0/lib/libuv.1.dylib]
33: 0x104f46458 uv__io_poll [/opt/homebrew/Cellar/libuv/1.43.0/lib/libuv.1.dylib]
34: 0x104f37058 uv_run [/opt/homebrew/Cellar/libuv/1.43.0/lib/libuv.1.dylib]
35: 0x102b42c60 node::SpinEventLoop(node::Environment*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
36: 0x102c47b58 node::NodeMainInstance::Run(int*, node::Environment*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
37: 0x102c477ac node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
38: 0x102bd7dc0 node::Start(int, char**) [/opt/homebrew/Cellar/node/17.5.0/bin/node]
39: 0x1051cd0f4
[1] 45333 abort npx open-rpc-typings --output-ts .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm the schema works with https://playground.open-rpc.org so it should be valid... I will investigate, we have some cyclic structs in the response type TypeTag
maybe that's causing problem...
I will work on simplifying the responses after I finish other devnet tasks, hopefully we can remove TypeTag and make the schema simpler
#[schemars(with = "json_schema::Identifier")] module: Identifier, | ||
#[schemars(with = "json_schema::Identifier")] function: Identifier, | ||
#[schemars(with = "Option<Vec<json_schema::TypeTag>>")] type_arguments: Option< | ||
Vec<TypeTag>, | ||
>, | ||
arguments: Vec<RpcCallArg>, | ||
gas_object_id: ObjectID, | ||
gas_budget: u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N00b question: why do we use the schemar marco on line 77 but not on line 82?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the schemars
tag is used to tell the macro to generate schema with the provided Type instead of the actual declared Type, we need this because Identifier
and TypeTag
belongs to the move package so we can't implement JsonSchema
trait for them, instead we use proxy types in json_schema
to generate the schema.
Thanks! @Clay-Mysten I will rebase this PR and go thought the cargo install process (didn't know it's broken), I will see if I can fix it, please bear with me :) |
82708c5
to
715a571
Compare
@Clay-Mysten you can use |
Update Cargo install command per input in PR: #1588
But I would like to know why it is needed when the previous command had worked. The new one appears to be working for me now (or is at least fetching the packages without error). Thanks! |
Also see the TODOs I left inline during my edits. |
* more refactoring * updated doc
Start edits and add TODOs to RPC server doc
3b3f5ff
to
a96cc1a
Compare
* Update install.md Update Cargo install command per input in PR: #1588 * Update install.md * Update install.md
* add open rpc rpc.discover support * * generated open rpc spec in sui/open_rpc/spec * more refactoring * updated doc * update doc * update rpc spec * rename package * remove unused deps * more docs added JsonSchema for MoveStructLayout * Update json-rpc.md Start edits and add TODOs to RPC server doc * address comments in doc Co-authored-by: Clay-Mysten <100217682+Clay-Mysten@users.noreply.github.com>
* Update install.md Update Cargo install command per input in PR: #1588 * Update install.md * Update install.md
* add open rpc rpc.discover support * * generated open rpc spec in sui/open_rpc/spec * more refactoring * updated doc * update doc * update rpc spec * rename package * remove unused deps * more docs added JsonSchema for MoveStructLayout * Update json-rpc.md Start edits and add TODOs to RPC server doc * address comments in doc Co-authored-by: Clay-Mysten <100217682+Clay-Mysten@users.noreply.github.com>
* Update install.md Update Cargo install command per input in PR: #1588 * Update install.md * Update install.md
This PR added a proc macro to generate JSON-RPC spec file
sui/open_rpc/spec/openrpc.json
andrpc.discover
method for the rpc-server.The Open-RPC spec can be viewed here
Notable changes:
Todos:
sui_moveCall
require Base64 encoded bytes as input, which is not very json-rpc friendly, I will be changing it to use SuiJson instead so we can use strings as arg inputsRefactor return types, not all data are useful to downstream and can be removed/ transformed to Json value.