CosmWasm / CosmWasm/cw-storage-plus
multiindex key definition - footgun
- Dominant language
- Rust
- Stars
- 51
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
I am having an issue with CW-storage-plus. (thanks to Eris/Phil @0xPhilipp for pointing it out)
I have managed to produce an example which demonstrates it here - [testcase](https://github.com/PFC-developer/storage-testcase)
I have a key which is a (u64,&str) .. and it works ok, until I put in a u64 > 128, and it then gives a UTF-8 error
how do I remedy this.
is there a way to do this without migrating the index in the existing smart contract
the error returned is as follows
```
called `Result::unwrap()` on an `Err` value: InvalidUtf8 { msg: "invalid utf-8 sequence of 1 bytes from index 9" }
thread 'testing::tests::test_128' panicked at contracts/hub-tf/src/testing/tests.rs:2100:10:
```
this was due to a multiindex signature not being defined properly.
the following patch to the test case [resolves](https://github.com/PFC-developer/storage-testcase/compare/main...mod-2) it.
the issue is here as I think this should have resulted in a compile error (the PK was badly defined in the original case), but it wasn't.
Thanks!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked storage-testcase repository and the panic location at contracts/hub-tf/src/testing/tests.rs:2100, then compare the original case with the mod-2 patch. Trace how the malformed multiindex signature is accepted and determine what behavior would prevent the invalid UTF-8 failure. Done means the bad primary-key definition is rejected or diagnosed before runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100