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: documentation updates to abci #18625

Merged
merged 4 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ is `BeginBlock` -> `DeliverTx` (for all txs) -> `EndBlock`.
ABCI++ 2.0 also brings `ExtendVote` and `VerifyVoteExtension` ABCI methods. These
methods allow applications to extend and verify pre-commit votes. The Cosmos SDK
allows an application to define handlers for these methods via `ExtendVoteHandler`
and `VerifyVoteExtensionHandler` respectively. Please see [here](https://docs.cosmos.network/v0.50/building-apps/vote-extensions)
and `VerifyVoteExtensionHandler` respectively. Please see [here](https://docs.cosmos.network/v0.50/build/abci++/01-vote-extensions)
for more info.

#### Set PreBlocker
Expand Down
2 changes: 2 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (
// logic in verifying a vote extension from another validator during the pre-commit
// phase. The response MUST be deterministic. An error is returned if vote
// extensions are not enabled or if verifyVoteExt fails or panics.
// We highly recommend a size validation due to performance degredation,
// see more here https://docs.cometbft.com/v0.38/qa/cometbft-qa-38#vote-extensions-testbed
Comment on lines 641 to +645
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment in the VerifyVoteExtension function suggests implementing size validation to prevent performance degradation, but the actual validation logic is not present in the code. It would be beneficial to either implement the size validation or clarify the comment if the validation is expected to be handled elsewhere.

func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (resp *abci.ResponseVerifyVoteExtension, err error) {
if app.verifyVoteExt == nil {
Comment on lines 641 to 647
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).VerifyVoteExtension (baseapp/abci.go:644)

return nil, errors.New("application VerifyVoteExtension handler not set")
Expand Down
52 changes: 52 additions & 0 deletions docs/build/abci++/00-introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Introduction

## What is ABCI++?
samricotta marked this conversation as resolved.
Show resolved Hide resolved

ABCI++, Application Blockchain Interface is the interface between CometBFT and the application. Within the release of ABCI 2.0 for the 0.38 CometBFT release there were additional methods introduced.
samricotta marked this conversation as resolved.
Show resolved Hide resolved

The 5 methods introduced during ABCI 2.0 are:

- `PrepareProposal`
- `ProcessProposal`
- `ExtendVote`
- `VerifyVoteExtension`
- `FinalizeBlock`


## The Flow

## PrepareProposal

Based on their 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 is implemented. If no custom handler exists, all transactions are validated. Please see [this](https://github.com/fatal-fruit/abci-workshop) tutorial for more information on custom handlers.
samricotta marked this conversation as resolved.
Show resolved Hide resolved
samricotta marked this conversation as resolved.
Show resolved Hide resolved

Please note that vote extensions will only be available on the following height in which vote extensions are enabled. To see more details on vote extensions please see [here](https://docs.cosmos.network/main/build/abci++/01-vote-extensions).
samricotta marked this conversation as resolved.
Show resolved Hide resolved

After creating the proposal, the proposer returns it to CometBFT.

PrepareProposal CAN be non-deterministic.


## ExtendVote and VerifyVoteExtensions

These methods allow applications to extend the voting process by requiring validators to perform additional actions beyond simply validating blocks.

If vote extensions are enabled, `ExtendVote` will be called on every validator and each one will return its vote extension which is in practice a bunch of bytes. As mentioned above this data (vote extension) can only be retrieved in the next block height during `PrepareProposal`. Additionally, this data can be arbitrary, but in the provided tutorials, it serves as an oracle or proof of transactions in the mempool. Essentially, vote extensions are processed and injected as transactions. Examples of use-cases for vote extensions include prices for a price oracle or encryption shares for an encrypted transaction mempool. `ExtendVote` CAN be non-deterministic.

`VerifyVoteExtensions` is performed on every validator multiple times, so they can verify other validators' vote extensions. This check is submitted to validate the integrity and validity of the vote extensions preventing malicious or invalid vote extensions.

Additionally, applications must keep the vote extension data concise as it can degrade the performance of their chain.

`VerifyVoteExtensions` MUST be deterministic.


## ProcessProposal

This method allows validators to perform application-specific checks on the block proposal and is called on all validators. This is an important step in the consensus process, as it ensures that the block is valid and meets the requirements of the application. For example, validators could check that the block contains all the required transactions or that the block does not create any invalid state transitions.

The implementation of `ProcessProposal` MUST be deterministic.

## FinalizeBlock

`FinalizeBlock` is then called and is responsible for updating the state of the blockchain and making the block available to users
Copy link
Member

Choose a reason for hiding this comment

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

Just a reminder to add a redirect for this in the docs repo, so that the previous links continue to work as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes perf, thank you for the reminder

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ to consider the size of the vote extensions as they could increase latency in bl
production. See [here](https://github.com/cometbft/cometbft/blob/v0.38.0-rc1/docs/qa/CometBFT-QA-38.md#vote-extensions-testbed)
for more details.

Click [here](https://docs.cosmos.network/main/user/tutorials/vote-extensions) if you would like a walkthrough of how to implement vote extensions.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This link will be available once the tutorials are merged



## Verify Vote Extension

Similar to extending a vote, an application can also verify vote extensions from
Expand All @@ -51,6 +54,9 @@ validators will share the same view of what vote extensions they verify dependin
on how votes are propagated. See [here](https://github.com/cometbft/cometbft/blob/v0.38.0-rc1/spec/abci/abci++_methods.md#verifyvoteextension)
for more details.

Additionally, please keep in mind that performance can be degraded if vote extensions are too big (https://docs.cometbft.com/v0.38/qa/cometbft-qa-38#vote-extensions-testbed), so we highly recommend a size validation in `VerifyVoteExtensions`.


## Vote Extension Propagation

The agreed upon vote extensions at height `H` are provided to the proposing validator
Expand Down
Loading