Skip to content

Commit

Permalink
Restore old from_module/from_code workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
uint committed Sep 28, 2022
1 parent ab315e4 commit 2dc8841
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/vm/src/instance.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::ptr::NonNull;
use std::sync::Mutex;
Expand All @@ -21,7 +22,7 @@ use crate::imports::{
use crate::imports::{do_db_next, do_db_scan};
use crate::memory::{read_region, write_region};
use crate::size::Size;
use crate::wasm_backend::compile;
use crate::wasm_backend::{compile, make_compile_time_store};

#[derive(Copy, Clone, Debug)]
pub struct GasReport {
Expand Down Expand Up @@ -61,12 +62,13 @@ where
/// This is the only Instance constructor that can be called from outside of cosmwasm-vm,
/// e.g. in test code that needs a customized variant of cosmwasm_vm::testing::mock_instance*.
pub fn from_code(
store: &mut Store,
code: &[u8],
backend: Backend<A, S, Q>,
options: InstanceOptions,
memory_limit: Option<Size>,
) -> VmResult<Self> {
let store = make_compile_time_store(memory_limit, &[]);

let (module, _) = compile(code, memory_limit, &[])?;
Instance::from_module(
store,
Expand All @@ -79,8 +81,8 @@ where
)
}

pub(crate) fn from_module(
store: &mut Store,
pub(crate) fn from_module<'s>(
store: impl wasmer::AsStoreMut,
module: &Module,
backend: Backend<A, S, Q>,
gas_limit: u64,
Expand Down
1 change: 1 addition & 0 deletions packages/vm/src/wasm_backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mod store;

pub use compile::compile;
pub use limiting_tunables::LimitingTunables;
pub use store::make_compile_time_store;
pub use store::make_runtime_store;

0 comments on commit 2dc8841

Please sign in to comment.