diff --git a/baseapp/abci.go b/baseapp/abci.go index 45a33ff78f..989f174139 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -354,6 +354,12 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) { commitID := app.cms.Commit() app.logger.Info("commit synced", "commit", fmt.Sprintf("%X", commitID)) + // Reset the Check state to the latest committed. + // + // NOTE: This is safe because Tendermint holds a lock on the mempool for + // Commit. Use the header from this latest block. + app.setCheckState(header) + // empty/reset the deliver state app.deliverState = nil diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index b148149956..73df34027e 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -206,6 +206,24 @@ func TestBaseAppBeginBlockConsensusParams(t *testing.T) { require.Equal(t, maxGas, newCtx.ConsensusParams().Block.MaxGas) } +func TestBaseAppCheckStateUpdated(t *testing.T) { + t.Parallel() + + logger := defaultLogger() + db := dbm.NewMemDB() + name := t.Name() + app := NewBaseApp(name, logger, db, nil) + app.init() + + // block exec + for i := 1; i <= 10; i++ { + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: int64(i)}}) + app.Commit() + } + + require.Equal(t, int64(10), app.checkState.ctx.BlockHeight()) +} + type paramStore struct { db *dbm.MemDB } diff --git a/demo/test_sequencer.sh b/demo/test_sequencer.sh index e5c4066d93..d16e3af1a0 100755 --- a/demo/test_sequencer.sh +++ b/demo/test_sequencer.sh @@ -61,18 +61,18 @@ else echo "send failed..." fi -## NOTE: There is a bug in the current Ramus that only validators can execute tx. -# ${L2BINARYNAME} keys add bob --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test -# sleep 1 -# BOB_ADDR=$(${L2BINARYNAME} keys show bob -a --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test) -# echo $ALICE_ADDR -# ${L2BINARYNAME} tx bank send $ALICE_ADDR $BOB_ADDR 10stake --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test --chain-id $L2_CHAIN_ID -y -# sleep 30 +# NOTE: There is a bug in the current Ramus that only validators can execute tx. +${L2BINARYNAME} keys add bob --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test +sleep 1 +BOB_ADDR=$(${L2BINARYNAME} keys show bob -a --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test) +echo $ALICE_ADDR +${L2BINARYNAME} tx bank send $ALICE_ADDR $BOB_ADDR 10stake --home $L2_KEYRING_DIR/$SEQUENCER_DIR --keyring-backend=test --chain-id $L2_CHAIN_ID -y +sleep 30 -# # Check alice's balance -# BALANCE=$(${L2BINARYNAME} query bank balances $BOB_ADDR --home $L2_KEYRING_DIR/$SEQUENCER_DIR --output json | jq -r '.balances[0].amount') -# if [ 10 -eq ${BALANCE} ]; then -# echo "send success!" -# else -# echo "send failed..." -# fi +# Check alice's balance +BALANCE=$(${L2BINARYNAME} query bank balances $BOB_ADDR --home $L2_KEYRING_DIR/$SEQUENCER_DIR --output json | jq -r '.balances[0].amount') +if [ 10 -eq ${BALANCE} ]; then + echo "send success!" +else + echo "send failed..." +fi