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

update spec and fix code snippets #9334

Merged
merged 18 commits into from
May 19, 2021
Merged

update spec and fix code snippets #9334

merged 18 commits into from
May 19, 2021

Conversation

robert-zaremba
Copy link
Collaborator

@robert-zaremba robert-zaremba commented May 14, 2021

Description

closes: #9257


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@robert-zaremba robert-zaremba added T:Docs Changes and features related to documentation. C:x/authz labels May 14, 2021
@robert-zaremba robert-zaremba added this to the v0.43 milestone May 14, 2021
@robert-zaremba robert-zaremba removed this from the v0.43 milestone May 14, 2021
Copy link
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Looking good. A lot of little suggestions.

The code snippets need to be fixed. Also, some of the code snippets include the comment (those in the concepts and state documents), and some do not (those in the messages document). Not sure if this was intentional.


## Msg/Grant
## Grant
Copy link
Contributor

Choose a reason for hiding this comment

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

This section is about the message. I think we might want to reference the message not the method.

Suggested change
## Grant
## MsgGrant

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wanted to discuss and describe service methods, not the request objects. That's why I'm not using Msg prefix.

Copy link
Contributor

@ryanchristo ryanchristo May 16, 2021

Choose a reason for hiding this comment

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

The title of this document is Messages. The next line of this section is "An authorization-grant is created using the MsgGrant message." Then we provide a code snippet for MsgGrant. And then we further discuss the message, "This message is expected to fail if..." Switching to the method names for the title of each section without changing the content or even mentioning the method is confusing.

Copy link
Collaborator Author

@robert-zaremba robert-zaremba May 17, 2021

Choose a reason for hiding this comment

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

OK, I can rename the file and the header to 03_tx_service.

[edit] renamed to 03_services.md.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Each service has exactly one argument, so it makes sense to describe the argument (MsgGrant) in this case.

x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
proto/cosmos/authz/v1beta1/tx.proto Outdated Show resolved Hide resolved
proto/cosmos/authz/v1beta1/tx.proto Outdated Show resolved Hide resolved
x/authz/spec/01_concepts.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Show resolved Hide resolved
@ryanchristo
Copy link
Contributor

ryanchristo commented May 15, 2021

It might be nice to order the triple (granter, Authorization, grantee) rather than (granter, grantee, Authorization), which would reflect the RDF order subject-predicate-object.

Also, the use of parenthesis around the triple seems a bit odd to me. We might want to consider removing the parenthesis or using another format such as granter/authorization/grantee. Thoughts?

Also, we need to make sure that we are consistent. Sometimes we use Authorization, sometimes we use AuthorizationType, and sometimes we use msg type.

robert-zaremba and others added 2 commits May 16, 2021 12:27
Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>
@robert-zaremba
Copy link
Collaborator Author

It might be nice to order the triple (granter, Authorization, grantee) rather than (granter, grantee, Authorization), which would reflect the RDF order subject-predicate-object.

Interesting idea. I think we don't need this at this level. The order of this relation is hidden from the user, and it's a storage detail. We use (granter, grantee, Authorization) because we need a prefix scan based on (granter, grantee).

@codecov
Copy link

codecov bot commented May 16, 2021

Codecov Report

Merging #9334 (a711248) into master (53fe03e) will decrease coverage by 0.08%.
The diff coverage is n/a.

❗ Current head a711248 differs from pull request most recent head 1767cdc. Consider uploading reports for the commit 1767cdc to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9334      +/-   ##
==========================================
- Coverage   60.39%   60.30%   -0.09%     
==========================================
  Files         589      588       -1     
  Lines       37087    36978     -109     
==========================================
- Hits        22399    22301      -98     
+ Misses      12711    12700      -11     
  Partials     1977     1977              
Impacted Files Coverage Δ
x/upgrade/keeper/grpc_query.go 58.82% <0.00%> (-15.26%) ⬇️
x/upgrade/keeper/keeper.go 76.51% <0.00%> (-3.10%) ⬇️
x/staking/types/msg.go 54.92% <0.00%> (-2.40%) ⬇️
x/staking/client/cli/tx.go 17.98% <0.00%> (ø)
x/upgrade/client/testutil/suite.go
x/staking/keeper/msg_server.go 0.45% <0.00%> (+0.01%) ⬆️

@ryanchristo
Copy link
Contributor

ryanchristo commented May 16, 2021

Interesting idea. I think we don't need this at this level. The order of this relation is hidden from the user, and it's a storage detail. We use (granter, grantee, Authorization) because we need a prefix scan based on (granter, grantee).

Ok, just a thought. No need to change the order or the format for the triple.

A few items remaining:

  1. There are two typos in the comment for the Grant method and we should probably be consistent with how we refer to the triple. See comment.
  2. There is still one use of msg type rather than Authorization when referring to the triple that should probably be updated for consistency. See comment.
  3. There are still a couple code snippets that do not start on the correct line (I understand the comment should not be included). See comment and comment.
  4. If we intend to discuss the methods rather than the messages, I think we need to update some of the content. It is not clear that we are describing the service methods. See comment.

robert-zaremba and others added 3 commits May 17, 2021 16:38
Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>
@robert-zaremba
Copy link
Collaborator Author

Thanks for review @ryanchrypto . I've renamed the 3_messages file to 3_services, updated snippets and used Authorization instead of Msg Type when we talk about grant.

Copy link
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

I've renamed the 3_messages file to 3_services

In other module specifications, we describe the messages in a messages.md file and we do not have a services.md file. Do you think we should be breaking the pattern here?

The content for each section in the services.md file (renamed from messages.md) describes the messages. I am not sure why renaming each section to the service method names and then renaming the file to services.md are necessary changes if we are not updating the content to include explanations of the service methods.

Maybe it would make more sense if we added an explanation and a code snippet for each method? If we rename the file, we should probably use the singular tx_service.md rather than services.md unless we intend to include the query service.

I have added more suggestions. I also think we could do a better job throughout our specs and documentation on using consistent naming conventions (i.e. when to use backticks, how to refer to Protobuf services and messages, etc.). It would be nice to have a styleguide that everyone could reference when writing documentation, but this is out of scope for this pull request.

Comment on lines 9 to 11
## Grant

An authorization-grant is created using the `MsgGrant` message.
Copy link
Contributor

Choose a reason for hiding this comment

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

The "Grant" section does not include an explanation of Grant. It currently explains MsgGrant and provides a snippet of the MsgGrant message. This is what I was talking about when I said it was confusing to change the title of each section without changing the content.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, we should start describing the method. I have updated the section. Hope it sound better now. (same for comments below)

Comment on lines 25 to 27
## Revoke

An grant can be removed with `MsgRevoke` message.
Copy link
Contributor

Choose a reason for hiding this comment

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

The "Revoke" section does not include an explanation of Revoke. It currently explains MsgRevoke and provides a snippet of the MsgRevoke message. This is what I was talking about when I said it was confusing to change the title of each section without changing the content.

Comment on lines 36 to 38
## Exec

When a grantee wants to execute transaction on behalf of a granter, it must send `MsgExec`.
Copy link
Contributor

Choose a reason for hiding this comment

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

The "Exec" section does not include an explanation of Exec. It currently explains MsgExec and provides a snippet of the MsgExec message. This is what I was talking about when I said it was confusing to change the title of each section without changing the content.


# Tx Msg Service

In this section we describe the Protobuf Msg service for the authz module.
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
In this section we describe the Protobuf Msg service for the authz module.
In this section we describe the Protobuf Msg service for the `x/authz` module.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure about it. x/authz emphasis package name, "authz module" is a plain English. Do you have a preference?

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense. I do not have a strong preference. This would be a good example of something to explain in a styleguide for writing documentation/specifications (maybe added to SPEC-SPEC).

x/authz/spec/01_concepts.md Show resolved Hide resolved
x/authz/spec/03_services.md Outdated Show resolved Hide resolved
x/authz/spec/03_services.md Outdated Show resolved Hide resolved
x/authz/spec/03_services.md Outdated Show resolved Hide resolved
x/authz/spec/03_services.md Outdated Show resolved Hide resolved
x/authz/spec/03_services.md Outdated Show resolved Hide resolved
@robert-zaremba
Copy link
Collaborator Author

In other module specifications, we describe the messages in a messages.md file and we do not have a services.md file. Do you think we should be breaking the pattern here?

This is what I'm proposing here. I think in recent discussions we want to promote the services oriented API.
@aaronc , @AmauryM - do you have an opinion here?

robert-zaremba and others added 2 commits May 18, 2021 11:33
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
@cyberbono3 cyberbono3 self-requested a review May 18, 2021 11:32
@amaury1093
Copy link
Contributor

This is what I'm proposing here. I think in recent discussions we want to promote the services oriented API.
@aaronc , @AmauryM - do you have an opinion here?

we do have a SPEC-SPEC here: https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/SPEC-SPEC.md. IMO we should strictly follow the spec-spec for now.

We can start a separate issue/discussion about whether we want to update SPEC-SPEC. I agree we should promote the service-oriented design. However, I still think it's useful to separate query services and msg services into 2 files, so I wouldn't call it 03_services.md. Maybe 03_query_service.md and 04_msg_service.md? Anyway, we should discuss this in a separate issue, and keep 03_messages.md in this PR.

Copy link
Contributor

@cyberbono3 cyberbono3 left a comment

Choose a reason for hiding this comment

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

LGTM

@ryanchristo
Copy link
Contributor

we do have a SPEC-SPEC here: https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/SPEC-SPEC.md. IMO we should strictly follow the spec-spec for now.

We can start a separate issue/discussion about whether we want to update SPEC-SPEC. I agree we should promote the service-oriented design. However, I still think it's useful to separate query services and msg services into 2 files, so I wouldn't call it 03_services.md. Maybe 03_query_service.md and 04_msg_service.md? Anyway, we should discuss this in a separate issue, and keep 03_messages.md in this PR.

This makes sense to me. I think @robert-zaremba was moving in the direction of making valid improvements but we should discuss updating the spec-spec document before changing the structure here.

@aaronc
Copy link
Member

aaronc commented May 18, 2021

we do have a SPEC-SPEC here: https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/SPEC-SPEC.md. IMO we should strictly follow the spec-spec for now.
We can start a separate issue/discussion about whether we want to update SPEC-SPEC. I agree we should promote the service-oriented design. However, I still think it's useful to separate query services and msg services into 2 files, so I wouldn't call it 03_services.md. Maybe 03_query_service.md and 04_msg_service.md? Anyway, we should discuss this in a separate issue, and keep 03_messages.md in this PR.

This makes sense to me. I think @robert-zaremba was moving in the direction of making valid improvements but we should discuss updating the spec-spec document before changing the structure here.

I think this approach that @ryanchristo is suggesting makes sense

@robert-zaremba
Copy link
Collaborator Author

We discussed it during the stand up and arrived to the same conclusion

Copy link
Contributor

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Looks good to me! A few nitpicks but I approve.

x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
x/authz/spec/03_messages.md Outdated Show resolved Hide resolved
Copy link
Contributor

@aleem1314 aleem1314 left a comment

Choose a reason for hiding this comment

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

lgtm

robert-zaremba and others added 3 commits May 19, 2021 12:00
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
@robert-zaremba robert-zaremba added the A:automerge Automatically merge PR once all prerequisites pass. label May 19, 2021
@robert-zaremba
Copy link
Collaborator Author

The GitHub CI strikes again.

@mergify mergify bot merged commit b36664d into master May 19, 2021
@mergify mergify bot deleted the robert/authz-spec branch May 19, 2021 20:22
roysc pushed a commit to vulcanize/cosmos-sdk that referenced this pull request Jun 23, 2021
* update spec and fix code snippets

* updating authz.Grant documentation

* Update proto/cosmos/authz/v1beta1/tx.proto

Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>

* rename messages to services

* Update proto/cosmos/authz/v1beta1/tx.proto

Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>

* update snippets

* Apply suggestions from code review

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>

* authz: update service docs to emphasis the service methods

* authz spec: rollback to use message oriented spec

* Apply suggestions from code review

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>

* Update MsgGrant type doc

Co-authored-by: Ryan Christoffersen <12519942+ryanchrypto@users.noreply.github.com>
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:x/authz C:x/slashing T:Docs Changes and features related to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update authz spec code snippets
7 participants