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

[Feature]: consume block gas meter don't panic #19317

Closed
yihuang opened this issue Feb 1, 2024 · 4 comments
Closed

[Feature]: consume block gas meter don't panic #19317

yihuang opened this issue Feb 1, 2024 · 4 comments

Comments

@yihuang
Copy link
Collaborator

yihuang commented Feb 1, 2024

Summary

When a transaction's execution exceeds the block gas meter, the out-of-gas error overrides the actual transaction execution result, which makes it tricky for indexers, explorers, and RPC wrappers to handle the transaction properly.
The current logic also doesn't commit the unlucky transaction result, I think it's not necessary, since it already passed ante handler logic which means the fee is already collected based on gas-wanted.
So the proposal is to simply ignore the error silently.

Problem Definition

  • Why do we need this feature?
    make the transaction result reflect the actual situation, and don't make the unlucky transaction to fail when the sender has paid gas fee.
  • What problems may be addressed by introducing this feature?
    indexers, explorers, and RPC wrappers can handle all transactions correctly.
  • Are there any disadvantages to including this feature?
    No.

Proposed Feature

Make consumeBlockGas recover the out-of-gas panic internally, don't let it propagate.

Alternatively, we can create a new method TryConsumeGas which doesn't panic but returns a proper error result when out of gas happens, and consumeBlockGas can log and ignore the error.

yihuang added a commit to yihuang/cosmos-sdk that referenced this issue Feb 1, 2024
@alexanderbez
Copy link
Contributor

If you evaluate the execution flow and you really think about it, the BlockGasMeter isn't needed at all. You already have block max gas validation when you create and verify the proposal. By the time you execute the proposal, you already know all txs are within the block gas limit (regardless of how much they actually consume).

@yihuang
Copy link
Collaborator Author

yihuang commented Feb 1, 2024

We have a slightly different situation, we try to keep it compatible with ethereum to refund unused gas (partially), at the same time we try to prevent too much unused gas-wanted waste too much block space, so we cap the tx wanted reported to cometbft, that makes the overflow tx happens occasionally.
When you refund unused gas to user, the user provided gas limit is not fully trustworthy.

@alexanderbez
Copy link
Contributor

Ahh I see. It's okay to submit a patch for this, but keep in mind. There may be a world in which block gas meter no longer exists as it's unnecessary.

cc @testinginprod @tac0turtle for server/v2.

@yihuang
Copy link
Collaborator Author

yihuang commented Feb 3, 2024

I guess we can hack this in our 0.47 fork for now, in the future I guess we can also live with it when the block gas meter is removed.

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

Successfully merging a pull request may close this issue.

2 participants