feat: Update Cosmos SDK to CometBFT v2 (#24837)
Co-authored-by: aljo242 <alex@interchainlabs.io>
This commit is contained in:
co-authored by
aljo242
parent
b78a6c660e
commit
fd170b5140
+9
-8
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/grpc/codes"
|
||||
grpcstatus "google.golang.org/grpc/status"
|
||||
@@ -286,7 +286,7 @@ func (app *BaseApp) OfferSnapshot(req *abci.OfferSnapshotRequest) (*abci.OfferSn
|
||||
return &abci.OfferSnapshotResponse{Result: abci.OFFER_SNAPSHOT_RESULT_REJECT}, nil
|
||||
|
||||
default:
|
||||
// CometBFT errors are defined here: https://github.com/cometbft/cometbft/blob/main/statesync/syncer.go
|
||||
// CometBFT errors are defined here: https://github.com/cometbft/cometbft/v2/blob/main/statesync/syncer.go
|
||||
// It may happen that in case of a CometBFT error, such as a timeout (which occurs after two minutes),
|
||||
// the process is aborted. This is done intentionally because deleting the database programmatically
|
||||
// can lead to more complicated situations.
|
||||
@@ -389,7 +389,7 @@ func (app *BaseApp) CheckTx(req *abci.CheckTxRequest) (*abci.CheckTxResponse, er
|
||||
// provided by the client's request.
|
||||
//
|
||||
// Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
|
||||
// Ref: https://github.com/cometbft/cometbft/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
|
||||
// Ref: https://github.com/cometbft/cometbft/v2/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
|
||||
func (app *BaseApp) PrepareProposal(req *abci.PrepareProposalRequest) (resp *abci.PrepareProposalResponse, err error) {
|
||||
if app.abciHandlers.PrepareProposalHandler == nil {
|
||||
return nil, errors.New("PrepareProposal handler not set")
|
||||
@@ -409,7 +409,7 @@ func (app *BaseApp) PrepareProposal(req *abci.PrepareProposalRequest) (resp *abc
|
||||
|
||||
// CometBFT must never call PrepareProposal with a height of 0.
|
||||
//
|
||||
// Ref: https://github.com/cometbft/cometbft/blob/059798a4f5b0c9f52aa8655fa619054a0154088c/spec/core/state.md?plain=1#L37-L38
|
||||
// Ref: https://github.com/cometbft/cometbft/v2/blob/059798a4f5b0c9f52aa8655fa619054a0154088c/spec/core/state.md?plain=1#L37-L38
|
||||
if req.Height < 1 {
|
||||
return nil, errors.New("PrepareProposal called with invalid height")
|
||||
}
|
||||
@@ -468,14 +468,14 @@ func (app *BaseApp) PrepareProposal(req *abci.PrepareProposalRequest) (resp *abc
|
||||
// handler, it will be recovered and we will reject the proposal.
|
||||
//
|
||||
// Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
|
||||
// Ref: https://github.com/cometbft/cometbft/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
|
||||
// Ref: https://github.com/cometbft/cometbft/v2/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
|
||||
func (app *BaseApp) ProcessProposal(req *abci.ProcessProposalRequest) (resp *abci.ProcessProposalResponse, err error) {
|
||||
if app.abciHandlers.ProcessProposalHandler == nil {
|
||||
return nil, errors.New("ProcessProposal handler not set")
|
||||
}
|
||||
|
||||
// CometBFT must never call ProcessProposal with a height of 0.
|
||||
// Ref: https://github.com/cometbft/cometbft/blob/059798a4f5b0c9f52aa8655fa619054a0154088c/spec/core/state.md?plain=1#L37-L38
|
||||
// Ref: https://github.com/cometbft/cometbft/v2/blob/059798a4f5b0c9f52aa8655fa619054a0154088c/spec/core/state.md?plain=1#L37-L38
|
||||
if req.Height < 1 {
|
||||
return nil, errors.New("ProcessProposal called with invalid height")
|
||||
}
|
||||
@@ -868,6 +868,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz
|
||||
TxResults: txResults,
|
||||
ValidatorUpdates: endBlock.ValidatorUpdates,
|
||||
ConsensusParamUpdates: &cp,
|
||||
NextBlockDelay: app.nextBlockDelay,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -876,7 +877,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz
|
||||
// by the transactions in the proposal, finally followed by the application's
|
||||
// EndBlock (if defined).
|
||||
//
|
||||
// For each raw transaction, i.e. a byte slice, BaseApp will only execute it if
|
||||
// For each raw transaction, i.e., a byte slice, BaseApp will only execute it if
|
||||
// it adheres to the sdk.Tx interface. Otherwise, the raw transaction will be
|
||||
// skipped. This is to support compatibility with proposers injecting vote
|
||||
// extensions into the proposal, which should not themselves be executed in cases
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
"github.com/cometbft/cometbft/crypto/secp256k1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
"github.com/cometbft/cometbft/v2/crypto/secp256k1"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
protoio "github.com/cosmos/gogoproto/io"
|
||||
"github.com/cosmos/gogoproto/jsonpb"
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cryptoenc "github.com/cometbft/cometbft/crypto/encoding"
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
cryptoenc "github.com/cometbft/cometbft/v2/crypto/encoding"
|
||||
cmttypes "github.com/cometbft/cometbft/v2/types"
|
||||
protoio "github.com/cosmos/gogoproto/io"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
@@ -156,7 +156,7 @@ func ValidateVoteExtensions(
|
||||
// validateExtendedCommitAgainstLastCommit validates an ExtendedCommitInfo against a LastCommit. Specifically,
|
||||
// it checks that the ExtendedCommit + LastCommit (for the same height), are consistent with each other + that
|
||||
// they are ordered correctly (by voting power) in accordance with
|
||||
// [comet](https://github.com/cometbft/cometbft/blob/4ce0277b35f31985bbf2c25d3806a184a4510010/types/validator_set.go#L784).
|
||||
// [comet](https://github.com/cometbft/cometbft/v2/blob/4ce0277b35f31985bbf2c25d3806a184a4510010/types/validator_set.go#L784).
|
||||
func validateExtendedCommitAgainstLastCommit(ec abci.ExtendedCommitInfo, lc comet.CommitInfo) error {
|
||||
// check that the rounds are the same
|
||||
if ec.Round != lc.Round() {
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtprotocrypto "github.com/cometbft/cometbft/api/cometbft/crypto/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtsecp256k1 "github.com/cometbft/cometbft/crypto/secp256k1"
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
cmtsecp256k1 "github.com/cometbft/cometbft/v2/crypto/secp256k1"
|
||||
cmttypes "github.com/cometbft/cometbft/v2/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
protoio "github.com/cosmos/gogoproto/io"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
|
||||
+14
-4
@@ -8,11 +8,12 @@ import (
|
||||
"slices"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/cockroachdb/errors"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
"github.com/cometbft/cometbft/crypto/tmhash"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
"github.com/cometbft/cometbft/v2/crypto/tmhash"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
protov2 "google.golang.org/protobuf/proto"
|
||||
@@ -55,6 +56,10 @@ const (
|
||||
execModeVoteExtension = sdk.ExecModeVoteExtension // Extend or verify a pre-commit vote
|
||||
execModeVerifyVoteExtension = sdk.ExecModeVerifyVoteExtension // Verify a vote extension
|
||||
execModeFinalize = sdk.ExecModeFinalize // Finalize a block proposal
|
||||
|
||||
// defaultNextBlockDelay is chosen following documentation in CometBFT:
|
||||
// https://github.com/cometbft/cometbft/blob/88ef3d267de491db98a654be0af6d791e8724ed0/spec/abci/abci%2B%2B_methods.md?plain=1#L689
|
||||
defaultNextBlockDelay = time.Second
|
||||
)
|
||||
|
||||
var _ servertypes.ABCI = (*BaseApp)(nil)
|
||||
@@ -108,6 +113,10 @@ type BaseApp struct {
|
||||
// flag for sealing options and parameters to a BaseApp
|
||||
sealed bool
|
||||
|
||||
// nextBlockDelay is the delay to wait until the next block after ABCI has committed.
|
||||
// This gives the application more time to receive precommits.
|
||||
nextBlockDelay time.Duration
|
||||
|
||||
// block height at which to halt the chain and gracefully shutdown
|
||||
haltHeight uint64
|
||||
|
||||
@@ -173,7 +182,7 @@ func NewBaseApp(
|
||||
logger: logger.With(log.ModuleKey, "baseapp"),
|
||||
name: name,
|
||||
db: db,
|
||||
cms: store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics()), // by default we use a no-op metric gather in store
|
||||
cms: store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics()), // by default, we use a no-op metric gather in store
|
||||
storeLoader: DefaultStoreLoader,
|
||||
grpcQueryRouter: NewGRPCQueryRouter(),
|
||||
msgServiceRouter: NewMsgServiceRouter(),
|
||||
@@ -181,6 +190,7 @@ func NewBaseApp(
|
||||
fauxMerkleMode: false,
|
||||
sigverifyTx: true,
|
||||
gasConfig: config.GasConfig{QueryGasLimit: math.MaxUint64},
|
||||
nextBlockDelay: defaultNextBlockDelay,
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
cmtjson "github.com/cometbft/cometbft/libs/json"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
cmtjson "github.com/cometbft/cometbft/v2/libs/json"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package baseapp
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cometbft/cometbft/v2/abci/types"
|
||||
|
||||
"cosmossdk.io/core/genesis"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
gogogrpc "github.com/cosmos/gogoproto/grpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/encoding"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
gogogrpc "github.com/cosmos/gogoproto/grpc"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package baseapp
|
||||
import (
|
||||
"time"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
|
||||
"cosmossdk.io/core/comet"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"cosmossdk.io/log"
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
|
||||
@@ -333,6 +334,20 @@ func (app *BaseApp) SetMempool(mempool mempool.Mempool) {
|
||||
app.mempool = mempool
|
||||
}
|
||||
|
||||
// SetNextBlockDelay sets the next block delay for the baseapp.
|
||||
//
|
||||
// The application is initialized with a default value of 1s.
|
||||
//
|
||||
// More information on this value and how it affects CometBFT can be found here:
|
||||
// https://github.com/cometbft/cometbft/blob/88ef3d267de491db98a654be0af6d791e8724ed0/spec/abci/abci%2B%2B_methods.md?plain=1#L689
|
||||
func (app *BaseApp) SetNextBlockDelay(delay time.Duration) {
|
||||
if app.sealed {
|
||||
panic("SetNextBlockDelay() on sealed BaseApp")
|
||||
}
|
||||
|
||||
app.nextBlockDelay = delay
|
||||
}
|
||||
|
||||
// SetProcessProposal sets the process proposal function for the BaseApp.
|
||||
func (app *BaseApp) SetProcessProposal(handler sdk.ProcessProposalHandler) {
|
||||
if app.sealed {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package baseapp
|
||||
import (
|
||||
"context"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
)
|
||||
|
||||
// ParamStore defines the interface the parameter store used by the BaseApp must
|
||||
|
||||
@@ -38,7 +38,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
pruningtypes "cosmossdk.io/store/pruning/types"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
|
||||
"cosmossdk.io/core/header"
|
||||
"cosmossdk.io/log"
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
tmproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
tmproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
abci "github.com/cometbft/cometbft/v2/abci/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package baseapp
|
||||
|
||||
import (
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v2"
|
||||
cmttypes "github.com/cometbft/cometbft/v2/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user