From e74a6a5b6674bed45d078027ef7374a1adb60627 Mon Sep 17 00:00:00 2001
From: Zett98
Date: Mon, 26 Sep 2022 21:56:26 +0200
Subject: [PATCH] update base64
---
crates/vm_library/src/incoming.rs | 6 +++---
crates/vm_library/src/instance.rs | 3 +--
crates/vm_library/src/run_loop.rs | 6 +++---
crates/vm_library/src/state.rs | 6 +++---
crates/vm_library/tests/common/mod.rs | 24 +++++++++++++++++-------
crates/vm_library/tests/fa12.rs | 21 ++++++++++++++++-----
crates/vm_library/tests/increment.rs | 13 ++++++++++---
7 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/crates/vm_library/src/incoming.rs b/crates/vm_library/src/incoming.rs
index fafc037..89733b5 100644
--- a/crates/vm_library/src/incoming.rs
+++ b/crates/vm_library/src/incoming.rs
@@ -1,12 +1,12 @@
use wasmer::Module;
use crate::{managed::value::Value, ticket_table::Ticket};
-pub struct InvokeManaged {
- pub mod_: Module,
+pub struct InvokeManaged<'a> {
+ pub mod_: &'a Module,
pub arg: Value,
pub initial_storage: Value,
pub constants: Vec<(i32, Value)>,
- pub tickets: Vec,
+ pub tickets: &'a [Ticket],
pub source: String,
pub sender: String,
pub self_addr: String,
diff --git a/crates/vm_library/src/instance.rs b/crates/vm_library/src/instance.rs
index e6103e6..c8f11cd 100644
--- a/crates/vm_library/src/instance.rs
+++ b/crates/vm_library/src/instance.rs
@@ -14,7 +14,6 @@ use crate::{
pub fn invoke_managed(t: InvokeManaged) -> VMResult {
let arena = unsafe { &mut ARENA };
-
let module = t.mod_;
let env = Context {
inner: Rc::new(RefCell::new(Inner {
@@ -30,7 +29,7 @@ pub fn invoke_managed(t: InvokeManaged) -> VMResult {
let store = module.store();
let instance = Box::from(
- Instance::new(&module, &imports::make_imports(&env, store))
+ Instance::new(module, &imports::make_imports(&env, store))
.map_err(|err| VmError::RuntimeErr(format!("Failed to create instance {}", err)))?,
);
diff --git a/crates/vm_library/src/run_loop.rs b/crates/vm_library/src/run_loop.rs
index c2c4459..7b875c5 100644
--- a/crates/vm_library/src/run_loop.rs
+++ b/crates/vm_library/src/run_loop.rs
@@ -165,7 +165,7 @@ fn handle_originate(
self_: addr.clone(),
originated_by,
storage: bincode::serialize(&initial_storage).expect("error"),
- module: Box::from(Some(module)),
+ module: Some(Box::from(module)),
serialized_module: serialized,
constants: bincode::serialize(&constants).expect("error"),
};
@@ -207,11 +207,11 @@ fn handle_invoke(
let constantst: Vec<(i32, Value)> =
bincode::deserialize(&contract.constants).expect("error");
let invoke_payload = InvokeManaged {
- mod_: (*contract.module).clone().unwrap(),
+ mod_: (contract.module.as_ref().unwrap()),
arg,
initial_storage,
constants: constantst,
- tickets,
+ tickets: &tickets,
source: transaction.source.clone(),
sender: transaction
.sender
diff --git a/crates/vm_library/src/state.rs b/crates/vm_library/src/state.rs
index b0d7ffe..ef36051 100644
--- a/crates/vm_library/src/state.rs
+++ b/crates/vm_library/src/state.rs
@@ -15,7 +15,7 @@ pub struct ContractType {
#[serde(with = "serde_bytes")]
pub storage: Vec,
#[serde(skip_deserializing, skip_serializing)]
- pub module: Box