diff --git a/baseapp/abci.go b/baseapp/abci.go index dc36a9ab4e81..3ef7fa77c090 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -45,15 +45,13 @@ func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitCha // On a new chain, we consider the init chain block height as 0, even though // req.InitialHeight is 1 by default. initHeader := cmtproto.Header{ChainID: req.ChainId, Time: req.Time} + app.initialHeight = req.InitialHeight app.logger.Info("InitChain", "initialHeight", req.InitialHeight, "chainID", req.ChainId) // Set the initial height, which will be used to determine if we are proposing // or processing the first block or not. app.initialHeight = req.InitialHeight - if app.initialHeight == 0 { // If initial height is 0, set it to 1 - app.initialHeight = 1 - } // if req.InitialHeight is > 1, then we set the initial version on all stores if req.InitialHeight > 1 { @@ -677,32 +675,46 @@ func (app *BaseApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.Respons AppHash: app.LastCommitID().Hash, } - // app.finalizeBlockState.ctx will already be initialized - // by InitChain or by ProcessProposal. Context is now updated with Header information. + // Initialize the FinalizeBlock state. If this is the first block, it should + // already be initialized in InitChain. Otherwise app.finalizeBlockState will be + // nil, since it is reset on Commit. + if app.finalizeBlockState == nil { + app.setState(execModeFinalize, header) + } else { + // In the first block, app.finalizeBlockState.ctx will already be initialized + // by InitChain. Context is now updated with Header information. + app.finalizeBlockState.ctx = app.finalizeBlockState.ctx. + WithBlockHeader(header). + WithBlockHeight(req.Height). + WithHeaderInfo(coreheader.Info{ + ChainID: app.chainID, + Height: req.Height, + Time: req.Time, + Hash: req.Hash, + AppHash: app.LastCommitID().Hash, + }) + } + + gasMeter := app.getBlockGasMeter(app.finalizeBlockState.ctx) + app.finalizeBlockState.ctx = app.finalizeBlockState.ctx. - WithBlockHeader(header). + WithBlockGasMeter(gasMeter). WithHeaderHash(req.Hash). + WithConsensusParams(app.GetConsensusParams(app.finalizeBlockState.ctx)). + WithVoteInfos(req.DecidedLastCommit.Votes). + WithExecMode(sdk.ExecModeFinalize). WithHeaderInfo(coreheader.Info{ ChainID: app.chainID, Height: req.Height, Time: req.Time, Hash: req.Hash, AppHash: app.LastCommitID().Hash, - }). - WithConsensusParams(app.GetConsensusParams(app.finalizeBlockState.ctx)). - WithVoteInfos(req.DecidedLastCommit.Votes). - WithExecMode(sdk.ExecModeFinalize). - WithCometInfo(cometInfo{ - Misbehavior: req.Misbehavior, - ValidatorsHash: req.NextValidatorsHash, - ProposerAddress: req.ProposerAddress, - LastCommit: req.DecidedLastCommit, - }) - - gasMeter := app.getBlockGasMeter(app.finalizeBlockState.ctx) - - app.finalizeBlockState.ctx = app.finalizeBlockState.ctx. - WithBlockGasMeter(gasMeter) + }).WithCometInfo(cometInfo{ + Misbehavior: req.Misbehavior, + ValidatorsHash: req.NextValidatorsHash, + ProposerAddress: req.ProposerAddress, + LastCommit: req.DecidedLastCommit, + }) if app.checkState != nil { app.checkState.ctx = app.checkState.ctx. diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 778373571ca0..5487f5c371d6 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -164,8 +164,6 @@ func TestABCI_InitChain(t *testing.T) { require.Equal(t, value, resQ.Value) // commit and ensure we can still query - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) require.NoError(t, err) _, err = app.Commit() @@ -580,12 +578,6 @@ func TestABCI_FinalizeBlock_DeliverTx(t *testing.T) { txs = append(txs, txBytes) } - _, err := suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{ - Height: int64(blockN) + 1, - Txs: txs, - }) - require.NoError(t, err) - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: int64(blockN) + 1, Txs: txs, @@ -737,8 +729,6 @@ 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)) - _, err = suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: count}) - require.NoError(t, err) _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: count}) require.NoError(t, err) _, err = suite.baseApp.Commit() @@ -907,10 +897,6 @@ func TestABCI_TxGasLimits(t *testing.T) { }) require.NoError(t, err) - _, err = suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{ - Height: 1, - }) - require.NoError(t, err) _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 1, }) @@ -948,12 +934,6 @@ func TestABCI_TxGasLimits(t *testing.T) { } // Deliver the txs - _, err = suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{ - Height: 2, - Txs: txs, - }) - require.NoError(t, err) - res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: 2, Txs: txs, @@ -1319,9 +1299,7 @@ func TestPrepareCheckStateCalledWithCheckState(t *testing.T) { wasPrepareCheckStateCalled = true }) - _, err := app.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) - require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) @@ -1345,9 +1323,7 @@ func TestPrecommiterCalledWithDeliverState(t *testing.T) { wasPrecommiterCalled = true }) - _, err := app.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) - require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 9388badfa324..ea7c9f5ed66b 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -138,13 +138,7 @@ func NewBaseAppSuiteWithSnapshots(t *testing.T, cfg SnapshotsConfig, opts ...fun txs = append(txs, txBytes) } - _, err := suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{ - Height: height, - Txs: txs, - }) - require.NoError(t, err) - - _, err = suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ + _, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: height, Txs: txs, }) @@ -196,8 +190,6 @@ func TestLoadVersion(t *testing.T) { require.Equal(t, emptyCommitID, lastID) // execute a block, collect commit ID - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) - require.NoError(t, err) res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) commitID1 := storetypes.CommitID{Version: 1, Hash: res.AppHash} @@ -205,8 +197,6 @@ func TestLoadVersion(t *testing.T) { require.NoError(t, err) // execute a block, collect commit ID - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 2}) - require.NoError(t, err) res, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) commitID2 := storetypes.CommitID{Version: 2, Hash: res.AppHash} @@ -230,8 +220,6 @@ func TestLoadVersion(t *testing.T) { testLoadVersionHelper(t, app, int64(1), commitID1) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 2}) - require.NoError(t, err) _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) _, err = app.Commit() @@ -320,8 +308,6 @@ func TestSetLoader(t *testing.T) { require.Nil(t, err) // "execute" one block - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 2}) - require.NoError(t, err) res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) require.NotNil(t, res.AppHash) @@ -371,8 +357,6 @@ func TestLoadVersionInvalid(t *testing.T) { err = app.LoadVersion(-1) require.Error(t, err) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) - require.NoError(t, err) res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) commitID1 := storetypes.CommitID{Version: 1, Hash: res.AppHash} @@ -592,15 +576,11 @@ func TestABCI_CreateQueryContext(t *testing.T) { name := t.Name() app := baseapp.NewBaseApp(name, log.NewTestLogger(t), db, nil) - _, err := app.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) - require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) + _, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) _, err = app.Commit() require.NoError(t, err) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 2}) - require.NoError(t, err) _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 2}) require.NoError(t, err) _, err = app.Commit() @@ -686,8 +666,6 @@ 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++ { - _, err := app.ProcessProposal(&abci.RequestProcessProposal{Height: i}) - require.NoError(t, err) res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: i}) require.NoError(t, err) _, err = app.Commit() diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index ec87767ebd01..23acbe99409b 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -115,8 +115,6 @@ func TestMsgService(t *testing.T) { app.MsgServiceRouter(), testdata.MsgServerImpl{}, ) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: 1}) - require.NoError(t, err) _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: 1}) require.NoError(t, err) diff --git a/baseapp/streaming_test.go b/baseapp/streaming_test.go index 2f5953047e6b..68ab1320ef1f 100644 --- a/baseapp/streaming_test.go +++ b/baseapp/streaming_test.go @@ -69,7 +69,7 @@ func TestABCI_MultiListener_StateChanges(t *testing.T) { var expectedChangeSet []*storetypes.StoreKVPair // create final block context state - _, err := suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{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++ { @@ -133,7 +133,6 @@ func Test_Ctx_with_StreamingManager(t *testing.T) { for blockN := 0; blockN < nBlocks; blockN++ { - suite.baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: int64(blockN) + 1}) suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: int64(blockN) + 1}) ctx := getFinalizeBlockStateCtx(suite.baseApp) diff --git a/server/mock/app_test.go b/server/mock/app_test.go index f7253a17dab3..bb5bd906cc2e 100644 --- a/server/mock/app_test.go +++ b/server/mock/app_test.go @@ -60,7 +60,7 @@ func TestInitApp(t *testing.T) { require.Equal(t, []byte("bar"), qres.Value) } -func TestFinalizeBlock(t *testing.T) { +func TestDeliverTx(t *testing.T) { app := SetupApp(t) key := "my-special-key" @@ -72,13 +72,6 @@ func TestFinalizeBlock(t *testing.T) { tx := NewTx(key, value, randomAccounts[0].Address) txBytes := tx.GetSignBytes() - _, err := app.ProcessProposal(&abci.RequestProcessProposal{ - Hash: []byte("apphash"), - Height: 1, - Txs: [][]byte{txBytes}, - }) - require.NoError(t, err) - res, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{ Hash: []byte("apphash"), Height: 1, diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 594619c8e8d1..7043f2eba3bf 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -70,6 +70,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000000000000))), } + app := NewSimApp(options.Logger, options.DB, nil, true, options.AppOpts) genesisState := app.DefaultGenesis() genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) diff --git a/tests/e2e/server/export_test.go b/tests/e2e/server/export_test.go index fac1514e3c88..45616e7029b5 100644 --- a/tests/e2e/server/export_test.go +++ b/tests/e2e/server/export_test.go @@ -95,10 +95,6 @@ func TestExportCmd_Height(t *testing.T) { // Fast forward to block `tc.fastForward`. for i := int64(2); i <= tc.fastForward; i++ { - app.ProcessProposal(&abci.RequestProcessProposal{ - Height: i, - }) - app.FinalizeBlock(&abci.RequestFinalizeBlock{ Height: i, }) diff --git a/tests/integration/bank/app_test.go b/tests/integration/bank/app_test.go index cf0a883dd8bd..da860ca21e8b 100644 --- a/tests/integration/bank/app_test.go +++ b/tests/integration/bank/app_test.go @@ -141,7 +141,7 @@ func checkBalance(t *testing.T, baseApp *baseapp.BaseApp, addr sdk.AccAddress, b t.Helper() ctxCheck := baseApp.NewContext(true) keeperBalances := keeper.GetAllBalances(ctxCheck, addr) - require.Truef(t, balances.Equal(keeperBalances), "expected %v, got %v", balances, keeperBalances) + require.True(t, balances.Equal(keeperBalances)) } func TestSendNotEnoughBalance(t *testing.T) { @@ -152,16 +152,10 @@ func TestSendNotEnoughBalance(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc} s := createTestSuite(t, genAccs) baseApp := s.App.BaseApp - - _, err := baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: baseApp.LastBlockHeight() + 1}) - require.NoError(t, err) - - // context must be taken after InitChain/ProcessProposal, otherwise it's nil ctx := baseApp.NewContext(false) - require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) - // FinalizeBlock call is needed because `app.finalizeBlockState.ms.Write()` is called - _, err = baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) + _, err := baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) _, err = baseApp.Commit() require.NoError(t, err) @@ -176,9 +170,6 @@ func TestSendNotEnoughBalance(t *testing.T) { sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)}) header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() - - _, err = baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: baseApp.LastBlockHeight() + 1}) - require.NoError(t, err) _, _, err = simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) require.Error(t, err) @@ -200,13 +191,10 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc} s := createTestSuite(t, genAccs) baseApp := s.App.BaseApp - - _, err := baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: baseApp.LastBlockHeight() + 1}) - require.NoError(t, err) ctx := baseApp.NewContext(false) require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67)))) - _, err = baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + _, err := baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) _, err = baseApp.Commit() require.NoError(t, err) @@ -262,11 +250,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { t.Logf("testing %s", tc.desc) header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() - - _, err := baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) - require.NoError(t, err) - - _, _, err = simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { require.NoError(t, err) } else { @@ -290,14 +274,11 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc1, acc2} s := createTestSuite(t, genAccs) baseApp := s.App.BaseApp - - _, err := baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: baseApp.LastBlockHeight() + 1}) - require.NoError(t, err) - ctx := baseApp.NewContext(false) + 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(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) + _, err := baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) _, err = baseApp.Commit() require.NoError(t, err) @@ -321,11 +302,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { for _, tc := range testCases { header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() - - _, err := baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: baseApp.LastBlockHeight() + 1}) - require.NoError(t, err) - - _, _, err = simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { @@ -343,10 +320,8 @@ func TestMsgMultiSendDependent(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc1, acc2} s := createTestSuite(t, genAccs) baseApp := s.App.BaseApp - - _, err = baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: baseApp.LastBlockHeight() + 1}) - require.NoError(t, err) ctx := baseApp.NewContext(false) + require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42)))) _, err = baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{Height: baseApp.LastBlockHeight() + 1}) require.NoError(t, err) @@ -382,10 +357,6 @@ func TestMsgMultiSendDependent(t *testing.T) { for _, tc := range testCases { header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1} txConfig := moduletestutil.MakeTestTxConfig() - - _, err = baseApp.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) - require.NoError(t, err) - _, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) @@ -401,17 +372,8 @@ func TestMsgSetSendEnabled(t *testing.T) { genAccs := []authtypes.GenesisAccount{acc1} s := createTestSuite(t, genAccs) - _, err := s.App.ProcessProposal(&abci.RequestProcessProposal{Height: s.App.LastBlockHeight() + 1}) - require.NoError(t, err) - ctx := s.App.BaseApp.NewContext(false) require.NoError(t, testutil.FundAccount(ctx, s.BankKeeper, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 101)))) - - _, err = s.App.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.App.LastBlockHeight() + 1}) - require.NoError(t, err) - _, err = s.App.Commit() - require.NoError(t, err) - addr1Str := addr1.String() govAddr := s.BankKeeper.GetAuthority() goodGovProp, err := govv1.NewMsgSubmitProposal( @@ -474,10 +436,6 @@ func TestMsgSetSendEnabled(t *testing.T) { t.Run(tc.desc, func(tt *testing.T) { header := cmtproto.Header{Height: s.App.LastBlockHeight() + 1} txGen := moduletestutil.MakeTestTxConfig() - - _, err = s.App.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) - require.NoError(t, err) - _, _, err = simtestutil.SignCheckDeliver(tt, txGen, s.App.BaseApp, header, tc.msgs, "", []uint64{0}, tc.accSeqs, tc.expSimPass, tc.expPass, priv1) if len(tc.expInError) > 0 { require.Error(tt, err) diff --git a/tests/integration/distribution/keeper/msg_server_test.go b/tests/integration/distribution/keeper/msg_server_test.go index 20f0df11f0f3..3315e2f7a62e 100644 --- a/tests/integration/distribution/keeper/msg_server_test.go +++ b/tests/integration/distribution/keeper/msg_server_test.go @@ -285,7 +285,6 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) { t.Run(tc.name, func(t *testing.T) { res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) @@ -436,7 +435,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) { tc.preRun() res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) if tc.expErr { @@ -532,7 +531,7 @@ func TestMsgWithdrawValidatorCommission(t *testing.T) { t.Run(tc.name, func(t *testing.T) { res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) if tc.expErr { @@ -635,7 +634,7 @@ func TestMsgFundCommunityPool(t *testing.T) { t.Run(tc.name, func(t *testing.T) { res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) if tc.expErr { @@ -763,7 +762,7 @@ func TestMsgUpdateParams(t *testing.T) { t.Run(tc.name, func(t *testing.T) { res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) if tc.expErr { @@ -842,7 +841,7 @@ func TestMsgCommunityPoolSpend(t *testing.T) { t.Run(tc.name, func(t *testing.T) { res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) if tc.expErr { @@ -944,7 +943,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) { t.Run(tc.name, func(t *testing.T) { res, err := f.app.RunMsg( tc.msg, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) if tc.expErr { diff --git a/tests/integration/slashing/keeper/keeper_test.go b/tests/integration/slashing/keeper/keeper_test.go index e85516278bd7..8ee839168d4b 100644 --- a/tests/integration/slashing/keeper/keeper_test.go +++ b/tests/integration/slashing/keeper/keeper_test.go @@ -190,7 +190,7 @@ func TestUnJailNotBonded(t *testing.T) { } _, err = f.app.RunMsg( &msgUnjail, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) assert.ErrorContains(t, err, "cannot be unjailed") @@ -206,7 +206,7 @@ func TestUnJailNotBonded(t *testing.T) { // verify we can immediately unjail _, err = f.app.RunMsg( &msgUnjail, - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), integration.WithAutomaticCommit(), ) assert.NilError(t, err) diff --git a/tests/integration/store/rootmulti/rollback_test.go b/tests/integration/store/rootmulti/rollback_test.go index 0680818523e4..9e4454bdcb1b 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 ( - "encoding/json" "fmt" "testing" @@ -25,21 +24,16 @@ func TestRollback(t *testing.T) { } app := simapp.NewSimappWithCustomOptions(t, false, options) ver0 := app.LastBlockHeight() - appStateBz, _ := json.Marshal(app.DefaultGenesis()) - - app.InitChain(&abci.RequestInitChain{ - ConsensusParams: simtestutil.DefaultConsensusParams, - AppStateBytes: appStateBz, - InitialHeight: 1, - }) - // commit 10 blocks for i := int64(1); i <= 10; i++ { header := cmtproto.Header{ Height: ver0 + i, AppHash: app.LastCommitID().Hash, } - app.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) + + app.FinalizeBlock(&abci.RequestFinalizeBlock{ + Height: header.Height, + }) ctx := app.NewContextLegacy(false, header) store := ctx.KVStore(app.GetKey("bank")) store.Set([]byte("key"), []byte(fmt.Sprintf("value%d", i))) @@ -69,7 +63,6 @@ func TestRollback(t *testing.T) { Height: ver0 + i, AppHash: app.LastCommitID().Hash, } - app.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: header.Height}) ctx := app.NewContextLegacy(false, header) store := ctx.KVStore(app.GetKey("bank")) diff --git a/testutil/integration/example_test.go b/testutil/integration/example_test.go index bc8cbcd48441..83712071b72f 100644 --- a/testutil/integration/example_test.go +++ b/testutil/integration/example_test.go @@ -167,7 +167,7 @@ func Example_oneModule() { Params: params, }, // this allows to the begin and end blocker of the module before and after the message - integration.WithAutomaticProcessProposal(), + integration.WithAutomaticFinalizeBlock(), // this allows to commit the state after the message integration.WithAutomaticCommit(), ) diff --git a/testutil/integration/options.go b/testutil/integration/options.go index 955475736dad..d2a6aacdb001 100644 --- a/testutil/integration/options.go +++ b/testutil/integration/options.go @@ -2,21 +2,13 @@ package integration // Config is the configuration for the integration app. type Config struct { - AutomaticProcessProposal bool - AutomaticFinalizeBlock bool - AutomaticCommit bool + AutomaticFinalizeBlock bool + AutomaticCommit bool } // Option is a function that can be used to configure the integration app. type Option func(*Config) -// WithAutomaticProcessProposal calls ABCI process proposal. -func WithAutomaticProcessProposal() Option { - return func(cfg *Config) { - cfg.AutomaticProcessProposal = true - } -} - // WithAutomaticFinalizeBlock calls ABCI finalize block. func WithAutomaticFinalizeBlock() Option { return func(cfg *Config) { diff --git a/testutil/integration/router.go b/testutil/integration/router.go index 2ffa702ed9af..4270d493ad8c 100644 --- a/testutil/integration/router.go +++ b/testutil/integration/router.go @@ -132,13 +132,6 @@ func (app *App) RunMsg(msg sdk.Msg, option ...Option) (*codectypes.Any, error) { defer app.Commit() } - if cfg.AutomaticProcessProposal { - height := app.LastBlockHeight() + 1 - if _, err := app.ProcessProposal(&cmtabcitypes.RequestProcessProposal{Height: height}); err != nil { - return nil, fmt.Errorf("failed to run process proposal: %w", err) - } - } - if cfg.AutomaticFinalizeBlock { height := app.LastBlockHeight() + 1 if _, err := app.FinalizeBlock(&cmtabcitypes.RequestFinalizeBlock{Height: height}); err != nil { diff --git a/testutil/sims/tx_helpers.go b/testutil/sims/tx_helpers.go index 361f6cd01c14..9c8244c347d6 100644 --- a/testutil/sims/tx_helpers.go +++ b/testutil/sims/tx_helpers.go @@ -141,8 +141,7 @@ func SignCheckDeliver( require.False(t, finalizeSuccess) } - _, err = app.Commit() - require.NoError(t, err) + 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/x/simulation/simulate.go b/x/simulation/simulate.go index 0add06f4f7ec..3a118dde7134 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -42,7 +42,6 @@ func initChain( ChainId: chainID, ConsensusParams: consensusParams, Time: genesisTimestamp, - InitialHeight: int64(config.InitialBlockHeight), } res, err := app.InitChain(&req) if err != nil { @@ -181,21 +180,6 @@ func SimulateFromSeed( // Run the BeginBlock handler logWriter.AddEntry(BeginBlockEntry(blockHeight)) - // Run ProcessProposal to remain compliant with the ABCI spec - _, err := app.ProcessProposal(&abci.RequestProcessProposal{ - Txs: finalizeBlockReq.Txs, - ProposedLastCommit: finalizeBlockReq.DecidedLastCommit, - Misbehavior: finalizeBlockReq.Misbehavior, - Hash: finalizeBlockReq.Hash, - Height: finalizeBlockReq.Height, - Time: finalizeBlockReq.Time, - NextValidatorsHash: finalizeBlockReq.NextValidatorsHash, - ProposerAddress: finalizeBlockReq.ProposerAddress, - }) - if err != nil { - return true, params, err - } - res, err := app.FinalizeBlock(finalizeBlockReq) if err != nil { return true, params, err diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index f3299d1848b9..6c42e1dc9d4e 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -91,10 +91,7 @@ func TestSlashingMsgs(t *testing.T) { require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) - _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) + app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) ctxCheck = baseApp.NewContext(true) validator, err := stakingKeeper.GetValidator(ctxCheck, sdk.ValAddress(addr1)) diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 87c4ae36d676..04a026780d53 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -79,8 +79,6 @@ func TestStakingMsgs(t *testing.T) { require.NoError(t, err) require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1))) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) require.NoError(t, err) ctxCheck = app.BaseApp.NewContext(true) @@ -91,8 +89,6 @@ func TestStakingMsgs(t *testing.T) { require.Equal(t, types.Bonded, validator.Status) require.True(math.IntEq(t, bondTokens, validator.BondedTokens())) - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: app.LastBlockHeight() + 1}) - require.NoError(t, err) _, err = app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: app.LastBlockHeight() + 1}) require.NoError(t, err) @@ -114,8 +110,6 @@ func TestStakingMsgs(t *testing.T) { delegateMsg := types.NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin) header = cmtproto.Header{Height: app.LastBlockHeight() + 1} - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) - require.NoError(t, err) _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2) require.NoError(t, err) @@ -127,8 +121,6 @@ func TestStakingMsgs(t *testing.T) { // begin unbonding beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin) header = cmtproto.Header{Height: app.LastBlockHeight() + 1} - _, err = app.ProcessProposal(&abci.RequestProcessProposal{Height: header.Height}) - require.NoError(t, err) _, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2) require.NoError(t, err)