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: Update build/abci docs #22067

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/build/abci/00-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The 5 methods introduced during ABCI 2.0 (compared to ABCI v0) are:

Based on validator voting power, CometBFT chooses a block proposer and calls `PrepareProposal` on the block proposer's application (Cosmos SDK). The selected block proposer is responsible for collecting outstanding transactions from the mempool, adhering to the application's specifications. The application can enforce custom transaction ordering and incorporate additional transactions, potentially generated from vote extensions in the previous block.

To perform this manipulation on the application side, a custom handler must be implemented. By default, the Cosmos SDK provides `PrepareProposalHandler`, used in conjunction with an application specific mempool. A custom handler can be written by application developer, if a noop handler provided, all transactions are considered valid. Please see [this](https://github.com/fatal-fruit/abci-workshop) tutorial for more information on custom handlers.
To perform this manipulation on the application side, a custom handler must be implemented. By default, the Cosmos SDK provides `PrepareProposalHandler`, used in conjunction with an application specific mempool. A custom handler can be written by application developer, if a noop handler provided, all transactions are considered valid.

Please note that vote extensions will only be available on the following height in which vote extensions are enabled. More information about vote extensions can be found [here](https://docs.cosmos.network/main/build/abci/vote-extensions).

Expand Down
4 changes: 2 additions & 2 deletions docs/build/abci/01-prepare-proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ selected DO NOT exceed the maximum block gas (if set) and the maximum bytes prov
by `req.MaxBytes`.

```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/abci_utils.go
https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/baseapp/abci_utils.go
```

This default implementation can be overridden by the application developer in
Expand All @@ -38,7 +38,7 @@ favor of a custom implementation in [`app_di.go`](https://docs.cosmos.network/ma
```go
prepareOpt := func(app *baseapp.BaseApp) {
abciPropHandler := baseapp.NewDefaultProposalHandler(mempool, app)
app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()))
app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler())
}

baseAppOptions = append(baseAppOptions, prepareOpt)
Expand Down
4 changes: 2 additions & 2 deletions docs/build/abci/02-process-proposal.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ and `ProcessProposal` for the new proposal.
Here is the implementation of the default implementation:

```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/abci_utils.go#L153-L159
https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/baseapp/abci_utils.go#L224-L231
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

The linked implementation does not contain the DefaultProcessProposal function.

The function DefaultProcessProposal was not found in the specified lines of abci_utils.go or anywhere else in the v0.52.0-beta.1 version of the repository. This suggests that the documentation may be outdated or referencing a non-existent implementation.

  • Verify if the function has been renamed or relocated in a newer version.
  • Update the documentation to reflect the current state of the codebase accurately.
🔗 Analysis chain

Verify the updated implementation link and consider adding a version note.

The link to the implementation has been updated to a newer version, which is good for keeping the documentation current. However, please verify that the linked code still accurately represents the default implementation of ProcessProposal.

Consider adding a note that the link may change with future SDK versions, to help readers understand that they might need to adjust for their specific version.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the linked code represents the default ProcessProposal implementation

# Test: Check if the linked file and lines exist and contain the expected content
gh api repos/cosmos/cosmos-sdk/contents/baseapp/abci_utils.go?ref=v0.52.0-beta.1 | jq -r '.content' | base64 -d | sed -n '224,231p' | grep -q "func DefaultProcessProposal"

if [ $? -eq 0 ]; then
    echo "The linked code appears to contain the default ProcessProposal implementation."
else
    echo "The linked code may not accurately represent the default ProcessProposal implementation. Please verify."
fi

Length of output: 480


Script:

#!/bin/bash
# Description: Verify the linked code represents the default ProcessProposal implementation without using base64

# Fetch the raw content of the specified file and lines
gh api repos/cosmos/cosmos-sdk/contents/baseapp/abci_utils.go?ref=v0.52.0-beta.1 \
  -H "Accept: application/vnd.github.v3.raw" | sed -n '224,231p' | grep -q "func DefaultProcessProposal"

if [ $? -eq 0 ]; then
    echo "The linked code appears to contain the default ProcessProposal implementation."
else
    echo "The linked code may not accurately represent the default ProcessProposal implementation. Please verify."
fi

Length of output: 420


Script:

#!/bin/bash
# Description: Search the entire abci_utils.go file for the DefaultProcessProposal function

# Search for the function in the specified file
if gh api repos/cosmos/cosmos-sdk/contents/baseapp/abci_utils.go?ref=v0.52.0-beta.1 \
    -H "Accept: application/vnd.github.v3.raw" | grep -q "func DefaultProcessProposal"; then
    echo "The function DefaultProcessProposal exists in baseapp/abci_utils.go."
else
    echo "The function DefaultProcessProposal was not found in baseapp/abci_utils.go. Searching the entire repository."

    # Search the entire repository for the function
    gh api repos/cosmos/cosmos-sdk/contents?recursive=true | jq -r '.[]?.path' | grep '.go$' | while read -r file; do
        gh api repos/cosmos/cosmos-sdk/contents/"$file"?ref=v0.52.0-beta.1 \
            -H "Accept: application/vnd.github.v3.raw" | grep -H "func DefaultProcessProposal" && echo "Found in $file"
    done
fi

Length of output: 502


Script:

#!/bin/bash
# Description: Search the entire repository for the DefaultProcessProposal function using ast-grep

ast-grep --lang go --pattern 'func DefaultProcessProposal($_)' .

Length of output: 66

```

Like `PrepareProposal` this implementation is the default and can be modified by
the application developer in [`app_di.go`](https://docs.cosmos.network/main/build/building-apps/app-go-di). If you decide to implement
your own `ProcessProposal` handler, you must be sure to ensure that the transactions
your own `ProcessProposal` handler, you must ensure that the transactions
provided in the proposal DO NOT exceed the maximum block gas and `maxtxbytes` (if set).

```go
Expand Down
4 changes: 2 additions & 2 deletions docs/build/abci/03-vote-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defined in ABCI++.
## Extend Vote

ABCI2.0 (colloquially called ABCI++) allows an application to extend a pre-commit vote with arbitrary data. This process does NOT have to be deterministic, and the data returned can be unique to the
validator process. The Cosmos SDK defines [`baseapp.ExtendVoteHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.1/types/abci.go#L26-L27):
validator process. The Cosmos SDK defines [`baseapp.ExtendVoteHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/types/abci.go#L26-L27):

```go
type ExtendVoteHandler func(Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error)
Expand All @@ -35,7 +35,7 @@ Click [here](https://docs.cosmos.network/main/build/abci/vote-extensions) if you

Similar to extending a vote, an application can also verify vote extensions from
other validators when validating their pre-commits. For a given vote extension,
this process MUST be deterministic. The Cosmos SDK defines [`sdk.VerifyVoteExtensionHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.1/types/abci.go#L29-L31):
this process MUST be deterministic. The Cosmos SDK defines [`sdk.VerifyVoteExtensionHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/types/abci.go#L29-L31):

```go
type VerifyVoteExtensionHandler func(Context, *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error)
Expand Down
Loading