From c79e00bd7e77089feecdc568fcf6c3977bb2ffa2 Mon Sep 17 00:00:00 2001 From: "roy.lieu" Date: Wed, 18 Sep 2024 15:22:31 +0800 Subject: [PATCH] Put the gas profiling in moveos repo --- Cargo.lock | 31 ++++++++++--------- Cargo.toml | 4 +-- .../moveos-gas-profiling}/Cargo.toml | 6 ++-- .../moveos-gas-profiling}/src/aggregate.rs | 0 .../moveos-gas-profiling}/src/erased.rs | 0 .../moveos-gas-profiling}/src/flamegraph.rs | 0 .../moveos-gas-profiling}/src/lib.rs | 0 .../moveos-gas-profiling}/src/log.rs | 0 .../moveos-gas-profiling}/src/misc.rs | 0 .../moveos-gas-profiling}/src/profiler.rs | 23 ++++++++++++++ .../moveos-gas-profiling}/src/render.rs | 0 .../moveos-gas-profiling}/src/report.rs | 0 .../templates/index.html | 0 13 files changed, 45 insertions(+), 19 deletions(-) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/Cargo.toml (85%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/aggregate.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/erased.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/flamegraph.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/lib.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/log.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/misc.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/profiler.rs (94%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/render.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/src/report.rs (100%) rename {crates/rooch-gas-profiling => moveos/moveos-gas-profiling}/templates/index.html (100%) diff --git a/Cargo.lock b/Cargo.lock index 004eaa1b0c..d76226de9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6880,6 +6880,22 @@ dependencies = [ "tokio", ] +[[package]] +name = "moveos-gas-profiling" +version = "0.7.0" +dependencies = [ + "anyhow", + "handlebars", + "inferno", + "move-binary-format", + "move-core-types", + "move-vm-types", + "moveos-types", + "regex", + "serde_json", + "smallvec", +] + [[package]] name = "moveos-object-runtime" version = "0.7.0" @@ -9495,21 +9511,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "rooch-gas-profiling" -version = "0.7.0" -dependencies = [ - "anyhow", - "handlebars", - "inferno", - "move-binary-format", - "move-core-types", - "move-vm-types", - "regex", - "serde_json", - "smallvec", -] - [[package]] name = "rooch-genesis" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index 84fab1de47..5dcd1e7e35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ "moveos/raw-store", "moveos/smt", "moveos/moveos-eventbus", + "moveos/moveos-gas-profiling", "crates/data_verify", "crates/rooch", "crates/rooch-benchmarks", @@ -49,7 +50,6 @@ members = [ "crates/rooch-event", "crates/testsuite", "crates/rooch-ord", - "crates/rooch-gas-profiling", "frameworks/bitcoin-move", "frameworks/framework-builder", "frameworks/framework-release", @@ -97,6 +97,7 @@ moveos-object-runtime = { path = "moveos/moveos-object-runtime" } moveos-compiler = { path = "moveos/moveos-compiler" } moveos-eventbus = { path = "moveos/moveos-eventbus" } accumulator = { path = "moveos/moveos-commons/accumulator" } +moveos-gas-profiling = { path = "moveos/moveos-gas-profiling" } # crates for Rooch rooch = { path = "crates/rooch" } @@ -130,7 +131,6 @@ data-verify = { path = "crates/data_verify" } rooch-db = { path = "crates/rooch-db" } rooch-event = { path = "crates/rooch-event" } rooch-ord = { path = "crates/rooch-ord" } -rooch-gas-profiling = { path = "crates/rooch-gas-profiling" } # frameworks framework-types = { path = "frameworks/framework-types" } diff --git a/crates/rooch-gas-profiling/Cargo.toml b/moveos/moveos-gas-profiling/Cargo.toml similarity index 85% rename from crates/rooch-gas-profiling/Cargo.toml rename to moveos/moveos-gas-profiling/Cargo.toml index 45a627d8ff..0524c6fe33 100644 --- a/crates/rooch-gas-profiling/Cargo.toml +++ b/moveos/moveos-gas-profiling/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rooch-gas-profiling" +name = "moveos-gas-profiling" # Workspace inherited keys version = { workspace = true } @@ -20,4 +20,6 @@ anyhow = { workspace = true } regex = { workspace = true } serde_json = { workspace = true } smallvec = { workspace = true } -handlebars = { workspace = true } \ No newline at end of file +handlebars = { workspace = true } + +moveos-types = { workspace = true } \ No newline at end of file diff --git a/crates/rooch-gas-profiling/src/aggregate.rs b/moveos/moveos-gas-profiling/src/aggregate.rs similarity index 100% rename from crates/rooch-gas-profiling/src/aggregate.rs rename to moveos/moveos-gas-profiling/src/aggregate.rs diff --git a/crates/rooch-gas-profiling/src/erased.rs b/moveos/moveos-gas-profiling/src/erased.rs similarity index 100% rename from crates/rooch-gas-profiling/src/erased.rs rename to moveos/moveos-gas-profiling/src/erased.rs diff --git a/crates/rooch-gas-profiling/src/flamegraph.rs b/moveos/moveos-gas-profiling/src/flamegraph.rs similarity index 100% rename from crates/rooch-gas-profiling/src/flamegraph.rs rename to moveos/moveos-gas-profiling/src/flamegraph.rs diff --git a/crates/rooch-gas-profiling/src/lib.rs b/moveos/moveos-gas-profiling/src/lib.rs similarity index 100% rename from crates/rooch-gas-profiling/src/lib.rs rename to moveos/moveos-gas-profiling/src/lib.rs diff --git a/crates/rooch-gas-profiling/src/log.rs b/moveos/moveos-gas-profiling/src/log.rs similarity index 100% rename from crates/rooch-gas-profiling/src/log.rs rename to moveos/moveos-gas-profiling/src/log.rs diff --git a/crates/rooch-gas-profiling/src/misc.rs b/moveos/moveos-gas-profiling/src/misc.rs similarity index 100% rename from crates/rooch-gas-profiling/src/misc.rs rename to moveos/moveos-gas-profiling/src/misc.rs diff --git a/crates/rooch-gas-profiling/src/profiler.rs b/moveos/moveos-gas-profiling/src/profiler.rs similarity index 94% rename from crates/rooch-gas-profiling/src/profiler.rs rename to moveos/moveos-gas-profiling/src/profiler.rs index 370cdcbe47..0bd942b302 100644 --- a/crates/rooch-gas-profiling/src/profiler.rs +++ b/moveos/moveos-gas-profiling/src/profiler.rs @@ -11,6 +11,7 @@ use move_core_types::language_storage::{ModuleId, TypeTag}; use move_vm_types::gas::{GasMeter, SimpleInstruction}; use move_vm_types::natives::function::PartialVMResult; use move_vm_types::views::{TypeView, ValueView}; +use moveos_types::transaction::{VerifiedMoveAction, VerifiedMoveOSTransaction}; pub struct GasProfiler { base: G, @@ -426,3 +427,25 @@ impl GasProfiler { } } } + +pub fn new_gas_profiler(tx: VerifiedMoveOSTransaction, base_gas_meter: G) -> GasProfiler { + match tx.action { + VerifiedMoveAction::Script { .. } => { + unreachable!( + "Script payload is not supported yet" + ) + } + VerifiedMoveAction::Function { + call, + bypass_visibility: _, + } => GasProfiler::new_function( + base_gas_meter, + call.function_id.module_id, + call.function_id.function_name, + call.ty_args, + ), + VerifiedMoveAction::ModuleBundle { .. } => { + unreachable!("ModuleBundle payload is not supported yet") + } + } +} diff --git a/crates/rooch-gas-profiling/src/render.rs b/moveos/moveos-gas-profiling/src/render.rs similarity index 100% rename from crates/rooch-gas-profiling/src/render.rs rename to moveos/moveos-gas-profiling/src/render.rs diff --git a/crates/rooch-gas-profiling/src/report.rs b/moveos/moveos-gas-profiling/src/report.rs similarity index 100% rename from crates/rooch-gas-profiling/src/report.rs rename to moveos/moveos-gas-profiling/src/report.rs diff --git a/crates/rooch-gas-profiling/templates/index.html b/moveos/moveos-gas-profiling/templates/index.html similarity index 100% rename from crates/rooch-gas-profiling/templates/index.html rename to moveos/moveos-gas-profiling/templates/index.html