-
Notifications
You must be signed in to change notification settings - Fork 396
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
removed reseting of gas meter each time we enter a query #216
Conversation
d66ca02
to
d5b472f
Compare
@reuvenpo thank you for bringing this forward. I am working on CosmWasm/cosmwasm#494 to add such test potential to our standard test contract (your recursion idea plus a variable gas burning - sha256 hash loop). That is on 0.10.0 and we need to update go-cosmwasm CosmWasm/wasmvm#123 before we can use it. I saw this last night after you pointed the bug. We need a different entry point for the external smart queries than the internal keeper. OR we do... but it is there at the external query handler that we need to set the gas limit, not in the keeper. I built the contract to demo this issue. Unless you are really blocked by this, I would like to update everything to 0.10.0-alpha and get the test contract here with failing test cases before we start fixing bugs. Best way to ensure we squash them and there are no regressions |
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
==========================================
- Coverage 72.02% 72.01% -0.02%
==========================================
Files 27 27
Lines 2624 2623 -1
==========================================
- Hits 1890 1889 -1
Misses 622 622
Partials 112 112
Continue to review full report at Codecov.
|
I don't think there's a need for different entry points. I guess up until now queries didn't charge any gas and no one cared? |
We are not blocked by this. These last few PRs have been backports of changes that we have made in our repo, back to yours. We're fixing these bugs on our side, so we don't even need to pull in the full set of updates from your side yet. |
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 needs a bit of fixing. Copying the TG messages in here as well.
@ethansf Sorry for my confusion!
I believeQuerySmart
should receive an additionalisExternalQuery bool
param.
If it'sfalse
then doctx = ctx.WithGasMeter(sdk.NewGasMeter(k.queryGasLimit))
If it'strue
, it means the used gas from this query should be charged from thectx
of the caller
If it'sfalse
, we should use.WithGasMeter
in order to prevent query spam/dos
AndqueryGasLimit
should be taken from.wasmd/config/config.toml
This makes it the an external query from one contract to another contract uses the caller GasMeter. If it's not an external query then cosmos-sdk doesn't meter gas, but we want to meter gas because these queries can be very resource demanding, so we se a global queryGasLimit Also see CosmWasm/wasmd#216
I just merged #218 that expos ees 0.10 cosmwasn here and also the new gas metering. And the recursive query for testing. I will look at this soon, tests first |
Thanks for finding the issue and pushing a patch. I fixed this in #226 while still enforcing the limit on external queries. And adding a number of tests to ensure it works. |
Cool 👍 |
This PR removes a line that was reseting the gas meter for each query, which meant that recursive queries would not report any gas usage, since it would be charged on a new meter, which the caller has no access to.
We now observe that gas is charged for external queries.
I expect some tests will fail after this first commit. Let;s see if they do. Are there tests that run such contract-to-contract queries?