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

Add Tendermint max block size param to genesis config file #843

Merged

Conversation

sug0
Copy link
Collaborator

@sug0 sug0 commented Nov 30, 2022

We allow validators to configure the max transaction batch size at genesis (up to 90 MiB worth of tx data). Tendermint is configured with a hard-coded value of 100 MiB per serialized block; this is fine, because we enforce tx data size on an application basis, with the block space allocator abstraction.


NOTES: https://hackmd.io/DJVZdogGSuKjw3fjVKv7ag?view

TODO: Add maximum gas cap on blocks

@sug0 sug0 force-pushed the tiago/ethbridge/max-block-size-genesis-param branch from 414b6e9 to a937e00 Compare December 6, 2022 11:08
@sug0 sug0 force-pushed the tiago/ethbridge/max-block-size-genesis-param branch from a937e00 to d1301b5 Compare December 7, 2022 09:02
@sug0 sug0 marked this pull request as ready for review December 7, 2022 14:41
@sug0 sug0 requested a review from james-chf December 7, 2022 14:41
@sug0 sug0 marked this pull request as draft December 7, 2022 16:31
Copy link
Contributor

@james-chf james-chf left a comment

Choose a reason for hiding this comment

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

lgtm though I think we should mark out Tendermint consensus params in their own config struct (either in this PR, or some later one). This PR should be targeting main

apps/src/lib/config/genesis.rs Outdated Show resolved Hide resolved
@sug0
Copy link
Collaborator Author

sug0 commented Dec 8, 2022

@james-chf can't target main yet, because the block space allocator is a hard dependency of this PR. without it, blocks are always configured to be 100 MiB in size, which isn't ideal. I guess I forgot to mention that in the description 😅 btw, I'm still missing the evidence config. will add that tomorrow

@sug0
Copy link
Collaborator Author

sug0 commented Dec 9, 2022

so, actually, it looks like we do not configure evidence params right now, and they seem to be using 1 MiB of space at most, by default. that should be plenty of space, so I'm not going to touch that config.

@sug0 sug0 marked this pull request as ready for review December 9, 2022 09:15
@sug0 sug0 requested a review from james-chf December 9, 2022 09:22
@sug0 sug0 marked this pull request as draft December 9, 2022 13:12
@james-chf
Copy link
Contributor

@james-chf can't target main yet, because the block space allocator is a hard dependency of this PR. without it, blocks are always configured to be 100 MiB in size, which isn't ideal. I guess I forgot to mention that in the description 😅 btw, I'm still missing the evidence config. will add that tomorrow

Wouldn't it just be setting a max cap of 100 MiB rather than having blocks always be 100 MiB in size? (I would have thought applying this PR to main, there would be no functional change, except the max possible block size would be different, but I could be wrong). In that case, the changes in this PR don't look like they depend on the block space allocator PRs.

@sug0 sug0 marked this pull request as ready for review December 9, 2022 15:19
@sug0
Copy link
Collaborator Author

sug0 commented Dec 12, 2022

@james-chf can't target main yet, because the block space allocator is a hard dependency of this PR. without it, blocks are always configured to be 100 MiB in size, which isn't ideal. I guess I forgot to mention that in the description 😅 btw, I'm still missing the evidence config. will add that tomorrow

Wouldn't it just be setting a max cap of 100 MiB rather than having blocks always be 100 MiB in size? (I would have thought applying this PR to main, there would be no functional change, except the max possible block size would be different, but I could be wrong). In that case, the changes in this PR don't look like they depend on the block space allocator PRs.

yeah, it'd just set a max block size of 100 MiB, but I'm not sure if it's a good idea to include this PR in main without a way to throttle the num of txs included in a block

@@ -111,6 +115,16 @@ impl Parameters {
pos_inflation_amount,
} = self;

// write max proposal bytes parameter
Copy link
Member

Choose a reason for hiding this comment

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

We should add validation somewhere that the input isn't insane. Here perhaps?

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe it' crazy to validate genesis input. But we will need some mechanism for validation if it is changed by governance. Tomas mentioned something about guarding it with VPs. Maybe a separate pr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we're grabbing this parameter from the toml config, whose deserialization already has some logic that checks if it is in the range [1 B, 90 MiB]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure if that's enough?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I missed that. So good enough for now. For governance, I'm not so sure as it doesn't require a hard fork but just a change in storage. So we might need this VP idea. But that can be a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

btw I think I misinterpreted the Tendermint specs. https://github.com/tendermint/tendermint/blob/v0.34.x/spec/abci/apps.md#blockparamsmaxbytes

I think the hard cap for a block might be 100 mb - 1 b, instead of 100 mb, since they're using an open interval

Comment on lines +24 to +36
// TODO: improve this code; use some kind of prefix
// tree to efficiently match `key`
is_epoch_duration_storage_key(key)
|| is_max_expected_time_per_block_key(key)
|| is_tx_whitelist_key(key)
|| is_vp_whitelist_key(key)
|| is_implicit_vp_key(key)
|| is_epochs_per_year_key(key)
|| is_pos_gain_p_key(key)
|| is_pos_gain_d_key(key)
|| is_staked_ratio_key(key)
|| is_pos_inflation_amount_key(key)
|| is_max_proposal_bytes_key(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

oic the efficiency issue now. It would be good I guess if all protocol parameters were under some subtree e.g. /parameters/protocol/... or something, then we could easily recognize them

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was playing around with trie codegen over the weekend for this specific use-case, but I still need to improve the generated code. https://gist.github.com/sug0/1bc632eb19ebdeb2d596c1617fba4138

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

btw, we do have the same internal address as a prefix in each of these keys

apps/src/lib/config/genesis.rs Outdated Show resolved Hide resolved
apps/src/lib/node/ledger/tendermint_node.rs Show resolved Hide resolved
core/src/types/chain.rs Outdated Show resolved Hide resolved
core/src/types/chain.rs Show resolved Hide resolved
@sug0 sug0 requested a review from james-chf December 12, 2022 16:16
@sug0 sug0 mentioned this pull request Dec 12, 2022
8 tasks
Copy link
Contributor

@james-chf james-chf left a comment

Choose a reason for hiding this comment

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

lgtm!

@sug0 sug0 merged commit efa9f34 into eth-bridge-integration Dec 12, 2022
@sug0 sug0 deleted the tiago/ethbridge/max-block-size-genesis-param branch December 12, 2022 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants