Skip to content
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

checkDiscountEligibility doesn't work for queries & sudo messages #2134

Open
dimiandre opened this issue Feb 25, 2025 · 0 comments
Open

checkDiscountEligibility doesn't work for queries & sudo messages #2134

dimiandre opened this issue Feb 25, 2025 · 0 comments

Comments

@dimiandre
Copy link

dimiandre commented Feb 25, 2025

Environment

wasmd version: v0.54.0
cosmos-sdk: v0.50.11
wasmvm: 2.2.1

Description of the bug

When ever someone queries a smart contract using smart queries, the node reports the following error:

5:13PM WRN cannot get tx contracts from context module=x/wasm

that seems to be relative to the checkDiscountEligibility function, traking transaction count

sdkCtx, discount := k.checkDiscountEligibility(sdkCtx, codeInfo.CodeHash, k.IsPinnedCode(ctx, contractInfo.CodeID))

The same error happens also when a contract gets executed using a sudo message, for example from the governance module.

sdkCtx, discount := k.checkDiscountEligibility(sdkCtx, codeInfo.CodeHash, k.IsPinnedCode(ctx, contractInfo.CodeID))

From my debugging, it seems that TxContractsFromContex is returning ok = false

func TxContractsFromContext(ctx context.Context) (TxContracts, bool) {

How to reproduce

1- Clone wasmd repo
2- Build
3- Init a new chain, add a new key, add balance, create gentx, collect, run the chain
4- Store cw_template.wasm
5- Instantiate it
6- Query the contract
7- Check validator logs

# Query the contract
dimi@neuralyzer contracts % wasmd q wasm contract-state smart wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d '{"get_count":{}}' 
data:
  count: 0

# Validator logs

5:30PM INF committed state block_app_hash=C35779674F03EB87878085647A84D904B62A775D39D0580B72E2ABBDED2E3795 height=43 module=state
5:30PM INF indexed block events height=43 module=txindex
5:31PM WRN cannot get tx contracts from context module=x/wasm
5:31PM INF received proposal module=consensus proposal="Proposal{44/0 (0F82DB7F3B770CA04987D27205F93D78868D0FC8200805494E5FAA1B5421A4F9:1:152CABAE22FA, -1) 57C8A7003B17 @ 2025-02-25T16:31:02.83917Z}" proposer=AC712EE8776AD8B2A232DF4E15177B966AE2CBC8

Additional notes
The same function (checkDiscountEligibility) works correctly when called from execute and instantiate transactions.

Everything is working correctly even if the error it's shown, simply all the query and sudo transactions are never discounted.

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

No branches or pull requests

1 participant