Skip to content

Commit

Permalink
Modify tests in executor-service to handle FA
Browse files Browse the repository at this point in the history
  • Loading branch information
manudhundi committed Nov 22, 2024
1 parent 3ad1e66 commit 0a45e67
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 32 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 0 additions & 8 deletions aptos-move/aptos-vm/tests/sharded_block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ fn test_partitioner_v2_uniform_sharded_block_executor_no_conflict() {
}

#[test]
#[ignore]
// Sharded execution with cross shard conflict doesn't work for now because we don't have
// cross round dependency tracking yet.
fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_parallel() {
Expand All @@ -52,7 +51,6 @@ fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_parallel() {
}

#[test]
#[ignore]
fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_sequential() {
for merge_discard in [false, true] {
let num_shards = 7;
Expand All @@ -67,7 +65,6 @@ fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_sequential()
}

#[test]
#[ignore]
fn test_partitioner_v2_uniform_sharded_block_executor_with_random_transfers_parallel() {
for merge_discard in [false, true] {
let num_shards = 3;
Expand All @@ -86,7 +83,6 @@ fn test_partitioner_v2_uniform_sharded_block_executor_with_random_transfers_para
}

#[test]
#[ignore]
fn test_partitioner_v2_uniform_sharded_block_executor_with_random_transfers_sequential() {
for merge_discard in [false, true] {
let mut rng = OsRng;
Expand Down Expand Up @@ -121,7 +117,6 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_no_conflict()
}

#[test]
#[ignore]
// Sharded execution with cross shard conflict doesn't work for now because we don't have
// cross round dependency tracking yet.
fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_parallel() {
Expand All @@ -138,7 +133,6 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_
}

#[test]
#[ignore]
fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_sequential() {
for merge_discard in [false, true] {
let num_shards = 7;
Expand All @@ -153,7 +147,6 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_
}

#[test]
#[ignore]
fn test_partitioner_v2_connected_component_sharded_block_executor_with_random_transfers_parallel() {
for merge_discard in [false, true] {
let num_shards = 3;
Expand All @@ -172,7 +165,6 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_with_random_tr
}

#[test]
#[ignore]
fn test_partitioner_v2_connected_component_sharded_block_executor_with_random_transfers_sequential()
{
for merge_discard in [false, true] {
Expand Down
1 change: 1 addition & 0 deletions execution/executor-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ crossbeam-channel = { workspace = true }
ctrlc = "3.4.0"
dashmap = { workspace = true }
itertools = { workspace = true }
move-core-types = { workspace = true }
num_cpus = { workspace = true }
once_cell = { workspace = true }
rayon = { workspace = true }
Expand Down
107 changes: 85 additions & 22 deletions execution/executor-service/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@ use aptos_language_e2e_tests::{
};
use aptos_types::{
account_address::AccountAddress,
account_config::ObjectGroupResource,
block_executor::{
config::BlockExecutorConfigFromOnchain, partitioner::PartitionedTransactions,
},
state_store::state_key::inner::StateKeyInner,
on_chain_config::{FeatureFlag, Features, OnChainConfig},
state_store::state_key::{inner::StateKeyInner, StateKey},
transaction::{
analyzed_transaction::AnalyzedTransaction,
signature_verified_transaction::SignatureVerifiedTransaction, Transaction,
TransactionOutput,
analyzed_transaction::{
initialize_default_to_fa_apt_store, AnalyzedTransaction, DEFAULT_TO_FA_APT_STORE,
},
signature_verified_transaction::SignatureVerifiedTransaction,
Transaction, TransactionOutput,
},
write_set::TOTAL_SUPPLY_STATE_KEY,
};
use aptos_vm::{
aptos_vm::AptosVMBlockExecutor,
sharded_block_executor::{executor_client::ExecutorClient, ShardedBlockExecutor},
VMBlockExecutor,
};
use move_core_types::move_resource::MoveStructType;
use std::{
collections::HashMap,
sync::{Arc, Mutex},
Expand Down Expand Up @@ -75,6 +81,25 @@ pub fn compare_txn_outputs(
sharded_txn_output: Vec<TransactionOutput>,
) {
assert_eq!(unsharded_txn_output.len(), sharded_txn_output.len());

// TODO: Fix total_supply with FA enabled
let key_to_filter = AccountAddress::from_hex_literal("0xa").unwrap();
let state_key_to_filter =
StateKey::resource_group(&key_to_filter, &ObjectGroupResource::struct_tag());
let path_to_filter = if let StateKeyInner::AccessPath(access_path) = state_key_to_filter.inner()
{
access_path
} else {
panic!("Expected AccessPath");
};

let total_supply_table_handle =
if let StateKeyInner::TableItem { handle, .. } = TOTAL_SUPPLY_STATE_KEY.inner() {
handle
} else {
panic!("Expected TableItem");
};

for i in 0..unsharded_txn_output.len() {
assert_eq!(
unsharded_txn_output[i].status(),
Expand All @@ -84,28 +109,59 @@ pub fn compare_txn_outputs(
unsharded_txn_output[i].gas_used(),
sharded_txn_output[i].gas_used()
);
//assert_eq!(unsharded_txn_output[i].write_set(), sharded_txn_output[i].write_set());
assert_eq!(
unsharded_txn_output[i].events(),
sharded_txn_output[i].events()
);
// Global supply tracking for coin is not supported in sharded execution yet, so we filter
// out the table item from the write set, which has the global supply. This is a hack until
// we support global supply tracking in sharded execution.
let unsharded_write_set_without_table_item = unsharded_txn_output[i]
.write_set()
.into_iter()
.filter(|(k, _)| matches!(k.inner(), &StateKeyInner::AccessPath(_)))
.collect::<Vec<_>>();
let sharded_write_set_without_table_item = sharded_txn_output[i]
.write_set()
.into_iter()
.filter(|(k, _)| matches!(k.inner(), &StateKeyInner::AccessPath(_)))
.collect::<Vec<_>>();
assert_eq!(
unsharded_write_set_without_table_item,
sharded_write_set_without_table_item
);
if *DEFAULT_TO_FA_APT_STORE.get().unwrap() {
let unsharded_write_set_without_table_item = unsharded_txn_output[i]
.write_set()
.into_iter()
.filter(|(k, _)| {
if let StateKeyInner::AccessPath(access_path) = k.inner() {
!(access_path.address == key_to_filter
&& access_path.path == path_to_filter.path)
} else {
true
}
})
.filter(|(k, _)| {
if let StateKeyInner::TableItem { handle, .. } = k.inner() {
handle != total_supply_table_handle
} else {
true
}
})
.collect::<Vec<_>>();
let sharded_write_set_without_table_item = sharded_txn_output[i]
.write_set()
.into_iter()
.filter(|(k, _)| {
if let StateKeyInner::AccessPath(access_path) = k.inner() {
!(access_path.address == key_to_filter
&& access_path.path == path_to_filter.path)
} else {
true
}
})
.filter(|(k, _)| {
if let StateKeyInner::TableItem { handle, .. } = k.inner() {
handle != total_supply_table_handle
} else {
true
}
})
.collect::<Vec<_>>();
assert_eq!(
unsharded_write_set_without_table_item,
sharded_write_set_without_table_item
);
} else {
assert_eq!(
unsharded_txn_output[i].write_set(),
sharded_txn_output[i].write_set()
);
}
}
}

Expand Down Expand Up @@ -157,6 +213,13 @@ pub fn sharded_block_executor_with_conflict<E: ExecutorClient<FakeDataStore>>(
let mut transactions = Vec::new();
let mut accounts = Vec::new();
let mut txn_hash_to_account = HashMap::new();

if DEFAULT_TO_FA_APT_STORE.get().is_none() {
let features = Features::fetch_config(&executor.data_store()).unwrap_or_default();
let use_fa_balance = features.is_enabled(FeatureFlag::NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE);
initialize_default_to_fa_apt_store(use_fa_balance);
}

for _ in 0..num_accounts {
let account = generate_account_at(&mut executor, AccountAddress::random());
accounts.push(Mutex::new(account));
Expand Down
2 changes: 0 additions & 2 deletions execution/executor-service/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub fn create_thread_remote_executor_shards(
}

#[test]
#[ignore]
fn test_sharded_block_executor_no_conflict() {
use std::thread;

Expand All @@ -75,7 +74,6 @@ fn test_sharded_block_executor_no_conflict() {
}

#[test]
#[ignore]
fn test_sharded_block_executor_with_conflict() {
use std::thread;

Expand Down

0 comments on commit 0a45e67

Please sign in to comment.