Skip to content

Commit

Permalink
Merge branch 'main' into prune-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang authored Nov 29, 2024
2 parents 8c31b08 + 6cfe2dc commit 37f4ccb
Show file tree
Hide file tree
Showing 153 changed files with 3,253 additions and 1,856 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### Improvements

* RocksDB libraries have been upgraded to support RockDB v9 instead of v8.
* (testutil/integration) [#22616](https://github.com/cosmos/cosmos-sdk/pull/22616) Remove double context in integration tests v1.
* Use integrationApp.Context() instead of creating a context prior.

Expand Down
2 changes: 1 addition & 1 deletion api/cosmos/staking/v1beta1/staking.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,12 @@ func (app *BaseApp) FinalizeBlock(req *abci.FinalizeBlockRequest) (res *abci.Fin
defer func() {
// call the streaming service hooks with the FinalizeBlock messages
for _, streamingListener := range app.streamingManager.ABCIListeners {
if err := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); err != nil {
if streamErr := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); streamErr != nil {
app.logger.Error("ListenFinalizeBlock listening hook failed", "height", req.Height, "err", err)
if app.streamingManager.StopNodeOnErr {
// if StopNodeOnErr is set, we should return the streamErr in order to stop the node
err = streamErr
}
}
}
}()
Expand Down Expand Up @@ -976,12 +980,12 @@ func (app *BaseApp) Commit() (*abci.CommitResponse, error) {
rms.SetCommitHeader(header)
}

app.cms.Commit()

resp := &abci.CommitResponse{
RetainHeight: retainHeight,
}

app.cms.Commit()

abciListeners := app.streamingManager.ABCIListeners
if len(abciListeners) > 0 {
ctx := app.finalizeBlockState.Context()
Expand All @@ -991,6 +995,14 @@ func (app *BaseApp) Commit() (*abci.CommitResponse, error) {
for _, abciListener := range abciListeners {
if err := abciListener.ListenCommit(ctx, *resp, changeSet); err != nil {
app.logger.Error("Commit listening hook failed", "height", blockHeight, "err", err)
if app.streamingManager.StopNodeOnErr {
err = fmt.Errorf("Commit listening hook failed: %w", err)
rollbackErr := app.cms.RollbackToVersion(blockHeight - 1)
if rollbackErr != nil {
return nil, errors.Join(err, rollbackErr)
}
return nil, err
}
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion client/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func CheckCometError(err error, tx cmttypes.Tx) *sdk.TxResponse {
txHash := fmt.Sprintf("%X", tx.Hash())

switch {
case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())):
case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())) ||
strings.Contains(errStr, strings.ToLower(sdkerrors.ErrTxInMempoolCache.Error())):
return &sdk.TxResponse{
Code: sdkerrors.ErrTxInMempoolCache.ABCICode(),
Codespace: sdkerrors.ErrTxInMempoolCache.Codespace(),
Expand All @@ -73,6 +74,13 @@ func CheckCometError(err error, tx cmttypes.Tx) *sdk.TxResponse {
TxHash: txHash,
}

case strings.Contains(errStr, "no signatures supplied"):
return &sdk.TxResponse{
Code: sdkerrors.ErrNoSignatures.ABCICode(),
Codespace: sdkerrors.ErrNoSignatures.Codespace(),
TxHash: txHash,
}

default:
return nil
}
Expand Down
44 changes: 23 additions & 21 deletions client/v2/broadcast/comet/comet.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,24 @@ func (c *CometBFTBroadcaster) Broadcast(ctx context.Context, txBytes []byte) ([]
func (c *CometBFTBroadcaster) broadcast(ctx context.Context, txBytes []byte,
fn func(ctx context.Context, tx cmttypes.Tx) (*coretypes.ResultBroadcastTx, error),
) (*apiacbci.TxResponse, error) {
bResult, err := fn(ctx, txBytes)
res, err := fn(ctx, txBytes)
if errRes := checkCometError(err, txBytes); errRes != nil {
return errRes, nil
}

return newResponseFormatBroadcastTx(bResult), err
if res == nil {
return nil, err
}

parsedLogs, _ := parseABCILogs(res.Log)
return &apiacbci.TxResponse{
Code: res.Code,
Codespace: res.Codespace,
Data: res.Data.String(),
RawLog: res.Log,
Logs: parsedLogs,
Txhash: res.Hash.String(),
}, err
}

// checkCometError checks for errors returned by the CometBFT network and returns an appropriate TxResponse.
Expand All @@ -145,7 +157,8 @@ func checkCometError(err error, tx cmttypes.Tx) *apiacbci.TxResponse {
txHash := fmt.Sprintf("%X", tx.Hash())

switch {
case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())):
case strings.Contains(errStr, strings.ToLower(mempool.ErrTxInCache.Error())) ||
strings.Contains(errStr, strings.ToLower(sdkerrors.ErrTxInMempoolCache.Error())):
return &apiacbci.TxResponse{
Code: sdkerrors.ErrTxInMempoolCache.ABCICode(),
Codespace: sdkerrors.ErrTxInMempoolCache.Codespace(),
Expand All @@ -166,27 +179,16 @@ func checkCometError(err error, tx cmttypes.Tx) *apiacbci.TxResponse {
Txhash: txHash,
}

default:
return nil
}
}
case strings.Contains(errStr, "no signatures supplied"):
return &apiacbci.TxResponse{
Code: sdkerrors.ErrNoSignatures.ABCICode(),
Codespace: sdkerrors.ErrNoSignatures.Codespace(),
Txhash: txHash,
}

// newResponseFormatBroadcastTx returns a TxResponse given a ResultBroadcastTx from cometbft
func newResponseFormatBroadcastTx(res *coretypes.ResultBroadcastTx) *apiacbci.TxResponse {
if res == nil {
default:
return nil
}

parsedLogs, _ := parseABCILogs(res.Log)

return &apiacbci.TxResponse{
Code: res.Code,
Codespace: res.Codespace,
Data: res.Data.String(),
RawLog: res.Log,
Logs: parsedLogs,
Txhash: res.Hash.String(),
}
}

// parseABCILogs attempts to parse a stringified ABCI tx log into a slice of
Expand Down
26 changes: 12 additions & 14 deletions client/v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module cosmossdk.io/client/v2

go 1.23.1
go 1.23.3

require (
cosmossdk.io/api v0.7.6
Expand All @@ -25,6 +25,7 @@ require (
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/dgraph-io/ristretto/v2 v2.0.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
golang.org/x/arch v0.12.0 // indirect
Expand All @@ -33,12 +34,12 @@ require (
require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.2-20241120201313-68e42a58b301.1 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.2-20240130113600-88ef6483f90f.1 // indirect
cosmossdk.io/collections v0.4.1-0.20241104084251-838f1557af0a // indirect
cosmossdk.io/collections v0.4.1-0.20241128094659-bd76b47e1d8b // indirect
cosmossdk.io/core/testing v0.0.0-20241108153815-606544c7be7e // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/log v1.5.0
cosmossdk.io/math v1.4.0
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect
cosmossdk.io/schema v0.3.1-0.20241128094659-bd76b47e1d8b // indirect
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
Expand All @@ -49,7 +50,6 @@ require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.2.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
Expand All @@ -58,11 +58,11 @@ require (
github.com/cockroachdb/pebble v1.1.2 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v1.0.0-rc1.0.20240908111210-ab0be101882f
github.com/cometbft/cometbft-db v0.15.0 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1 // indirect
github.com/cometbft/cometbft v1.0.0-rc2.0.20241127125717-4ce33b646ac9
github.com/cometbft/cometbft-db v1.0.1 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc2 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.3-0.20240911104526-ddc3f09bfc22 // indirect
github.com/cosmos/cosmos-db v1.1.0 // indirect
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/gogoproto v1.7.0
Expand All @@ -72,16 +72,14 @@ require (
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/dgraph-io/badger/v4 v4.3.0 // indirect
github.com/dgraph-io/ristretto v0.1.2-0.20240116140435-c67e07994f91 // indirect
github.com/dgraph-io/badger/v4 v4.4.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/dot v1.6.2 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
Expand All @@ -91,7 +89,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -114,7 +112,7 @@ require (
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.9 // indirect
Expand All @@ -139,7 +137,7 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/rs/cors v1.11.1 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand Down
Loading

0 comments on commit 37f4ccb

Please sign in to comment.