-
Notifications
You must be signed in to change notification settings - Fork 23
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: Specification update to clean up and improve documentation for proto message definitions #388
base: main
Are you sure you want to change the base?
Conversation
fb4bc88
to
df235a5
Compare
658ad21
to
e4dfc42
Compare
85a8dc1
to
99947b7
Compare
030315e
to
3c26875
Compare
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.
.
22a1201
to
5ffdb1c
Compare
8abac61
to
243d22f
Compare
I believe I've addressed or responded to each comment, thank you all for your diligence. |
13d4594
to
238d649
Compare
@@ -33,116 +39,167 @@ option java_multiple_files = true; | |||
|
|||
/** | |||
* Representation of a Hedera Schedule entry in the network Merkle tree. | |||
* | |||
* As with all network entities, a schedule has a unique entity number, which is usually given along | |||
* with the network's shard and realm in the form of a shard.realm.number id. | |||
*/ |
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 doesn't seem to conform to the Style Guidelines - "Include a line break (<br/>
) after the first line, then a brief description, if appropriate. Not every field needs additional description, but every message does."
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.
Good point, I will improve this message with some clear description.
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.
Updated.
comment boxes are limited to roughly 80 characters width. The primary | ||
"code" interaction with proto files and markdown files is in review. | ||
Also, some markdown processors struggle with longer lines. | ||
- Use blank lines (with `*` prefix) for paragraph breaks in message or |
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 think might be a little confusing. When should a message have a blank line and when should it have a <p>
?
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.
All specification content should be as close to clean markdown as the current processor permits. The use of <p>
in fields is necessitated by limitations of markdown tables; messages should always prefer a blank line over a <p>
tag.
I'll add some clarifying text here.
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.
Updated.
* On success, the resulting TransactionReceipt contains the newly created TopicId. | ||
* Request is [ConsensusCreateTopicTransactionBody](#proto.ConsensusCreateTopicTransactionBody) | ||
* Create an HCS topic. | ||
* <p> |
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.
Maybe we could add a section on Service definitions to the Style Guidelines. Seems messages cannot contain <p>
tags but Services can is that true?
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.
It's tricky because gRPC service syntax is somewhat "bolted on" and reuses other proto syntax with different keywords.
Basically, a service
is equivalent to a message
; a rpc
is equivalent to a field
.
I'll add something to that effect to the guidelines.
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.
Updated.
*/ | ||
int32 number = 3; | ||
} | ||
|
||
/** | ||
* UNDOCUMENTED | ||
* Submit a message for consensus. | ||
* <p> |
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.
Should messages contain <p>
tags or only blank lines 🤔
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.
Good catch, messages should just be blank lines, in order to remain clean markdown syntax.
Occasional exceptions may be required temporarily until we upgrade to a version of Java (23 or later) with the markdown syntax for Javadoc (JEP 467) available, and update PBJ to translate the documentation accordingly.
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.
Updated.
* The bytes of each uint64 or uint32 encoded for the hash input | ||
* MUST be in Big-Endian format. | ||
* <p> | ||
* <hr/> |
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.
Just wondering in general on the guidance of when is it advisable or appropriate to add <hr/>
tags ?
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.
In large blocks of documentation, it is appropriate to add hr
tags to set apart large groupings of closely related items, or provide visual separation for multiple broad topics.
In general, such usage should be rare, however, as we would prefer not to need such large blocks of documentation in most situations.
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.
Updated.
* <p> | ||
* If the `autoRenewAccount` value for this topic is set to a valid account | ||
* with sufficient HBAR balance to pay renewal fees when this topic | ||
* expires, the system SHALL automatically renew this topic, extending the |
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.
Is this a description or a requirement?
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.
Requirement, just a complex one to express.
*/ | ||
Timestamp expirationTime = 2; | ||
|
||
/** | ||
* The new key to control updates to the contract | ||
* If set, modify the key that authorizes updates to the contract. | ||
* <p> |
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.
Here we have a <p>
tag but in the previous field we have a <br/>
?
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 separates summary from requirements. The prior field requires more description than the summary statement, so it includes a descriptive sentence or two; this field does not require that additional descriptive content.
string memo = 9 [deprecated = true]; | ||
|
||
/** | ||
* If set, modify the short memo for this smart contract.<br/> |
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.
should the <br/>
be on the next line ?
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 syntax guidelines place the <br/>
tag at the end of the line. This generally reads better than a tag before text on a line.
e.g.
text ending in a break.<br/>
is generally easier to read than
<br/>text starting with a break
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.
Added this to guidelines.
* or more signatures. | ||
* - The account key of the account associated to the live hash. | ||
* - Any one key from the key list in the live hash entry. | ||
* - Any combination of keys from the key list in the live hash entry. | ||
*/ |
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 transactionBody might be missing heading ### Block Stream Effects
.
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 entire transaction is deprecated (see block on line 5), and has no block stream effects.
*/ | ||
int32 number = 3; | ||
} | ||
|
||
/** | ||
* UNDOCUMENTED | ||
* Submit a message for consensus. | ||
* <p> |
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.
Is there some heuristic around when messages should have <p>
tags or should we always favour blank lines for breaks in messages?
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.
Always prefer a blank line.
This line is an error that I will fix.
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.
Updated.
sentences than "normal" prose. Some describe the flow as "staccato". | ||
- Add another blank line after requirements for `message` documents only. | ||
- Each message that represents a transaction body **must** document the | ||
Block Stream effects with a heading `### Block Stream Effects`. |
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.
Could also add here that any heading such as ### Block Stream Effects
should not have a <br/>
since titles are block elements (like paragraphs)
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.
Updated.
description or requirements, not here. | ||
- A good rule of thumb is that if this first sentence exceeds 60 | ||
characters, then it is trying to describe too much. | ||
- Include a line break (`<br/>`) after the first line, then a brief description, |
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.
Additional Note: A <br/>
should never be alone on a line; it should always appear at end of the line instead.
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'll update these in the HIP that defines this file, and replicate here.
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.
Updated.
Blank lines break the automated documentation generator in **fields** | ||
because fields are output as markdown tables, and markdown tables require | ||
each row to be a single long line. | ||
- Be _prescriptive_ in requirements. Do not _describe_ the behavior. |
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.
In proto specification 2 we had the required
tag but that has been removed in v3. Should every field now try to have the equivalent of either an optional
or required
tag in the comments e.g. "This field SHALL not be empty" or what are the guidelines around that?
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.
optional
still exists in proto3 and later versions (2023 edition is latest, I believe); it requests "explicit presence".
Required fields are the only ones we probably should describe, since optional is the default.
Note, PBJ
currently does not support explicit presence, so that feature gap will need to be closed before we can enforce such a guideline.
How would this read, as a guideline?
The default state for any field is "optional", and all required fields should be specified as such. If the presence or absence of a field must be clear separate from the default value of that field, the field should use proto3 "explicit presence" and be marked with the
optional
keyword.
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.
Updated.
*/ | ||
string memo = 2; | ||
|
||
// The choices here are arranged by service in roughly lexicographic |
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.
If we can have code comments -- for example here to clarify the oneof
data structure then we could maybe add a section in the style guidelines to illustrate and clarify?
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.
Good idea, I'll work on that.
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.
Updated.
ConsensusDeleteTopicTransactionBody consensusDeleteTopic = 20; | ||
|
||
/** | ||
* Submit a message to a topic.<br/> |
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.
In the Style Guidelines it states "Include a line break (<br/>)
after the first line, then a brief description, if appropriate." Is this applicable to fields as well?
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.
Yes, both messages and fields may have description, if the summary line is not sufficient.
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.
Added some clarification to the guidelines.
238d649
to
99339af
Compare
…message definitions * Added svg diagrams for most state objects. * Clean up copyright headers to remove non-printing characters. * Began reworking documents to produce clear documentation via the most common document processor for protobuf * There are limitations that encourage a slightly different style. * Markdown produces the best output (with slight modifications to the template), so that is selected. * Added a modified markdown template (to work around the "sanitization" bug in the docs processor for markdown). * Now we can add most HTML tags in the markdown, allowing things like line breaks in attribute descriptions. * The results are much better, might be something worth submitting as a PR upstream (along with some non-trivial examples)... * This allows using a line with only `<br/>` or `<p>` in place of blank lines (that break the markdown tables). * Ideally the go code would do this, but that's a bigger lift, this works for now. * Thorough update of many proto files in state. * Committed a fully generated set of docs in this branch for review purposes, will remove before completing the task. * Moved document outputs to `documents/api/services` to allow for other document sets * Removed unused imports to quiet warnings. * Replicate "service" documentation to the message body entries for clarity * Message bodies were just "see ..." references, which do not link well, and push content specification to the service API, which muddies both. * Rewrite message body documentation to *content* specification * Rewrite "service" API documentation to *API* specification. * Adjust common fields to have consistent descriptions. Mass update of the copyright header. * Updated copyright header to match services standard. * Corrected incorrect copy-paste of older years in state. * Removed hidden zero-width characters. * Removed unnecessary additions. * Adjusted query header and query response header text to be more uniform. * Thorough update across services proto definitions * State messages complete * Consensus service complete * Smart Contract service complete. * Crypto Service complete. * Miscellaneous protos complete. * File Service complete. * Freeze Service complete. * Transaction and records complete. * Synthetic node_stake_update transaction complete. * Query and Response complete. * General Queries complete. * Harmonized crypto_get_info and get_account_details * Discovered no service interface defines `getByKey`, we may be able to completely remove that query, with it's handler in network admin service, and just reserve the field number in query and hedera functionality henceforth. * Found a few more unsupported queries and marked them deprecated in the query.proto one-of block. * Network Service complete * Schedule Service complete * Token Service complete * Fixed the new `token_reject` file, which was not created according to the content in the HIP. * Utility Service complete. * Address Book Service complete. * Minor updates and clarification only. * HIP 904 additions * Updated all airdrop and pending airdrop entries. * Response Code * Separate due to size (iover 360 fields) and frequent changes. Will be addressed in a separate PR to minimize conflict with ongoing services work. Signed-off-by: Joseph Sinclair <[email protected]>
* Documentation is moved to the hip-1037-documentation branch Signed-off-by: Joseph Sinclair <[email protected]>
* Fixed incorrect reference in block header. * Improvements to style guidelines file. * Small review fixes. Signed-off-by: Joseph Sinclair <[email protected]>
* Many suggestions slightly rewritten to better match style guidelines. * Harmonized use of the `reserved` keyword. * Added several clarifications to style guidelines. Signed-off-by: Joseph Sinclair <[email protected]>
99339af
to
329b970
Compare
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.
Partial review of UtilService LGTM.
Massive update to all services proto files to update and correct in-place
specification and documentation.
common document processor for protobuf
so that is selected.
the docs processor for markdown).
in attribute descriptions.
<br/>
or<p>
in place of blanklines (that break the markdown tables).
purposes.
documents/api/services
to allow for other document setsand push content specification to the service API, which muddies both.
getByKey
, we may be able tocompletely remove that query, with it's handler in network admin service,
and just reserve the field number in query and hedera functionality henceforth.
query.proto one-of block.
token_reject
file, which was not created according tothe content in the HIP.
Will be addressed in a separate PR and HIP to minimize conflict.