Skip to content

Commit

Permalink
Convert the Script to CompiledScript and do the checking with it. (ro…
Browse files Browse the repository at this point in the history
  • Loading branch information
steelgeek091 authored Apr 1, 2024
1 parent b2fd023 commit 98484d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions moveos/moveos/src/vm/moveos_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use super::data_cache::{into_change_set, MoveosDataCache};
use crate::gas::table::{get_gas_schedule_entries, initial_cost_schedule, ClassifiedGasMeter};
use crate::gas::{table::MoveOSGasMeter, SwitchableGasMeter};
use move_binary_format::compatibility::Compatibility;
use move_binary_format::file_format::CompiledScript;
use move_binary_format::normalized;
use move_binary_format::{
access::ModuleAccess,
Expand All @@ -19,6 +20,7 @@ use move_core_types::{
value::MoveTypeLayout,
vm_status::{KeptVMStatus, StatusCode},
};
use move_model::script_into_module;
use move_vm_runtime::data_cache::TransactionCache;
use move_vm_runtime::{
config::VMConfig,
Expand Down Expand Up @@ -198,6 +200,19 @@ where
.map_err(|e| e.finish(location.clone()))?;
let _resolved_args =
self.resolve_argument(&loaded_function, call.args.clone(), location)?;

let compiled_script_opt = CompiledScript::deserialize(call.code.as_slice());
let compiled_script = match compiled_script_opt {
Ok(v) => v,
Err(err) => return Err(err.finish(Location::Undefined)),
};
let script_module = script_into_module(compiled_script);
let result = moveos_verifier::verifier::verify_module(&script_module, self.remote);
match result {
Ok(_) => {}
Err(err) => return Err(err),
}

Ok(VerifiedMoveAction::Script { call })
}
MoveAction::Function(call) => {
Expand Down

0 comments on commit 98484d2

Please sign in to comment.