Use contract rent to decide sudo call gas limit#467
Merged
Conversation
udpatil
reviewed
Dec 27, 2022
| } | ||
| rentBalance := contract.RentBalance | ||
| gasPrice := k.GetParams(ctx).SudoCallGasPrice | ||
| gasDec := sdk.NewDec(int64(rentBalance)).Quo(gasPrice) |
Collaborator
There was a problem hiding this comment.
is it possible for gasPrice to be zero? If so we should have zero div protection here.
Collaborator
Author
There was a problem hiding this comment.
good point, updated
| // possible for the actual computation to go above the specified limit, but | ||
| // the associated contract would be charged corresponding rent. | ||
| tmpCtx := sdkCtx.WithGasMeter(sdk.NewGasMeter(sdkCtx.GasMeter().Limit())) | ||
| gasLimit, err := k.GetContractGasLimit(sdkCtx, contractAddress) |
Collaborator
There was a problem hiding this comment.
why are we passing contractAddress here (and above in sudo args as []byte instead of AccAddress which is a defined type for []byte IIRC?
|
udpatil
approved these changes
Dec 28, 2022
masih
pushed a commit
that referenced
this pull request
Sep 29, 2025
masih
pushed a commit
that referenced
this pull request
Sep 30, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe your changes and provide context
Set sudo gas limit based on the remaining rent of a contract instead of overall block gas limit so that the processing may time out sooner without affecting processing outcome. There would also be no race condition since there could be at most one sudo call happening at a time for the same contract.
Testing performed to validate your change
unit test
local chain test