Skip to content

Commit

Permalink
implement CodeStorage and ModuleStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
steelgeek091 committed Dec 24, 2024
1 parent 747b8d8 commit 93c3140
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 50 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ vergen-pretty = "0.3.6"
crossbeam-channel = "0.5.13"
inferno = "0.11.21"
handlebars = "4.2.2"
ambassador = "0.4.1"

# Note: the BEGIN and END comments below are required for external tooling. Do not remove.
# BEGIN MOVE DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions crates/rooch-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function_name = { workspace = true }

move-core-types = { workspace = true }
move-resource-viewer = { workspace = true }
move-vm-runtime = { workspace = true }

moveos = { workspace = true }
moveos-store = { workspace = true }
Expand Down
11 changes: 7 additions & 4 deletions crates/rooch-executor/src/actor/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use rooch_types::transaction::{
};
use std::str::FromStr;
use std::sync::Arc;
use move_vm_runtime::RuntimeEnvironment;

pub struct ExecutorActor {
root: ObjectMeta,
Expand All @@ -69,10 +70,11 @@ impl ExecutorActor {
let resolver = RootObjectResolver::new(root.clone(), &moveos_store);
let gas_parameters = FrameworksGasParameters::load_from_chain(&resolver)?;

let runtime_environment = RuntimeEnvironment::new(gas_parameters.all_natives());

let moveos = MoveOS::new(
&runtime_environment,
moveos_store.clone(),
gas_parameters.all_natives(),
MoveOSConfig::default(),
system_pre_execute_functions(),
system_post_execute_functions(),
)?;
Expand Down Expand Up @@ -521,10 +523,11 @@ impl Handler<EventData> for ExecutorActor {
let resolver = RootObjectResolver::new(self.root.clone(), &self.moveos_store);
let gas_parameters = FrameworksGasParameters::load_from_chain(&resolver)?;

let runtime_environment = RuntimeEnvironment::new(gas_parameters.all_natives());

self.moveos = MoveOS::new(
&runtime_environment,
self.moveos_store.clone(),
gas_parameters.all_natives(),
MoveOSConfig::default(),
system_pre_execute_functions(),
system_post_execute_functions(),
)?;
Expand Down
9 changes: 5 additions & 4 deletions crates/rooch-executor/src/actor/reader_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use anyhow::Result;
use async_trait::async_trait;
use coerce::actor::{context::ActorContext, message::Handler, Actor, LocalActorRef};
use move_resource_viewer::MoveValueAnnotator;
use move_vm_runtime::RuntimeEnvironment;
use moveos::moveos::MoveOS;
use moveos::moveos::MoveOSConfig;
use moveos_eventbus::bus::EventData;
Expand Down Expand Up @@ -51,10 +52,10 @@ impl ReaderExecutorActor {
) -> Result<Self> {
let resolver = RootObjectResolver::new(root.clone(), &moveos_store);
let gas_parameters = FrameworksGasParameters::load_from_chain(&resolver)?;
let runtime_environment = RuntimeEnvironment::new(gas_parameters.all_natives());
let moveos = MoveOS::new(
&runtime_environment,
moveos_store.clone(),
gas_parameters.all_natives(),
MoveOSConfig::default(),
system_pre_execute_functions(),
system_post_execute_functions(),
)?;
Expand Down Expand Up @@ -321,11 +322,11 @@ impl Handler<EventData> for ReaderExecutorActor {

let resolver = RootObjectResolver::new(self.root.clone(), &self.moveos_store);
let gas_parameters = FrameworksGasParameters::load_from_chain(&resolver)?;
let runtime_environment = RuntimeEnvironment::new(gas_parameters.all_natives());

self.moveos = MoveOS::new(
&runtime_environment,
self.moveos_store.clone(),
gas_parameters.all_natives(),
MoveOSConfig::default(),
system_pre_execute_functions(),
system_post_execute_functions(),
)?;
Expand Down
9 changes: 5 additions & 4 deletions crates/rooch-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use std::collections::BTreeMap;
use std::path::PathBuf;
use std::str::FromStr;
use std::{fs::File, io::Write, path::Path};
use move_vm_runtime::RuntimeEnvironment;

pub static ROOCH_LOCAL_GENESIS: Lazy<RoochGenesis> = Lazy::new(|| {
let network: RoochNetwork = BuiltinChainID::Local.into();
Expand Down Expand Up @@ -311,10 +312,10 @@ impl RoochGenesis {

let vm_config = MoveOSConfig::default();
let (moveos_store, _temp_dir) = MoveOSStore::mock_moveos_store()?;
let runtime_environment = RuntimeEnvironment::new(gas_parameter.all_natives());
let moveos = MoveOS::new(
&runtime_environment,
moveos_store,
gas_parameter.all_natives(),
vm_config,
vec![],
vec![],
)?;
Expand Down Expand Up @@ -412,10 +413,10 @@ impl RoochGenesis {
self.initial_gas_config.max_gas_amount,
self.initial_gas_config.entries.clone(),
)?;
let runtime_environment = RuntimeEnvironment::new(genesis_gas_parameter.all_natives());
let moveos = MoveOS::new(
&runtime_environment,
rooch_db.moveos_store.clone(),
genesis_gas_parameter.all_natives(),
MoveOSConfig::default(),
vec![],
vec![],
)?;
Expand Down
5 changes: 3 additions & 2 deletions crates/rooch-integration-test-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use rooch_types::framework::auth_validator::TxValidateResult;
use rooch_types::function_arg::FunctionArg;
use std::path::PathBuf;
use std::{collections::BTreeMap, path::Path};
use move_vm_runtime::RuntimeEnvironment;
use tracing::debug;

pub struct MoveOSTestRunner<'a> {
Expand Down Expand Up @@ -117,10 +118,10 @@ impl<'a> MoveOSTestAdapter<'a> for MoveOSTestRunner<'a> {
let moveos_store = MoveOSStore::new(temp_dir.path(), &registry).unwrap();
let genesis_gas_parameter = FrameworksGasParameters::initial();
let genesis: &RoochGenesis = &rooch_genesis::ROOCH_LOCAL_GENESIS;
let runtime_environment = RuntimeEnvironment::new(genesis_gas_parameter.all_natives());
let moveos = MoveOS::new(
&runtime_environment,
moveos_store.clone(),
genesis_gas_parameter.all_natives(),
MoveOSConfig::default(),
rooch_types::framework::system_pre_execute_functions(),
rooch_types::framework::system_post_execute_functions(),
)
Expand Down
6 changes: 4 additions & 2 deletions crates/rooch/src/tx_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use rooch_types::framework::system_pre_execute_functions;
use rooch_types::transaction::RoochTransactionData;
use std::rc::Rc;
use std::str::FromStr;
use move_vm_runtime::RuntimeEnvironment;

pub fn execute_tx_locally(
state_root_bytes: Vec<u8>,
Expand Down Expand Up @@ -214,9 +215,10 @@ pub fn prepare_execute_env(
client_resolver,
)));

let runtime_environment = RuntimeEnvironment::new(gas_parameters.all_natives());

let vm = MoveOSVM::new(
gas_parameters.all_natives(),
MoveOSConfig::default().vm_config,
&runtime_environment,
)
.expect("create MoveVM failed");

Expand Down
5 changes: 5 additions & 0 deletions moveos/moveos-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ prometheus = { workspace = true }
tokio = { workspace = true }
function_name = { workspace = true }
tracing = { workspace = true }
ambassador = { workspace = true }
bytes = { workspace = true }

move-core-types = { workspace = true }
move-vm-types = { workspace = true }
move-binary-format = { workspace = true }
move-vm-runtime = { workspace = true }

moveos-types = { workspace = true }
raw-store = { workspace = true }
Expand Down
Loading

0 comments on commit 93c3140

Please sign in to comment.