Skip to content

Use contract rent to decide sudo call gas limit#467

Merged
codchen merged 2 commits intomasterfrom
tony-chen-fix-gas
Dec 28, 2022
Merged

Use contract rent to decide sudo call gas limit#467
codchen merged 2 commits intomasterfrom
tony-chen-fix-gas

Conversation

@codchen
Copy link
Collaborator

@codchen codchen commented Dec 27, 2022

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

}
rentBalance := contract.RentBalance
gasPrice := k.GetParams(ctx).SudoCallGasPrice
gasDec := sdk.NewDec(int64(rentBalance)).Quo(gasPrice)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible for gasPrice to be zero? If so we should have zero div protection here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we passing contractAddress here (and above in sudo args as []byte instead of AccAddress which is a defined type for []byte IIRC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@github-actions
Copy link

Code Coverage

Package Line Rate Complexity Health
github.com/sei-protocol/sei-chain/aclmapping/bank 100% 0
github.com/sei-protocol/sei-chain/aclmapping/dex 97% 0
github.com/sei-protocol/sei-chain/aclmapping/oracle 100% 0
github.com/sei-protocol/sei-chain/aclmapping/staking 82% 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 59% 0
github.com/sei-protocol/sei-chain/app/antedecorators 74% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/config 85% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle 73% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle/provider 50% 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 46% 0
github.com/sei-protocol/sei-chain/utils/datastructures 90% 0
github.com/sei-protocol/sei-chain/x/dex 58% 0
github.com/sei-protocol/sei-chain/x/dex/cache 86% 0
github.com/sei-protocol/sei-chain/x/dex/client/cli/query 23% 0
github.com/sei-protocol/sei-chain/x/dex/contract 52% 0
github.com/sei-protocol/sei-chain/x/dex/exchange 89% 0
github.com/sei-protocol/sei-chain/x/dex/keeper 67% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/abci 30% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/msgserver 78% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/query 82% 0
github.com/sei-protocol/sei-chain/x/dex/migrations 87% 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 83% 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 75% 0
github.com/sei-protocol/sei-chain/x/mint/simulation 95% 0
github.com/sei-protocol/sei-chain/x/mint/types 2% 0
github.com/sei-protocol/sei-chain/x/nitro/client/cli 45% 0
github.com/sei-protocol/sei-chain/x/nitro/keeper 80% 0
github.com/sei-protocol/sei-chain/x/nitro/replay 63% 0
github.com/sei-protocol/sei-chain/x/oracle 64% 0
github.com/sei-protocol/sei-chain/x/oracle/keeper 82% 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% (5048 / 33900) 0

@codchen codchen merged commit 466e430 into master Dec 28, 2022
masih pushed a commit that referenced this pull request Sep 29, 2025
## Describe your changes and provide context
- toExecute is supposed to be overwritten 
- added summary log line

## Testing performed to validate your change
- load tests confirm performance not impacted
masih pushed a commit that referenced this pull request Sep 30, 2025
## Describe your changes and provide context
- toExecute is supposed to be overwritten 
- added summary log line

## Testing performed to validate your change
- load tests confirm performance not impacted
@masih masih deleted the tony-chen-fix-gas branch October 31, 2025 15:52
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.

2 participants