Skip to content

Commit

Permalink
Make rdk compatible with tendermint (#1115)
Browse files Browse the repository at this point in the history
* Change so that app.checkState is updated even when ABCI commits

* Add test to check update of checkState
  • Loading branch information
Mdaiki0730 authored Sep 8, 2023
1 parent ae53464 commit f2293da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
6 changes: 6 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
28 changes: 14 additions & 14 deletions demo/test_sequencer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f2293da

Please sign in to comment.