-
Notifications
You must be signed in to change notification settings - Fork 336
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
Canonical address length bumped to 54, max bumped to 64 #995
Conversation
I do not know why it is failing so many tests :(((((( |
There are multiple smaller issues, one is just formatting. Start by running the following commands locally:
That should point you to the most obvious problems. |
In let dest_ptr = create_empty(&mut instance, 50); creates a memory region for the human address result. This is too short now. Change the 50 to 70 to make the tests pass. This is done 4x in the same file. |
Ahh it is a wasm error with windows, I tried changing CONTRACT to directly reference |
Ah, you are on Windows. Then this is a bit tricky. We support developing smart contracts on Windows (i.e. the guest), but not developing the cosmwas-vm (i.e. the host). This is because our Wasm backend (singlepass) does not support Windows yet. Anyways, you can run |
whoops, this time i need to look directly at circleci errors. let me fix that right now |
packages/schema/src/remove.rs
Outdated
@@ -37,7 +37,7 @@ pub fn remove_schemas(schemas_dir: &path::Path) -> Result<(), io::Error> { | |||
#[cfg(test)] | |||
mod tests { | |||
use super::*; | |||
use std::ffi::OsStr; | |||
// use std::ffi::OsStr; |
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.
Why this change? Seems unrelatet and causes compile errors.
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.
that was a formatting thing, my bad gonna revert that.
another question... and this is a stupid rust beginner question but since im on windows does
let source_ptr = write_data(&env, &[61; 33]);
the 33 here needs to be increased, not the 61 right? Testing locally returns the windows contract error
And |
Ok going to fix these last few errors today |
This commit still does not fix the issue in the staking module, IDK why its throwing the |
oh darn, this attempted fix actually failed more tests 😖 |
having issues with wsl for testing i am a trainwreck |
I am struggling with these tests :/// const DEFAULT_MEMORY_LIMIT: Option<Size> = Some(Size::mebi(16)); this memory limit applied to a mock instance is somehow not enough for the staking contract to call with the new canonical address length? and the other failures in the package vm are somehow related to the instantiated array let source_ptr = write_data(&env, &[61; 33]); which should be longer? im not good enough at rust to really understand them but I feel I was close haha sorry to bother, would really appreciate it, |
packages/vm/src/imports.rs
Outdated
@@ -1190,7 +1190,7 @@ mod tests { | |||
let (env, mut instance) = make_instance(api); | |||
|
|||
let source_ptr = write_data(&env, &[61; 33]); |
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.
let source_ptr = write_data(&env, &[61; 33]); | |
let source_ptr = write_data(&env, &[61; 65]); |
Something like [42; 5]
means an array filled with five 42s, so basically [42, 42, 42, 42, 42]
.
Here we're testing that we get an appropriate error if there is too much data. Since you increased the limit and length 33 is now OK, you want to change it to something that should cause an error.
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.
You'll also want to change the assertions below (lines 1206-1207) to match the new length and max length.
packages/vm/src/imports.rs
Outdated
@@ -994,7 +994,7 @@ mod tests { | |||
let api = MockApi::default(); | |||
let (env, _instance) = make_instance(api); | |||
|
|||
let source_ptr = write_data(&env, &[61; 100]); | |||
let source_ptr = write_data(&env, &[61; 33]); |
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.
Is this change needed? This test seemed perfectly OK before.
packages/vm/src/imports.rs
Outdated
@@ -1087,7 +1087,7 @@ mod tests { | |||
let api = MockApi::default(); | |||
let (env, mut instance) = make_instance(api); | |||
|
|||
let source_ptr = write_data(&env, &[61; 100]); |
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.
Same as for do_addr_validate_fails_for_large_inputs
- I don't think this is what you wanted to do?
Let's figure this out! Regarding the
I don't think that's the line you want. That's the overall limit for the total size of an instance of a contract, and it should be plenty. I think this is what you want to update: Looks like this is how much space will be allocated to store the canonical address, and with your changes it's too small. |
Thanks so much for the patience and suggestions. I really appreciate it, probably wouldve taken me another year to figure this out. |
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
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.
Code looks good to me, thanks. Could you just add those CHANGELOG entries to the ### Changed
section of ## [Unreleased]
:
- cosmwasm-std/cosmwasm-vm: Increase canonical address lengths up to 64 bytes.
- cosmwasm-std/cosmwasm-vm: In `MockApi`, increase max length of supported human
addresses from 24 bytes to 54 bytes by using a longer canonical
representation. This allows you to insert typical bech32 addresses in tests.
([#995])
[#995]: https://github.com/CosmWasm/cosmwasm/pull/995
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.
Looks good to me. Thank you!
@uint anything to add?
Nope, looks good! Thanks for contributing, @lukerhoads! |
No description provided.