Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added RequestBeginBlock.IsProofBlock for create_empty_blocks=false #10004

Closed
wants to merge 2 commits into from
Closed

Added RequestBeginBlock.IsProofBlock for create_empty_blocks=false #10004

wants to merge 2 commits into from

Conversation

TobiaszCudnik
Copy link

@TobiaszCudnik TobiaszCudnik commented Feb 24, 2023

Description

Closes: cosmos-sdk#10240

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 BeginBlockers 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:

tendermint/consensus/state.go

Lines 1039 to 1049 in 35581cf

// needProofBlock returns true on the first height (so the genesis app hash is signed right away)
// and where the last block (height-1) caused the app hash to change
func (cs *State) needProofBlock(height int64) bool {
if height == cs.state.InitialHeight {
return true
}
lastBlockMeta := cs.blockStore.LoadBlockMeta(height - 1)
if lastBlockMeta == nil {
panic(fmt.Sprintf("needProofBlock: last block meta for height %d not found", height-1))
}

and used for create_empty_blocks in enterNewRound:

tendermint/consensus/state.go

Lines 1028 to 1035 in 35581cf

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

TODO

  • regression test

@github-actions
Copy link

github-actions bot commented Mar 7, 2023

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.

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'
1 participant