Skip to content

Commit

Permalink
use pre-compiled aptos-common when dumping the code
Browse files Browse the repository at this point in the history
  • Loading branch information
rahxephon89 committed Sep 2, 2024
1 parent 8f37c12 commit 7c723de
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
30 changes: 26 additions & 4 deletions aptos-move/aptos-e2e-comparison-testing/src/data_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{
add_aptos_packages_to_data_store, check_aptos_packages_availability, compile_aptos_packages,
data_state_view::DataStateView, dump_and_compile_from_package_metadata, is_aptos_package,
CompilationCache, DataManager, IndexWriter, PackageInfo, TxnIndex,
CompilationCache, DataManager, IndexWriter, PackageInfo, TxnIndex, APTOS_COMMONS,
};
use anyhow::{format_err, Result};
use aptos_framework::natives::code::PackageMetadata;
use aptos_language_e2e_tests::data_store::FakeDataStore;
use aptos_rest_client::Client;
use aptos_types::{
state_store::{state_key::StateKey, state_value::StateValue, TStateView},
Expand Down Expand Up @@ -161,7 +163,17 @@ impl DataCollection {

pub async fn dump_data(&self, begin: Version, limit: u64) -> Result<()> {
println!("begin dumping data");
let compilation_cache = Arc::new(Mutex::new(CompilationCache::default()));
let aptos_commons_path = self.current_dir.join(APTOS_COMMONS);
if !check_aptos_packages_availability(aptos_commons_path.clone()) {
return Err(anyhow::Error::msg("aptos packages are missing"));
}
let mut compiled_cache = CompilationCache::default();
let _ = compile_aptos_packages(
&aptos_commons_path,
&mut compiled_cache.compiled_package_cache_v1,
false,
);
let compilation_cache = Arc::new(Mutex::new(compiled_cache));
let data_manager = Arc::new(Mutex::new(DataManager::new_with_dir_creation(
&self.current_dir,
)));
Expand Down Expand Up @@ -203,8 +215,18 @@ impl DataCollection {
let data_manager = data_manager.clone();
let index = index_writer.clone();

let state_view =
DataStateView::new_with_data_reads(self.debugger.clone(), version);
let mut data_state = FakeDataStore::default();
let cache_v1 = compilation_cache
.lock()
.unwrap()
.compiled_package_cache_v1
.clone();
add_aptos_packages_to_data_store(&mut data_state, &cache_v1);
let state_view = DataStateView::new_with_data_reads_and_code(
self.debugger.clone(),
version,
data_state,
);

let txn_execution_thread = tokio::task::spawn_blocking(move || {
let epoch_result_res =
Expand Down
14 changes: 13 additions & 1 deletion aptos-move/aptos-e2e-comparison-testing/src/data_state_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl DataStateView {
}
}

pub fn new_with_data_reads(
pub fn _new_with_data_reads(
db: Arc<dyn AptosValidatorInterface + Send>,
version: Version,
) -> Self {
Expand All @@ -46,6 +46,18 @@ impl DataStateView {
}
}

pub fn new_with_data_reads_and_code(
db: Arc<dyn AptosValidatorInterface + Send>,
version: Version,
code_data: FakeDataStore,
) -> Self {
Self {
debugger_view: DebuggerStateView::new(db, version),
code_data: Some(code_data),
data_read_state_keys: Some(Arc::new(Mutex::new(HashMap::new()))),
}
}

pub fn get_state_keys(self) -> Arc<Mutex<HashMap<StateKey, StateValue>>> {
self.data_read_state_keys.unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/aptos-e2e-comparison-testing/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn add_packages_to_data_store(
}
}

fn add_aptos_packages_to_data_store(
pub(crate) fn add_aptos_packages_to_data_store(
data_store: &mut FakeDataStore,
compiled_package_map: &HashMap<PackageInfo, HashMap<ModuleId, Vec<u8>>>,
) {
Expand Down

0 comments on commit 7c723de

Please sign in to comment.