Skip to content

Added abci.RequestBeginBlock.IsProofBlock for create_empty_blocks=false - #491

Closed
TobiaszCudnik wants to merge 1 commit into
cometbft:mainfrom
TobiaszCudnik:cosmos-sdk-10240-is-proof-block
Closed

TobiaszCudnik wants to merge 1 commit into
cometbft:mainfrom
TobiaszCudnik:cosmos-sdk-10240-is-proof-block

Conversation

@TobiaszCudnik

Copy link
Copy Markdown

Ported from tendermint/tendermint#10004
Closes: cosmos-sdk#10240
Related to #370

This PR extends abci.RequestBeginBlock with IsProofBlock, used when create_empty_blocks=false.

Main changes in:

  • consensus/state.go
  • proto/tendermint/abci/types.proto

The IsProofBlock flag is used by modules in BeginBlock methods to avoid write ops for those blocks. "Proof blocks" happen when:

  • no txs in the mempool
  • current apphash differs form the prev block's apphash
  • empty blocks should NOT be created

"Proof block" is currently defined in tendermint/consensus/state.go:1041:

cometbft/consensus/state.go

Lines 1050 to 1060 in 24040f5

func (cs *State) needProofBlock(height int64) bool {
if height == cs.state.InitialHeight {
return true
}
lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1)
if lastBlockMeta == nil {
// See https://github.com/cometbft/cometbft/issues/370
cs.Logger.Info("short-circuited needProofBlock", "height", height, "InitialHeight", cs.state.InitialHeight)
return true
}

and used for create_empty_blocks in enterNewRound:

cometbft/consensus/state.go

Lines 1037 to 1047 in 24040f5

waitForTxs := cs.config.WaitForTxs() && round == 0 && !cs.needProofBlock(height)
if waitForTxs {
if cs.config.CreateEmptyBlocksInterval > 0 {
cs.scheduleTimeout(cs.config.CreateEmptyBlocksInterval, height, round,
cstypes.RoundStepNewRound)
}
} else {
cs.enterPropose(height, round)
}
}

Related links


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments

@adizere

adizere commented Mar 10, 2023

Copy link
Copy Markdown
Contributor

Thanks for the PR @TobiaszCudnik !

There's a couple of concerns here:

Nature of change

The PR changes proto/tendermint/abci/types.proto, so it will be a Go API/ABCI change. To my understanding, we can treat this change as forward compatible due to protobuf support, i.e., nodes running current version (which does not have the new field is_proof_block) should be able to parse responses from nodes running the version with your proposed change (and simply ignore the new field, without breaking). Let me know if you think this is in/correct as it will help us assess the impact of the change.

Relation to SDK

This change is directly dependent on impact and priority in the SDK. So we'll take their feedback into account, in particular this coment. Thanks @tac0turtle or team for weighing in here (not urgent!)

Priority

We're working at full capacity to release v0.38 (alpha) to unblock multiple teams in the ecosystem. Give us a few weeks to sort that out. Then we'll get back to you to schedule including this potentially in v0.38 or v0.39. Thanks for the patience! If this blocks anything on your side, don't hesitate to let us know.

@TobiaszCudnik

Copy link
Copy Markdown
Author

nodes running current version (which does not have the new field is_proof_block) should be able to parse responses from nodes running the version with your proposed change

That is correct, only the known IDs will be parsed. Itd break if someone adds another field with the same proto ID (5), eg from another consensus implementation. Although if some validators wont update, they'll keep producing empty blocks (AFAIK).

Give us a few weeks to sort that out

Take your time, Im still figuring out the best way to test this. It would probably need a regression test for Cosmos and a regular one for Comet.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale For use by stalebot label Mar 27, 2023
@github-actions github-actions Bot closed this Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale For use by stalebot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty blocks are being created even though create_empty_blocks = false is set in 'config.toml'

2 participants