Skip to content
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

Open
wants to merge 15 commits into
base: next
Choose a base branch
from
Open

docs: generate RPC documentation #542

wants to merge 15 commits into from

Conversation

polydez
Copy link
Contributor

@polydez polydez commented Nov 5, 2024

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.

@polydez polydez changed the base branch from main to next November 5, 2024 12:03
# Conflicts:
#	CHANGELOG.md
@polydez polydez marked this pull request as ready for review November 7, 2024 16:34
Copy link
Contributor

@bobbinth bobbinth left a 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?

Comment on lines +18 to 19
// The block number.
fixed32 block_num = 2;
Copy link
Contributor

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.

Comment on lines +21 to 22
// The account ID.
account.AccountId account_id = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Comment on lines +22 to 23
// Merkle path to verify the account's inclusion in the MMR.
uint32 block_num = 3;
Copy link
Contributor

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.

Comment on lines +14 to 15
// A summary of an account.
message AccountSummary {
Copy link
Contributor

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.

Comment on lines +31 to 32
// Account details encoded using Miden native format.
optional bytes details = 2;
Copy link
Contributor

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.

Comment on lines +6 to 7
// Represents an MMR delta.
message MmrDelta {
Copy link
Contributor

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.

Comment on lines +6 to 7
// Represents a Merkle path.
message MerklePath {
Copy link
Contributor

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."

@polydez
Copy link
Contributor Author

polydez commented Nov 17, 2024

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?

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.

@Mirko-von-Leipzig Mirko-von-Leipzig changed the title RPC documentation docs: generate RPC documentation Dec 3, 2024
@Mirko-von-Leipzig
Copy link
Contributor

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?

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?

Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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).
Copy link
Contributor

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).
Copy link
Contributor

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.

Copy link
Contributor

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?

Comment on lines +42 to +45
docker run --rm \
-v $(PWD)/docs:/out \
-v $(PWD)/proto:/protos \
pseudomuto/protoc-gen-doc --doc_opt=/out/api.tmpl,api.md
Copy link
Contributor

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 the docs folder with these instructions
  • optionally remove these instructions from here (only manual invocation)
  • add ci check to ensure we stay in sync

Copy link
Contributor

@bobbinth bobbinth left a 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.

Comment on lines +9 to 10
// Gets a list of proofs for given nullifier hashes, each proof as a sparse Merkle Tree.
rpc CheckNullifiers(requests.CheckNullifiersRequest) returns (responses.CheckNullifiersResponse) {}
Copy link
Contributor

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?

Comment on lines +15 to 23
// 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) {}
Copy link
Contributor

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update docs for endpoints
4 participants