-
Notifications
You must be signed in to change notification settings - Fork 402
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
Limit simulation gas #674
Limit simulation gas #674
Conversation
Codecov Report
@@ Coverage Diff @@
## master #674 +/- ##
==========================================
+ Coverage 60.22% 60.24% +0.02%
==========================================
Files 48 48
Lines 5340 5361 +21
==========================================
+ Hits 3216 3230 +14
- Misses 1896 1902 +6
- Partials 228 229 +1
|
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.
lgtm. nice fix
return next(ctx, tx, simulate) | ||
} | ||
|
||
// apply custom node gas limit |
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.
Looks good. Maybe this could be "simplified"? But fine as is.
if d.gasLimit != nil {
ctx = ctx.WithGasMeter(sdk.NewGasMeter(*d.gasLimit))
} else if maxGas := ctx.ConsensusParams().GetBlock().MaxGas; maxGas > 0 {
ctx = ctx.WithGasMeter(sdk.NewGasMeter(sdk.Gas(maxGas)))
}
return next(ctx, tx, simulate)
@@ -107,3 +111,77 @@ func TestCountTxDecorator(t *testing.T) { | |||
}) | |||
} | |||
} | |||
func TestLimitSimulationGasDecorator(t *testing.T) { |
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.
nice tests
// SimulationGasLimit is the max gas to be used in a tx simulation call. | ||
// When not set the consensus max block gas is used instead | ||
SimulationGasLimit *uint64 | ||
// SimulationGasLimit is the max gas to be used in a smart query contract call |
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.
Just taking a look at this. You mean, SmartQueryGasLimit
.
* Limit simulation gas * Put parameters on separate lines
* Limit simulation gas * Put parameters on separate lines
Resolves #670
Adds a new startup param/config and ante handler to limit gas for simulations: