Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Mar 21, 2024
1 parent 70cf8db commit 290e26f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions substrate/frame/contracts/src/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ impl<T: Config> WasmBlob<T> {
host_state: H,
schedule: &Schedule<T>,
allow_deprecated: AllowDeprecatedInterface,
compilation_mode: CompilationMode,
) -> Result<(Store<H>, Memory, InstancePre), &'static str>
where
E: Environment<H>,
Expand Down Expand Up @@ -366,6 +365,7 @@ impl<T: Config> Executable<T> for WasmBlob<T> {
&code,
self.code_info.determinism,
Some(StackLimits::default()),
CompilationMode::Lazy,
false,
)
.map_err(|err| {
Expand All @@ -381,7 +381,6 @@ impl<T: Config> Executable<T> for WasmBlob<T> {
ExportedFunction::Call => AllowDeprecatedInterface::Yes,
ExportedFunction::Constructor => AllowDeprecatedInterface::No,
},
CompilationMode::Lazy,
)
.map_err(|msg| {
log::debug!(target: LOG_TARGET, "failed to instantiate code to wasmi: {}", msg);
Expand Down
5 changes: 3 additions & 2 deletions substrate/frame/contracts/src/wasm/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ impl LoadedModule {
let module = if validate_module {
Module::new(&engine, code)
} else {
unsafe { Module::new_unsafe(&engine, code) }
// Safety: The code has been validated, Therefore we know that it's a valid binary.
unsafe { Module::new_unchecked(&engine, code) }
}
.map_err(|err| {
log::debug!(target: LOG_TARGET, "Module creation failed: {:?}", err);
"Can't load the module into wasmi!"
})?;

#[cfg(test)]
LOADED_MODULE_TRACKER.with(|t| t.borrow_mut().push(_validate_module));
LOADED_MODULE_TRACKER.with(|t| t.borrow_mut().push(validate_module));

// Return a `LoadedModule` instance with
// __valid__ module.
Expand Down

0 comments on commit 290e26f

Please sign in to comment.