Skip to content

Commit

Permalink
revert: last block height == 0 check (#3225)
Browse files Browse the repository at this point in the history
Closes #2271
  • Loading branch information
rootulp authored Apr 2, 2024
1 parent 21723d6 commit 897b448
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
20 changes: 1 addition & 19 deletions app/prepare_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,7 @@ func (app *App) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePr
app.ParamsKeeper,
app.MsgGateKeeper,
)

var txs [][]byte
// This if statement verifies whether the preparation of the proposal
// pertains to the first block. If it does, the block is constructed using
// an empty set of transactions. However, even without this validation,
// the initial block is anticipated to be devoid of transactions, as
// established by the findings presented in
// https://github.com/celestiaorg/celestia-app/issues/1899;
// The inclusion of this check is out of an abundance of caution.
// The rationale behind having an empty first block revolves around the fact
// that no transactions can enter the mempool since no committed state exists
// until after the first block is committed (at which point the Genesis state
// gets committed too). Consequently, the prepare proposal request for the
// first block is expected to contain no transaction, so is the first block.
if app.LastBlockHeight() == 0 {
txs = make([][]byte, 0)
} else {
txs = FilterTxs(app.Logger(), sdkCtx, handler, app.txConfig, req.BlockData.Txs)
}
txs := FilterTxs(app.Logger(), sdkCtx, handler, app.txConfig, req.BlockData.Txs)

// build the square from the set of valid and prioritised transactions.
// The txs returned are the ones used in the square and block
Expand Down
22 changes: 0 additions & 22 deletions app/test/prepare_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,3 @@ func queryAccountInfo(capp *app.App, accs []string, kr keyring.Keyring) []blobfa
}
return infos
}

func TestPrepareProposalZeroTxsInFirstBlock(t *testing.T) {
accounts := testfactory.GenerateAccounts(6)
testApp, _, kr := testutil.NewTestAppWithGenesisSet(app.DefaultConsensusParams(), accounts...)
require.Equal(t, int64(0), testApp.LastBlockHeight())
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
sendTxs := coretypes.Txs{testutil.SendTxWithManualSequence(
t,
encCfg.TxConfig,
kr,
accounts[0],
accounts[1],
1000,
testutil.ChainID,
1,
1,
)}.ToSliceOfBytes()
resp := testApp.PrepareProposal(abci.RequestPrepareProposal{
BlockData: &tmproto.Data{Txs: sendTxs},
})
require.Len(t, resp.BlockData.Txs, 0)
}

0 comments on commit 897b448

Please sign in to comment.