-
Notifications
You must be signed in to change notification settings - Fork 329
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
Add query_list functionality / tests #509
Conversation
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.
I will try to dig deeper
|
||
/// This returns the list of ids for all active swaps | ||
pub fn all_swap_ids<S: ReadonlyStorage>(storage: &S) -> StdResult<Vec<String>> { | ||
prefixed_read(PREFIX_SWAP, storage) |
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.
If you change this from prefixed_read(PREFIX_SWAP, storage).range...
to storage.range...
does this pass?
Sounds like a bug in the ReadonlyPrefixedStorage
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.
With this change it passes:
// prefixed_read(PREFIX_SWAP, storage)
storage
Seems like range_with_prefix
does something funny.
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.
Yes, I've just tried it. The results are different, though, as iterating over the whole storage gives different entries.
I would love to analyse / fix this, but I totally lack debugging capabilities in the vm. How do I print / log, by example? println!
does nothing.
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.
I pushed a simplification. Any time you call range()
with Some(b"key")
as either start or end, we get this bug.
Time to look at the vm-wasm interface
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.
I would love to analyse / fix this, but I totally lack debugging capabilities in the vm. How do I print / log, by example? println! does nothing.
There is no way to print from wasm, just from native code (when compiling unit tests).
It's kind of odd to let a contract print to the same place as all the log files... they could definitely make some havoc or at least confusion there.
Maybe we could consider enabling printing from wasm with some debug
vm flag. But that is totally out of scope.
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.
I will debug this. Thank you for finding a reproduceable case. It involves lots of internals of vm-wasm boundaries
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.
Maybe we could consider enabling printing from wasm with some
debug
vm flag.
+1 to that. Printing, or at the very least logging to a file.
Notes:
Stack trace of an error:
|
I can also cause the error with this. Clearly it is
|
The issue is in // actual code properly creates a region from input, this is for control
let start = start.map(|s| Box::new(Region{offset: 50, length: 500, capacity: 500}));
let start_ptr = match start {
Some(reg) => &*reg as *const Region as u32,
None => 0,
}; which gives us this on the VM side: However, if I do the same logic, but without the maps (and only handle the let start = Box::new(Region{offset: 100, length: 200, capacity: 300});
let start_ptr = &*start as *const Region as u32; I end up with this on the VM side: All these maps and pointer references cause chaos somewhere... I'm going to make all the branches more explicit |
f0abe54
to
4d55816
Compare
Solution in #511 |
A small PR to reproduce #508 in cosmwasm.