-
Notifications
You must be signed in to change notification settings - Fork 44
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
docs: generate RPC documentation #542
base: next
Are you sure you want to change the base?
Conversation
# Conflicts: # CHANGELOG.md
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.
Thank you! Not a full review, but I left some comments inline. These comments are not exhaustive - similar issues apply in other places which I haven't commented on. Basically, in may cases the added comments are not very useful. We should go a layer deeper and explain things more so that even an unfamiliar person can understand them.
Regarding the new doc format. I'm not sure I like it. It combines everything together, and IMO, makes docs more difficult to navigate. Is there a way to generate docs separately for RPC, store, and block producers components?
// The block number. | ||
fixed32 block_num = 2; |
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.
This comment is not very helpful (i.e., we can see from the name that this is a block number). Sometimes, such things cannot be avoided, but in this case, we should actually provide more detail on what this block number means.
// The account ID. | ||
account.AccountId account_id = 3; |
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.
Same comment as above.
// Merkle path to verify the account's inclusion in the MMR. | ||
uint32 block_num = 3; |
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.
This comment doesn't seem correct.
// A summary of an account. | ||
message AccountSummary { |
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.
"A summary of an account" comment is not very helpful here. I would expand it to a couple of sentences which describe what it is and what it is used for.
// Account details encoded using Miden native format. | ||
optional bytes details = 2; |
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 would describe what the details actually contain (i think they contain full account state description, right?). Also, we should say why the are optional.
// Represents an MMR delta. | ||
message MmrDelta { |
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.
Let's add some detail on what is the MMR delta.
// Represents a Merkle path. | ||
message MerklePath { |
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.
nit: let's say "Represents a Merkle authentication path."
I tried, but didn't find any way to do it by just using tools for automatic docs generation. We still have options, for example, we can write script for post-processing of generated docs in order to regroup their contents. Or regroup them manually. |
I imagine we would have to more concretely separate the various RPC service files. Which is something we want to do at some point in any case I believe? |
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.
LGTM; some questions, suggestions but nothing major.
Probably we should have an actual documentation person go over the wording of things, but that can be a separate pass once we're happy.
@@ -6,6 +6,7 @@ import "requests.proto"; | |||
import "responses.proto"; | |||
|
|||
service Api { | |||
// Submits proven transaction to the Miden network |
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.
// Submits proven transaction to the Miden network | |
// Submits proven transaction to the Miden network. |
**Returns** | ||
|
||
This method doesn't return any data. | ||
Full API documentation located [here](../../docs/api.md). |
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.
This link will break once published. Issue of course is that we're sharing documentation between crates within a workspace.
This isn't an immediate issue imo; just something to consider as we flesh out our solution to this.
**Returns** | ||
|
||
- `notes`: `[Note]` – list of all notes of the current chain. | ||
Full API documentation located [here](../../docs/api.md). |
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.
Similar link breakage on publish.
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.
This gets generated but doesn't actually do anything afterwards iiuc? Should this be checked in?
Or maybe this could be used to specify/separate the various rpc
endpoints into separate docs somehow?
docker run --rm \ | ||
-v $(PWD)/docs:/out \ | ||
-v $(PWD)/proto:/protos \ | ||
pseudomuto/protoc-gen-doc --doc_opt=/out/api.tmpl,api.md |
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.
We probably need a separate CI check to ensure the generated docs match this?
I'm also unsure if this should be part of make doc
like this; though maybe its fine.
I would:
- add a
README.md
with instructions to thedocs
folder with these instructions - optionally remove these instructions from here (only manual invocation)
- add ci check to ensure we stay in sync
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.
Thank you! I left some comments inline - mostly not related to this PR.
For this PR, I think the updates in the .proto
files look fine, but I think auto-generated documentation is not great. I think it actually makes things a bit worse as compared to now.
So, maybe we split the PR so that we can commit .proto
changes and maybe update the existing documentation to match the current state.
Then, in a separate PR, we can try to refactor how the .proto
files are organized as @Mirko-von-Leipzig suggested or maybe do something else that will improve the overall readability of the documentation.
// Gets a list of proofs for given nullifier hashes, each proof as a sparse Merkle Tree. | ||
rpc CheckNullifiers(requests.CheckNullifiersRequest) returns (responses.CheckNullifiersResponse) {} |
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.
@igamigo - are we using this endpoint anywhere in the client?
// Returns the latest state of an account with the specified ID. | ||
rpc GetAccountDetails(requests.GetAccountDetailsRequest) returns (responses.GetAccountDetailsResponse) {} | ||
|
||
// Returns the latest state proofs of accounts with the specified IDs. | ||
rpc GetAccountProofs(requests.GetAccountProofsRequest) returns (responses.GetAccountProofsResponse) {} | ||
|
||
// Returns delta of the account states in the range from `from_block_num` (exclusive) to | ||
// `to_block_num` (inclusive). | ||
rpc GetAccountStateDelta(requests.GetAccountStateDeltaRequest) returns (responses.GetAccountStateDeltaResponse) {} |
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.
Not for this PR, but it feels like we should normalize these endpoints somehow. For example:
- I'm not sure if we are actually using
GetAccountStateDelta
in the client - @igamigo, could you check? - I think the current
GetAccountDetails
endpoint returns the entire account, which would probably not work for large accounts. GetAccountProofsRequest
is used primarily for FPI, but maybe it can be used for other things as well?
Generally, we should probably list the use case we have for retrieving account data from the node and see if these 3 methods are still the right way to get this data. @polydez - could you create an issue for this?
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.
Resolves #512
Added generation of API reference documentation (resulting file is docs/api.md). Regrouped documentation in order to utilize node docs in docs/index.md.
The most challenging here is to automatically generate corresponding messages right after each endpoint and this seems to be impossible to do using
protoc-gen-doc
or any other tools I had chance to try. So if it is crucial, we will probably need to regroup them manually. But for the first attempt I tried to do fully automated API reference docs generation.