Skip to content

Commit 67c3381

Browse files
fix: add v53 support, remove v52, fix scripts, etc (#282)
* append to versions.json * this works lol * works' * fix sidebar * fixes * ok * handle special case * add comment on special case * sync and banners * sync * fixed * re-sync * restore v47 directory contents
1 parent f94df2b commit 67c3381

File tree

657 files changed

+16336
-16636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

657 files changed

+16336
-16636
lines changed

docs/build/abci/00-introduction.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## What is ABCI?
44

5-
ABCI, Application Blockchain Interface is the interface between CometBFT and the application. More information about ABCI can be found in the specs [here](https://docs.cometbft.com/v1.0/spec/abci/). Within the release of ABCI 2.0 for the 0.38 CometBFT release there were additional methods introduced.
5+
ABC, Application Blockchain Interface is the interface between CometBFT and the application, more information about ABCI can be found [here](https://docs.cometbft.com/v0.38/spec/abci/). Within the release of ABCI 2.0 for the 0.38 CometBFT release there were additional methods introduced.
66

7-
The 5 methods introduced during ABCI 2.0 (compared to ABCI v0) are:
7+
The 5 methods introduced during ABCI 2.0 are:
88

99
* `PrepareProposal`
1010
* `ProcessProposal`
@@ -17,11 +17,11 @@ The 5 methods introduced during ABCI 2.0 (compared to ABCI v0) are:
1717

1818
## PrepareProposal
1919

20-
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.
20+
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.
2121

22-
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.
22+
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.
2323

24-
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).
24+
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/03-vote-extensions.md).
2525

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

@@ -41,11 +41,11 @@ If vote extensions are enabled, `ExtendVote` will be called on every validator a
4141

4242
`VerifyVoteExtensions` is performed on every validator multiple times in order to 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.
4343

44-
Additionally, applications must keep the vote extension data concise as it can degrade the performance of their chain, see testing results [here](https://docs.cometbft.com/v1.0/references/qa/cometbft-qa-38#vote-extensions-testbed).
44+
Additionally, applications must keep the vote extension data concise as it can degrade the performance of their chain, see testing results [here](https://docs.cometbft.com/v0.38/qa/cometbft-qa-38#vote-extensions-testbed).
4545

4646
`VerifyVoteExtensions` MUST be deterministic.
4747

4848

4949
## FinalizeBlock
5050

51-
`FinalizeBlock` is then called and is responsible for updating the state of the blockchain and making the block available to users.
51+
`FinalizeBlock` is then called and is responsible for updating the state of the blockchain and making the block available to users

docs/build/abci/01-prepare-proposal.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ it would like the block constructed.
2424

2525
The Cosmos SDK defines the `DefaultProposalHandler` type, which provides applications with
2626
`PrepareProposal` and `ProcessProposal` handlers. If you decide to implement your
27-
own `PrepareProposal` handler, you must ensure that the transactions
27+
own `PrepareProposal` handler, you must be sure to ensure that the transactions
2828
selected DO NOT exceed the maximum block gas (if set) and the maximum bytes provided
2929
by `req.MaxBytes`.
3030

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

3535
This default implementation can be overridden by the application developer in
36-
favor of a custom implementation in [`app_di.go`](https://docs.cosmos.network/main/build/building-apps/app-go-di):
36+
favor of a custom implementation in [`app.go`](../building-apps/01-app-go-v2.md):
3737

3838
```go
3939
prepareOpt := func(app *baseapp.BaseApp) {
40-
abciPropHandler := baseapp.NewDefaultProposalHandler(mempool, app)
41-
app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler())
40+
abciPropHandler := baseapp.NewDefaultProposalHandler(mempool, app)
41+
app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler())
4242
}
4343

4444
baseAppOptions = append(baseAppOptions, prepareOpt)
45-
```
45+
```

docs/build/abci/02-process-proposal.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
`ProcessProposal` handles the validation of a proposal from `PrepareProposal`,
44
which also includes a block header. Meaning, that after a block has been proposed
5-
the other validators have the right to accept or reject that block. The validator in the
5+
the other validators have the right to vote on a block. The validator in the
66
default implementation of `PrepareProposal` runs basic validity checks on each
77
transaction.
88

99
Note, `ProcessProposal` MAY NOT be non-deterministic, i.e. it must be deterministic.
1010
This means if `ProcessProposal` panics or fails and we reject, all honest validator
11-
processes should reject (i.e., prevote nil). If so, then CometBFT will start a new round with a new block proposal, and the same cycle will happen with `PrepareProposal`
12-
and `ProcessProposal` for the new proposal.
11+
processes will prevote nil and the CometBFT round will proceed again until a valid
12+
proposal is proposed.
1313

1414
Here is the implementation of the default implementation:
1515

1616
```go reference
17-
https://github.com/cosmos/cosmos-sdk/blob/v0.52.0-beta.1/baseapp/abci_utils.go#L224-L231
17+
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/baseapp/abci_utils.go#L153-L159
1818
```
1919

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

2525
```go
2626
processOpt := func(app *baseapp.BaseApp) {
27-
abciPropHandler := baseapp.NewDefaultProposalHandler(mempool, app)
28-
app.SetProcessProposal(abciPropHandler.ProcessProposalHandler())
27+
abciPropHandler := baseapp.NewDefaultProposalHandler(mempool, app)
28+
app.SetProcessProposal(abciPropHandler.ProcessProposalHandler())
2929
}
3030

3131
baseAppOptions = append(baseAppOptions, processOpt)

docs/build/abci/03-vote-extensions.md

Lines changed: 11 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,50 @@ defined in ABCI++.
77

88
## Extend Vote
99

10-
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
11-
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):
10+
ABCI++ allows an application to extend a pre-commit vote with arbitrary data. This
11+
process does NOT have to be deterministic, and the data returned can be unique to the
12+
validator process. The Cosmos SDK defines [`baseapp.ExtendVoteHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.50.1/types/abci.go#L26-L27):
1213

1314
```go
14-
type ExtendVoteHandler func(Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error)
15+
type ExtendVoteHandler func(Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error)
1516
```
1617

1718
An application can set this handler in `app.go` via the `baseapp.SetExtendVoteHandler`
1819
`BaseApp` option function. The `sdk.ExtendVoteHandler`, if defined, is called during
1920
the `ExtendVote` ABCI method. Note, if an application decides to implement
2021
`baseapp.ExtendVoteHandler`, it MUST return a non-nil `VoteExtension`. However, the vote
21-
extension can be empty. See [here](https://docs.cometbft.com/v1.0/spec/abci/abci++_methods#extendvote)
22+
extension can be empty. See [here](https://github.com/cometbft/cometbft/blob/v0.38.0-rc1/spec/abci/abci++_methods.md#extendvote)
2223
for more details.
2324

2425
There are many decentralized censorship-resistant use cases for vote extensions.
2526
For example, a validator may want to submit prices for a price oracle or encryption
2627
shares for an encrypted transaction mempool. Note, an application should be careful
2728
to consider the size of the vote extensions as they could increase latency in block
28-
production. See [here](https://docs.cometbft.com/v1.0/references/qa/cometbft-qa-38#vote-extensions-testbed)
29+
production. See [here](https://github.com/cometbft/cometbft/blob/v0.38.0-rc1/docs/qa/CometBFT-QA-38.md#vote-extensions-testbed)
2930
for more details.
3031

31-
Click [here](https://docs.cosmos.network/main/build/abci/vote-extensions) if you would like a walkthrough of how to implement vote extensions.
32+
Click [here](https://docs.cosmos.network/main/user/tutorials/vote-extensions) if you would like a walkthrough of how to implement vote extensions.
3233

3334

3435
## Verify Vote Extension
3536

3637
Similar to extending a vote, an application can also verify vote extensions from
3738
other validators when validating their pre-commits. For a given vote extension,
38-
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):
39+
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):
3940

4041
```go
41-
type VerifyVoteExtensionHandler func(Context, *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error)
42+
type VerifyVoteExtensionHandler func(Context, *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error)
4243
```
4344

4445
An application can set this handler in `app.go` via the `baseapp.SetVerifyVoteExtensionHandler`
4546
`BaseApp` option function. The `sdk.VerifyVoteExtensionHandler`, if defined, is called
4647
during the `VerifyVoteExtension` ABCI method. If an application defines a vote
4748
extension handler, it should also define a verification handler. Note, not all
4849
validators will share the same view of what vote extensions they verify depending
49-
on how votes are propagated. See [here](https://docs.cometbft.com/v1.0/spec/abci/abci++_methods#verifyvoteextension)
50+
on how votes are propagated. See [here](https://github.com/cometbft/cometbft/blob/v0.38.0-rc1/spec/abci/abci++_methods.md#verifyvoteextension)
5051
for more details.
5152

52-
Additionally, please keep in mind that performance can be degraded if vote extensions are too big ([see vote extension testbed](https://docs.cometbft.com/v1.0/references/qa/cometbft-qa-38#vote-extensions-testbed)), so we highly recommend a size validation in `VerifyVoteExtensions`.
53+
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`.
5354

5455

5556
## Vote Extension Propagation
@@ -120,163 +121,3 @@ func (k Keeper) BeginBlocker(ctx context.Context) error {
120121
return nil
121122
}
122123
```
123-
124-
## Vote Extensions on v2
125-
126-
### Extend Vote
127-
128-
In v2, the `ExtendVoteHandler` function works in the same way as it does in v1,
129-
but the implementation is passed as a server option when calling `cometbft.New`.
130-
131-
```go
132-
serverOptions.ExtendVoteHandler = CustomExtendVoteHandler()
133-
134-
func CustomExtendVoteHandler() handlers.ExtendVoteHandler {
135-
return func(ctx context.Context, rm store.ReaderMap, evr *v1.ExtendVoteRequest) (*v1.ExtendVoteResponse, error) {
136-
return &v1.ExtendVoteResponse{
137-
VoteExtension: []byte("BTC=1234567.89;height=" + fmt.Sprint(evr.Height)),
138-
}, nil
139-
}
140-
}
141-
```
142-
143-
### Verify Vote Extension
144-
145-
Same as above:
146-
147-
```go
148-
serverOptions.VerifyVoteExtensionHandler = CustomVerifyVoteExtensionHandler()
149-
150-
func CustomVerifyVoteExtensionHandler() handlers.VerifyVoteExtensionHandler {
151-
return func(context.Context, store.ReaderMap, *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) {
152-
return &abci.VerifyVoteExtensionResponse{}, nil
153-
}
154-
}
155-
156-
```
157-
158-
### Prepare and Process Proposal
159-
160-
These are also passed in as server options when calling `cometbft.New`.
161-
162-
```go
163-
serverOptions.PrepareProposalHandler = CustomPrepareProposal[T]()
164-
serverOptions.ProcessProposalHandler = CustomProcessProposalHandler[T]()
165-
```
166-
167-
The PrepareProposal handler can be used to inject vote extensions into the block proposal
168-
by using the `cometbft.RawTx` util function, which allows passing in arbitrary bytes.
169-
170-
```go
171-
func CustomPrepareProposal[T transaction.Tx]() handlers.PrepareHandler[T] {
172-
return func(ctx context.Context, app handlers.AppManager[T], codec transaction.Codec[T], req *v1.PrepareProposalRequest, chainID string) ([]T, error) {
173-
var txs []T
174-
for _, tx := range req.Txs {
175-
decTx, err := codec.Decode(tx)
176-
if err != nil {
177-
continue
178-
}
179-
180-
txs = append(txs, decTx)
181-
}
182-
183-
// "Process" vote extensions (we'll just inject all votes)
184-
injectedTx, err := json.Marshal(req.LocalLastCommit)
185-
if err != nil {
186-
return nil, err
187-
}
188-
189-
// put the injected tx into the first position
190-
txs = append([]T{cometbft.RawTx(injectedTx).(T)}, txs...)
191-
192-
return txs, nil
193-
}
194-
}
195-
```
196-
197-
The ProcessProposal handler can be used to recover the vote extensions from the first transaction
198-
and perform any necessary verification on them. In the example below we also use the
199-
`cometbft.ValidateVoteExtensions` util to verify the signature of the vote extensions;
200-
this function takes a "validatorStore" function that returns the public key of a validator
201-
given its consensus address. In the example we use the default staking module to get the
202-
validators.
203-
204-
```go
205-
func CustomProcessProposalHandler[T transaction.Tx]() handlers.ProcessHandler[T] {
206-
return func(ctx context.Context, am handlers.AppManager[T], c transaction.Codec[T], req *v1.ProcessProposalRequest, chainID string) error {
207-
// Get all vote extensions from the first tx
208-
209-
injectedTx := req.Txs[0]
210-
var voteExts v1.ExtendedCommitInfo
211-
if err := json.Unmarshal(injectedTx, &voteExts); err != nil {
212-
return err
213-
}
214-
215-
// Get validators from the staking module
216-
res, err := am.Query(
217-
ctx,
218-
0,
219-
&staking.QueryValidatorsRequest{},
220-
)
221-
if err != nil {
222-
return err
223-
}
224-
225-
validatorsResponse := res.(*staking.QueryValidatorsResponse)
226-
consAddrToPubkey := map[string]cryptotypes.PubKey{}
227-
228-
for _, val := range validatorsResponse.GetValidators() {
229-
cv := val.ConsensusPubkey.GetCachedValue()
230-
if cv == nil {
231-
return fmt.Errorf("public key cached value is nil")
232-
}
233-
234-
cpk, ok := cv.(cryptotypes.PubKey)
235-
if ok {
236-
consAddrToPubkey[string(cpk.Address().Bytes())] = cpk
237-
} else {
238-
return fmt.Errorf("invalid public key type")
239-
}
240-
}
241-
242-
// First verify that the vote extensions injected by the proposer are correct
243-
if err := cometbft.ValidateVoteExtensions(
244-
ctx,
245-
am,
246-
chainID,
247-
func(ctx context.Context, b []byte) (cryptotypes.PubKey, error) {
248-
if _, ok := consAddrToPubkey[string(b)]; !ok {
249-
return nil, fmt.Errorf("validator not found")
250-
}
251-
return consAddrToPubkey[string(b)], nil
252-
},
253-
voteExts,
254-
req.Height,
255-
&req.ProposedLastCommit,
256-
); err != nil {
257-
return err
258-
}
259-
260-
// TODO: do something with the vote extensions
261-
262-
return nil
263-
}
264-
}
265-
```
266-
267-
268-
### Preblocker
269-
270-
In v2, the `PreBlocker` function works in the same way as it does in v1. However, it is
271-
now passed in as an option to `appbuilder.Build`.
272-
273-
```go
274-
app.App, err = appBuilder.Build(runtime.AppBuilderWithPreblocker(
275-
func(ctx context.Context, txs []T) error {
276-
// to recover the vote extension use
277-
voteExtBz := txs[0].Bytes()
278-
err := doSomethingWithVoteExt(voteExtBz)
279-
return err
280-
},
281-
))
282-
```

docs/build/abci/04-checktx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ https://github.com/cosmos/cosmos-sdk/blob/31c604762a434c7b676b6a89897ecbd7c4653a
2020

2121
## CheckTx Handler
2222

23-
`CheckTxHandler` allows users to extend the logic of `CheckTx`. `CheckTxHandler` is called by pasding context and the transaction bytes received through ABCI. It is required that the handler returns deterministic results given the same transaction bytes.
23+
`CheckTxHandler` allows users to extend the logic of `CheckTx`. `CheckTxHandler` is called by passing context and the transaction bytes received through ABCI. It is required that the handler returns deterministic results given the same transaction bytes.
2424

2525
:::note
2626
we return the raw decoded transaction here to avoid decoding it twice.

0 commit comments

Comments
 (0)