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

Reject proposal if max block gas is exceeded #674

Merged
merged 3 commits into from
Mar 31, 2023

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented Mar 30, 2023

Describe your changes and provide context

Implementation for https://github.com/sei-protocol/sei-chain/pull/new/tony-chen-max-block-gas-check

We want honest validators (i.e. validators who do not use a maliciously modified binary) to reject block proposals whose transactions' GasWanted add up to something greater than max block gas. Since transactions in block proposals are sent as raw bytes, the only place to decode them would be on application-level during ProcessProposal. For context, ProcessProposal is called during prevote phase by validators, and if it returns a status of REJECT, validators will vote nil.

Testing performed to validate your change

unit test
integration test in a loadtest cluster with a modified node to verify such proposal will indeed be rejected

@codchen codchen requested a review from philipsu522 March 30, 2023 06:01
func (app *App) checkTotalBlockGasWanted(ctx sdk.Context, txs [][]byte) bool {
totalGasWanted := uint64(0)
for _, tx := range txs {
decoded, err := app.txDecoder(tx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: If we have perf concern, we can make decode run in parallel, and then use atomic integer for calculating totalGasWanted

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah good point. I'll add it in in a later PR if we find this to be a bottleneck

@github-actions
Copy link

Code Coverage

Package Line Rate Complexity Health
github.com/sei-protocol/sei-chain/aclmapping/bank 83% 0
github.com/sei-protocol/sei-chain/aclmapping/dex 100% 0
github.com/sei-protocol/sei-chain/aclmapping/oracle 100% 0
github.com/sei-protocol/sei-chain/aclmapping/staking 96% 0
github.com/sei-protocol/sei-chain/aclmapping/tokenfactory 96% 0
github.com/sei-protocol/sei-chain/aclmapping/utils 0% 0
github.com/sei-protocol/sei-chain/aclmapping/wasm 83% 0
github.com/sei-protocol/sei-chain/app 62% 0
github.com/sei-protocol/sei-chain/app/antedecorators 76% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/config 85% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle 67% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle/provider 48% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/router/v1 45% 0
github.com/sei-protocol/sei-chain/store/whitelist/cachemulti 100% 0
github.com/sei-protocol/sei-chain/store/whitelist/kv 100% 0
github.com/sei-protocol/sei-chain/store/whitelist/multi 100% 0
github.com/sei-protocol/sei-chain/utils 59% 0
github.com/sei-protocol/sei-chain/utils/datastructures 90% 0
github.com/sei-protocol/sei-chain/utils/logging 100% 0
github.com/sei-protocol/sei-chain/x/dex 58% 0
github.com/sei-protocol/sei-chain/x/dex/cache 87% 0
github.com/sei-protocol/sei-chain/x/dex/client/cli/query 22% 0
github.com/sei-protocol/sei-chain/x/dex/contract 53% 0
github.com/sei-protocol/sei-chain/x/dex/exchange 94% 0
github.com/sei-protocol/sei-chain/x/dex/keeper 62% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/abci 24% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/msgserver 79% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/query 82% 0
github.com/sei-protocol/sei-chain/x/dex/migrations 88% 0
github.com/sei-protocol/sei-chain/x/dex/types 1% 0
github.com/sei-protocol/sei-chain/x/dex/types/utils 100% 0
github.com/sei-protocol/sei-chain/x/dex/types/wasm 50% 0
github.com/sei-protocol/sei-chain/x/epoch 11% 0
github.com/sei-protocol/sei-chain/x/epoch/keeper 66% 0
github.com/sei-protocol/sei-chain/x/epoch/types 2% 0
github.com/sei-protocol/sei-chain/x/mint 0% 0
github.com/sei-protocol/sei-chain/x/mint/keeper 61% 0
github.com/sei-protocol/sei-chain/x/mint/simulation 95% 0
github.com/sei-protocol/sei-chain/x/mint/types 3% 0
github.com/sei-protocol/sei-chain/x/nitro/client/cli 45% 0
github.com/sei-protocol/sei-chain/x/nitro/keeper 83% 0
github.com/sei-protocol/sei-chain/x/nitro/replay 63% 0
github.com/sei-protocol/sei-chain/x/oracle 67% 0
github.com/sei-protocol/sei-chain/x/oracle/keeper 83% 0
github.com/sei-protocol/sei-chain/x/oracle/simulation 18% 0
github.com/sei-protocol/sei-chain/x/oracle/types 3% 0
github.com/sei-protocol/sei-chain/x/tokenfactory/keeper 85% 0
github.com/sei-protocol/sei-chain/x/tokenfactory/types 2% 0
Summary 15% (5199 / 34285) 0

@codchen codchen merged commit 9c3d039 into master Mar 31, 2023
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.

3 participants