fix: cosmwasm evm query path repeatable undercharged evm exec#18
fix: cosmwasm evm query path repeatable undercharged evm exec#18mattkii wants to merge 2 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 47 minutes and 52 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Hardens the internal EVM call helper
CallEVMWithData(x/vm/keeper/call_evm.go)against undercharged, repeatable internal EVM execution triggered from the SDK side
(e.g. the KiiChain CosmWasm→EVM ERC20 query bindings).
Two compounding problems were addressed:
gasCapwas ignored.CallEVMWithDataalways set the messageGasLimittoconfig.DefaultGasCap(25M), regardless of thegasCapargument or the caller'sremaining SDK gas budget. A caller passing a smaller cap (or relying on the
remaining budget) could not constrain the internal execution.
full gas refund (
refundQuotient = 1) and skip theminimumGasUsedfloor, sores.GasUsedcan fall far below the real pre-refund compute (res.MaxUsedGas).ConsumeGas(res.GasUsed)therefore billed validators for a fraction of the workactually performed, enabling a refund-maximizing contract to repeat the same heavy
workload while paying almost nothing.
Changes in
CallEVMWithData:GasLimitby the providedgasCapwhen set (min(gasCap, DefaultGasCap)),falling back to
DefaultGasCapwhen nil — so callers can cap execution to theirremaining budget.
res.MaxUsedGaswhenit exceeds
res.GasUsed, for non-precompile calls. Precompile sub-calls keep theirexisting accounting to avoid disturbing precompile gas costs.
Most critical file to review:
x/vm/keeper/call_evm.go.This is the EVM-fork half of the fix; the companion change lives in
KiiChain/kiichain(wasmbinding/evm/queries.go), which passes a realgasCapderived from the transaction's remaining SDK gas to these helpers.Author Checklist
I have...
report KCNL1DDA-89 (CosmWasm→EVM query path repeatable undercharged internal
EVM execution).
mainbranch — branchfix/wasm-repeatable-undercharged-internal-evm-execwas cut from and targetsmain.How to review
x/vm/keeper/call_evm.go— confirm thegasCapbounding and theMaxUsedGasvsGasUsedcharging logic (note the!callFromPrecompileguard).CallEVMandCallEVMWithDatasuites green).