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: amend docs for 52 changes #21992

Merged
merged 4 commits into from
Oct 1, 2024
Merged

docs: amend docs for 52 changes #21992

merged 4 commits into from
Oct 1, 2024

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Oct 1, 2024

Description

this pr focuses on a few pages in the build modules section

closes #7985


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Documentation
    • Updated the BeginBlocker and EndBlocker sections to clarify implementation details and provide links to newer Cosmos SDK versions.
    • Enhanced the "Keepers" document with clearer explanations and a new section on state management.
    • Introduced a new section on "Errors v2," detailing changes in error handling practices and emphasizing the importance of custom error definitions.
    • Revised the encoding document to reflect the transition from Amino to Protocol Buffers, providing updated guidance on best practices.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces updates to multiple documentation files related to the Cosmos SDK. Key changes include clarifications and updates to the BeginBlocker and EndBlocker methods, with new examples and links reflecting the latest SDK version. The documentation on "Keepers" has been enhanced to provide better clarity on implementation and state management. Additionally, a new section on "Errors v2" has been added, outlining a zero dependency errors package and maintaining existing guidance on error handling.

Changes

Files Change Summary
docs/build/building-modules/06-beginblock-endblock.md, docs/build/building-modules/06-keeper.md - Updated BeginBlocker and EndBlocker documentation with new examples and links to Cosmos SDK version 0.52.0-beta.1.
- Enhanced "Keepers" documentation for clarity on implementation and state management.
docs/build/building-modules/12-errors.md - Added a new section on "Errors v2," detailing changes in error handling practices and registration.
docs/learn/advanced/05-encoding.md - Updated guidance on encoding transition from Amino to Protocol Buffers, including new sections on state management and Any encoding.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CosmosSDK
    participant Documentation

    User->>Documentation: Request for `BeginBlocker` and `EndBlocker` info
    Documentation->>CosmosSDK: Fetch updated examples and links
    CosmosSDK-->>Documentation: Return new examples and links
    Documentation-->>User: Provide updated documentation
Loading

Assessment against linked issues

Objective Addressed Explanation
Document best practices for data serialization (#7985) The PR does not provide specific serialization examples or best practices.

Possibly related PRs

  • docs: add instructions to change DefaultGenesis #21680: The changes in this PR involve updating documentation related to customizing the DefaultGenesis parameters, which may relate to the overall documentation improvements seen in the main PR regarding BeginBlocker and EndBlocker.
  • docs: fix broken links #21751: This PR focuses on fixing broken links in the documentation, which aligns with the main PR's goal of enhancing clarity and relevance in the documentation for BeginBlocker and EndBlocker.
  • docs: minor cleanup to simulation docs  #21777: The updates in this PR enhance the clarity of simulation documentation, which is relevant to the overall improvements in documentation quality seen in the main PR.
  • docs: posted a link to the developers Github #21828: This PR improves the accessibility of developer resources in the documentation, which complements the main PR's efforts to clarify implementation details in the Cosmos SDK documentation.

Suggested labels

C:x/epochs, C:x/authz, C:Simulations

Suggested reviewers

  • sontrinh16
  • julienrbrt

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tac0turtle tac0turtle marked this pull request as ready for review October 1, 2024 08:06
@tac0turtle tac0turtle requested a review from a team as a code owner October 1, 2024 08:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
docs/build/building-modules/12-errors.md (2)

17-19: Approved: New note about "Errors v2" is informative and well-placed.

The addition of this note provides valuable information about the changes in error handling with "Errors v2". It's clear, concise, and relevant to the document's topic.

Consider adding a brief explanation of the implications or benefits of these changes for developers. This could help readers understand why this change was made and how it affects their work with the Cosmos SDK.


Line range hint 1-100: Overall document structure and content remain coherent and informative.

The addition of the note about "Errors v2" integrates well with the existing content. The document continues to provide valuable guidance on error handling in Cosmos SDK modules.

For future updates, consider:

  1. Expanding on the implications of "Errors v2" for module developers.
  2. Providing a code example demonstrating how to manually wrap stack traces and add tracing information with the new error handling approach.
  3. Updating the existing code examples to reflect any changes introduced by "Errors v2", if applicable.

These additions would further enhance the document's value for developers working with the latest version of the Cosmos SDK.

🧰 Tools
🪛 LanguageTool

[style] ~15-~15: Consider using a more formal alternative.
Context: ...th a codespace that is meant to provide more information to clients and normal go errors. The Co...

(MORE_INFO)

docs/build/building-modules/06-beginblock-endblock.md (1)

52-53: Consider reducing empty lines

While adding empty lines can improve readability by separating content sections, multiple empty lines might be unnecessary. Consider reducing these two empty lines to a single line for consistency with the rest of the document.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3a20261 and aefd4d7c521abae8b503000f1e708795199ad2cc.

📒 Files selected for processing (2)
  • docs/build/building-modules/06-beginblock-endblock.md (2 hunks)
  • docs/build/building-modules/12-errors.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/build/building-modules/06-beginblock-endblock.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

docs/build/building-modules/12-errors.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🔇 Additional comments (4)
docs/build/building-modules/06-beginblock-endblock.md (4)

27-27: LGTM: Improved documentation link

The update to use an absolute path for the ctx documentation link enhances the reliability of the reference. This change ensures that readers can access the correct Go documentation for the context package regardless of the current document's location.


38-40: LGTM: Updated BeginBlocker example link

The example link for BeginBlocker has been updated to reference the latest SDK version (v0.52.0-beta.1), which keeps the documentation current. The slight change in the file path is noted.

Please verify that the linked content in the new version accurately represents the BeginBlocker implementation for the distribution module.

✅ Verification successful

Verification Successful: BeginBlocker example is accurate

The linked content for BeginBlocker in the distribution module matches the current implementation in SDK version v0.52.0-beta.1.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the content of the BeginBlocker example
curl -s https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.52.0-beta.1/x/distribution/keeper/abci.go | sed -n '13,40p'

Length of output: 291


Script:

#!/bin/bash
# Correctly verify the content of the BeginBlocker example in the distribution module
curl -s https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.52.0-beta.1/x/distribution/keeper/abci.go | sed -n '13,40p'

Length of output: 977


47-51: LGTM: Added EndBlocker example with validator updates

The addition of an EndBlocker example from the staking module, specifically showing validator updates, enhances the documentation by providing a more comprehensive view of EndBlocker usage. This complements the previous gov module example well.

Please verify the content of this new EndBlocker example:

✅ Verification successful

Verified: EndBlocker example accurately reflects staking module's implementation

The retrieved EndBlocker implementation from the staking module matches the example provided in the documentation. No removed or replaced code discrepancies were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the content of the new EndBlocker example with validator updates
curl -s https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.52.0-beta.1/x/staking/keeper/abci.go | sed -n '12,17p'

Length of output: 291


Script:

#!/bin/bash
# Confirm the existence of the staking module's abci.go file and retrieve relevant lines
curl -s https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.52.0-beta.1/x/staking/keeper/abci.go | head -n 20

Length of output: 563


41-44: Clarification needed: EndBlocker example change

The example for EndBlocker has been updated to reference the latest SDK version (v0.52.0-beta.1), which is good. However, there are two significant changes that require clarification:

  1. The example module has changed from staking to gov. Could you provide context for this change? Is the gov module's EndBlocker more representative or easier to understand?

  2. The referenced line range has significantly decreased (from 22-27 to just line 22). This suggests a major simplification of the EndBlocker implementation. Could you confirm if this is intentional and if it still provides a comprehensive example of EndBlocker functionality?

Please verify the content and context of the new EndBlocker example:

✅ Verification successful

EndBlocker Example Update Verified

The EndBlocker example has been updated to reference SDK version v0.52.0-beta.1 and now includes detailed implementation (lines 22-27), providing a comprehensive overview of the EndBlocker functionality in the gov module.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the content of the EndBlocker example
curl -s https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.52.0-beta.1/x/gov/keeper/abci.go | sed -n '22p'

Length of output: 291


Script:

#!/bin/bash
# Fetch lines 22-27 of the EndBlocker function for detailed inspection
curl -s https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.52.0-beta.1/x/gov/keeper/abci.go | sed -n '22,27p'

Length of output: 545

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Oct 1, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
docs/build/building-modules/06-keeper.md (2)

51-51: LGTM: Improved codec description with minor suggestion

The updated description of the cdc field provides more detailed information about the codec types that can be used, which is helpful for developers. It correctly mentions both proto and amino codecs.

Consider adding a brief explanation of when to use each codec type (BinaryCodec, JSONCodec, or Codec) to provide even more guidance to developers.


63-65: LGTM: New State Management section with link suggestion

The addition of a State Management section is a valuable improvement to the documentation. It provides a clear entry point for developers to learn about this important aspect of module development.

The markdown link to the Collections documentation is currently disabled for link checking. Consider adding a TODO comment to remind updating this link once the Collections documentation is available, ensuring it doesn't remain as a dead link in the future.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between aefd4d7c521abae8b503000f1e708795199ad2cc and 18175e6.

📒 Files selected for processing (2)
  • docs/build/building-modules/06-keeper.md (2 hunks)
  • docs/learn/advanced/05-encoding.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/build/building-modules/06-keeper.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

docs/learn/advanced/05-encoding.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🪛 LanguageTool
docs/learn/advanced/05-encoding.md

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)

🔇 Additional comments (4)
docs/build/building-modules/06-keeper.md (1)

44-50: LGTM: Updated reference to newer SDK version

The link to the staking module's Keeper type definition has been appropriately updated to reference a more recent version of the Cosmos SDK (v0.52.0-beta.1). This change ensures that the documentation stays current with the latest SDK release.

docs/learn/advanced/05-encoding.md (3)

81-82: LGTM: Updated GitHub reference

The link to the GitHub repository has been correctly updated to reference v0.52.0-beta.1. This change ensures that the documentation points to the latest version of the codebase.


86-89: LGTM: Updated and added GitHub references

The changes in this section improve the documentation by:

  1. Updating the link to the decoder to reference v0.52.0-beta.1.
  2. Adding a new link to the encoder, also referencing v0.52.0-beta.1.

These updates ensure that the documentation points to the latest version of the codebase and provide a more complete reference for developers by including both the decoder and encoder implementations.


Line range hint 270-285: LGTM: Important addition about Any implementation changes

This new section provides critical information about the Cosmos SDK's transition from gogoproto to the official google.golang.org/protobuf package. It clearly outlines:

  1. Which methods from the official package should not be used.
  2. The alternative helper functions provided by the Cosmos SDK.
  3. A practical example demonstrating how to pack a sdk.Msg using the new approach.

This addition is extremely valuable for developers working with the SDK, as it helps prevent potential issues related to the Any type's implementation and ensures compatibility with the SDK's conventions.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)

Comment on lines +66 to +69
In the Cosmos SDK, it is crucial to be methodical and selective when managing state within a module, as improper state management can lead to inefficiency, security risks, and scalability issues. Not all data belongs in the on-chain state; it's important to store only essential blockchain data that needs to be verified by consensus. Storing unnecessary information, especially client-side data, can bloat the state and slow down performance. Instead, developers should focus on using an off-chain database to handle supplementary data, extending the API as needed. This approach minimizes on-chain complexity, optimizes resource usage, and keeps the blockchain state lean and efficient, ensuring scalability and smooth operations.


The Cosmos SDK leverages Protocol Buffers (protobuf) for efficient state management, providing a well-structured, binary encoding format that ensures compatibility and performance across different modules. The SDK’s recommended approach for managing state is through the [collections package](../pacakges/02-collections.md), which simplifies state handling by offering predefined data structures like maps and indexed sets, reducing the complexity of managing raw state data. While users can opt for custom encoding schemes if they need more flexibility or have specialized requirements, they should be aware that such custom implementations may not integrate seamlessly with indexers that decode state data on the fly. This could lead to challenges in data retrieval, querying, and interoperability, making protobuf a safer and more future-proof choice for most use cases.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

LGTM: Comprehensive State Management guidance with minor typo

This new section provides excellent guidance on state management in Cosmos SDK. It covers crucial aspects such as:

  • The importance of selective on-chain data storage
  • The use of off-chain databases for supplementary data
  • Leveraging Protocol Buffers for efficient state management
  • Recommending the collections package for simplified state handling

The content is informative and will be valuable for developers working with Cosmos SDK modules.

There's a typo in the link to the collections package documentation. "pacakges" should be "packages".

Please apply this fix:

-The SDK's recommended approach for managing state is through the [collections package](../pacakges/02-collections.md),
+The SDK's recommended approach for managing state is through the [collections package](../packages/02-collections.md),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
In the Cosmos SDK, it is crucial to be methodical and selective when managing state within a module, as improper state management can lead to inefficiency, security risks, and scalability issues. Not all data belongs in the on-chain state; it's important to store only essential blockchain data that needs to be verified by consensus. Storing unnecessary information, especially client-side data, can bloat the state and slow down performance. Instead, developers should focus on using an off-chain database to handle supplementary data, extending the API as needed. This approach minimizes on-chain complexity, optimizes resource usage, and keeps the blockchain state lean and efficient, ensuring scalability and smooth operations.
The Cosmos SDK leverages Protocol Buffers (protobuf) for efficient state management, providing a well-structured, binary encoding format that ensures compatibility and performance across different modules. The SDKs recommended approach for managing state is through the [collections package](../pacakges/02-collections.md), which simplifies state handling by offering predefined data structures like maps and indexed sets, reducing the complexity of managing raw state data. While users can opt for custom encoding schemes if they need more flexibility or have specialized requirements, they should be aware that such custom implementations may not integrate seamlessly with indexers that decode state data on the fly. This could lead to challenges in data retrieval, querying, and interoperability, making protobuf a safer and more future-proof choice for most use cases.
In the Cosmos SDK, it is crucial to be methodical and selective when managing state within a module, as improper state management can lead to inefficiency, security risks, and scalability issues. Not all data belongs in the on-chain state; it's important to store only essential blockchain data that needs to be verified by consensus. Storing unnecessary information, especially client-side data, can bloat the state and slow down performance. Instead, developers should focus on using an off-chain database to handle supplementary data, extending the API as needed. This approach minimizes on-chain complexity, optimizes resource usage, and keeps the blockchain state lean and efficient, ensuring scalability and smooth operations.
The Cosmos SDK leverages Protocol Buffers (protobuf) for efficient state management, providing a well-structured, binary encoding format that ensures compatibility and performance across different modules. The SDK's recommended approach for managing state is through the [collections package](../packages/02-collections.md), which simplifies state handling by offering predefined data structures like maps and indexed sets, reducing the complexity of managing raw state data. While users can opt for custom encoding schemes if they need more flexibility or have specialized requirements, they should be aware that such custom implementations may not integrate seamlessly with indexers that decode state data on the fly. This could lead to challenges in data retrieval, querying, and interoperability, making protobuf a safer and more future-proof choice for most use cases.

Comment on lines 50 to 51
Modules are recommended to use [collections](../../build/pacakges/02-collections.md) for handling encoding and decoding of state. Usage of collections handles marshal and unmarshal for you. By default protobuf is used but other encodings can be used if preferred.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct typo and improve sentence structure

The new content provides valuable information about using collections for state encoding and decoding. However, there are a few improvements to be made:

  1. There's a typo in the word "pacakges" in the link. It should be "packages".
  2. The sentence structure can be improved for better clarity.

Here's a suggested revision:

-Modules are recommended to use [collections](../../build/pacakges/02-collections.md) for handling encoding and decoding of state. Usage of collections handles marshal and unmarshal for you. By default protobuf is used but other encodings can be used if preferred. 
+Modules are recommended to use [collections](../../build/packages/02-collections.md) for handling encoding and decoding of state. Collections handle marshaling and unmarshaling for you. By default, Protobuf is used, but other encodings can be used if preferred.

This revision corrects the typo, improves sentence structure, and adds proper capitalization for "Protobuf".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Modules are recommended to use [collections](../../build/pacakges/02-collections.md) for handling encoding and decoding of state. Usage of collections handles marshal and unmarshal for you. By default protobuf is used but other encodings can be used if preferred.
Modules are recommended to use [collections](../../build/packages/02-collections.md) for handling encoding and decoding of state. Collections handle marshaling and unmarshaling for you. By default, Protobuf is used, but other encodings can be used if preferred.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)

Copy link
Contributor

@hieuvubk hieuvubk left a comment

Choose a reason for hiding this comment

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

lgtm

docs/learn/advanced/05-encoding.md Outdated Show resolved Hide resolved
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
docs/learn/advanced/05-encoding.md (3)

50-51: Improve clarity and fix typo in the collections section

The new content provides valuable information about using collections for state encoding and decoding. However, there are a few improvements to be made:

  1. There's a typo in the word "packages" in the link.
  2. The sentence structure can be improved for better clarity.

Here's a suggested revision:

-Modules are recommended to use [collections](../../build/pacakges/02-collections.md) for handling encoding and decoding of state. Usage of collections handles marshal and unmarshal for you. By default protobuf is used but other encodings can be used if preferred. 
+Modules are recommended to use [collections](../../build/packages/02-collections.md) for handling encoding and decoding of state. Collections handle marshaling and unmarshaling for you. By default, Protobuf is used, but other encodings can be used if preferred.

This revision corrects the typo, improves sentence structure, and adds proper capitalization for "Protobuf".

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)


Line range hint 114-180: Approve detailed explanation of Any usage with a minor suggestion

The expanded explanation of interface encoding and Any usage is excellent. It provides developers with a clear understanding of how to use Any for encoding interfaces in protobuf, including practical examples and explanations of the UnpackInterfaces method.

One minor suggestion to further improve this section:

Consider adding a brief note about the performance implications of using Any for interface encoding. This could help developers make informed decisions about when to use this approach.

Example:

Note: While `Any` provides flexibility for encoding interfaces, it may have some performance overhead due to the additional type information it carries. Consider the trade-offs between flexibility and performance when deciding to use `Any` in your application.

Overall, great job on improving this section!

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)


Line range hint 182-228: Approve new section on Any's TypeURL with a suggestion for clarification

The new section on Any's TypeURL is a valuable addition to the documentation. It clearly explains the Cosmos SDK's approach to TypeURLs and highlights important compatibility considerations when working with different protobuf implementations.

The introduction of helper functions from cosmos-proto/anyutil is particularly useful for maintaining consistency with the SDK's TypeURL format.

To further improve this section, consider adding a brief explanation of why the Cosmos SDK chose to omit the type.googleapis.com prefix. This could help developers better understand the rationale behind this decision.

Example addition:

The Cosmos SDK omits the `type.googleapis.com` prefix to keep TypeURLs shorter and more manageable within the ecosystem. This decision prioritizes readability and reduces overhead in message serialization.

Overall, excellent addition to the documentation!

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 18175e6 and 598fc22.

📒 Files selected for processing (1)
  • docs/learn/advanced/05-encoding.md (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/learn/advanced/05-encoding.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

🪛 LanguageTool
docs/learn/advanced/05-encoding.md

[uncategorized] ~50-~50: Did you mean: “By default,”?
Context: ... handles marshal and unmarshal for you. By default protobuf is used but other encodings ca...

(BY_DEFAULT_COMMA)


[uncategorized] ~50-~50: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...hal for you. By default protobuf is used but other encodings can be used if preferre...

(COMMA_COMPOUND_SENTENCE_2)

🔇 Additional comments (2)
docs/learn/advanced/05-encoding.md (2)

81-89: LGTM: Updated references to latest SDK version

The changes in this section appropriately update the links and references to the latest version of the Cosmos SDK (v0.52.0-beta.1). This ensures that the documentation stays current with the most recent implementation.


Line range hint 1-228: Overall improvement in encoding documentation

This update to the encoding documentation aligns well with the PR objectives of enhancing the build modules documentation. The changes include:

  1. Updated information on using collections for state encoding and decoding.
  2. Refreshed references to the latest Cosmos SDK version.
  3. Expanded explanation of interface encoding and Any usage.
  4. New section on Any's TypeURL and compatibility considerations.

These improvements provide developers with more comprehensive and up-to-date information on encoding practices within the Cosmos SDK. The added examples and clarifications contribute to a better understanding of key concepts, particularly around interface encoding and Any usage.

The documentation now better addresses the need for clear guidelines on data serialization practices, which was an objective mentioned in the linked issue #7985. However, to fully meet that objective, consider adding a dedicated section or expanding existing sections to cover best practices for data serialization more explicitly.

Overall, these changes significantly enhance the quality and usefulness of the encoding documentation.

@julienrbrt julienrbrt added this pull request to the merge queue Oct 1, 2024
Merged via the queue into main with commit 52d8b2e Oct 1, 2024
70 checks passed
@julienrbrt julienrbrt deleted the marko/docs-52 branch October 1, 2024 09:52
mergify bot pushed a commit that referenced this pull request Oct 1, 2024
Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com>
(cherry picked from commit 52d8b2e)
julienrbrt pushed a commit that referenced this pull request Oct 1, 2024
Co-authored-by: Marko <marko@baricevic.me>
alpe added a commit that referenced this pull request Oct 1, 2024
* main:
  docs: amend docs for 52 changes  (#21992)
  test: migrate e2e/authz to system tests (#21819)
  refactor(runtime/v2): use StoreBuilder (#21989)
  feat(schema): add API descriptors, struct, oneof & list types, and wire encoding spec (#21482)
  docs: add instructions to change DefaultGenesis (#21680)
  feat(x/staking)!: Add metadata field to validator info (#21315)
  chore(x/authz)!: Remove account keeper dependency (#21632)
alpe added a commit that referenced this pull request Oct 1, 2024
* main:
  docs: amend docs for 52 changes  (#21992)
  test: migrate e2e/authz to system tests (#21819)
  refactor(runtime/v2): use StoreBuilder (#21989)
  feat(schema): add API descriptors, struct, oneof & list types, and wire encoding spec (#21482)
  docs: add instructions to change DefaultGenesis (#21680)
  feat(x/staking)!: Add metadata field to validator info (#21315)
  chore(x/authz)!: Remove account keeper dependency (#21632)
  chore(contributing): delete link (#21990)
  test(gov): Migrate e2e to system test (#21927)
  test: e2e/client to system tests (#21981)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document best practices for data serialization
4 participants