fix: Revert 16794 (backport #16895) (#16896)

Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2023-07-10 08:02:04 +00:00 committed by GitHub
parent 4762a2fa7d
commit 8295e4a3e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 66 additions and 206 deletions

View File

@ -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.

View File

@ -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)

View File

@ -136,13 +136,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,
})
@ -194,8 +188,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}
@ -203,8 +195,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}
@ -228,8 +218,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()
@ -316,8 +304,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)
@ -367,8 +353,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}
@ -588,15 +572,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()
@ -682,8 +662,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()

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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,
})

View File

@ -283,7 +283,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(),
)
@ -433,7 +432,7 @@ func TestMsgSetWithdrawAddress(t *testing.T) {
tc.preRun()
res, err := f.app.RunMsg(
tc.msg,
integration.WithAutomaticProcessProposal(),
integration.WithAutomaticFinalizeBlock(),
integration.WithAutomaticCommit(),
)
if tc.expErr {
@ -529,7 +528,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 {
@ -631,7 +630,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 {
@ -759,7 +758,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 {
@ -838,7 +837,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 {
@ -940,7 +939,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 {

View File

@ -189,7 +189,7 @@ func TestUnJailNotBonded(t *testing.T) {
}
_, err = f.app.RunMsg(
&msgUnjail,
integration.WithAutomaticProcessProposal(),
integration.WithAutomaticFinalizeBlock(),
integration.WithAutomaticCommit(),
)
assert.ErrorContains(t, err, "cannot be unjailed")
@ -205,7 +205,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)

View File

@ -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"))

View File

@ -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(),
)

View File

@ -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) {

View File

@ -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 {

View File

@ -140,8 +140,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}

View File

@ -139,7 +139,7 @@ func createTestSuite(t *testing.T, genesisAccounts []authtypes.GenesisAccount) s
func checkBalance(t *testing.T, baseApp *baseapp.BaseApp, addr sdk.AccAddress, balances sdk.Coins, keeper bankkeeper.Keeper) {
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) {
@ -150,16 +150,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)
@ -174,9 +168,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)
@ -198,13 +189,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)
@ -260,11 +248,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 {
@ -288,14 +272,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)
@ -319,11 +300,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 {
@ -341,10 +318,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)
@ -380,10 +355,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)
@ -399,17 +370,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(
@ -472,10 +434,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)

View File

@ -42,7 +42,6 @@ func initChain(
ChainId: chainID,
ConsensusParams: consensusParams,
Time: genesisTimestamp,
InitialHeight: int64(config.InitialBlockHeight),
}
res, err := app.InitChain(&req)
if err != nil {
@ -180,21 +179,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

View File

@ -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))

View File

@ -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)