diff --git a/baseapp/abci.go b/baseapp/abci.go index ce84668f4767..38eb07a5f646 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -37,7 +37,7 @@ const ( QueryPathBroadcastTx = "/cosmos.tx.v1beta1.Service/BroadcastTx" ) -func (app *BaseApp) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { +func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { if req.ChainId != app.chainID { return nil, fmt.Errorf("invalid chain-id on InitChain; expected: %s, got: %s", app.chainID, req.ChainId) } @@ -126,7 +126,7 @@ func (app *BaseApp) InitChain(_ context.Context, req *abci.RequestInitChain) (*a }, nil } -func (app *BaseApp) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) { +func (app *BaseApp) Info(req *abci.RequestInfo) (*abci.ResponseInfo, error) { lastCommitID := app.cms.LastCommitID() return &abci.ResponseInfo{ @@ -193,7 +193,7 @@ func (app *BaseApp) Query(_ context.Context, req *abci.RequestQuery) (resp *abci } // ListSnapshots implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) { +func (app *BaseApp) ListSnapshots(req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) { resp := &abci.ResponseListSnapshots{Snapshots: []*abci.Snapshot{}} if app.snapshotManager == nil { return resp, nil @@ -218,7 +218,7 @@ func (app *BaseApp) ListSnapshots(_ context.Context, req *abci.RequestListSnapsh } // LoadSnapshotChunk implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) { +func (app *BaseApp) LoadSnapshotChunk(req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) { if app.snapshotManager == nil { return &abci.ResponseLoadSnapshotChunk{}, nil } @@ -239,7 +239,7 @@ func (app *BaseApp) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSn } // OfferSnapshot implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) { +func (app *BaseApp) OfferSnapshot(req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) { if app.snapshotManager == nil { app.logger.Error("snapshot manager not configured") return &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ABORT}, nil @@ -292,7 +292,7 @@ func (app *BaseApp) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnaps } // ApplySnapshotChunk implements the ABCI interface. It delegates to app.snapshotManager if set. -func (app *BaseApp) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) { +func (app *BaseApp) ApplySnapshotChunk(req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) { if app.snapshotManager == nil { app.logger.Error("snapshot manager not configured") return &abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ABORT}, nil @@ -332,7 +332,7 @@ func (app *BaseApp) ApplySnapshotChunk(_ context.Context, req *abci.RequestApply // internal CheckTx state if the AnteHandler passes. Otherwise, the ResponseCheckTx // will contain relevant error information. Regardless of tx execution outcome, // the ResponseCheckTx will contain relevant gas execution context. -func (app *BaseApp) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { +func (app *BaseApp) CheckTx(req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { var mode execMode switch { @@ -373,7 +373,7 @@ func (app *BaseApp) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci. // // 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 -func (app *BaseApp) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (resp *abci.ResponsePrepareProposal, err error) { +func (app *BaseApp) PrepareProposal(req *abci.RequestPrepareProposal) (resp *abci.ResponsePrepareProposal, err error) { if app.prepareProposal == nil { return nil, errors.New("PrepareProposal method not set") } @@ -445,7 +445,7 @@ func (app *BaseApp) PrepareProposal(_ context.Context, req *abci.RequestPrepareP // // 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 -func (app *BaseApp) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (resp *abci.ResponseProcessProposal, err error) { +func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abci.ResponseProcessProposal, err error) { if app.processProposal == nil { return nil, errors.New("app.ProcessProposal is not set") } @@ -572,7 +572,7 @@ func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) ( // logic in verifying a vote extension from another validator during the pre-commit // phase. The response MUST be deterministic. An error is returned if vote // extensions are not enabled or if verifyVoteExt fails or panics. -func (app *BaseApp) VerifyVoteExtension(_ context.Context, req *abci.RequestVerifyVoteExtension) (resp *abci.ResponseVerifyVoteExtension, err error) { +func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (resp *abci.ResponseVerifyVoteExtension, err error) { // If vote extensions are not enabled, as a safety precaution, we return an // error. cp := app.GetConsensusParams(app.voteExtensionState.ctx) @@ -617,7 +617,7 @@ func (app *BaseApp) VerifyVoteExtension(_ context.Context, req *abci.RequestVeri // skipped. This is to support compatibility with proposers injecting vote // extensions into the proposal, which should not themselves be executed in cases // where they adhere to the sdk.Tx interface. -func (app *BaseApp) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { +func (app *BaseApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { var events []abci.Event if err := app.validateFinalizeBlockHeight(req); err != nil { @@ -691,12 +691,8 @@ func (app *BaseApp) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBl } events = append(events, endBlock.Events...) - cp := app.GetConsensusParams(app.finalizeBlockState.ctx) - // TODO: Populate fields. - // - // Ref: https://github.com/cosmos/cosmos-sdk/issues/12272 return &abci.ResponseFinalizeBlock{ Events: events, TxResults: txResults, @@ -713,7 +709,7 @@ func (app *BaseApp) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBl // defined in config, Commit will execute a deferred function call to check // against that height and gracefully halt if it matches the latest committed // height. -func (app *BaseApp) Commit(_ context.Context, _ *abci.RequestCommit) (*abci.ResponseCommit, error) { +func (app *BaseApp) Commit() (*abci.ResponseCommit, error) { header := app.finalizeBlockState.ctx.BlockHeader() retainHeight := app.GetBlockRetentionHeight(header.Height) diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 41eb027ecff9..0cdbf605c322 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -36,7 +36,7 @@ func TestABCI_Info(t *testing.T) { suite := NewBaseAppSuite(t) reqInfo := abci.RequestInfo{} - res, err := suite.baseApp.Info(context.TODO(), &reqInfo) + res, err := suite.baseApp.Info(&reqInfo) require.NoError(t, err) require.Equal(t, "", res.Version) @@ -69,12 +69,12 @@ func TestABCI_InitChain(t *testing.T) { Data: key, } - _, err := app.InitChain(context.TODO(), &abci.RequestInitChain{ChainId: "wrong-chain-id"}) + _, err := app.InitChain(&abci.RequestInitChain{ChainId: "wrong-chain-id"}) // initChain is nil and chain ID is wrong - panics require.Error(t, err) // initChain is nil - nothing happens - _, err = app.InitChain(context.TODO(), &abci.RequestInitChain{ChainId: "test-chain-id"}) + _, err = app.InitChain(&abci.RequestInitChain{ChainId: "test-chain-id"}) require.NoError(t, err) resQ, err := app.Query(context.TODO(), &query) require.NoError(t, err) @@ -88,7 +88,7 @@ func TestABCI_InitChain(t *testing.T) { require.Nil(t, err) require.Equal(t, int64(0), app.LastBlockHeight()) - initChainRes, err := app.InitChain(context.TODO(), &abci.RequestInitChain{AppStateBytes: []byte("{}"), ChainId: "test-chain-id"}) // must have valid JSON genesis file, even if empty + initChainRes, err := app.InitChain(&abci.RequestInitChain{AppStateBytes: []byte("{}"), ChainId: "test-chain-id"}) // must have valid JSON genesis file, even if empty require.NoError(t, err) // The AppHash returned by a new chain is the sha256 hash of "". @@ -107,12 +107,12 @@ func TestABCI_InitChain(t *testing.T) { chainID = getCheckStateCtx(app).ChainID() require.Equal(t, "test-chain-id", chainID, "ChainID in checkState not set correctly in InitChain") - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Hash: initChainRes.AppHash, Height: 1, }) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() resQ, err = app.Query(context.TODO(), &query) require.NoError(t, err) require.Equal(t, int64(1), app.LastBlockHeight()) @@ -132,8 +132,8 @@ func TestABCI_InitChain(t *testing.T) { require.Equal(t, value, resQ.Value) // commit and ensure we can still query - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) + app.Commit() resQ, err = app.Query(context.TODO(), &query) require.NoError(t, err) @@ -146,12 +146,11 @@ func TestABCI_InitChain_WithInitialHeight(t *testing.T) { app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) app.InitChain( - context.TODO(), &abci.RequestInitChain{ InitialHeight: 3, }, ) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() require.Equal(t, int64(3), app.LastBlockHeight()) } @@ -162,17 +161,16 @@ func TestABCI_FinalizeBlock_WithInitialHeight(t *testing.T) { app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) app.InitChain( - context.TODO(), &abci.RequestInitChain{ InitialHeight: 3, }, ) - _, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 4}) + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 4}) require.Error(t, err, "invalid height: 4; expected: 3") - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 3}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 3}) + app.Commit() require.Equal(t, int64(3), app.LastBlockHeight()) } @@ -187,7 +185,7 @@ func TestABCI_GRPCQuery(t *testing.T) { suite := NewBaseAppSuite(t, grpcQueryOpt) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -203,8 +201,8 @@ func TestABCI_GRPCQuery(t *testing.T) { require.Equal(t, sdkerrors.ErrInvalidHeight.ABCICode(), resQuery.Code, resQuery) require.Contains(t, resQuery.Log, "TestABCI_GRPCQuery is not ready; please wait for first block") - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: suite.baseApp.LastBlockHeight() + 1}) - suite.baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.baseApp.LastBlockHeight() + 1}) + suite.baseApp.Commit() reqQuery := abci.RequestQuery{ Data: reqBz, @@ -265,7 +263,7 @@ func TestBaseApp_PrepareCheckState(t *testing.T) { app := baseapp.NewBaseApp(name, logger, db, nil) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - app.InitChain(context.TODO(), &abci.RequestInitChain{ + app.InitChain(&abci.RequestInitChain{ ConsensusParams: cp, }) @@ -275,7 +273,7 @@ func TestBaseApp_PrepareCheckState(t *testing.T) { }) app.Seal() - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() require.Equal(t, true, wasPrepareCheckStateCalled) } @@ -292,7 +290,7 @@ func TestBaseApp_Precommit(t *testing.T) { app := baseapp.NewBaseApp(name, logger, db, nil) app.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - app.InitChain(context.TODO(), &abci.RequestInitChain{ + app.InitChain(&abci.RequestInitChain{ ConsensusParams: cp, }) @@ -302,7 +300,7 @@ func TestBaseApp_Precommit(t *testing.T) { }) app.Seal() - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() require.Equal(t, true, wasPrecommiterCalled) } @@ -317,7 +315,7 @@ func TestABCI_CheckTx(t *testing.T) { baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImpl{t, capKey1, counterKey}) nTxs := int64(5) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -326,7 +324,7 @@ func TestABCI_CheckTx(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - r, err := suite.baseApp.CheckTx(context.Background(), &abci.RequestCheckTx{Tx: txBytes}) + r, err := suite.baseApp.CheckTx(&abci.RequestCheckTx{Tx: txBytes}) require.NoError(t, err) require.True(t, r.IsOK(), fmt.Sprintf("%v", r)) require.Empty(t, r.GetEvents()) @@ -339,7 +337,7 @@ func TestABCI_CheckTx(t *testing.T) { require.Equal(t, nTxs, storedCounter) // if a block is committed, CheckTx state should be reset - _, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, Hash: []byte("hash"), }) @@ -348,7 +346,7 @@ func TestABCI_CheckTx(t *testing.T) { require.NotNil(t, getCheckStateCtx(suite.baseApp).BlockGasMeter(), "block gas meter should have been set to checkState") require.NotEmpty(t, getCheckStateCtx(suite.baseApp).HeaderHash()) - suite.baseApp.Commit(context.Background(), &abci.RequestCommit{}) + suite.baseApp.Commit() checkStateStore = getCheckStateCtx(suite.baseApp).KVStore(capKey1) storedBytes := checkStateStore.Get(counterKey) @@ -360,7 +358,7 @@ func TestABCI_FinalizeBlock_DeliverTx(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } suite := NewBaseAppSuite(t, anteOpt) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -383,7 +381,7 @@ func TestABCI_FinalizeBlock_DeliverTx(t *testing.T) { txs = append(txs, txBytes) } - res, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: int64(blockN) + 1, Txs: txs, }) @@ -399,7 +397,7 @@ func TestABCI_FinalizeBlock_DeliverTx(t *testing.T) { require.Equal(t, sdk.MarkEventsToIndex(counterEvent(sdk.EventTypeMessage, counter).ToABCIEvents(), map[string]struct{}{})[0].Attributes[0], events[2].Attributes[0], "msg handler update counter event") } - suite.baseApp.Commit(context.Background(), &abci.RequestCommit{}) + suite.baseApp.Commit() } } @@ -408,7 +406,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { anteOpt := func(bapp *baseapp.BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } suite := NewBaseAppSuite(t, anteOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -424,7 +422,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, Txs: [][]byte{txBytes}, }) @@ -454,7 +452,7 @@ func TestABCI_FinalizeBlock_MultiMsg(t *testing.T) { txBytes, err = suite.txConfig.TxEncoder()(builder.GetTx()) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, Txs: [][]byte{txBytes}, }) @@ -485,7 +483,7 @@ func TestABCI_Query_SimulateTx(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -517,7 +515,7 @@ func TestABCI_Query_SimulateTx(t *testing.T) { Path: "/app/simulate", Data: txBytes, } - queryResult, err := suite.baseApp.Query(context.Background(), &query) + queryResult, err := suite.baseApp.Query(context.TODO(), &query) require.NoError(t, err) require.True(t, queryResult.IsOK(), queryResult.Log) @@ -529,8 +527,8 @@ func TestABCI_Query_SimulateTx(t *testing.T) { require.Equal(t, result.Events, simRes.Result.Events) require.True(t, bytes.Equal(result.Data, simRes.Result.Data)) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: count}) - suite.baseApp.Commit(context.Background(), &abci.RequestCommit{}) + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: count}) + suite.baseApp.Commit() } } @@ -544,11 +542,11 @@ func TestABCI_InvalidTransaction(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, }) @@ -557,7 +555,7 @@ func TestABCI_InvalidTransaction(t *testing.T) { emptyTx := suite.txConfig.NewTxBuilder().GetTx() bz, err := suite.txConfig.TxEncoder()(emptyTx) require.NoError(t, err) - result, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + result, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, Txs: [][]byte{bz}, }) @@ -671,15 +669,15 @@ func TestABCI_TxGasLimits(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, }) - suite.baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + suite.baseApp.Commit() testCases := []struct { tx signing.Tx @@ -710,7 +708,7 @@ func TestABCI_TxGasLimits(t *testing.T) { } // Deliver the txs - res, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 2, Txs: txs, }) @@ -760,7 +758,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ MaxGas: 100, @@ -768,7 +766,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) { }, }) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) testCases := []struct { tx signing.Tx @@ -793,7 +791,7 @@ func TestABCI_MaxBlockGasLimits(t *testing.T) { tx := tc.tx // reset block gas - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: suite.baseApp.LastBlockHeight() + 1}) + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.baseApp.LastBlockHeight() + 1}) // execute the transaction multiple times for j := 0; j < tc.numDelivers; j++ { @@ -858,7 +856,7 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{ Block: &cmtproto.BlockParams{ MaxGas: 9, @@ -876,7 +874,7 @@ func TestABCI_GasConsumptionBadTx(t *testing.T) { txBytes2, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - _, err = suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.baseApp.LastBlockHeight() + 1, Txs: [][]byte{txBytes, txBytes2}, }) @@ -896,7 +894,7 @@ func TestABCI_Query(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImplGasMeterOnly{}) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -910,7 +908,7 @@ func TestABCI_Query(t *testing.T) { tx := newTxCounter(t, suite.txConfig, 0, 0) // query is empty before we do anything - res, err := suite.baseApp.Query(context.Background(), &query) + res, err := suite.baseApp.Query(context.TODO(), &query) require.NoError(t, err) require.Equal(t, 0, len(res.Value)) @@ -919,27 +917,27 @@ func TestABCI_Query(t *testing.T) { require.NoError(t, err) require.NotNil(t, resTx) - res, err = suite.baseApp.Query(context.Background(), &query) + res, err = suite.baseApp.Query(context.TODO(), &query) require.NoError(t, err) require.Equal(t, 0, len(res.Value)) bz, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, Txs: [][]byte{bz}, }) require.NoError(t, err) - res, err = suite.baseApp.Query(context.Background(), &query) + res, err = suite.baseApp.Query(context.TODO(), &query) require.NoError(t, err) require.Equal(t, 0, len(res.Value)) // query returns correct value after Commit - suite.baseApp.Commit(context.Background(), &abci.RequestCommit{}) + suite.baseApp.Commit() - res, err = suite.baseApp.Query(context.Background(), &query) + res, err = suite.baseApp.Query(context.TODO(), &query) require.NoError(t, err) require.Equal(t, value, res.Value) } @@ -1039,7 +1037,7 @@ func TestABCI_GetBlockRetentionHeight(t *testing.T) { tc := tc tc.bapp.SetParamStore(¶mStore{db: dbm.NewMemDB()}) - tc.bapp.InitChain(context.TODO(), &abci.RequestInitChain{ + tc.bapp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{ Evidence: &cmtproto.EvidenceParams{ MaxAgeNumBlocks: tc.maxAgeBlocks, @@ -1068,8 +1066,8 @@ func TestPrepareCheckStateCalledWithCheckState(t *testing.T) { wasPrepareCheckStateCalled = true }) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + app.Commit() require.Equal(t, true, wasPrepareCheckStateCalled) } @@ -1090,8 +1088,8 @@ func TestPrecommiterCalledWithDeliverState(t *testing.T) { wasPrecommiterCalled = true }) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + app.Commit() require.Equal(t, true, wasPrecommiterCalled) } @@ -1107,7 +1105,7 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { baseapptestutil.RegisterKeyValueServer(suite.baseApp.MsgServiceRouter(), MsgKeyValueImpl{}) baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), NoopCounterServerImpl{}) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1119,7 +1117,7 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { Tx: txBytes, Type: abci.CheckTxType_New, } - _, err = suite.baseApp.CheckTx(context.Background(), &reqCheckTx) + _, err = suite.baseApp.CheckTx(&reqCheckTx) require.NoError(t, err) tx2 := newTxCounter(t, suite.txConfig, 1, 1) @@ -1134,7 +1132,7 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { MaxTxBytes: 1000, Height: 1, } - resPrepareProposal, err := suite.baseApp.PrepareProposal(context.Background(), &reqPrepareProposal) + resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal) require.NoError(t, err) require.Equal(t, 2, len(resPrepareProposal.Txs)) @@ -1147,11 +1145,11 @@ func TestABCI_Proposal_HappyPath(t *testing.T) { Height: reqPrepareProposal.Height, } - resProcessProposal, err := suite.baseApp.ProcessProposal(context.Background(), &reqProcessProposal) + resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) - res, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.baseApp.LastBlockHeight() + 1, Txs: [][]byte{txBytes}, }) @@ -1184,7 +1182,7 @@ func TestABCI_Proposal_Read_State_PrepareProposal(t *testing.T) { suite := NewBaseAppSuite(t, setInitChainerOpt, prepareOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ InitialHeight: 1, ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1193,7 +1191,7 @@ func TestABCI_Proposal_Read_State_PrepareProposal(t *testing.T) { MaxTxBytes: 1000, Height: 1, // this value can't be 0 } - resPrepareProposal, err := suite.baseApp.PrepareProposal(context.Background(), &reqPrepareProposal) + resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal) require.NoError(t, err) require.Equal(t, 0, len(resPrepareProposal.Txs)) @@ -1203,7 +1201,7 @@ func TestABCI_Proposal_Read_State_PrepareProposal(t *testing.T) { Height: reqPrepareProposal.Height, } - resProcessProposal, err := suite.baseApp.ProcessProposal(context.Background(), &reqProcessProposal) + resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) @@ -1220,7 +1218,7 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1234,7 +1232,7 @@ func TestABCI_PrepareProposal_ReachedMaxBytes(t *testing.T) { MaxTxBytes: 1500, Height: 1, } - resPrepareProposal, err := suite.baseApp.PrepareProposal(context.Background(), &reqPrepareProposal) + resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal) require.NoError(t, err) require.Equal(t, 11, len(resPrepareProposal.Txs)) } @@ -1247,7 +1245,7 @@ func TestABCI_PrepareProposal_BadEncoding(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1259,7 +1257,7 @@ func TestABCI_PrepareProposal_BadEncoding(t *testing.T) { MaxTxBytes: 1000, Height: 1, } - resPrepareProposal, err := suite.baseApp.PrepareProposal(context.Background(), &reqPrepareProposal) + resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal) require.NoError(t, err) require.Equal(t, 1, len(resPrepareProposal.Txs)) } @@ -1272,7 +1270,7 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt, baseapp.SetMempool(pool)) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1284,7 +1282,7 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { Tx: txBytes, Type: abci.CheckTxType_New, } - checkTxRes, err := suite.baseApp.CheckTx(context.Background(), &reqCheckTx) + checkTxRes, err := suite.baseApp.CheckTx(&reqCheckTx) require.NoError(t, err) require.True(t, checkTxRes.IsOK()) @@ -1299,7 +1297,7 @@ func TestABCI_PrepareProposal_Failures(t *testing.T) { MaxTxBytes: 1000, Height: 1, } - res, err := suite.baseApp.PrepareProposal(context.Background(), &req) + res, err := suite.baseApp.PrepareProposal(&req) require.NoError(t, err) require.Equal(t, 1, len(res.Txs)) } @@ -1312,7 +1310,7 @@ func TestABCI_PrepareProposal_PanicRecovery(t *testing.T) { } suite := NewBaseAppSuite(t, prepareOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1322,7 +1320,7 @@ func TestABCI_PrepareProposal_PanicRecovery(t *testing.T) { } require.NotPanics(t, func() { - res, err := suite.baseApp.PrepareProposal(context.Background(), &req) + res, err := suite.baseApp.PrepareProposal(&req) require.NoError(t, err) require.Equal(t, req.Txs, res.Txs) }) @@ -1336,12 +1334,12 @@ func TestABCI_ProcessProposal_PanicRecovery(t *testing.T) { } suite := NewBaseAppSuite(t, processOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) require.NotPanics(t, func() { - res, err := suite.baseApp.ProcessProposal(context.Background(), &abci.RequestProcessProposal{Height: 1}) + res, err := suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) require.NoError(t, err) require.Equal(t, res.Status, abci.ResponseProcessProposal_REJECT) }) @@ -1374,7 +1372,7 @@ func TestABCI_Proposal_Reset_State_Between_Calls(t *testing.T) { suite := NewBaseAppSuite(t, prepareOpt, processOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -1386,7 +1384,7 @@ func TestABCI_Proposal_Reset_State_Between_Calls(t *testing.T) { // Let's pretend something happened and PrepareProposal gets called many // times, this must be safe to do. for i := 0; i < 5; i++ { - resPrepareProposal, err := suite.baseApp.PrepareProposal(context.Background(), &reqPrepareProposal) + resPrepareProposal, err := suite.baseApp.PrepareProposal(&reqPrepareProposal) require.NoError(t, err) require.Equal(t, 0, len(resPrepareProposal.Txs)) } @@ -1400,7 +1398,7 @@ func TestABCI_Proposal_Reset_State_Between_Calls(t *testing.T) { // Let's pretend something happened and ProcessProposal gets called many // times, this must be safe to do. for i := 0; i < 5; i++ { - resProcessProposal, err := suite.baseApp.ProcessProposal(context.Background(), &reqProcessProposal) + resProcessProposal, err := suite.baseApp.ProcessProposal(&reqProcessProposal) require.NoError(t, err) require.Equal(t, abci.ResponseProcessProposal_ACCEPT, resProcessProposal.Status) } diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7ba35d40a933..b9142271809b 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -21,6 +21,7 @@ import ( "golang.org/x/exp/maps" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -48,7 +49,7 @@ const ( execModeFinalize // Finalize a block proposal ) -var _ abci.Application = (*BaseApp)(nil) +var _ servertypes.ABCI = (*BaseApp)(nil) // BaseApp reflects the ABCI application implementation. type BaseApp struct { diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index bc8376577de9..afc192fa964a 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -98,7 +98,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun baseapptestutil.RegisterKeyValueServer(suite.baseApp.MsgServiceRouter(), MsgKeyValueImpl{}) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -131,13 +131,13 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun txs = append(txs, txBytes) } - _, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: height, Txs: txs, }) require.NoError(t, err) - _, err = suite.baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = suite.baseApp.Commit() require.NoError(t, err) // wait for snapshot to be taken, since it happens asynchronously @@ -183,17 +183,17 @@ func TestLoadVersion(t *testing.T) { require.Equal(t, emptyCommitID, lastID) // execute a block, collect commit ID - res, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) + res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) commitID1 := storetypes.CommitID{Version: 1, Hash: res.AppHash} - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) // execute a block, collect commit ID - res, err = app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 2}) + res, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) commitID2 := storetypes.CommitID{Version: 2, Hash: res.AppHash} - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) // reload with LoadLatestVersion @@ -213,9 +213,9 @@ func TestLoadVersion(t *testing.T) { testLoadVersionHelper(t, app, int64(1), commitID1) - _, err = app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 2}) + _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) testLoadVersionHelper(t, app, int64(2), commitID2) @@ -299,10 +299,10 @@ func TestSetLoader(t *testing.T) { require.Nil(t, err) // "execute" one block - res, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 2}) + res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) require.NotNil(t, res.AppHash) - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) // check db is properly updated @@ -348,10 +348,10 @@ func TestLoadVersionInvalid(t *testing.T) { err = app.LoadVersion(-1) require.Error(t, err) - res, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) + res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) commitID1 := storetypes.CommitID{Version: 1, Hash: res.AppHash} - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) // create a new app with the stores mounted under the same cap key @@ -452,7 +452,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) { } suite := NewBaseAppSuite(t, anteOpt) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -476,7 +476,7 @@ func TestCustomRunTxPanicHandler(t *testing.T) { require.PanicsWithValue(t, customPanicMsg, func() { bz, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{bz}}) + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{bz}}) }) } } @@ -491,7 +491,7 @@ func TestBaseAppAnteHandler(t *testing.T) { deliverKey := []byte("deliver-key") baseapptestutil.RegisterCounterServer(suite.baseApp.MsgServiceRouter(), CounterServerImpl{t, capKey1, deliverKey}) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &cmtproto.ConsensusParams{}, }) @@ -505,7 +505,7 @@ func TestBaseAppAnteHandler(t *testing.T) { txBytes, err := suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Empty(t, res.Events) require.False(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -522,7 +522,7 @@ func TestBaseAppAnteHandler(t *testing.T) { txBytes, err = suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err = suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Empty(t, res.Events) require.False(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -539,7 +539,7 @@ func TestBaseAppAnteHandler(t *testing.T) { txBytes, err = suite.txConfig.TxEncoder()(tx) require.NoError(t, err) - res, err = suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.NotEmpty(t, res.TxResults[0].Events) require.True(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res)) @@ -549,7 +549,7 @@ func TestBaseAppAnteHandler(t *testing.T) { require.Equal(t, int64(2), getIntFromStore(t, store, anteKey)) require.Equal(t, int64(1), getIntFromStore(t, store, deliverKey)) - suite.baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + suite.baseApp.Commit() } // Test and ensure that invalid block heights always cause errors. @@ -563,11 +563,11 @@ func TestABCI_CreateQueryContext(t *testing.T) { name := t.Name() app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + app.Commit() - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 2}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) + app.Commit() testCases := []struct { name string @@ -603,7 +603,7 @@ func TestSetMinGasPrices(t *testing.T) { func TestGetMaximumBlockGas(t *testing.T) { suite := NewBaseAppSuite(t) - suite.baseApp.InitChain(context.Background(), &abci.RequestInitChain{}) + suite.baseApp.InitChain(&abci.RequestInitChain{}) ctx := suite.baseApp.NewContext(true, cmtproto.Header{}) // TODO remove header here suite.baseApp.StoreConsensusParams(ctx, cmtproto.ConsensusParams{Block: &cmtproto.BlockParams{MaxGas: 0}}) @@ -647,9 +647,9 @@ func TestLoadVersionPruning(t *testing.T) { // Commit seven blocks, of which 7 (latest) is kept in addition to 6, 5 // (keep recent) and 3 (keep every). for i := int64(1); i <= 7; i++ { - res, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: i}) + res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: i}) require.NoError(t, err) - _, err = app.Commit(context.Background(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) lastCommitID = storetypes.CommitID{Version: i, Hash: res.AppHash} } diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index df24fe0a6c73..5e9910e4a179 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -118,7 +118,7 @@ func TestBaseApp_BlockGas(t *testing.T) { genState := GenesisStateWithSingleValidator(t, cdc, appBuilder) stateBytes, err := cmtjson.MarshalIndent(genState, "", " ") require.NoError(t, err) - bapp.InitChain(context.TODO(), &abci.RequestInitChain{ + bapp.InitChain(&abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: simtestutil.DefaultConsensusParams, AppStateBytes: stateBytes, @@ -158,7 +158,7 @@ func TestBaseApp_BlockGas(t *testing.T) { _, txBytes, err := createTestTx(txConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID()) require.NoError(t, err) - rsp, err := bapp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + rsp, err := bapp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) // check result diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 452a47af3864..eeee401a7d82 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -115,7 +115,7 @@ func TestMsgService(t *testing.T) { app.MsgServiceRouter(), testdata.MsgServerImpl{}, ) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) msg := testdata.MsgCreateDog{Dog: &testdata.Dog{Name: "Spot"}} @@ -156,7 +156,7 @@ func TestMsgService(t *testing.T) { // Send the tx to the app txBytes, err := txConfig.TxEncoder()(txBuilder.GetTx()) require.NoError(t, err) - res, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) + res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1, Txs: [][]byte{txBytes}}) require.NoError(t, err) require.Equal(t, abci.CodeTypeOK, res.TxResults[0].Code, "res=%+v", res) } diff --git a/baseapp/snapshot_test.go b/baseapp/snapshot_test.go index 65b19c919238..216946a9f6fa 100644 --- a/baseapp/snapshot_test.go +++ b/baseapp/snapshot_test.go @@ -23,7 +23,7 @@ func TestABCI_ListSnapshots(t *testing.T) { suite := NewBaseAppSuiteWithSnapshots(t, ssCfg) - resp, err := suite.baseApp.ListSnapshots(context.TODO(), &abci.RequestListSnapshots{}) + resp, err := suite.baseApp.ListSnapshots(&abci.RequestListSnapshots{}) require.NoError(t, err) for _, s := range resp.Snapshots { require.NotEmpty(t, s.Hash) @@ -122,7 +122,7 @@ func TestABCI_SnapshotWithPruning(t *testing.T) { t.Run(name, func(t *testing.T) { suite := NewBaseAppSuiteWithSnapshots(t, tc.ssCfg) - resp, err := suite.baseApp.ListSnapshots(context.Background(), &abci.RequestListSnapshots{}) + resp, err := suite.baseApp.ListSnapshots(&abci.RequestListSnapshots{}) require.NoError(t, err) for _, s := range resp.Snapshots { require.NotEmpty(t, s.Hash) @@ -150,13 +150,13 @@ func TestABCI_SnapshotWithPruning(t *testing.T) { } // Query 1 - res, err := suite.baseApp.Query(context.Background(), &abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight}) + res, err := suite.baseApp.Query(context.TODO(), &abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight}) require.NoError(t, err) require.NotNil(t, res, "height: %d", lastExistingHeight) require.NotNil(t, res.Value, "height: %d", lastExistingHeight) // Query 2 - res, err = suite.baseApp.Query(context.Background(), &abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight - 1}) + res, err = suite.baseApp.Query(context.TODO(), &abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight - 1}) require.NoError(t, err) require.NotNil(t, res, "height: %d", lastExistingHeight-1) @@ -195,7 +195,7 @@ func TestABCI_LoadSnapshotChunk(t *testing.T) { for name, tc := range testCases { t.Run(name, func(t *testing.T) { - resp, _ := suite.baseApp.LoadSnapshotChunk(context.Background(), &abci.RequestLoadSnapshotChunk{ + resp, _ := suite.baseApp.LoadSnapshotChunk(&abci.RequestLoadSnapshotChunk{ Height: tc.height, Format: tc.format, Chunk: tc.chunk, @@ -248,7 +248,7 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) { for name, tc := range testCases { tc := tc t.Run(name, func(t *testing.T) { - resp, err := suite.baseApp.OfferSnapshot(context.Background(), &abci.RequestOfferSnapshot{Snapshot: tc.snapshot}) + resp, err := suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: tc.snapshot}) if tc.isErr { require.Error(t, err) return @@ -259,7 +259,7 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) { } // Offering a snapshot after one has been accepted should error - resp, err := suite.baseApp.OfferSnapshot(context.Background(), &abci.RequestOfferSnapshot{Snapshot: &abci.Snapshot{ + resp, err := suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: &abci.Snapshot{ Height: 1, Format: snapshottypes.CurrentFormat, Chunks: 3, @@ -269,7 +269,7 @@ func TestABCI_OfferSnapshot_Errors(t *testing.T) { require.NoError(t, err) require.Equal(t, &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ACCEPT}, resp) - resp, err = suite.baseApp.OfferSnapshot(context.Background(), &abci.RequestOfferSnapshot{Snapshot: &abci.Snapshot{ + resp, err = suite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: &abci.Snapshot{ Height: 2, Format: snapshottypes.CurrentFormat, Chunks: 3, @@ -300,7 +300,7 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { targetSuite := NewBaseAppSuiteWithSnapshots(t, targetCfg) // fetch latest snapshot to restore - respList, err := srcSuite.baseApp.ListSnapshots(context.Background(), &abci.RequestListSnapshots{}) + respList, err := srcSuite.baseApp.ListSnapshots(&abci.RequestListSnapshots{}) require.NoError(t, err) require.NotEmpty(t, respList.Snapshots) snapshot := respList.Snapshots[0] @@ -309,13 +309,13 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { require.GreaterOrEqual(t, snapshot.Chunks, uint32(3), "Not enough snapshot chunks") // begin a snapshot restoration in the target - respOffer, err := targetSuite.baseApp.OfferSnapshot(context.Background(), &abci.RequestOfferSnapshot{Snapshot: snapshot}) + respOffer, err := targetSuite.baseApp.OfferSnapshot(&abci.RequestOfferSnapshot{Snapshot: snapshot}) require.NoError(t, err) require.Equal(t, &abci.ResponseOfferSnapshot{Result: abci.ResponseOfferSnapshot_ACCEPT}, respOffer) // We should be able to pass an invalid chunk and get a verify failure, before // reapplying it. - respApply, err := targetSuite.baseApp.ApplySnapshotChunk(context.Background(), &abci.RequestApplySnapshotChunk{ + respApply, err := targetSuite.baseApp.ApplySnapshotChunk(&abci.RequestApplySnapshotChunk{ Index: 0, Chunk: []byte{9}, Sender: "sender", @@ -329,7 +329,7 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { // fetch each chunk from the source and apply it to the target for index := uint32(0); index < snapshot.Chunks; index++ { - respChunk, err := srcSuite.baseApp.LoadSnapshotChunk(context.Background(), &abci.RequestLoadSnapshotChunk{ + respChunk, err := srcSuite.baseApp.LoadSnapshotChunk(&abci.RequestLoadSnapshotChunk{ Height: snapshot.Height, Format: snapshot.Format, Chunk: index, @@ -337,7 +337,7 @@ func TestABCI_ApplySnapshotChunk(t *testing.T) { require.NoError(t, err) require.NotNil(t, respChunk.Chunk) - respApply, err := targetSuite.baseApp.ApplySnapshotChunk(context.Background(), &abci.RequestApplySnapshotChunk{ + respApply, err := targetSuite.baseApp.ApplySnapshotChunk(&abci.RequestApplySnapshotChunk{ Index: index, Chunk: respChunk.Chunk, }) diff --git a/baseapp/streaming_test.go b/baseapp/streaming_test.go index 644f35eebd0d..e4a896a40d28 100644 --- a/baseapp/streaming_test.go +++ b/baseapp/streaming_test.go @@ -51,7 +51,6 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { suite := NewBaseAppSuite(t, anteOpt, distOpt, streamingManagerOpt, addListenerOpt) suite.baseApp.InitChain( - context.TODO(), &abci.RequestInitChain{ ConsensusParams: &tmproto.ConsensusParams{}, }, @@ -69,7 +68,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { var expectedChangeSet []*storetypes.StoreKVPair // create final block context state - _, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: int64(blockN) + 1, Txs: txs}) + _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1, Txs: txs}) require.NoError(t, err) for i := 0; i < txPerHeight; i++ { @@ -94,7 +93,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { txs = append(txs, txBytes) } - res, err := suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: int64(blockN) + 1, Txs: txs}) + res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1, Txs: txs}) require.NoError(t, err) for _, tx := range res.TxResults { events := tx.GetEvents() @@ -103,7 +102,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { // require.Equal(t, sdk.MarkEventsToIndex(counterEvent(sdk.EventTypeMessage, counter).ToABCIEvents(), map[string]struct{}{})[0], events[2], "msg handler update counter event") } - suite.baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + suite.baseApp.Commit() require.Equal(t, expectedChangeSet, mockListener1.ChangeSet, "should contain the same changeSet") require.Equal(t, expectedChangeSet, mockListener2.ChangeSet, "should contain the same changeSet") @@ -119,7 +118,7 @@ func Test_Ctx_with_StreamingManager(t *testing.T) { addListenerOpt := func(bapp *baseapp.BaseApp) { bapp.CommitMultiStore().AddListeners([]storetypes.StoreKey{distKey1}) } suite := NewBaseAppSuite(t, streamingManagerOpt, addListenerOpt) - suite.baseApp.InitChain(context.TODO(), &abci.RequestInitChain{ + suite.baseApp.InitChain(&abci.RequestInitChain{ ConsensusParams: &tmproto.ConsensusParams{}, }) @@ -133,7 +132,7 @@ func Test_Ctx_with_StreamingManager(t *testing.T) { for blockN := 0; blockN < nBlocks; blockN++ { - suite.baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: int64(blockN) + 1}) + suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1}) ctx := getFinalizeBlockStateCtx(suite.baseApp) sm := ctx.StreamingManager() @@ -141,6 +140,6 @@ func Test_Ctx_with_StreamingManager(t *testing.T) { require.Equal(t, listeners, sm.ABCIListeners, fmt.Sprintf("should contain same listeners: %v", listeners)) require.Equal(t, true, sm.StopNodeOnErr, "should contain StopNodeOnErr = true") - suite.baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + suite.baseApp.Commit() } } diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index 5242cd306a5c..bdd1e75316db 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -83,15 +83,14 @@ func (s *IntegrationTestSuite) SetupSuite() { s.NoError(err) // init chain will set the validator set and initialize the genesis accounts - app.InitChain(context.TODO(), - &abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: sims.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, + app.InitChain(&abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: sims.DefaultConsensusParams, + AppStateBytes: stateBytes, + }, ) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, NextValidatorsHash: valSet.Hash(), diff --git a/runtime/app.go b/runtime/app.go index 399679873cf5..e2cb361d4c84 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -18,6 +18,7 @@ import ( nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -179,11 +180,12 @@ func (a *App) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (a *App) RegisterTendermintService(clientCtx client.Context) { + cmtApp := server.NewCometABCIWrapper(a) cmtservice.RegisterTendermintService( clientCtx, a.GRPCQueryRouter(), a.interfaceRegistry, - a.Query, + cmtApp.Query, ) } diff --git a/server/cmt_abci.go b/server/cmt_abci.go new file mode 100644 index 000000000000..3db12dafed5a --- /dev/null +++ b/server/cmt_abci.go @@ -0,0 +1,72 @@ +package server + +import ( + "context" + + abci "github.com/cometbft/cometbft/abci/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" +) + +type cometABCIWrapper struct { + app servertypes.ABCI +} + +func NewCometABCIWrapper(app servertypes.ABCI) abci.Application { + return cometABCIWrapper{app: app} +} + +func (w cometABCIWrapper) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) { + return w.app.Info(req) +} + +func (w cometABCIWrapper) Query(ctx context.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error) { + return w.app.Query(ctx, req) +} + +func (w cometABCIWrapper) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { + return w.app.CheckTx(req) +} + +func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { + return w.app.InitChain(req) +} + +func (w cometABCIWrapper) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + return w.app.PrepareProposal(req) +} + +func (w cometABCIWrapper) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { + return w.app.ProcessProposal(req) +} + +func (w cometABCIWrapper) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { + return w.app.FinalizeBlock(req) +} + +func (w cometABCIWrapper) ExtendVote(ctx context.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + return w.app.ExtendVote(ctx, req) +} + +func (w cometABCIWrapper) VerifyVoteExtension(_ context.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + return w.app.VerifyVoteExtension(req) +} + +func (w cometABCIWrapper) Commit(_ context.Context, _ *abci.RequestCommit) (*abci.ResponseCommit, error) { + return w.app.Commit() +} + +func (w cometABCIWrapper) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) { + return w.app.ListSnapshots(req) +} + +func (w cometABCIWrapper) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) { + return w.app.OfferSnapshot(req) +} + +func (w cometABCIWrapper) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) { + return w.app.LoadSnapshotChunk(req) +} + +func (w cometABCIWrapper) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) { + return w.app.ApplySnapshotChunk(req) +} diff --git a/server/mock/app.go b/server/mock/app.go index fd325ce5195a..bc5af766258d 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -17,6 +17,7 @@ import ( bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -24,7 +25,7 @@ import ( // NewApp creates a simple mock kvstore app for testing. It should work // similar to a real app. Make sure rootDir is empty before running the test, // in order to guarantee consistent results. -func NewApp(rootDir string, logger log.Logger) (abci.Application, error) { +func NewApp(rootDir string, logger log.Logger) (servertypes.ABCI, error) { db, err := db.NewGoLevelDB("mock", filepath.Join(rootDir, "data"), nil) if err != nil { return nil, err diff --git a/server/mock/app_test.go b/server/mock/app_test.go index 35a6c5222a90..f204c5f5f26c 100644 --- a/server/mock/app_test.go +++ b/server/mock/app_test.go @@ -10,13 +10,14 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/stretchr/testify/require" + servertypes "github.com/cosmos/cosmos-sdk/server/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) // SetupApp initializes a new application, // failing t if initialization fails. -func SetupApp(t *testing.T) abci.Application { +func SetupApp(t *testing.T) servertypes.ABCI { t.Helper() logger := log.NewTestLogger(t) @@ -38,13 +39,13 @@ func TestInitApp(t *testing.T) { req := abci.RequestInitChain{ AppStateBytes: appState, } - res, err := app.InitChain(context.TODO(), &req) + res, err := app.InitChain(&req) require.NoError(t, err) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Hash: res.AppHash, Height: 1, }) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() // make sure we can query these values query := abci.RequestQuery{ @@ -52,7 +53,7 @@ func TestInitApp(t *testing.T) { Data: []byte("foo"), } - qres, err := app.Query(context.TODO(), &query) + qres, err := app.Query(context.Background(), &query) require.NoError(t, err) require.Equal(t, uint32(0), qres.Code, qres.Log) require.Equal(t, []byte("bar"), qres.Value) @@ -70,7 +71,7 @@ func TestDeliverTx(t *testing.T) { tx := NewTx(key, value, randomAccounts[0].Address) txBytes := tx.GetSignBytes() - res, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ Hash: []byte("apphash"), Height: 1, Txs: [][]byte{txBytes}, @@ -78,7 +79,7 @@ func TestDeliverTx(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, res.AppHash) - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) // make sure we can query these values @@ -87,7 +88,7 @@ func TestDeliverTx(t *testing.T) { Data: []byte(key), } - qres, err := app.Query(context.TODO(), &query) + qres, err := app.Query(context.Background(), &query) require.NoError(t, err) require.Equal(t, uint32(0), qres.Code, qres.Log) require.Equal(t, []byte(value), qres.Value) diff --git a/server/start.go b/server/start.go index cd9d0a086360..54eab658d8b9 100644 --- a/server/start.go +++ b/server/start.go @@ -265,7 +265,8 @@ func startStandAlone(svrCtx *Context, appCreator types.AppCreator, opts StartCmd emitServerInfoMetrics() - svr, err := server.NewServer(addr, transport, app) + cmtApp := NewCometABCIWrapper(app) + svr, err := server.NewServer(addr, transport, cmtApp) if err != nil { return fmt.Errorf("error creating listener: %v", err) } @@ -427,11 +428,12 @@ func startCmtNode( app types.Application, svrCtx *Context, ) (tmNode *node.Node, err error) { + cmtApp := NewCometABCIWrapper(app) tmNode, err = node.NewNode( cfg, pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()), nodeKey, - proxy.NewLocalClientCreator(app), + proxy.NewLocalClientCreator(cmtApp), genDocProvider, cmtcfg.DefaultDBProvider, node.DefaultMetricsProvider(cfg.Instrumentation), diff --git a/server/types/abci.go b/server/types/abci.go new file mode 100644 index 000000000000..965aed3df673 --- /dev/null +++ b/server/types/abci.go @@ -0,0 +1,37 @@ +package types + +import ( + "context" + + abci "github.com/cometbft/cometbft/abci/types" +) + +// ABCI is an interface that enables any finite, deterministic state machine +// to be driven by a blockchain-based replication engine via the ABCI. +type ABCI interface { + // Info/Query Connection + Info(*abci.RequestInfo) (*abci.ResponseInfo, error) // Return application info + Query(context.Context, *abci.RequestQuery) (*abci.ResponseQuery, error) // Query for state + + // Mempool Connection + CheckTx(*abci.RequestCheckTx) (*abci.ResponseCheckTx, error) // Validate a tx for the mempool + + // Consensus Connection + InitChain(*abci.RequestInitChain) (*abci.ResponseInitChain, error) // Initialize blockchain w validators/other info from CometBFT + PrepareProposal(*abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) + ProcessProposal(*abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) + // Deliver the decided block with its txs to the Application + FinalizeBlock(*abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) + // Create application specific vote extension + ExtendVote(context.Context, *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) + // Verify application's vote extension data + VerifyVoteExtension(*abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) + // Commit the state and return the application Merkle root hash + Commit() (*abci.ResponseCommit, error) + + // State Sync Connection + ListSnapshots(*abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) // List available snapshots + OfferSnapshot(*abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) // Offer a snapshot to the application + LoadSnapshotChunk(*abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) // Load a snapshot chunk + ApplySnapshotChunk(*abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) // Apply a shapshot chunk +} diff --git a/server/types/app.go b/server/types/app.go index 4b94665c7280..e40cf099d2bc 100644 --- a/server/types/app.go +++ b/server/types/app.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/log" "cosmossdk.io/store/snapshots" storetypes "cosmossdk.io/store/types" - abci "github.com/cometbft/cometbft/abci/types" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" @@ -35,7 +34,7 @@ type ( // The interface defines the necessary contracts to be implemented in order // to fully bootstrap and start an application. Application interface { - abci.Application + ABCI RegisterAPIRoutes(*api.Server, config.APIConfig) diff --git a/simapp/app.go b/simapp/app.go index ff3b5ea41a37..57db9b56e043 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -702,11 +702,12 @@ func (app *SimApp) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { + cmtApp := server.NewCometABCIWrapper(app) cmtservice.RegisterTendermintService( clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, - app.Query, + cmtApp.Query, ) } diff --git a/simapp/app_test.go b/simapp/app_test.go index f809189e8ed4..33cf504d4f98 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -1,7 +1,6 @@ package simapp import ( - "context" "encoding/json" "fmt" "testing" @@ -66,12 +65,12 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { } // finalize block so we have CheckTx state set - _, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, }) require.NoError(t, err) - _, err = app.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = app.Commit() require.NoError(t, err) // Making a new app object with the db, so that initchain hasn't been called @@ -115,8 +114,8 @@ func TestRunMigrations(t *testing.T) { } // Initialize the chain - app.InitChain(context.TODO(), &abci.RequestInitChain{}) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.InitChain(&abci.RequestInitChain{}) + app.Commit() testCases := []struct { name string diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 0a7ae9c8f02f..62de7b69fa23 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -1,7 +1,6 @@ package simapp import ( - "context" "encoding/json" "flag" "fmt" @@ -289,7 +288,7 @@ func TestAppSimulationAfterImport(t *testing.T) { newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt, baseapp.SetChainID(SimAppChainID)) require.Equal(t, "SimApp", newApp.Name()) - newApp.InitChain(context.TODO(), &abci.RequestInitChain{ + newApp.InitChain(&abci.RequestInitChain{ AppStateBytes: exported.AppState, ChainId: SimAppChainID, }) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 77c06fa17f7d..bb36b5ee2d5f 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -1,7 +1,6 @@ package simapp import ( - "context" "encoding/json" "fmt" "os" @@ -83,7 +82,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio require.NoError(t, err) // Initialize the chain - _, err = app.InitChain(context.TODO(), &abci.RequestInitChain{ + _, err = app.InitChain(&abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: simtestutil.DefaultConsensusParams, AppStateBytes: stateBytes, @@ -134,7 +133,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs require.NoError(t, err) // init chain will set the validator set and initialize the genesis accounts - _, err = app.InitChain(context.TODO(), &abci.RequestInitChain{ + _, err = app.InitChain(&abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: simtestutil.DefaultConsensusParams, AppStateBytes: stateBytes, @@ -143,7 +142,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs require.NoError(t, err) require.NoError(t, err) - _, err = app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, NextValidatorsHash: valSet.Hash(), diff --git a/tests/e2e/server/export_test.go b/tests/e2e/server/export_test.go index 2f2a2be32a6d..45616e7029b5 100644 --- a/tests/e2e/server/export_test.go +++ b/tests/e2e/server/export_test.go @@ -95,10 +95,10 @@ func TestExportCmd_Height(t *testing.T) { // Fast forward to block `tc.fastForward`. for i := int64(2); i <= tc.fastForward; i++ { - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: i, }) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() } output := &bytes.Buffer{} @@ -182,17 +182,16 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, ge err = genutil.ExportGenesisFile(&appGenesis, serverCtx.Config.GenesisFile()) assert.NilError(t, err) - app.InitChain(context.TODO(), - &abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simtestutil.DefaultConsensusParams, - AppStateBytes: appGenesis.AppState, - }, + app.InitChain(&abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: simtestutil.DefaultConsensusParams, + AppStateBytes: appGenesis.AppState, + }, ) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, }) - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() cmd := server.ExportCmd( func(_ log.Logger, _ dbm.DB, _ io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOptions types.AppOptions, modulesToExport []string) (types.ExportedApp, error) { diff --git a/tests/integration/gov/genesis_test.go b/tests/integration/gov/genesis_test.go index 93896b5c69ea..4a1cd9e869e5 100644 --- a/tests/integration/gov/genesis_test.go +++ b/tests/integration/gov/genesis_test.go @@ -1,7 +1,6 @@ package gov_test import ( - "context" "encoding/json" "testing" @@ -76,7 +75,7 @@ func TestImportExportQueues(t *testing.T) { ctx := s1.app.BaseApp.NewContext(false, cmtproto.Header{}) addrs := simtestutil.AddTestAddrs(s1.BankKeeper, s1.StakingKeeper, ctx, 1, valTokens) - s1.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + s1.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: s1.app.LastBlockHeight() + 1, }) @@ -132,19 +131,17 @@ func TestImportExportQueues(t *testing.T) { ) assert.NilError(t, err) - s2.app.InitChain(context.TODO(), - &abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simtestutil.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) + s2.app.InitChain(&abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: simtestutil.DefaultConsensusParams, + AppStateBytes: stateBytes, + }) - s2.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + s2.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: s2.app.LastBlockHeight() + 1, }) - s2.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + s2.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: s2.app.LastBlockHeight() + 1, }) diff --git a/tests/integration/store/rootmulti/rollback_test.go b/tests/integration/store/rootmulti/rollback_test.go index d4d5cf2b0f76..803040b42e2b 100644 --- a/tests/integration/store/rootmulti/rollback_test.go +++ b/tests/integration/store/rootmulti/rollback_test.go @@ -1,7 +1,6 @@ package rootmulti_test import ( - "context" "fmt" "testing" @@ -31,16 +30,16 @@ func TestRollback(t *testing.T) { AppHash: app.LastCommitID().Hash, } - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: header.Height, }) ctx := app.NewContext(false, header) store := ctx.KVStore(app.GetKey("bank")) store.Set([]byte("key"), []byte(fmt.Sprintf("value%d", i))) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: header.Height, }) - app.Commit(context.TODO(), nil) + app.Commit() } assert.Equal(t, ver0+10, app.LastBlockHeight()) @@ -63,14 +62,14 @@ func TestRollback(t *testing.T) { Height: ver0 + i, AppHash: app.LastCommitID().Hash, } - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: header.Height}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: header.Height}) ctx := app.NewContext(false, header) store := ctx.KVStore(app.GetKey("bank")) store.Set([]byte("key"), []byte(fmt.Sprintf("VALUE%d", i))) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: header.Height, }) - app.Commit(context.TODO(), nil) + app.Commit() } assert.Equal(t, ver0+10, app.LastBlockHeight()) diff --git a/testutil/integration/router.go b/testutil/integration/router.go index fc51f7614906..fc4cebee89fc 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -88,7 +88,7 @@ func NewIntegrationApp( panic(fmt.Errorf("failed to load application version from store: %w", err)) } - if _, err := bApp.InitChain(context.TODO(), &cmtabcitypes.RequestInitChain{ChainId: appName, ConsensusParams: simtestutil.DefaultConsensusParams}); err != nil { + if _, err := bApp.InitChain(&cmtabcitypes.RequestInitChain{ChainId: appName, ConsensusParams: simtestutil.DefaultConsensusParams}); err != nil { panic(fmt.Errorf("failed to initialize application: %w", err)) } } else { @@ -96,12 +96,12 @@ func NewIntegrationApp( panic(fmt.Errorf("failed to load application version from store: %w", err)) } - if _, err := bApp.InitChain(context.TODO(), &cmtabcitypes.RequestInitChain{ChainId: appName}); err != nil { + if _, err := bApp.InitChain(&cmtabcitypes.RequestInitChain{ChainId: appName}); err != nil { panic(fmt.Errorf("failed to initialize application: %w", err)) } } - bApp.Commit(context.TODO(), nil) + bApp.Commit() ctx := sdkCtx.WithBlockHeader(cmtproto.Header{ChainID: appName}).WithIsCheckTx(true) @@ -128,13 +128,12 @@ func (app *App) RunMsg(msg sdk.Msg, option ...Option) (*codectypes.Any, error) { } if cfg.AutomaticCommit { - defer app.Commit(context.TODO(), nil) + defer app.Commit() } if cfg.AutomaticFinalizeBlock { height := app.LastBlockHeight() + 1 - ctx := app.ctx.WithBlockHeight(height).WithChainID(appName) - if _, err := app.FinalizeBlock(ctx, &cmtabcitypes.RequestFinalizeBlock{Height: height}); err != nil { + if _, err := app.FinalizeBlock(&cmtabcitypes.RequestFinalizeBlock{Height: height}); err != nil { return nil, fmt.Errorf("failed to run finalize block: %w", err) } } diff --git a/testutil/network/util.go b/testutil/network/util.go index 65f157ae4c38..c70108535c74 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -18,6 +18,7 @@ import ( cmttime "github.com/cometbft/cometbft/types/time" "golang.org/x/sync/errgroup" + "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" servercmtlog "github.com/cosmos/cosmos-sdk/server/log" @@ -51,11 +52,12 @@ func startInProcess(cfg Config, val *Validator) error { return appGenesis.ToGenesisDoc() } + cmtApp := server.NewCometABCIWrapper(app) tmNode, err := node.NewNode( //resleak:notresource cmtCfg, pvm.LoadOrGenFilePV(cmtCfg.PrivValidatorKeyFile(), cmtCfg.PrivValidatorStateFile()), nodeKey, - proxy.NewLocalClientCreator(app), + proxy.NewLocalClientCreator(cmtApp), appGenesisProvider, cmtcfg.DefaultDBProvider, node.DefaultMetricsProvider(cmtCfg.Instrumentation), diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index 0d0d9291e709..6fdbec1f5b71 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -1,7 +1,6 @@ package sims import ( - "context" "encoding/json" "fmt" "time" @@ -158,7 +157,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon } // init chain will set the validator set and initialize the genesis accounts - _, err = app.InitChain(context.Background(), &abci.RequestInitChain{ + _, err = app.InitChain(&abci.RequestInitChain{ Validators: []abci.ValidatorUpdate{}, ConsensusParams: DefaultConsensusParams, AppStateBytes: stateBytes, @@ -169,7 +168,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon // commit genesis changes if !startupConfig.AtGenesis { - _, err = app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, NextValidatorsHash: valSet.Hash(), }) diff --git a/testutil/sims/tx_helpers.go b/testutil/sims/tx_helpers.go index a74a22475768..56c42bfc551d 100644 --- a/testutil/sims/tx_helpers.go +++ b/testutil/sims/tx_helpers.go @@ -124,7 +124,7 @@ func SignCheckDeliver( bz, err := txCfg.TxEncoder()(tx) require.NoError(t, err) - resBlock, err := app.FinalizeBlock(context.TODO(), &types2.RequestFinalizeBlock{ + resBlock, err := app.FinalizeBlock(&types2.RequestFinalizeBlock{ Height: header.Height, Txs: [][]byte{bz}, }) @@ -139,7 +139,7 @@ func SignCheckDeliver( require.False(t, finalizeSuccess) } - app.Commit(context.TODO(), &types2.RequestCommit{}) + app.Commit() gInfo := sdk.GasInfo{GasWanted: uint64(txResult.GasWanted), GasUsed: uint64(txResult.GasUsed)} txRes := sdk.Result{Data: txResult.Data, Log: txResult.Log, Events: txResult.Events} diff --git a/testutil/testnet/cometstarter.go b/testutil/testnet/cometstarter.go index ea884ae0cc09..993e5b447528 100644 --- a/testutil/testnet/cometstarter.go +++ b/testutil/testnet/cometstarter.go @@ -9,7 +9,6 @@ import ( "syscall" "cosmossdk.io/log" - abcitypes "github.com/cometbft/cometbft/abci/types" cmtcfg "github.com/cometbft/cometbft/config" cmted25519 "github.com/cometbft/cometbft/crypto/ed25519" "github.com/cometbft/cometbft/node" @@ -18,7 +17,9 @@ import ( "github.com/cometbft/cometbft/proxy" cmttypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/server" servercmtlog "github.com/cosmos/cosmos-sdk/server/log" + servertypes "github.com/cosmos/cosmos-sdk/server/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) @@ -29,7 +30,7 @@ import ( // the number of available methods on CometStarter will grow. type CometStarter struct { logger log.Logger - app abcitypes.Application + app servertypes.ABCI cfg *cmtcfg.Config valPrivKey cmted25519.PrivKey genesis []byte @@ -44,7 +45,7 @@ type CometStarter struct { // // NewCometStarter(...).Logger(...).Start() func NewCometStarter( - app abcitypes.Application, + app servertypes.ABCI, cfg *cmtcfg.Config, valPrivKey cmted25519.PrivKey, genesis []byte, @@ -144,6 +145,7 @@ func (s *CometStarter) Start() (n *node.Node, err error) { return appGenesis.ToGenesisDoc() } + cmtApp := server.NewCometABCIWrapper(s.app) for i := 0; i < s.startTries; i++ { s.cfg.P2P.ListenAddress = s.likelyAvailableAddress() if s.rpcListen { @@ -154,7 +156,7 @@ func (s *CometStarter) Start() (n *node.Node, err error) { s.cfg, fpv, nodeKey, - proxy.NewLocalClientCreator(s.app), + proxy.NewLocalClientCreator(cmtApp), appGenesisProvider, cmtcfg.DefaultDBProvider, node.DefaultMetricsProvider(s.cfg.Instrumentation), diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index a3c65046feda..02c8625baedd 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/rand" "testing" "time" @@ -123,7 +122,7 @@ func (suite *SimTestSuite) TestSimulateGrant() { blockTime := time.Now().UTC() ctx := suite.ctx.WithBlockTime(blockTime) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -151,7 +150,7 @@ func (suite *SimTestSuite) TestSimulateRevoke() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -188,7 +187,7 @@ func (suite *SimTestSuite) TestSimulateExec() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash}) + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash}) initAmt := sdk.TokensFromConsensusPower(200000, sdk.DefaultPowerReduction) initCoins := sdk.NewCoins(sdk.NewCoin("stake", initAmt)) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index f069c4c43885..19146dae3a7c 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -1,7 +1,6 @@ package bank_test import ( - "context" "testing" "cosmossdk.io/depinject" @@ -153,9 +152,9 @@ func TestSendNotEnoughBalance(t *testing.T) { ctx := baseApp.NewContext(false, cmtproto.Header{}) require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) - _, err := baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + _, err := baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) - _, err = baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = baseApp.Commit() require.NoError(t, err) res1 := s.AccountKeeper.GetAccount(ctx, addr1) @@ -192,9 +191,9 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { ctx := baseApp.NewContext(false, cmtproto.Header{}) require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) - _, err := baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + _, err := baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) - _, err = baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = baseApp.Commit() require.NoError(t, err) res1 := s.AccountKeeper.GetAccount(ctx, addr1) @@ -276,9 +275,9 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) - _, err := baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + _, err := baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) - _, err = baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = baseApp.Commit() require.NoError(t, err) testCases := []appTestCase{ @@ -321,9 +320,9 @@ func TestMsgMultiSendDependent(t *testing.T) { ctx := baseApp.NewContext(false, cmtproto.Header{}) require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) - _, err = baseApp.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + _, err = baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) - _, err = baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + _, err = baseApp.Commit() require.NoError(t, err) testCases := []appTestCase{ diff --git a/x/bank/bench_test.go b/x/bank/bench_test.go index e232887f8d72..ed62692caef1 100644 --- a/x/bank/bench_test.go +++ b/x/bank/bench_test.go @@ -1,7 +1,6 @@ package bank_test import ( - "context" "fmt" "math/rand" "testing" @@ -75,7 +74,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { ctx := baseApp.NewContext(false, cmtproto.Header{}) require.NoError(b, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000)))) - baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + baseApp.Commit() txGen := moduletestutil.MakeTestTxConfig() txEncoder := txGen.TxEncoder() @@ -99,14 +98,13 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) { require.NoError(b, err) baseApp.FinalizeBlock( - context.TODO(), &abci.RequestFinalizeBlock{ Height: height, Txs: [][]byte{bz}, }, ) - baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + baseApp.Commit() height++ } @@ -127,7 +125,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { ctx := baseApp.NewContext(false, cmtproto.Header{}) require.NoError(b, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000)))) - baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + baseApp.Commit() txGen := moduletestutil.MakeTestTxConfig() txEncoder := txGen.TxEncoder() @@ -151,14 +149,13 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) { require.NoError(b, err) baseApp.FinalizeBlock( - context.TODO(), &abci.RequestFinalizeBlock{ Height: height, Txs: [][]byte{bz}, }, ) - baseApp.Commit(context.TODO(), &abci.RequestCommit{}) + baseApp.Commit() height++ } diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index 81a8a083abac..914a70d1b6db 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/rand" "testing" @@ -107,7 +106,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -136,7 +135,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -171,7 +170,7 @@ func (suite *SimTestSuite) TestSimulateModuleAccountMsgSend() { r := rand.New(s) accounts := suite.getTestingAccounts(r, accCount) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }, @@ -205,7 +204,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSendToModuleAccount() { r := rand.New(s) accounts := suite.getTestingAccounts(r, accCount) - suite.app.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index ef28fe728331..645003b609cb 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/rand" "testing" @@ -74,7 +73,7 @@ func (suite *SimTestSuite) TestSimulateMsgSetWithdrawAddress() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -116,7 +115,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() { suite.setupValidatorRewards(validator0.GetOperator()) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -175,7 +174,7 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName suite.distrKeeper.SetValidatorAccumulatedCommission(suite.ctx, validator0.GetOperator(), types.ValidatorAccumulatedCommission{Commission: valCommission}) suite.distrKeeper.SetValidatorAccumulatedCommission(suite.ctx, suite.genesisVals[0].GetOperator(), types.ValidatorAccumulatedCommission{Commission: valCommission}) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -206,7 +205,7 @@ func (suite *SimTestSuite) TestSimulateMsgFundCommunityPool() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 3) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index b4f8054aac13..e639c3f20e47 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/rand" "testing" "time" @@ -154,7 +153,7 @@ func (suite *SimTestSuite) TestSimulateMsgGrantAllowance() { accounts := suite.getTestingAccounts(r, 3) // new block - _, err := app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) require.NoError(err) // execute operation @@ -180,7 +179,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeAllowance() { accounts := suite.getTestingAccounts(r, 3) // begin a new block - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash}) feeAmt := sdk.TokensFromConsensusPower(200000, sdk.DefaultPowerReduction) feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt)) diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index c27ae1d19513..d325a7c72eef 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -215,7 +215,8 @@ func TestStartStandAlone(t *testing.T) { require.NoError(t, err) require.NoError(t, closeFn()) - svr, err := abci_server.NewServer(svrAddr, "socket", app) + cmtApp := server.NewCometABCIWrapper(app) + svr, err := abci_server.NewServer(svrAddr, "socket", cmtApp) require.NoError(t, err, "error creating listener") svr.SetLogger(servercmtlog.CometLoggerWrapper{Logger: logger.With("module", "abci-server")}) diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index c41b9c2a43c3..fc551fda5b43 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -1,7 +1,6 @@ package gov_test import ( - "context" "testing" "time" @@ -28,7 +27,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) { ctx := app.BaseApp.NewContext(false, cmtproto.Header{}) addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -88,7 +87,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { ctx := app.BaseApp.NewContext(false, cmtproto.Header{}) addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -177,7 +176,7 @@ func TestTickPassedDepositPeriod(t *testing.T) { ctx := app.BaseApp.NewContext(false, cmtproto.Header{}) addrs := simtestutil.AddTestAddrs(suite.BankKeeper, suite.StakingKeeper, ctx, 10, valTokens) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -255,7 +254,7 @@ func TestTickPassedVotingPeriod(t *testing.T) { SortAddresses(addrs) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -364,7 +363,7 @@ func TestProposalPassedEndblocker(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -423,7 +422,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -507,7 +506,7 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) { govMsgSvr := keeper.NewMsgServerImpl(suite.GovKeeper) stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index 3b5d39068373..d524808395cf 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "fmt" "math/rand" "testing" @@ -145,7 +144,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { r := rand.New(s) accounts := getTestingAccounts(t, r, suite.AccountKeeper, suite.BankKeeper, suite.StakingKeeper, ctx, 3) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -176,7 +175,7 @@ func TestSimulateMsgSubmitLegacyProposal(t *testing.T) { r := rand.New(s) accounts := getTestingAccounts(t, r, suite.AccountKeeper, suite.BankKeeper, suite.StakingKeeper, ctx, 3) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -234,7 +233,7 @@ func TestSimulateMsgCancelProposal(t *testing.T) { suite.GovKeeper.SetProposal(ctx, proposal) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -281,7 +280,7 @@ func TestSimulateMsgDeposit(t *testing.T) { suite.GovKeeper.SetProposal(ctx, proposal) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -329,7 +328,7 @@ func TestSimulateMsgVote(t *testing.T) { suite.GovKeeper.ActivateVotingPeriod(ctx, proposal) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) @@ -375,7 +374,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { suite.GovKeeper.ActivateVotingPeriod(ctx, proposal) - app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: app.LastBlockHeight() + 1, Hash: app.LastCommitID().Hash, }) diff --git a/x/group/simulation/operations_test.go b/x/group/simulation/operations_test.go index 9ed16aa15e0f..46b58367533d 100644 --- a/x/group/simulation/operations_test.go +++ b/x/group/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/rand" "testing" "time" @@ -131,7 +130,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroup() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 1) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -157,7 +156,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupWithPolicy() { r := rand.New(s) accounts := suite.getTestingAccounts(r, 1) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -198,7 +197,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupPolicy() { ) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -248,7 +247,7 @@ func (suite *SimTestSuite) TestSimulateSubmitProposal() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -311,7 +310,7 @@ func (suite *SimTestSuite) TestWithdrawProposal() { _, err = suite.groupKeeper.SubmitProposal(ctx, proposalReq) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -375,7 +374,7 @@ func (suite *SimTestSuite) TestSimulateVote() { _, err = suite.groupKeeper.SubmitProposal(ctx, proposalReq) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -447,7 +446,7 @@ func (suite *SimTestSuite) TestSimulateExec() { }) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -486,7 +485,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupAdmin() { ) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -525,7 +524,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMetadata() { ) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -564,7 +563,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMembers() { ) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -614,7 +613,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyAdmin() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -664,7 +663,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyDecisionPolicy() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -714,7 +713,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyMetadata() { groupPolicyRes, err := suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) suite.Require().NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) @@ -777,7 +776,7 @@ func (suite *SimTestSuite) TestSimulateLeaveGroup() { _, err = suite.groupKeeper.CreateGroupPolicy(ctx, accountReq) require.NoError(err) - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) diff --git a/x/nft/simulation/operations_test.go b/x/nft/simulation/operations_test.go index 6f6fd0f7b6c6..d81e7dd5d604 100644 --- a/x/nft/simulation/operations_test.go +++ b/x/nft/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/rand" "testing" "time" @@ -127,7 +126,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { ctx := suite.ctx.WithBlockTime(blockTime) // begin new block - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{ + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, }) diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 10dcc041290f..64f3997e48ab 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -1,7 +1,6 @@ package simulation import ( - "context" "fmt" "io" "math/rand" @@ -40,7 +39,7 @@ func initChain( ConsensusParams: consensusParams, Time: genesisTimestamp, } - res, err := app.InitChain(context.TODO(), &req) + res, err := app.InitChain(&req) if err != nil { panic(err) } @@ -177,7 +176,7 @@ func SimulateFromSeed( // Run the BeginBlock handler logWriter.AddEntry(BeginBlockEntry(int64(height))) - res, err := app.FinalizeBlock(context.TODO(), finalizeBlockReq) + res, err := app.FinalizeBlock(finalizeBlockReq) if err != nil { return true, params, err } @@ -222,7 +221,7 @@ func SimulateFromSeed( logWriter.AddEntry(EndBlockEntry(int64(height))) if config.Commit { - app.Commit(context.TODO(), &abci.RequestCommit{}) + app.Commit() } if proposerAddress == nil { diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 809301da2acc..42f72963ad10 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -91,7 +91,7 @@ func TestSlashingMsgs(t *testing.T) { require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) - app.FinalizeBlock(ctxCheck, &abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) ctxCheck = baseApp.NewContext(true, cmtproto.Header{}) validator, found := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index 2658d09652cb..0d11cec1175e 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "fmt" "math/rand" "testing" @@ -182,7 +181,7 @@ func (suite *SimTestSuite) TestSimulateMsgUnjail() { suite.distrKeeper.SetDelegatorStartingInfo(ctx, validator0.GetOperator(), val0AccAddress.Bytes(), distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200)) // begin a new block - suite.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, Time: blockTime}) + suite.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: suite.app.LastBlockHeight() + 1, Hash: suite.app.LastCommitID().Hash, Time: blockTime}) // execute operation op := simulation.SimulateMsgUnjail(codec.NewProtoCodec(suite.interfaceRegistry), suite.txConfig, suite.accountKeeper, suite.bankKeeper, suite.slashingKeeper, suite.stakingKeeper) diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 71e890036f0b..b121c436fb0e 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -82,7 +82,7 @@ func TestStakingMsgs(t *testing.T) { require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) - app.FinalizeBlock(ctxCheck, &abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) ctxCheck = app.BaseApp.NewContext(true, cmtproto.Header{}) validator, found := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) require.True(t, found) @@ -90,7 +90,7 @@ func TestStakingMsgs(t *testing.T) { require.Equal(t, types.Bonded, validator.Status) require.True(math.IntEq(t, bondTokens, validator.BondedTokens())) - app.FinalizeBlock(ctxCheck, &abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) // edit the validator description = types.NewDescription("bar_moniker", "", "", "", "") diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index bf1fb1843f67..651ce0b96904 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "context" "math/big" "math/rand" "testing" @@ -168,7 +167,7 @@ func (s *SimTestSuite) TestWeightedOperations() { // Abonormal scenarios, where the message are created by an errors are not tested here. func (s *SimTestSuite) TestSimulateMsgCreateValidator() { require := s.Require() - s.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash}) + s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash}) // execute operation op := simulation.SimulateMsgCreateValidator(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) @@ -212,7 +211,7 @@ func (s *SimTestSuite) TestSimulateMsgCancelUnbondingDelegation() { s.stakingKeeper.SetUnbondingDelegation(ctx, udb) s.setupValidatorRewards(ctx, validator0.GetOperator()) - s.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) + s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) // execute operation op := simulation.SimulateMsgCancelUnbondingDelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) @@ -240,7 +239,7 @@ func (s *SimTestSuite) TestSimulateMsgEditValidator() { // setup accounts[0] as validator _ = s.getTestingValidator0(ctx) - s.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) + s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) // execute operation op := simulation.SimulateMsgEditValidator(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) @@ -299,7 +298,7 @@ func (s *SimTestSuite) TestSimulateMsgUndelegate() { s.setupValidatorRewards(ctx, validator0.GetOperator()) - s.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) + s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) // execute operation op := simulation.SimulateMsgUndelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) @@ -341,7 +340,7 @@ func (s *SimTestSuite) TestSimulateMsgBeginRedelegate() { s.setupValidatorRewards(ctx, validator0.GetOperator()) s.setupValidatorRewards(ctx, validator1.GetOperator()) - s.app.FinalizeBlock(context.TODO(), &abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) + s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime}) // execute operation op := simulation.SimulateMsgBeginRedelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper) diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index 8985797a5074..4ed04a49d86d 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -1,7 +1,6 @@ package types import ( - "context" "encoding/json" "os" "path/filepath" @@ -127,8 +126,8 @@ func TestSetLoader(t *testing.T) { require.Equal(t, int64(1), oldApp.LastBlockHeight()) for i := int64(2); i <= upgradeHeight-1; i++ { - oldApp.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{Height: i}) - _, err := oldApp.Commit(context.Background(), &abci.RequestCommit{}) + oldApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: i}) + _, err := oldApp.Commit() require.NoError(t, err) } @@ -148,8 +147,8 @@ func TestSetLoader(t *testing.T) { require.Equal(t, upgradeHeight-1, newApp.LastBlockHeight()) // "execute" one block - newApp.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{Height: upgradeHeight}) - _, err = newApp.Commit(context.Background(), &abci.RequestCommit{}) + newApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: upgradeHeight}) + _, err = newApp.Commit() require.NoError(t, err) require.Equal(t, upgradeHeight, newApp.LastBlockHeight())