Skip to content

Commit

Permalink
[global cache] Draft e2e implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemitenkov committed Nov 6, 2024
1 parent 50c0277 commit 813cb54
Show file tree
Hide file tree
Showing 42 changed files with 677 additions and 224 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"aptos-move/aptos-gas-profiling",
"aptos-move/aptos-gas-schedule",
"aptos-move/aptos-gas-schedule-updator",
"aptos-move/aptos-global-cache-manager",
"aptos-move/aptos-memory-usage-tracker",
"aptos-move/aptos-native-interface",
"aptos-move/aptos-release-builder",
Expand Down Expand Up @@ -358,6 +359,7 @@ aptos-gas-schedule = { path = "aptos-move/aptos-gas-schedule" }
aptos-gas-schedule-updator = { path = "aptos-move/aptos-gas-schedule-updator" }
aptos-genesis = { path = "crates/aptos-genesis" }
aptos-github-client = { path = "crates/aptos-github-client" }
aptos-global-cache-manager = { path = "aptos-move/aptos-global-cache-manager" }
aptos-global-constants = { path = "config/global-constants" }
aptos-id-generator = { path = "crates/aptos-id-generator" }
aptos-indexer = { path = "crates/indexer" }
Expand Down
1 change: 1 addition & 0 deletions aptos-move/aptos-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ aptos-block-executor = { workspace = true }
aptos-consensus = { workspace = true }
aptos-crypto = { workspace = true }
aptos-gas-profiling = { workspace = true }
aptos-global-cache-manager = { workspace = true }
aptos-logger = { workspace = true }
aptos-rest-client = { workspace = true }
aptos-types = { workspace = true }
Expand Down
13 changes: 11 additions & 2 deletions aptos-move/aptos-debugger/src/aptos_debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use anyhow::{bail, format_err, Result};
use aptos_block_executor::txn_commit_hook::NoOpTransactionCommitHook;
use aptos_gas_profiling::{GasProfiler, TransactionGasLog};
use aptos_global_cache_manager::GlobalCacheManager;
use aptos_rest_client::Client;
use aptos_types::{
account_address::AccountAddress,
Expand Down Expand Up @@ -428,9 +429,15 @@ fn execute_block_no_limit(
state_view: &DebuggerStateView,
concurrency_level: usize,
) -> Result<Vec<TransactionOutput>, VMStatus> {
BlockAptosVM::execute_block::<_, NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>>(
let global_cache_manager = GlobalCacheManager::new_with_default_config();
global_cache_manager.mark_block_execution_start(state_view, None)?;
let result = BlockAptosVM::execute_block::<
_,
NoOpTransactionCommitHook<AptosTransactionOutput, VMStatus>,
>(
sig_verified_txns,
state_view,
&global_cache_manager,
BlockExecutorConfig {
local: BlockExecutorLocalConfig {
concurrency_level,
Expand All @@ -441,5 +448,7 @@ fn execute_block_no_limit(
},
None,
)
.map(BlockOutput::into_transaction_outputs_forced)
.map(BlockOutput::into_transaction_outputs_forced);
global_cache_manager.mark_block_execution_end(None)?;
result
}
1 change: 1 addition & 0 deletions aptos-move/aptos-e2e-comparison-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ default-run = "aptos-comparison-testing"
[dependencies]
anyhow = { workspace = true }
aptos-framework = { workspace = true }
aptos-global-cache-manager = { workspace = true }
aptos-language-e2e-tests = { workspace = true }
aptos-rest-client = { workspace = true }
aptos-types = { workspace = true }
Expand Down
15 changes: 13 additions & 2 deletions aptos-move/aptos-e2e-comparison-testing/src/data_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
};
use anyhow::{format_err, Result};
use aptos_framework::natives::code::PackageMetadata;
use aptos_global_cache_manager::GlobalCacheManager;
use aptos_rest_client::Client;
use aptos_types::{
state_store::{state_key::StateKey, state_value::StateValue, TStateView},
Expand Down Expand Up @@ -92,8 +93,18 @@ impl DataCollection {
// FIXME(#10412): remove the assert
let val = debugger_state_view.get_state_value(TOTAL_SUPPLY_STATE_KEY.deref());
assert!(val.is_ok() && val.unwrap().is_some());
AptosVM::execute_block_no_limit(&sig_verified_txns, debugger_state_view)
.map_err(|err| format_err!("Unexpected VM Error: {:?}", err))

let global_cache_manager = GlobalCacheManager::new_with_default_config();
global_cache_manager.mark_block_execution_start(debugger_state_view, None)?;
let result = AptosVM::execute_block_no_limit(
&sig_verified_txns,
debugger_state_view,
&global_cache_manager,
)
.map_err(|err| format_err!("Unexpected VM Error: {:?}", err));
global_cache_manager.mark_block_execution_end(None)?;

result
}

fn dump_and_check_src(
Expand Down
22 changes: 22 additions & 0 deletions aptos-move/aptos-global-cache-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "aptos-global-cache-manager"
description = "Aptos global module and environement cache manager"
version = "0.0.1"

# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
aptos-crypto = { workspace = true }
aptos-types = { workspace = true }
aptos-vm-environment = { workspace = true }
parking_lot = { workspace = true }
move-binary-format = { workspace = true }
move-core-types = { workspace = true }
move-vm-runtime = { workspace = true }
20 changes: 20 additions & 0 deletions aptos-move/aptos-global-cache-manager/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

/// Configuration used for global caches.
pub struct GlobalCacheConfig {
/// The maximum size of module cache. If module cache exceeds this capacity, it should be
/// flushed.
pub module_cache_capacity: usize,
/// The maximum size of struct name re-indexing map stored in runtime environment.
pub struct_name_index_map_capacity: usize,
}

impl Default for GlobalCacheConfig {
fn default() -> Self {
Self {
module_cache_capacity: 100_000,
struct_name_index_map_capacity: 100_000,
}
}
}
7 changes: 7 additions & 0 deletions aptos-move/aptos-global-cache-manager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

pub(crate) mod config;
mod manager;

pub use manager::GlobalCacheManager;
Loading

0 comments on commit 813cb54

Please sign in to comment.