Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix gas for comparison testing tool #13335

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
2 changes: 2 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 aptos-move/aptos-e2e-comparison-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ clap = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
move-binary-format = { workspace = true }
move-command-line-common = { workspace = true }
move-compiler = { workspace = true }
move-compiler-v2 = { workspace = true }
move-core-types = { workspace = true }
move-model = { workspace = true }
move-package = { workspace = true }
Expand Down
32 changes: 28 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,14 +163,25 @@ 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,
)));
let index_writer = Arc::new(Mutex::new(IndexWriter::new(&self.current_dir)));

let mut cur_version = begin;
let mut module_registry_map = HashMap::new();
let mut filtered_vec = vec![];
while cur_version < begin + limit {
let batch = if cur_version + self.batch_size <= begin + limit {
self.batch_size
Expand All @@ -182,6 +195,7 @@ impl DataCollection {
batch,
self.filter_condition,
&mut module_registry_map,
&mut filtered_vec,
)
.await;
// if error happens when collecting txns, log the version range
Expand All @@ -203,8 +217,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
Loading
Loading