Skip to content

Commit 7b69a9b

Browse files
tac0turtlegithub-actions[bot]
authored andcommitted
chore: Sync docs from cosmos-sdk/docs
1 parent 4845163 commit 7b69a9b

35 files changed

+162
-236
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ABCI 2.0 (colloquially called ABCI++) allows an application to extend a pre-comm
1111
validator process. The Cosmos SDK defines [`baseapp.ExtendVoteHandler`](https://github.com/cosmos/cosmos-sdk/blob/v0.53.0/types/abci.go#L32):
1212

1313
```go
14-
type ExtendVoteHandler func(Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error)
14+
type ExtendVoteHandler func(Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error)
1515
```
1616

1717
An application can set this handler in `app.go` via the `baseapp.SetExtendVoteHandler`
@@ -38,7 +38,7 @@ other validators when validating their pre-commits. For a given vote extension,
3838
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):
3939

4040
```go
41-
type VerifyVoteExtensionHandler func(Context, *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error)
41+
type VerifyVoteExtensionHandler func(Context, *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error)
4242
```
4343

4444
An application can set this handler in `app.go` via the `baseapp.SetVerifyVoteExtensionHandler`
@@ -78,7 +78,7 @@ will be available to the application during the subsequent `FinalizeBlock` call.
7878
An example of how a pre-FinalizeBlock hook could look like is shown below:
7979

8080
```go
81-
app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error {
81+
app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) error {
8282
allVEs := []VE{} // store all parsed vote extensions here
8383
for _, tx := range req.Txs {
8484
// define a custom function that tries to parse the tx as a vote extension

docs/build/architecture/adr-038-state-listening.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* 10/14/2022:
88
* Add `ListenCommit`, flatten the state writes in a block to a single batch.
99
* Remove listeners from cache stores, should only listen to `rootmulti.Store`.
10-
* Remove `HaltAppOnDeliveryError()`, the errors are propagated by default, the implementations should return nil if they don't want to propagate errors.
10+
* Remove `HaltAppOnDeliveryError()`, the errors are propagated by default, the implementations should return nil if don't want to propogate errors.
1111
* 26/05/2023: Update with ABCI 2.0
1212

1313
## Status
@@ -20,7 +20,7 @@ This ADR defines a set of changes to enable listening to state changes of indivi
2020

2121
## Context
2222

23-
Currently, KVStore data can be remotely accessed through [Queries](https://docs.cosmos.network/main/build/building-modules/messages-and-queries#queries)
23+
Currently, KVStore data can be remotely accessed through [Queries](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/messages-and-queries.md#queries)
2424
which proceed either through Tendermint and the ABCI, or through the gRPC server.
2525
In addition to these request/response queries, it would be beneficial to have a means of listening to state changes as they occur in real time.
2626

@@ -40,7 +40,7 @@ type MemoryListener struct {
4040
stateCache []StoreKVPair
4141
}
4242

43-
// NewMemoryListener creates a listener that accumulates the state writes in memory.
43+
// NewMemoryListener creates a listener that accumulate the state writes in memory.
4444
func NewMemoryListener() *MemoryListener {
4545
return &MemoryListener{}
4646
}
@@ -114,7 +114,7 @@ func (s *Store) Delete(key []byte) {
114114

115115
### MultiStore interface updates
116116

117-
We will update the `CommitMultiStore` interface to allow us to wrap a `MemoryListener` to a specific `KVStore`.
117+
We will update the `CommitMultiStore` interface to allow us to wrap a `Memorylistener` to a specific `KVStore`.
118118
Note that the `MemoryListener` will be attached internally by the concrete `rootmulti` implementation.
119119

120120
```go
@@ -224,9 +224,9 @@ so that the service can group the state changes with the ABCI requests.
224224
// ABCIListener is the interface that we're exposing as a streaming service.
225225
type ABCIListener interface {
226226
// ListenFinalizeBlock updates the streaming service with the latest FinalizeBlock messages
227-
ListenFinalizeBlock(ctx context.Context, req abci.FinalizeBlockRequest, res abci.FinalizeBlockResponse) error
228-
// ListenCommit updates the streaming service with the latest Commit messages and state changes
229-
ListenCommit(ctx context.Context, res abci.CommitResponse, changeSet []*StoreKVPair) error
227+
ListenFinalizeBlock(ctx context.Context, req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) error
228+
// ListenCommit updates the steaming service with the latest Commit messages and state changes
229+
ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*StoreKVPair) error
230230
}
231231
```
232232

@@ -267,16 +267,16 @@ We will modify the `FinalizeBlock` and `Commit` methods to pass ABCI requests an
267267
to any streaming service hooks registered with the `BaseApp`.
268268

269269
```go
270-
func (app *BaseApp) FinalizeBlock(req abci.FinalizeBlockRequest) abci.FinalizeBlockResponse {
270+
func (app *BaseApp) FinalizeBlock(req abci.RequestFinalizeBlock) abci.ResponseFinalizeBlock {
271271

272-
var abciRes abci.FinalizeBlockResponse
272+
var abciRes abci.ResponseFinalizeBlock
273273
defer func() {
274274
// call the streaming service hook with the FinalizeBlock messages
275275
for _, abciListener := range app.abciListeners {
276276
ctx := app.finalizeState.ctx
277277
blockHeight := ctx.BlockHeight()
278278
if app.abciListenersAsync {
279-
go func(req abci.FinalizeBlockRequest, res abci.FinalizeBlockResponse) {
279+
go func(req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) {
280280
if err := app.abciListener.FinalizeBlock(blockHeight, req, res); err != nil {
281281
app.logger.Error("FinalizeBlock listening hook failed", "height", blockHeight, "err", err)
282282
}
@@ -299,11 +299,11 @@ func (app *BaseApp) FinalizeBlock(req abci.FinalizeBlockRequest) abci.FinalizeBl
299299
```
300300

301301
```go
302-
func (app *BaseApp) Commit() abci.CommitResponse {
302+
func (app *BaseApp) Commit() abci.ResponseCommit {
303303

304304
...
305305

306-
res := abci.CommitResponse{
306+
res := abci.ResponseCommit{
307307
Data: commitID.Hash,
308308
RetainHeight: retainHeight,
309309
}
@@ -314,7 +314,7 @@ func (app *BaseApp) Commit() abci.CommitResponse {
314314
blockHeight := ctx.BlockHeight()
315315
changeSet := app.cms.PopStateCache()
316316
if app.abciListenersAsync {
317-
go func(res abci.CommitResponse, changeSet []store.StoreKVPair) {
317+
go func(res abci.ResponseCommit, changeSet []store.StoreKVPair) {
318318
if err := app.abciListener.ListenCommit(ctx, res, changeSet); err != nil {
319319
app.logger.Error("ListenCommit listening hook failed", "height", blockHeight, "err", err)
320320
}
@@ -354,7 +354,7 @@ var Handshake = plugin.HandshakeConfig{
354354
MagicCookieValue: "ef78114d-7bdf-411c-868f-347c99a78345",
355355
}
356356

357-
// ListenerPlugin is the base struct for all kinds of go-plugin implementations
357+
// ListenerPlugin is the base struc for all kinds of go-plugin implementations
358358
// It will be included in interfaces of different Plugins
359359
type ABCIListenerPlugin struct {
360360
// GRPCPlugin must still implement the Plugin interface
@@ -433,13 +433,13 @@ type GRPCClient struct {
433433
client ABCIListenerServiceClient
434434
}
435435

436-
func (m *GRPCClient) ListenFinalizeBlock(goCtx context.Context, req abci.FinalizeBlockRequest, res abci.FinalizeBlockResponse) error {
436+
func (m *GRPCClient) ListenFinalizeBlock(goCtx context.Context, req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) error {
437437
ctx := sdk.UnwrapSDKContext(goCtx)
438438
_, err := m.client.ListenDeliverTx(ctx, &ListenDeliverTxRequest{BlockHeight: ctx.BlockHeight(), Req: req, Res: res})
439439
return err
440440
}
441441

442-
func (m *GRPCClient) ListenCommit(goCtx context.Context, res abci.CommitResponse, changeSet []store.StoreKVPair) error {
442+
func (m *GRPCClient) ListenCommit(goCtx context.Context, res abci.ResponseCommit, changeSet []store.StoreKVPair) error {
443443
ctx := sdk.UnwrapSDKContext(goCtx)
444444
_, err := m.client.ListenCommit(ctx, &ListenCommitRequest{BlockHeight: ctx.BlockHeight(), Res: res, ChangeSet: changeSet})
445445
return err
@@ -471,11 +471,11 @@ And the pre-compiled Go plugin `Impl`(*this is only used for plugins that are wr
471471
// ABCIListener is the implementation of the baseapp.ABCIListener interface
472472
type ABCIListener struct{}
473473

474-
func (m *ABCIListenerPlugin) ListenFinalizeBlock(ctx context.Context, req abci.FinalizeBlockRequest, res abci.FinalizeBlockResponse) error {
474+
func (m *ABCIListenerPlugin) ListenFinalizeBlock(ctx context.Context, req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) error {
475475
// send data to external system
476476
}
477477

478-
func (m *ABCIListenerPlugin) ListenCommit(ctx context.Context, res abci.CommitResponse, changeSet []store.StoreKVPair) error {
478+
func (m *ABCIListenerPlugin) ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []store.StoreKVPair) error {
479479
// send data to external system
480480
}
481481

@@ -529,7 +529,7 @@ func NewStreamingPlugin(name string, logLevel string) (interface{}, error) {
529529

530530
We propose a `RegisterStreamingPlugin` function for the App to register `NewStreamingPlugin`s with the App's BaseApp.
531531
Streaming plugins can be of `Any` type; therefore, the function takes in an interface vs a concrete type.
532-
For example, we could have plugins of `ABCIListener`, `WasmListener` or `IBCListener`. Note that `RegisterStreamingPlugin` function
532+
For example, we could have plugins of `ABCIListener`, `WasmListener` or `IBCListener`. Note that `RegisterStreamingPluing` function
533533
is helper function and not a requirement. Plugin registration can easily be moved from the App to the BaseApp directly.
534534

535535
```go
@@ -720,5 +720,5 @@ These changes will provide a means of subscribing to KVStore state changes in re
720720
721721
### Neutral
722722
723-
* Introduces additionalbut optionalcomplexity to configuring and running a cosmos application
723+
* Introduces additional- but optional- complexity to configuring and running a cosmos application
724724
* If an application developer opts to use these features to expose data, they need to be aware of the ramifications/risks of that data exposure as it pertains to the specifics of their application

docs/build/architecture/adr-040-storage-and-smt-state-commitments.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ A new database snapshot will be created in every `EndBlocker` and identified by
9292
NOTE: `Commit` must be called exactly once per block. Otherwise we risk going out of sync for the version number and block height.
9393
NOTE: For the Cosmos SDK storage, we may consider splitting that interface into `Committer` and `PruningCommitter` - only the multiroot should implement `PruningCommitter` (cache and prefix store don't need pruning).
9494

95-
Number of historical versions for `abci.QueryRequest` and state sync snapshots is part of a node configuration, not a chain configuration (configuration implied by the blockchain consensus). A configuration should allow to specify number of past blocks and number of past blocks modulo some number (eg: 100 past blocks and one snapshot every 100 blocks for past 2000 blocks). Archival nodes can keep all past versions.
95+
Number of historical versions for `abci.RequestQuery` and state sync snapshots is part of a node configuration, not a chain configuration (configuration implied by the blockchain consensus). A configuration should allow to specify number of past blocks and number of past blocks modulo some number (eg: 100 past blocks and one snapshot every 100 blocks for past 2000 blocks). Archival nodes can keep all past versions.
9696

9797
Pruning old snapshots is effectively done by a database. Whenever we update a record in `SC`, SMT won't update nodes - instead it creates new nodes on the update path, without removing the old one. Since we are snapshotting each block, we need to change that mechanism to immediately remove orphaned nodes from the database. This is a safe operation - snapshots will keep track of the records and make it available when accessing past versions.
9898

9999
To manage the active snapshots we will either use a DB _max number of snapshots_ option (if available), or we will remove DB snapshots in the `EndBlocker`. The latter option can be done efficiently by identifying snapshots with block height and calling a store function to remove past versions.
100100

101101
#### Accessing old state versions
102102

103-
One of the functional requirements is to access old state. This is done through `abci.QueryRequest` structure. The version is specified by a block height (so we query for an object by a key `K` at block height `H`). The number of old versions supported for `abci.QueryRequest` is configurable. Accessing an old state is done by using available snapshots.
104-
`abci.QueryRequest` doesn't need old state of `SC` unless the `prove=true` parameter is set. The SMT merkle proof must be included in the `abci.QueryResponse` only if both `SC` and `SS` have a snapshot for requested version.
103+
One of the functional requirements is to access old state. This is done through `abci.RequestQuery` structure. The version is specified by a block height (so we query for an object by a key `K` at block height `H`). The number of old versions supported for `abci.RequestQuery` is configurable. Accessing an old state is done by using available snapshots.
104+
`abci.RequestQuery` doesn't need old state of `SC` unless the `prove=true` parameter is set. The SMT merkle proof must be included in the `abci.ResponseQuery` only if both `SC` and `SS` have a snapshot for requested version.
105105

106106
Moreover, Cosmos SDK could provide a way to directly access a historical state. However, a state machine shouldn't do that - since the number of snapshots is configurable, it would lead to nondeterministic execution.
107107

docs/build/architecture/adr-060-abci-1.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Instead, we will define an additional ABCI interface method on the existing
169169
or `EndBlock`. This new interface method will be defined as follows:
170170

171171
```go
172-
ProcessProposal(sdk.Context, abci.ProcessProposalRequest) error {}
172+
ProcessProposal(sdk.Context, abci.RequestProcessProposal) error {}
173173
```
174174

175175
Note, we must call `ProcessProposal` with a new internal branched state on the

docs/build/architecture/adr-063-core-module-api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ func NewKeeper(logger log.Logger) Keeper {
192192
}
193193
```
194194

195-
```
196-
197195
### Core `AppModule` extension interfaces
198196

199197

docs/build/architecture/adr-064-abci-2.0.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ vote extensions.
103103
We propose the following new handlers for applications to implement:
104104

105105
```go
106-
type ExtendVoteHandler func(sdk.Context, abci.ExtendVoteRequest) abci.ExtendVoteResponse
107-
type VerifyVoteExtensionHandler func(sdk.Context, abci.VerifyVoteExtensionRequest) abci.VerifyVoteExtensionResponse
106+
type ExtendVoteHandler func(sdk.Context, abci.RequestExtendVote) abci.ResponseExtendVote
107+
type VerifyVoteExtensionHandler func(sdk.Context, abci.RequestVerifyVoteExtension) abci.ResponseVerifyVoteExtension
108108
```
109109

110110
An ephemeral context and state will be supplied to both handlers. The
@@ -144,7 +144,7 @@ type VoteExtensionHandler struct {
144144

145145
// ExtendVoteHandler can do something with h.mk and possibly h.state to create
146146
// a vote extension, such as fetching a series of prices for supported assets.
147-
func (h VoteExtensionHandler) ExtendVoteHandler(ctx sdk.Context, req abci.ExtendVoteRequest) abci.ExtendVoteResponse {
147+
func (h VoteExtensionHandler) ExtendVoteHandler(ctx sdk.Context, req abci.RequestExtendVote) abci.ResponseExtendVote {
148148
prices := GetPrices(ctx, h.mk.Assets())
149149
bz, err := EncodePrices(h.cdc, prices)
150150
if err != nil {
@@ -156,30 +156,30 @@ func (h VoteExtensionHandler) ExtendVoteHandler(ctx sdk.Context, req abci.Extend
156156
// NOTE: Vote extensions can be overridden since we can timeout in a round.
157157
SetPrices(h.state, req, bz)
158158

159-
return abci.ExtendVoteResponse{VoteExtension: bz}
159+
return abci.ResponseExtendVote{VoteExtension: bz}
160160
}
161161

162162
// VerifyVoteExtensionHandler can do something with h.state and req to verify
163163
// the req.VoteExtension field, such as ensuring the provided oracle prices are
164164
// within some valid range of our prices.
165-
func (h VoteExtensionHandler) VerifyVoteExtensionHandler(ctx sdk.Context, req abci.VerifyVoteExtensionRequest) abci.VerifyVoteExtensionResponse {
165+
func (h VoteExtensionHandler) VerifyVoteExtensionHandler(ctx sdk.Context, req abci.RequestVerifyVoteExtension) abci.ResponseVerifyVoteExtension {
166166
prices, err := DecodePrices(h.cdc, req.VoteExtension)
167167
if err != nil {
168168
log("failed to decode vote extension", "err", err)
169-
return abci.VerifyVoteExtensionResponse{Status: REJECT}
169+
return abci.ResponseVerifyVoteExtension{Status: REJECT}
170170
}
171171

172172
if err := ValidatePrices(h.state, req, prices); err != nil {
173173
log("failed to validate vote extension", "prices", prices, "err", err)
174-
return abci.VerifyVoteExtensionResponse{Status: REJECT}
174+
return abci.ResponseVerifyVoteExtension{Status: REJECT}
175175
}
176176

177177
// store updated vote extensions at the given height
178178
//
179179
// NOTE: Vote extensions can be overridden since we can timeout in a round.
180180
SetPrices(h.state, req, req.VoteExtension)
181181

182-
return abci.VerifyVoteExtensionResponse{Status: ACCEPT}
182+
return abci.ResponseVerifyVoteExtension{Status: ACCEPT}
183183
}
184184
```
185185

@@ -301,7 +301,7 @@ during `ProcessProposal` because during replay, CometBFT will NOT call `ProcessP
301301
which would result in an incomplete state view.
302302

303303
```go
304-
func (a MyApp) PreBlocker(ctx sdk.Context, req *abci.FinalizeBlockRequest) error {
304+
func (a MyApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) error {
305305
voteExts := GetVoteExtensions(ctx, req.Txs)
306306

307307
// Process and perform some compute on vote extensions, storing any resulting
@@ -350,7 +350,7 @@ legacy ABCI types, e.g. `LegacyBeginBlockRequest` and `LegacyEndBlockRequest`. O
350350
we can come up with new types and names altogether.
351351

352352
```go
353-
func (app *BaseApp) FinalizeBlock(req abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) {
353+
func (app *BaseApp) FinalizeBlock(req abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
354354
ctx := ...
355355

356356
if app.preBlocker != nil {
@@ -375,7 +375,7 @@ func (app *BaseApp) FinalizeBlock(req abci.FinalizeBlockRequest) (*abci.Finalize
375375
endBlockResp, err := app.endBlock(app.finalizeBlockState.ctx)
376376
appendBlockEventAttr(beginBlockResp.Events, "end_block")
377377

378-
return abci.FinalizeBlockResponse{
378+
return abci.ResponseFinalizeBlock{
379379
TxResults: txExecResults,
380380
Events: joinEvents(beginBlockResp.Events, endBlockResp.Events),
381381
ValidatorUpdates: endBlockResp.ValidatorUpdates,

docs/build/building-apps/04-vote-extensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ process does NOT have to be deterministic, and the data returned can be unique t
1616
validator process. The Cosmos SDK defines `baseapp.ExtendVoteHandler`:
1717

1818
```go
19-
type ExtendVoteHandler func(Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error)
19+
type ExtendVoteHandler func(Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error)
2020
```
2121

2222
An application can set this handler in `app.go` via the `baseapp.SetExtendVoteHandler`
@@ -77,7 +77,7 @@ will be available to the application during the subsequent `FinalizeBlock` call.
7777
An example of how a pre-FinalizeBlock hook could look is shown below:
7878

7979
```go
80-
app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error {
80+
app.SetPreBlocker(func(ctx sdk.Context, req *abci.RequestFinalizeBlock) error {
8181
allVEs := []VE{} // store all parsed vote extensions here
8282
for _, tx := range req.Txs {
8383
// define a custom function that tries to parse the tx as a vote extension

0 commit comments

Comments
 (0)