-
Notifications
You must be signed in to change notification settings - Fork 13
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
Check the behavior when contract tries to open a file and fix it #219
Comments
use std::fs::File;
use std::io::prelude::*;
fn check_store(filename: String) {
let mut f = File::open(filename).expect("file not found");
let mut contents = String::new();
f.read_to_string(&mut contents)
.expect("something went wrong reading the file");
} |
Error in
Error in
|
Conculusion In cosmwasm/cosmwasm(line/cosmwasm), target=wasm32-unknown-unknown is used, so that std::fs functions return runtime errors at executing. Therefore, as for File::open, it cannot be executed.
In addition, when compiled with target=wasm32-wasi using WASI, for which File::open, etc. is standardized, and tried to do store of wasm, an error occurred in validation. (EXCEPT dynamic link branch)
Although there is a difference in the error contents between cosmwasm/cosmwasm and line/cosmwasm, the location causing the error is the same, and adding an abort feature as shown below will result in the same error contents. Found task |
@da1suk8 Could you try the wasm32-wasi version WASM in the dynamic link branch version LBM? The error "Wasm contract requires unsupported import" seems not to occur in dynamic link branch. It is because of this change (https://github.com/line/cosmwasm/blame/dynamic_link/packages/vm/src/compatibility.rs#L116). |
The following error occurred during instantiate in the dynamic link branch. It seems that execution itself is not possible.
Also, the following modification(https://github.com/line/cosmwasm/blame/dynamic_link/packages/vm/src/compatibility.rs#L116) to the dynamic link branch causes functions such as wasi_snapshot_preview1.fd_filestat_get to be judged as functions used by dynamic link when compiled by wasm32-wasi, etc. I have created a new issue. |
This contract should not be stored and needs to be fixed.
The text was updated successfully, but these errors were encountered: