oraichain / wasmd

Basic cosmos-sdk app with web assembly smart contracts
Other
3 stars 9 forks source link

kv store with key KVStoreKey{0x14007520260, wasm} has not been registered in stores #12

Open ducphamle2 opened 1 month ago

ducphamle2 commented 1 month ago

Context

Oraichain has a custom feature allowing EVM contracts to call CosmWasm contracts directly via Solidity.

This requires deploying a set of precompile contracts with logic written in Golang. These methods would have access to different Cosmos keepers to invoke appropriate queries and execute calls.

However, when running tests, the precompile logic couldn't have access to any module stores with the following similar errors across all modules:

kv store with key KVStoreKey{0x14007520260, wasm} has not been registered in stores

To Reproduce

Steps to reproduce the behavior:

  1. Deploy an EVM contract with precompile enabled
  2. Query the deployed contract that invokes CosmWasm queries
  3. View the full node's log to see the error

Expected behavior

There should be no error, and a result should be returned from CosmWasm.

Additional context

ducphamle2 commented 1 month ago

The root cause of this bug remains unknown. It seems that using the Cosmos keepers at the end of NewWasmApp directly is causing the problem. The keepers hold the store keys, and they don't match with the ctx.ms

ducphamle2 commented 1 month ago

A workaround is to add a new AnteHandler to register the precompiled contracts with Cosmos Keepers. Because AnteHandler can use keepers without error -> the precompiled contracts can also use them.

ducphamle2 commented 1 month ago

Fixed in #13