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

feat(baseapp): add option to disable block gas meter #19626

Merged
merged 7 commits into from
Mar 11, 2024

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Mar 3, 2024

ref: #19613

reasons

  • block gas meter logic is not compatible with parallel tx execution.
  • when a tx's execution result exceeds the block gas meter, despite the ante handler has succeeded, the tx result is replaced with an out-of-gas error, it's tricky for RPC client to know the actual execution result.
  • it's safe to do if validators has already validated the total tx gas wanted against the block gas limit, which we do in default process proposal handler.

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Introduced the option to disable the block gas meter in transactions, enhancing flexibility in transaction execution.
  • Refactor
    • Reordered import statements for flags in various test files to improve code organization and readability.

@yihuang yihuang requested a review from a team as a code owner March 3, 2024 06:46
Copy link
Contributor

coderabbitai bot commented Mar 3, 2024

Walkthrough

The recent changes involve updates to the client/keys package within the codebase. These modifications include reordering import statements, changing flag names and usage, and updating test functions related to key management operations.

Changes

File(s) Summary
client/keys/list.go Reordered import statements for flags within the keys package.
client/keys/list_test.go, client/keys/migrate_test.go Updated flag names and usage within test functions, switching from FlagHome to FlagKeyringDir.
client/keys/output_test.go Rearranged import order, moving require import below crypto imports.
client/keys/rename_test.go Updated flag usage within the runRenameCmd test function, replacing flags related to the keybase home directory with flags related to the keyring directory.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

CHANGELOG.md Outdated Show resolved Hide resolved
baseapp/baseapp.go Outdated Show resolved Hide resolved
@yihuang yihuang added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Mar 3, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 7628592 and 2e8c86649404d5a4cac344128388716f44072512.
Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • baseapp/baseapp.go (2 hunks)
  • baseapp/noopgasmeter.go (1 hunks)
  • baseapp/options.go (2 hunks)
Additional comments: 4
baseapp/noopgasmeter.go (1)
  • 5-17: The implementation of noopGasMeter correctly adheres to the no-op behavior expected from a gas meter that does not perform any operation. This ensures that when the block gas meter is disabled, transactions can execute without gas metering interference.
baseapp/options.go (2)
  • 122-124: The DisableBlockGasMeter function is correctly implemented, providing a straightforward way for developers to configure their applications to disable the block gas meter if desired. This enhances the flexibility and safety of transaction execution within the Cosmos SDK framework.
  • 395-396: The SetDisableBlockGasMeter method is correctly implemented, allowing for the disableBlockGasMeter flag to be set on the BaseApp struct. This method is essential for the functionality introduced by the PR, enabling the block gas meter to be disabled as needed.
baseapp/baseapp.go (1)
  • 661-664: The modification to the getBlockGasMeter method to return a noopGasMeter when disableBlockGasMeter is true is a direct implementation of the feature to disable block gas metering. This change is logically sound and aligns with the objective of the feature. However, it's important to ensure that the noopGasMeter implementation correctly adheres to the GasMeter interface without any unintended side effects, especially since it will be used in place of the standard gas meter when the feature is enabled.

Ensure that the noopGasMeter implementation is thoroughly tested, particularly its interaction with other components that expect a functioning gas meter. This includes testing scenarios where transactions are executed in parallel to verify that disabling the block gas meter does not introduce any inconsistencies or errors in transaction processing.

Comment on lines 189 to 195
// disableBlockGasMeter will disable the block gas meter if true, block gas meter is tricky to support
// when executing transactions in parallel.
// when disabled, the block gas meter in context is `nil`.
//
// SAFTY: it's safe to do if validators validates the total gas wanted in the proposal.
disableBlockGasMeter bool
Copy link
Contributor

Choose a reason for hiding this comment

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

The addition of the disableBlockGasMeter field to the BaseApp struct introduces the capability to disable the block gas meter. This change is crucial for supporting parallel transaction execution without the complications of block gas metering. However, it's important to ensure that this feature is well-documented, especially the safety aspects mentioned in the comment. The comment mentions that it's safe if validators validate the total gas wanted in the proposal, which implies a reliance on external validation mechanisms. This should be clearly documented in the official documentation to avoid misuse of the feature.

Consider enhancing the documentation around this feature, both in code comments and the official Cosmos SDK documentation, to clearly explain its usage, the conditions under which it is safe to disable the block gas meter, and the responsibilities of validators in this context.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yml

Commits Files that changed from the base of the PR and between 2e8c86649404d5a4cac344128388716f44072512 and 0a839baab5d443bee73cee7b6ff3e425568e4b05.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

I understand that the block gas meter is causing issues, but I mentioned in a similar PR there really is no need for the block gas meter -- it serves no purpose at all.

Now given that we don't want to break APIs in 0.50.x, this seems like a decent patch for 0.50.x

@yihuang
Copy link
Collaborator Author

yihuang commented Mar 4, 2024

I understand that the block gas meter is causing issues, but I mentioned in a similar PR there really is no need for the block gas meter -- it serves no purpose at all.

maybe there are a few extreme cases, like using a noop process proposal hander, I agree most of chains wouldn't care.

Now given that we don't want to break APIs in 0.50.x, this seems like a decent patch for 0.50.x

we can direct this PR to 0.50.x only, or merge it into main and backport to 0.50.x first, then on top of it, we can still merge your PR that remove it completely if we decided to do that, WDYT?

@alexanderbez
Copy link
Contributor

@yihuang let's target this on 0.50.x release line please. WE can merge from there

ref: cosmos#19613

block gas meter is not safe when executing transactions in parallel.
@yihuang
Copy link
Collaborator Author

yihuang commented Mar 5, 2024

@yihuang let's target this on 0.50.x release line please. WE can merge from there

done

RELEASE_NOTES.md Outdated

💬 [**Release Discussion**](https://github.com/orgs/cosmos/discussions/58)

## 🚀 Highlights

While early in our monthly release cadence, this release includes a few notable fixes:
Some months ago Cosmos SDK Eden was released. Missed the announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1).
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a comma after "Some months ago" for better readability: "Some months ago, Cosmos SDK Eden was released."

- Some months ago Cosmos SDK Eden was released.
+ Some months ago, Cosmos SDK Eden was released.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Some months ago Cosmos SDK Eden was released. Missed the announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1).
Some months ago, Cosmos SDK Eden was released. Missed the announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1).

For clarity, consider rephrasing the sentence to include a comma after the introductory phrase: "For this month, the patch release of the v0.50.x line includes a few features and improvements."

- For this month patch release of the v0.50.x line, a few features and improvements were added to the SDK.
+ For this month, the patch release of the v0.50.x line includes a few features and improvements.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Some months ago Cosmos SDK Eden was released. Missed the announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1).
Some months ago Cosmos SDK Eden was released. Missed the announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1).

RELEASE_NOTES.md Outdated

* Adds in-place testnet CLI command for creating testnets from local state (kudos to @czarcas7ic)
* Multiple fixes in baseapp, with fixes in `DefaultProposalHandler` and vote extensions
* Add a missed check in `x/auth/vesting`: [GHSA-4j93-fm92-rp4m](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-4j93-fm92-rp4m)

We recommended to upgrade to this patch release as soon as possible.
Copy link
Contributor

Choose a reason for hiding this comment

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

To improve clarity, consider rephrasing to: "We recommend upgrading to this patch release as soon as possible."

- We recommended to upgrade to this patch release as soon as possible.
+ We recommend upgrading to this patch release as soon as possible.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
We recommended to upgrade to this patch release as soon as possible.
We recommend upgrading to this patch release as soon as possible.

RELEASE_NOTES.md Outdated

We recommended to upgrade to this patch release as soon as possible.
When upgrading from <= v0.50.3, please ensure that 2/3 of the validator power upgrade to v0.50.4.

## 📝 Changelog

Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.50.5/CHANGELOG.md) for an exhaustive list of changes, or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.50.4...v0.50.5) from the last release.
Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.50.4/CHANGELOG.md) for an exhaustive list of changes, or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.50.3...v0.50.4) from the last release.

Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/v0.50.x/UPGRADING.md) when migrating from `v0.47.x` to `v0.50.1`.
Note, that the next SDK release, v0.51.0, will not include `x/params` migration, when migrating from < v0.47, v0.50.x **or** v0.47.x, is a mandatory migration.
Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify the migration requirements, consider rephrasing: "Note that the next SDK release, v0.51.0, will not include the x/params migration. When migrating from versions earlier than v0.47, including v0.50.x or v0.47.x, this migration is mandatory."

- Note, that the next SDK release, v0.51.0, will not include `x/params` migration, when migrating from < v0.47, v0.50.x **or** v0.47.x, is a mandatory migration.
+ Note that the next SDK release, v0.51.0, will not include the `x/params` migration. When migrating from versions earlier than v0.47, including v0.50.x or v0.47.x, this migration is mandatory.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Note, that the next SDK release, v0.51.0, will not include `x/params` migration, when migrating from < v0.47, v0.50.x **or** v0.47.x, is a mandatory migration.
Note that the next SDK release, v0.51.0, will not include the `x/params` migration. When migrating from versions earlier than v0.47, including v0.50.x or v0.47.x, this migration is mandatory.

baseapp/baseapp.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

🙌

@@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Features

* (baseapp) [#19626](https://github.com/cosmos/cosmos-sdk/pull/19626) Adds `DisableBlockGasMeter` option to `BaseApp`, which removes the block gas meter during transaction execution.
Copy link
Member

Choose a reason for hiding this comment

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

this will get in v0.50.5, can you move it below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

baseapp/baseapp.go Outdated Show resolved Hide resolved
@julienrbrt
Copy link
Member

we can direct this PR to 0.50.x only, or merge it into main and backport to 0.50.x first, then on top of it, we can still merge your PR that remove it completely if we decided to do that, WDYT?

Agreed with this take personally, we need to make sure we've removed it in v0.51 on baseapp or backport this then.

@julienrbrt julienrbrt merged commit f055cde into cosmos:release/v0.50.x Mar 11, 2024
42 of 45 checks passed
@julienrbrt julienrbrt changed the title feat: add option to disable block gas meter feat(baseapp): add option to disable block gas meter Mar 11, 2024
SpicyLemon added a commit to provenance-io/cosmos-sdk that referenced this pull request Mar 27, 2024
…0.50.5

* fix: in-place-testnet edgecases (backport cosmos#19516) (cosmos#19526)

Co-authored-by: Adam Tucker <[email protected]>

* fix(simapp): typo in GetStoreKeys (cosmos#19544)

* build(deps): Bump cosmossdk.io/math from 1.2.0 to 1.3.0 (cosmos#19562)

* fix(depinject): Authtx was not accepting custom signers (backport cosmos#19549) (cosmos#19551)

Co-authored-by: Devon Bear <[email protected]>
Co-authored-by: Qt <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* build(deps): Bump github.com/cosmos/cosmos-db from 1.0.0 to 1.0.2 (cosmos#19566)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Julien Robert <[email protected]>

* Merge pull request from GHSA-86h5-xcpx-cfqc

* fix slashing hole with test

* release notes + changelog

* word

* date

* updates

---------

Co-authored-by: Julien Robert <[email protected]>

* ci: run test pipeline on merge v0.50 branch (cosmos#19582)

* fix(staking): fix impossible conditions (cosmos#19621)

* docs: add section on creating a testnets from mainnet exports (backport cosmos#19475) (cosmos#19648)

Co-authored-by: Marko <[email protected]>

* build(deps): Bump cosmossdk.io/x/tx from 0.13.0 to 0.13.1 (cosmos#19665)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* feat(client/v2): marshal enum as string (cosmos#19653)

* refactor(x/auth): allow empty public keys for GetSignBytesAdapter (backport cosmos#19651) (cosmos#19675)

Co-authored-by: mmsqe <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* fix(types): check for HasABCIGenesis in CoreAppModuleBasicAdaptor (cosmos#19709)

* build(deps): Bump deps (backport cosmos#19655) (cosmos#19711)

Co-authored-by: Julien Robert <[email protected]>

* Merge pull request from GHSA-95rx-m9m5-m94v

* validate ExtendedCommit against LastCommit

test cases

* account for core.comet types

* logging

* linting

* cherry-pick staking fix

* nits

* linting fix

* run tests

---------

Co-authored-by: Marko <[email protected]>
Co-authored-by: Marko Baricevic <[email protected]>

* feat(baseapp): add option to disable block gas meter (cosmos#19626)

* feat(x/distribution): add rewards-by-validator autocli config (backport cosmos#19707) (cosmos#19714)

Co-authored-by: Julien Robert <[email protected]>

* fix(x/gov): grpc query tally for failed proposal (backport cosmos#19725) (cosmos#19727)

Co-authored-by: David Tumcharoen <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* chore: prepare v0.50.5 (cosmos#19715)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: yihuang <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Devon Bear <[email protected]>
Co-authored-by: Qt <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: khanh <[email protected]>
Co-authored-by: Tom <[email protected]>
Co-authored-by: Marko <[email protected]>
Co-authored-by: mmsqe <[email protected]>
Co-authored-by: Nikhil Vasan <[email protected]>
Co-authored-by: Marko Baricevic <[email protected]>
Co-authored-by: David Tumcharoen <[email protected]>
@faddat faddat mentioned this pull request Nov 8, 2024
12 tasks
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