-
Notifications
You must be signed in to change notification settings - Fork 871
Fix Begin/EndBlock stuck at infinite loop in contracts #457
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
18a2777
Fix Begin/EndBlock stuck at infinite loop in contracts
codchen 5844535
fix
codchen 08f3d3a
catch out of gas panic
codchen 41b7500
fix test
codchen a3171af
fix test
codchen f4c2b3b
fix test
codchen 9e43686
fix tests
codchen d764ee6
comment
codchen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this gas limit determined for begin / end block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's set at the beginning of Begin/EndBlock (and it merely infers the value here): https://github.com/sei-protocol/sei-chain/blob/master/x/dex/module.go#L234 and https://github.com/sei-protocol/sei-chain/blob/master/x/dex/contract/abci.go#L45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't account for the already spent gas though, right? because lets say gas limit is 1000, but the beginblock already spent 250, and the wasm contract needs 800. Then with this current PR, it would allow a total consumption of 1050 gas, right? or is that fine since we're only looking to mitigate the infinite gas issue?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's intentional. We don't want to take into account already spent gas because otherwise it may cause non-determinism - contract A may be processed and consume most gas in val 1 and contract B would fail because it only has little gas remaining whereas it could be opposite in val 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So IUCC in some cases (example Uday listed above) may perform more computation than the original gas limit but it will still fail later when we check the gas consumed?
If so, it might be useful to add a comment here for future reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would fail later because of greater than expected gas consumption, because the gas being consumed by contracts is on a new meter, so doesn't actually affect the original gas meter. I was just wondering whether that was ok considering that gas is generally tied to compute cost but this seems fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the gas limit is more like "no individual call can exceed it", but a soft limit overall. I'll add a comment for this