Skip to content

Remove ConsensusParams.TxSize and ConsensusParams.BlockGossip#2364

Merged
ebuchman merged 3 commits intodevelopfrom
2347-max-bytes
Sep 12, 2018
Merged

Remove ConsensusParams.TxSize and ConsensusParams.BlockGossip#2364
ebuchman merged 3 commits intodevelopfrom
2347-max-bytes

Conversation

@melekes
Copy link
Contributor

@melekes melekes commented Sep 10, 2018

Refs #2347

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

node/node.go Outdated

// Make MempoolReactor
maxBytes := state.ConsensusParams.TxSize.MaxBytes
maxBytes := state.ConsensusParams.BlockSize.MaxBytes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: MaxBytes - headerSize and so on


// Update mempool.
maxBytes := state.ConsensusParams.TxSize.MaxBytes
maxBytes := state.ConsensusParams.BlockSize.MaxBytes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: MaxBytes - headerSize and so on

func(stateDB dbm.DB, cs *ConsensusState, ctx context.Context) {
// XXX: is there a better way to change BlockPartSizeBytes?
cs.state.ConsensusParams.BlockPartSizeBytes = 512
// cs.state.ConsensusParams.BlockPartSizeBytes = 512
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXME: make BlockPartSizeBytes a variable?

@melekes melekes changed the title remove ConsensusParams.TxSize and ConsensusParams.BlockGossip [WIP] remove ConsensusParams.TxSize and ConsensusParams.BlockGossip Sep 10, 2018
@codecov-io
Copy link

codecov-io commented Sep 10, 2018

Codecov Report

Merging #2364 into develop will decrease coverage by 0.01%.
The diff coverage is 78.57%.

@@             Coverage Diff             @@
##           develop    #2364      +/-   ##
===========================================
- Coverage    60.96%   60.95%   -0.02%     
===========================================
  Files          197      197              
  Lines        16301    16259      -42     
===========================================
- Hits          9938     9910      -28     
+ Misses        5499     5489      -10     
+ Partials       864      860       -4
Impacted Files Coverage Δ
consensus/wal.go 61.24% <ø> (ø) ⬆️
blockchain/reactor.go 39.1% <0%> (-0.34%) ⬇️
consensus/state.go 76.4% <100%> (-0.86%) ⬇️
state/state.go 88.5% <100%> (ø) ⬆️
state/execution.go 75.62% <80%> (+0.36%) ⬆️
node/node.go 65.29% <80%> (+0.26%) ⬆️
libs/db/remotedb/remotedb.go 36.84% <0%> (-4.69%) ⬇️
consensus/reactor.go 72.61% <0%> (-0.94%) ⬇️
... and 2 more

@melekes melekes changed the title [WIP] remove ConsensusParams.TxSize and ConsensusParams.BlockGossip Remove ConsensusParams.TxSize and ConsensusParams.BlockGossip Sep 11, 2018
@melekes melekes requested a review from ValarDragon September 11, 2018 06:21

// BlockSize contains limits on the block size.
message BlockSize {
// Note: must be greater than 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't it be -1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlimited? Do you think it's a good idea?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best if we're consistent, so these ints all have the same domain

firstBlock := makeBlock(blockHeight, state)
secondBlock := makeBlock(blockHeight+1, state)
firstParts := firstBlock.MakePartSet(state.ConsensusParams.BlockGossip.BlockPartSizeBytes)
firstParts := firstBlock.MakePartSet(types.BlockPartSizeBytes)
Copy link
Contributor

@ValarDragon ValarDragon Sep 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't really understand why we don't want this as a consensus parameter. What optimizations are we getting by optimizing around 1MB blocks, it feels like we could still leave this as parameterized to me. (Or perhaps parameterize as "number of block parts")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: BlockPartSizeBytes really depends on the network bandwidth and network topology. It should be possible to make it adaptive to the current env by analysing the network, but it's #post-launch imho.

Plus we wasn't checking the size when accepting block part (no consensus per se 😄 ).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to reduce surface area for applications - its unlikely the applications should tweak this parameter directly, would be better if we had a heuristic for it based on the block size.

We'll still want to tweak this parameter in experiments, so we'll need a way for it to be configurable, but it will be a different domain than the ConsensusParams that gets updated by applications.

Copy link
Contributor

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A few minor nits. We also need to update the docs

firstBlock := makeBlock(blockHeight, state)
secondBlock := makeBlock(blockHeight+1, state)
firstParts := firstBlock.MakePartSet(state.ConsensusParams.BlockGossip.BlockPartSizeBytes)
firstParts := firstBlock.MakePartSet(types.BlockPartSizeBytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to reduce surface area for applications - its unlikely the applications should tweak this parameter directly, would be better if we had a heuristic for it based on the block size.

We'll still want to tweak this parameter in experiments, so we'll need a way for it to be configurable, but it will be a different domain than the ConsensusParams that gets updated by applications.

const (
// must be greater than params.BlockGossip.BlockPartSizeBytes + a few bytes
// must be greater than types.BlockPartSizeBytes + a few bytes
maxMsgSizeBytes = 1024 * 1024 // 1MB
Copy link
Contributor

@ebuchman ebuchman Sep 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New issue (#2381): We should make this a function of BlockPartSizeBytes. Probably should do something similar in other reactors (ie. max is a function of size of largest message).

// Update mempool.
maxBytes := state.ConsensusParams.TxSize.MaxBytes
filter := func(tx types.Tx) bool { return len(tx) <= maxBytes }
maxDataBytes := types.MaxDataBytesUnknownEvidence(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the State can expose a FilterTx method that does all this and returns a filter func can be passed into the NewMempool and mempool.Update?

cdc.RegisterConcrete(MockBadEvidence{}, "tendermint/MockBadEvidence", nil)
}

// MaxEvidenceBytesPerBlock returns the maximum evidence size per block.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth including the magic number (divide by 10) in the documentation

// TxSize contain limits on the tx size.
type TxSize struct {
MaxBytes int `json:"max_bytes"`
MaxBytes int `json:"max_txs_bytes"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json here should be max_bytes as well

params.BlockSize.MaxBytes, MaxBlockSizeBytes)
}

if params.BlockSize.MaxGas < -1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe these should all be the same for consistency? ie. < -1

if params2.TxSize.MaxGas > 0 {
res.TxSize.MaxGas = params2.TxSize.MaxGas
}
res.BlockSize.MaxBytes = int(params2.BlockSize.MaxBytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we unify these and remove the cast?

)

func newConsensusParams(txsBytes, partSize int) ConsensusParams {
func newConsensusParams(txsBytes, evidenceAge int) ConsensusParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • txBytes should be called maxBytes or blockBytes
  • we should also pass in maxGas or blockGas

}

func makeParams(txsBytes, blockGas, txBytes, txGas, partSize int) ConsensusParams {
func makeParams(txsBytes, blockGas, evidenceAge int) ConsensusParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deduplicate with newConsensusParams?


// BlockSize contains limits on the block size.
message BlockSize {
// Note: must be greater than 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably best if we're consistent, so these ints all have the same domain

@ebuchman ebuchman merged commit 0e1cd88 into develop Sep 12, 2018
@ebuchman ebuchman deleted the 2347-max-bytes branch September 12, 2018 19:44
@ebuchman
Copy link
Contributor

Follow up in #2382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants