refactor! : bump comet to v1 (#19726)
Co-authored-by: yihuang <yi.codeplayer@gmail.com>
This commit is contained in:
+14
-14
@@ -16,58 +16,58 @@ func NewCometABCIWrapper(app servertypes.ABCI) abci.Application {
|
||||
return cometABCIWrapper{app: app}
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) {
|
||||
func (w cometABCIWrapper) Info(_ context.Context, req *abci.InfoRequest) (*abci.InfoResponse, error) {
|
||||
return w.app.Info(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) Query(ctx context.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error) {
|
||||
func (w cometABCIWrapper) Query(ctx context.Context, req *abci.QueryRequest) (*abci.QueryResponse, error) {
|
||||
return w.app.Query(ctx, req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
|
||||
func (w cometABCIWrapper) CheckTx(_ context.Context, req *abci.CheckTxRequest) (*abci.CheckTxResponse, error) {
|
||||
return w.app.CheckTx(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
|
||||
func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) {
|
||||
return w.app.InitChain(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) {
|
||||
func (w cometABCIWrapper) PrepareProposal(_ context.Context, req *abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error) {
|
||||
return w.app.PrepareProposal(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
|
||||
func (w cometABCIWrapper) ProcessProposal(_ context.Context, req *abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error) {
|
||||
return w.app.ProcessProposal(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
|
||||
func (w cometABCIWrapper) FinalizeBlock(_ context.Context, req *abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error) {
|
||||
return w.app.FinalizeBlock(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) ExtendVote(ctx context.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) {
|
||||
func (w cometABCIWrapper) ExtendVote(ctx context.Context, req *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error) {
|
||||
return w.app.ExtendVote(ctx, req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) VerifyVoteExtension(_ context.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) {
|
||||
func (w cometABCIWrapper) VerifyVoteExtension(_ context.Context, req *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) {
|
||||
return w.app.VerifyVoteExtension(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) Commit(_ context.Context, _ *abci.RequestCommit) (*abci.ResponseCommit, error) {
|
||||
func (w cometABCIWrapper) Commit(_ context.Context, _ *abci.CommitRequest) (*abci.CommitResponse, error) {
|
||||
return w.app.Commit()
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) {
|
||||
func (w cometABCIWrapper) ListSnapshots(_ context.Context, req *abci.ListSnapshotsRequest) (*abci.ListSnapshotsResponse, error) {
|
||||
return w.app.ListSnapshots(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) {
|
||||
func (w cometABCIWrapper) OfferSnapshot(_ context.Context, req *abci.OfferSnapshotRequest) (*abci.OfferSnapshotResponse, error) {
|
||||
return w.app.OfferSnapshot(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) {
|
||||
func (w cometABCIWrapper) LoadSnapshotChunk(_ context.Context, req *abci.LoadSnapshotChunkRequest) (*abci.LoadSnapshotChunkResponse, error) {
|
||||
return w.app.LoadSnapshotChunk(req)
|
||||
}
|
||||
|
||||
func (w cometABCIWrapper) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) {
|
||||
func (w cometABCIWrapper) ApplySnapshotChunk(_ context.Context, req *abci.ApplySnapshotChunkRequest) (*abci.ApplySnapshotChunkResponse, error) {
|
||||
return w.app.ApplySnapshotChunk(req)
|
||||
}
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ func VersionCmd() *cobra.Command {
|
||||
BlockProtocol uint64
|
||||
P2PProtocol uint64
|
||||
}{
|
||||
CometBFT: cmtversion.TMCoreSemVer,
|
||||
CometBFT: cmtversion.CMTSemVer,
|
||||
ABCI: cmtversion.ABCIVersion,
|
||||
BlockProtocol: cmtversion.BlockProtocol,
|
||||
P2PProtocol: cmtversion.P2PProtocol,
|
||||
@@ -381,7 +381,7 @@ func BootstrapStateCmd[T types.Application](appCreator types.AppCreator[T]) *cob
|
||||
height = app.CommitMultiStore().LastCommitID().Version
|
||||
}
|
||||
|
||||
return node.BootstrapStateWithGenProvider(cmd.Context(), cfg, cmtcfg.DefaultDBProvider, getGenDocProvider(cfg), uint64(height), nil)
|
||||
return node.BootstrapState(cmd.Context(), cfg, cmtcfg.DefaultDBProvider, getGenDocProvider(cfg), uint64(height), nil)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -102,21 +102,21 @@ type GenesisJSON struct {
|
||||
|
||||
// InitChainer returns a function that can initialize the chain
|
||||
// with key/value pairs
|
||||
func InitChainer(key storetypes.StoreKey) func(sdk.Context, *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
|
||||
return func(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
|
||||
func InitChainer(key storetypes.StoreKey) func(sdk.Context, *abci.InitChainRequest) (*abci.InitChainResponse, error) {
|
||||
return func(ctx sdk.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) {
|
||||
stateJSON := req.AppStateBytes
|
||||
|
||||
genesisState := new(GenesisJSON)
|
||||
err := json.Unmarshal(stateJSON, genesisState)
|
||||
if err != nil {
|
||||
return &abci.ResponseInitChain{}, err
|
||||
return &abci.InitChainResponse{}, err
|
||||
}
|
||||
|
||||
for _, val := range genesisState.Values {
|
||||
store := ctx.KVStore(key)
|
||||
store.Set([]byte(val.Key), []byte(val.Value))
|
||||
}
|
||||
return &abci.ResponseInitChain{}, nil
|
||||
return &abci.InitChainResponse{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ func TestInitApp(t *testing.T) {
|
||||
appState, err := AppGenState(nil, genutiltypes.AppGenesis{}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := abci.RequestInitChain{
|
||||
req := abci.InitChainRequest{
|
||||
AppStateBytes: appState,
|
||||
}
|
||||
res, err := app.InitChain(&req)
|
||||
require.NoError(t, err)
|
||||
_, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
Hash: res.AppHash,
|
||||
Height: 1,
|
||||
})
|
||||
@@ -52,7 +52,7 @@ func TestInitApp(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// make sure we can query these values
|
||||
query := abci.RequestQuery{
|
||||
query := abci.QueryRequest{
|
||||
Path: "/store/main/key",
|
||||
Data: []byte("foo"),
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestDeliverTx(t *testing.T) {
|
||||
tx := NewTx(key, value, randomAccounts[0].Address)
|
||||
txBytes := tx.GetSignBytes()
|
||||
|
||||
res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{
|
||||
Hash: []byte("apphash"),
|
||||
Height: 1,
|
||||
Txs: [][]byte{txBytes},
|
||||
@@ -87,7 +87,7 @@ func TestDeliverTx(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// make sure we can query these values
|
||||
query := abci.RequestQuery{
|
||||
query := abci.QueryRequest{
|
||||
Path: "/store/main/key",
|
||||
Data: []byte(key),
|
||||
}
|
||||
|
||||
+43
-15
@@ -3,6 +3,8 @@ package server
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -12,14 +14,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cometbft/cometbft/abci/server"
|
||||
cmtstate "github.com/cometbft/cometbft/api/cometbft/state/v1"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmtcmd "github.com/cometbft/cometbft/cmd/cometbft/commands"
|
||||
cmtcfg "github.com/cometbft/cometbft/config"
|
||||
cmtjson "github.com/cometbft/cometbft/libs/json"
|
||||
"github.com/cometbft/cometbft/node"
|
||||
"github.com/cometbft/cometbft/p2p"
|
||||
pvm "github.com/cometbft/cometbft/privval"
|
||||
cmtstate "github.com/cometbft/cometbft/proto/tendermint/state"
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
"github.com/cometbft/cometbft/proxy"
|
||||
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
|
||||
"github.com/cometbft/cometbft/rpc/client/local"
|
||||
@@ -256,7 +258,7 @@ func startStandAlone[T types.Application](svrCtx *Context, svrCfg serverconfig.C
|
||||
if svrCfg.API.Enable || svrCfg.GRPC.Enable {
|
||||
// create tendermint client
|
||||
// assumes the rpc listen address is where tendermint has its rpc server
|
||||
rpcclient, err := rpchttp.New(svrCtx.Config.RPC.ListenAddress, "/websocket")
|
||||
rpcclient, err := rpchttp.New(svrCtx.Config.RPC.ListenAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -370,7 +372,7 @@ func startCmtNode(
|
||||
}
|
||||
|
||||
cmtApp := NewCometABCIWrapper(app)
|
||||
tmNode, err = node.NewNodeWithContext(
|
||||
tmNode, err = node.NewNode(
|
||||
ctx,
|
||||
cfg,
|
||||
pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
|
||||
@@ -411,14 +413,40 @@ func getAndValidateConfig(svrCtx *Context) (serverconfig.Config, error) {
|
||||
}
|
||||
|
||||
// getGenDocProvider returns a function which returns the genesis doc from the genesis file.
|
||||
func getGenDocProvider(cfg *cmtcfg.Config) func() (*cmttypes.GenesisDoc, error) {
|
||||
return func() (*cmttypes.GenesisDoc, error) {
|
||||
func getGenDocProvider(cfg *cmtcfg.Config) func() (node.ChecksummedGenesisDoc, error) {
|
||||
return func() (node.ChecksummedGenesisDoc, error) {
|
||||
appGenesis, err := genutiltypes.AppGenesisFromFile(cfg.GenesisFile())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return node.ChecksummedGenesisDoc{
|
||||
Sha256Checksum: []byte{},
|
||||
}, err
|
||||
}
|
||||
|
||||
return appGenesis.ToGenesisDoc()
|
||||
gen, err := appGenesis.ToGenesisDoc()
|
||||
if err != nil {
|
||||
return node.ChecksummedGenesisDoc{
|
||||
Sha256Checksum: []byte{},
|
||||
}, err
|
||||
}
|
||||
genbz, err := gen.AppState.MarshalJSON()
|
||||
if err != nil {
|
||||
return node.ChecksummedGenesisDoc{
|
||||
Sha256Checksum: []byte{},
|
||||
}, err
|
||||
}
|
||||
|
||||
bz, err := json.Marshal(genbz)
|
||||
if err != nil {
|
||||
return node.ChecksummedGenesisDoc{
|
||||
Sha256Checksum: []byte{},
|
||||
}, err
|
||||
}
|
||||
sum := sha256.Sum256(bz)
|
||||
|
||||
return node.ChecksummedGenesisDoc{
|
||||
GenesisDoc: gen,
|
||||
Sha256Checksum: sum[:],
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,7 +804,7 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
|
||||
DiscardABCIResponses: config.Storage.DiscardABCIResponses,
|
||||
})
|
||||
|
||||
state, genDoc, err := node.LoadStateFromDBOrGenesisDocProvider(stateDB, genDocProvider)
|
||||
state, genDoc, err := node.LoadStateFromDBOrGenesisDocProvider(stateDB, genDocProvider, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -792,12 +820,12 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
|
||||
_, context := getCtx(ctx, true)
|
||||
clientCreator := proxy.NewLocalClientCreator(cmtApp)
|
||||
metrics := node.DefaultMetricsProvider(cmtcfg.DefaultConfig().Instrumentation)
|
||||
_, _, _, _, proxyMetrics, _, _ := metrics(genDoc.ChainID)
|
||||
_, _, _, _, _, proxyMetrics, _, _ := metrics(genDoc.ChainID) // nolint: dogsled // function from comet
|
||||
proxyApp := proxy.NewAppConns(clientCreator, proxyMetrics)
|
||||
if err := proxyApp.Start(); err != nil {
|
||||
return nil, fmt.Errorf("error starting proxy app connections: %v", err)
|
||||
}
|
||||
res, err := proxyApp.Query().Info(context, proxy.RequestInfo)
|
||||
res, err := proxyApp.Query().Info(context, proxy.InfoRequest)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error calling Info: %v", err)
|
||||
}
|
||||
@@ -811,7 +839,7 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
|
||||
var block *cmttypes.Block
|
||||
switch {
|
||||
case appHeight == blockStore.Height():
|
||||
block = blockStore.LoadBlock(blockStore.Height())
|
||||
block, _ = blockStore.LoadBlock(blockStore.Height())
|
||||
// If the state's last blockstore height does not match the app and blockstore height, we likely stopped with the halt height flag.
|
||||
if state.LastBlockHeight != appHeight {
|
||||
state.LastBlockHeight = appHeight
|
||||
@@ -830,10 +858,10 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
block = blockStore.LoadBlock(blockStore.Height())
|
||||
block, _ = blockStore.LoadBlock(blockStore.Height())
|
||||
default:
|
||||
// If there is any other state, we just load the block
|
||||
block = blockStore.LoadBlock(blockStore.Height())
|
||||
block, _ = blockStore.LoadBlock(blockStore.Height())
|
||||
}
|
||||
|
||||
block.ChainID = newChainID
|
||||
@@ -856,7 +884,7 @@ func testnetify[T types.Application](ctx *Context, testnetAppCreator types.AppCr
|
||||
|
||||
// Sign the vote, and copy the proto changes from the act of signing to the vote itself
|
||||
voteProto := vote.ToProto()
|
||||
err = privValidator.SignVote(newChainID, voteProto)
|
||||
err = privValidator.SignVote(newChainID, voteProto, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+14
-14
@@ -12,38 +12,38 @@ type ABCI interface {
|
||||
// Info/Query Connection
|
||||
|
||||
// Info returns application info
|
||||
Info(*abci.RequestInfo) (*abci.ResponseInfo, error)
|
||||
Info(*abci.InfoRequest) (*abci.InfoResponse, error)
|
||||
// Query returns application state
|
||||
Query(context.Context, *abci.RequestQuery) (*abci.ResponseQuery, error)
|
||||
Query(context.Context, *abci.QueryRequest) (*abci.QueryResponse, error)
|
||||
|
||||
// Mempool Connection
|
||||
|
||||
// CheckTx validate a tx for the mempool
|
||||
CheckTx(*abci.RequestCheckTx) (*abci.ResponseCheckTx, error)
|
||||
CheckTx(*abci.CheckTxRequest) (*abci.CheckTxResponse, error)
|
||||
|
||||
// Consensus Connection
|
||||
|
||||
// InitChain Initialize blockchain w validators/other info from CometBFT
|
||||
InitChain(*abci.RequestInitChain) (*abci.ResponseInitChain, error)
|
||||
PrepareProposal(*abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error)
|
||||
ProcessProposal(*abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error)
|
||||
InitChain(*abci.InitChainRequest) (*abci.InitChainResponse, error)
|
||||
PrepareProposal(*abci.PrepareProposalRequest) (*abci.PrepareProposalResponse, error)
|
||||
ProcessProposal(*abci.ProcessProposalRequest) (*abci.ProcessProposalResponse, error)
|
||||
// FinalizeBlock deliver the decided block with its txs to the Application
|
||||
FinalizeBlock(*abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error)
|
||||
FinalizeBlock(*abci.FinalizeBlockRequest) (*abci.FinalizeBlockResponse, error)
|
||||
// ExtendVote create application specific vote extension
|
||||
ExtendVote(context.Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error)
|
||||
ExtendVote(context.Context, *abci.ExtendVoteRequest) (*abci.ExtendVoteResponse, error)
|
||||
// VerifyVoteExtension verify application's vote extension data
|
||||
VerifyVoteExtension(*abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error)
|
||||
VerifyVoteExtension(*abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error)
|
||||
// Commit the state and return the application Merkle root hash
|
||||
Commit() (*abci.ResponseCommit, error)
|
||||
Commit() (*abci.CommitResponse, error)
|
||||
|
||||
// State Sync Connection
|
||||
|
||||
// ListSnapshots list available snapshots
|
||||
ListSnapshots(*abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error)
|
||||
ListSnapshots(*abci.ListSnapshotsRequest) (*abci.ListSnapshotsResponse, error)
|
||||
// OfferSnapshot offer a snapshot to the application
|
||||
OfferSnapshot(*abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error)
|
||||
OfferSnapshot(*abci.OfferSnapshotRequest) (*abci.OfferSnapshotResponse, error)
|
||||
// LoadSnapshotChunk load a snapshot chunk
|
||||
LoadSnapshotChunk(*abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error)
|
||||
LoadSnapshotChunk(*abci.LoadSnapshotChunkRequest) (*abci.LoadSnapshotChunkResponse, error)
|
||||
// ApplySnapshotChunk apply a snapshot chunk
|
||||
ApplySnapshotChunk(*abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error)
|
||||
ApplySnapshotChunk(*abci.ApplySnapshotChunkRequest) (*abci.ApplySnapshotChunkResponse, error)
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
||||
cmtproto "github.com/cometbft/cometbft/api/cometbft/types/v1"
|
||||
cmttypes "github.com/cometbft/cometbft/types"
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/cosmos/gogoproto/grpc"
|
||||
|
||||
Reference in New Issue
Block a user