From a27c5205b470a22c5836d8163175b84e2c85bd04 Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Fri, 16 Feb 2024 20:59:10 +0100 Subject: [PATCH] [aggregator] Fix simulation & view for delayed fields (#12063) --- ...__view_function__test_view_aggregator.json | 1 + api/src/tests/move/pack_counter/Move.toml | 9 +++ .../move/pack_counter/sources/counter.move | 26 ++++++++ api/src/tests/simulation_test.rs | 60 ++++++++++++++++++- api/src/tests/view_function.rs | 31 +++++++++- .../aptos-debugger/src/aptos_debugger.rs | 6 +- aptos-move/aptos-vm/src/aptos_vm.rs | 28 +++++++-- .../aptos-vm/src/block_executor/vm_wrapper.rs | 5 +- aptos-move/aptos-vm/src/move_vm_ext/vm.rs | 9 +-- aptos-move/e2e-move-tests/src/harness.rs | 5 +- aptos-move/e2e-tests/src/executor.rs | 16 ++++- .../src/tests/failed_transaction_tests.rs | 5 +- .../e2e-testsuite/src/tests/verify_txn.rs | 48 +++++++-------- aptos-move/vm-genesis/src/lib.rs | 3 + .../src/writeset_builder.rs | 1 + .../execution/ptx-executor/src/runner.rs | 5 +- vm-validator/src/vm_validator.rs | 5 +- 17 files changed, 217 insertions(+), 46 deletions(-) create mode 100644 api/goldens/aptos_api__tests__view_function__test_view_aggregator.json create mode 100644 api/src/tests/move/pack_counter/Move.toml create mode 100644 api/src/tests/move/pack_counter/sources/counter.move diff --git a/api/goldens/aptos_api__tests__view_function__test_view_aggregator.json b/api/goldens/aptos_api__tests__view_function__test_view_aggregator.json new file mode 100644 index 0000000000000..890dac6191454 --- /dev/null +++ b/api/goldens/aptos_api__tests__view_function__test_view_aggregator.json @@ -0,0 +1 @@ +["10"] \ No newline at end of file diff --git a/api/src/tests/move/pack_counter/Move.toml b/api/src/tests/move/pack_counter/Move.toml new file mode 100644 index 0000000000000..5862b3a7c1612 --- /dev/null +++ b/api/src/tests/move/pack_counter/Move.toml @@ -0,0 +1,9 @@ +[package] +name = "pack_counter" +version = "0.0.0" + +[dependencies] +AptosFramework = { local = "../../../../../aptos-move/framework/aptos-framework" } + +[addresses] +addr = "_" diff --git a/api/src/tests/move/pack_counter/sources/counter.move b/api/src/tests/move/pack_counter/sources/counter.move new file mode 100644 index 0000000000000..7791659871958 --- /dev/null +++ b/api/src/tests/move/pack_counter/sources/counter.move @@ -0,0 +1,26 @@ +module addr::counter { + use 0x1::aggregator_v2::{Self, Aggregator}; + + struct Counter has key { + counter: Aggregator, + } + + fun init_module(account: &signer) { + let counter = Counter { + counter: aggregator_v2::create_aggregator(100), + }; + move_to(account, counter); + } + + public entry fun increment_counter() acquires Counter { + let counter = &mut borrow_global_mut(@addr).counter; + aggregator_v2::add(counter, 1); + } + + #[view] + public fun add_and_get_counter_value(): u64 acquires Counter { + let counter = &mut borrow_global_mut(@addr).counter; + aggregator_v2::add(counter, 10); + aggregator_v2::read(counter) + } +} diff --git a/api/src/tests/simulation_test.rs b/api/src/tests/simulation_test.rs index 52b032af86da7..eb821e74e7c64 100644 --- a/api/src/tests/simulation_test.rs +++ b/api/src/tests/simulation_test.rs @@ -4,8 +4,12 @@ use super::new_test_context; use aptos_api_test_context::{current_function_name, TestContext}; use aptos_crypto::ed25519::Ed25519Signature; -use aptos_types::transaction::authenticator::TransactionAuthenticator; +use aptos_types::transaction::{ + authenticator::TransactionAuthenticator, EntryFunction, TransactionPayload, +}; +use move_core_types::{ident_str, language_storage::ModuleId}; use serde_json::json; +use std::path::PathBuf; async fn simulate_aptos_transfer( context: &mut TestContext, @@ -82,3 +86,57 @@ async fn test_simulate_transaction_with_insufficient_balance() { let resp = simulate_aptos_transfer(&mut context, false, LARGE_TRANSFER_AMOUNT, 200).await; assert!(!resp[0]["success"].as_bool().is_some_and(|v| v)); } + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_simulate_txn_with_aggregator() { + let mut context = new_test_context(current_function_name!()); + let account = context.root_account().await; + + let named_addresses = vec![("addr".to_string(), account.address())]; + let path = PathBuf::from(std::env!("CARGO_MANIFEST_DIR")).join("src/tests/move/pack_counter"); + let payload = TestContext::build_package(path, named_addresses); + let txn = account.sign_with_transaction_builder(context.transaction_factory().payload(payload)); + context.commit_block(&vec![txn]).await; + + let payload = TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new(account.address(), ident_str!("counter").to_owned()), + ident_str!("increment_counter").to_owned(), + vec![], + vec![], + )); + let txn = account.sign_with_transaction_builder(context.transaction_factory().payload(payload)); + if let TransactionAuthenticator::Ed25519 { + public_key, + signature: _, + } = txn.authenticator_ref() + { + let function = format!("{}::counter::increment_counter", account.address()); + let resp = context + .expect_status_code(200) + .post( + "/transactions/simulate", + json!({ + "sender": txn.sender().to_string(), + "sequence_number": txn.sequence_number().to_string(), + "max_gas_amount": txn.max_gas_amount().to_string(), + "gas_unit_price": txn.gas_unit_price().to_string(), + "expiration_timestamp_secs": txn.expiration_timestamp_secs().to_string(), + "payload": { + "type": "entry_function_payload", + "function": function, + "type_arguments": [], + "arguments": [] + }, + "signature": { + "type": "ed25519_signature", + "public_key": public_key.to_string(), + "signature": Ed25519Signature::dummy_signature().to_string(), + } + }), + ) + .await; + assert!(resp[0]["success"].as_bool().is_some_and(|v| v)); + } else { + unreachable!("Simulation uses Ed25519 authenticator."); + } +} diff --git a/api/src/tests/view_function.rs b/api/src/tests/view_function.rs index 9d98afc3c7e38..fd125145f5e8d 100644 --- a/api/src/tests/view_function.rs +++ b/api/src/tests/view_function.rs @@ -2,12 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 use super::{new_test_context, new_test_context_with_config}; -use aptos_api_test_context::current_function_name; +use aptos_api_test_context::{current_function_name, TestContext}; use aptos_cached_packages::aptos_stdlib; use aptos_config::config::{NodeConfig, ViewFilter, ViewFunctionId}; use aptos_types::account_address::AccountAddress; use serde_json::{json, Value}; -use std::str::FromStr; +use std::{path::PathBuf, str::FromStr}; fn build_coin_balance_request(address: &AccountAddress) -> Value { json!({ @@ -188,7 +188,32 @@ async fn test_view_tuple() { .post( "/view", json!({ - "function":"0xa550c18::test_module::return_tuple", + "function": "0xa550c18::test_module::return_tuple", + "arguments": [], + "type_arguments": [], + }), + ) + .await; + context.check_golden_output_no_prune(resp); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_view_aggregator() { + let mut context = new_test_context(current_function_name!()); + let account = context.root_account().await; + + let named_addresses = vec![("addr".to_string(), account.address())]; + let path = PathBuf::from(std::env!("CARGO_MANIFEST_DIR")).join("src/tests/move/pack_counter"); + let payload = TestContext::build_package(path, named_addresses); + let txn = account.sign_with_transaction_builder(context.transaction_factory().payload(payload)); + context.commit_block(&vec![txn]).await; + + let function = format!("{}::counter::add_and_get_counter_value", account.address()); + let resp = context + .post( + "/view", + json!({ + "function": function, "arguments": [], "type_arguments": [], }), diff --git a/aptos-move/aptos-debugger/src/aptos_debugger.rs b/aptos-move/aptos-debugger/src/aptos_debugger.rs index 6cc92f8508520..65c2dc5c35148 100644 --- a/aptos-move/aptos-debugger/src/aptos_debugger.rs +++ b/aptos-move/aptos-debugger/src/aptos_debugger.rs @@ -78,7 +78,10 @@ impl AptosDebugger { // TODO(Gas): revisit this. let resolver = state_view.as_move_resolver(); - let vm = AptosVM::new(&resolver); + let vm = AptosVM::new( + &resolver, + /*override_is_delayed_field_optimization_capable=*/ Some(false), + ); // Module bundle is deprecated! if let TransactionPayload::ModuleBundle(_) = txn.payload() { @@ -268,6 +271,7 @@ impl AptosDebugger { features, TimedFeaturesBuilder::enable_all().build(), &state_view_storage, + /*aggregator_v2_type_tagging*/ false, ) .unwrap(); let mut session = move_vm.new_session(&state_view_storage, SessionId::Void); diff --git a/aptos-move/aptos-vm/src/aptos_vm.rs b/aptos-move/aptos-vm/src/aptos_vm.rs index c1e4d684338eb..0b4207c3d5f58 100644 --- a/aptos-move/aptos-vm/src/aptos_vm.rs +++ b/aptos-move/aptos-vm/src/aptos_vm.rs @@ -171,7 +171,10 @@ pub struct AptosVM { } impl AptosVM { - pub fn new(resolver: &impl AptosMoveResolver) -> Self { + pub fn new( + resolver: &impl AptosMoveResolver, + override_is_delayed_field_optimization_capable: Option, + ) -> Self { let _timer = TIMER.timer_with(&["AptosVM::new"]); let features = Features::fetch_config(resolver).unwrap_or_default(); @@ -191,11 +194,19 @@ impl AptosVM { .unwrap_or(0); let mut timed_features_builder = TimedFeaturesBuilder::new(chain_id, timestamp); - if let Some(profile) = crate::AptosVM::get_timed_feature_override() { + if let Some(profile) = Self::get_timed_feature_override() { timed_features_builder = timed_features_builder.with_override_profile(profile) } let timed_features = timed_features_builder.build(); + // If aggregator execution is enabled, we need to tag aggregator_v2 types, + // so they can be exchanged with identifiers during VM execution. + let override_is_delayed_field_optimization_capable = + override_is_delayed_field_optimization_capable + .unwrap_or_else(|| resolver.is_delayed_field_optimization_capable()); + let aggregator_v2_type_tagging = override_is_delayed_field_optimization_capable + && features.is_aggregator_v2_delayed_fields_enabled(); + let move_vm = MoveVmExt::new( native_gas_params, misc_gas_params, @@ -204,6 +215,7 @@ impl AptosVM { features.clone(), timed_features.clone(), resolver, + aggregator_v2_type_tagging, ) .expect("should be able to create Move VM; check if there are duplicated natives"); @@ -218,7 +230,7 @@ impl AptosVM { } } - pub(crate) fn new_session<'r, S: AptosMoveResolver>( + pub fn new_session<'r, S: AptosMoveResolver>( &self, resolver: &'r S, session_id: SessionId, @@ -1801,7 +1813,10 @@ impl AptosVM { gas_budget: u64, ) -> ViewFunctionOutput { let resolver = state_view.as_move_resolver(); - let vm = AptosVM::new(&resolver); + let vm = AptosVM::new( + &resolver, + /*override_is_delayed_field_optimization_capable=*/ Some(false), + ); let log_context = AdapterLogSchema::new(state_view.id(), 0); let mut gas_meter = match Self::memory_tracked_gas_meter(&vm, &log_context, gas_budget) { Ok(gas_meter) => gas_meter, @@ -2235,7 +2250,10 @@ pub struct AptosSimulationVM(AptosVM); impl AptosSimulationVM { pub fn new(resolver: &impl AptosMoveResolver) -> Self { - let mut vm = AptosVM::new(resolver); + let mut vm = AptosVM::new( + resolver, + /*override_is_delayed_field_optimization_capable=*/ Some(false), + ); vm.is_simulation = true; Self(vm) } diff --git a/aptos-move/aptos-vm/src/block_executor/vm_wrapper.rs b/aptos-move/aptos-vm/src/block_executor/vm_wrapper.rs index 3c65fbe55f83d..10c0cb6197a53 100644 --- a/aptos-move/aptos-vm/src/block_executor/vm_wrapper.rs +++ b/aptos-move/aptos-vm/src/block_executor/vm_wrapper.rs @@ -32,7 +32,10 @@ impl<'a, S: 'a + StateView + Sync> ExecutorTask for AptosExecutorTask<'a, S> { fn init(argument: &'a S) -> Self { // AptosVM has to be initialized using configs from storage. - let vm = AptosVM::new(&argument.as_move_resolver()); + let vm = AptosVM::new( + &argument.as_move_resolver(), + /*override_is_delayed_field_optimization_capable=*/ Some(true), + ); Self { vm, diff --git a/aptos-move/aptos-vm/src/move_vm_ext/vm.rs b/aptos-move/aptos-vm/src/move_vm_ext/vm.rs index de2742e714c50..ac185b314972a 100644 --- a/aptos-move/aptos-vm/src/move_vm_ext/vm.rs +++ b/aptos-move/aptos-vm/src/move_vm_ext/vm.rs @@ -72,6 +72,7 @@ impl MoveVmExt { timed_features: TimedFeatures, gas_hook: Option, resolver: &impl AptosMoveResolver, + aggregator_v2_type_tagging: bool, ) -> VMResult where F: Fn(DynamicExpression) + Send + Sync + 'static, @@ -100,10 +101,6 @@ impl MoveVmExt { type_byte_cost = 1; } - // If aggregator execution is enabled, we need to tag aggregator_v2 types, - // so they can be exchanged with identifiers during VM execution. - let aggregator_v2_type_tagging = features.is_aggregator_v2_delayed_fields_enabled(); - let mut builder = SafeNativeBuilder::new( gas_feature_version, native_gas_params.clone(), @@ -149,6 +146,7 @@ impl MoveVmExt { features: Features, timed_features: TimedFeatures, resolver: &impl AptosMoveResolver, + aggregator_v2_type_tagging: bool, ) -> VMResult { Self::new_impl::( native_gas_params, @@ -159,6 +157,7 @@ impl MoveVmExt { timed_features, None, resolver, + aggregator_v2_type_tagging, ) } @@ -171,6 +170,7 @@ impl MoveVmExt { timed_features: TimedFeatures, gas_hook: Option, resolver: &impl AptosMoveResolver, + aggregator_v2_type_tagging: bool, ) -> VMResult where F: Fn(DynamicExpression) + Send + Sync + 'static, @@ -184,6 +184,7 @@ impl MoveVmExt { timed_features, gas_hook, resolver, + aggregator_v2_type_tagging, ) } diff --git a/aptos-move/e2e-move-tests/src/harness.rs b/aptos-move/e2e-move-tests/src/harness.rs index b73d84506090a..f356fe93d5f03 100644 --- a/aptos-move/e2e-move-tests/src/harness.rs +++ b/aptos-move/e2e-move-tests/src/harness.rs @@ -828,7 +828,10 @@ impl MoveHarness { } pub fn new_vm(&self) -> AptosVM { - AptosVM::new(&self.executor.data_store().as_move_resolver()) + AptosVM::new( + &self.executor.data_store().as_move_resolver(), + /*override_is_delayed_field_optimization_capable=*/ None, + ) } pub fn set_default_gas_unit_price(&mut self, gas_unit_price: u64) { diff --git a/aptos-move/e2e-tests/src/executor.rs b/aptos-move/e2e-tests/src/executor.rs index 91afdeaac62ac..3457ab7e68141 100644 --- a/aptos-move/e2e-tests/src/executor.rs +++ b/aptos-move/e2e-tests/src/executor.rs @@ -615,7 +615,9 @@ impl FakeExecutor { // TODO(Gas): revisit this. let resolver = self.data_store.as_move_resolver(); - let vm = AptosVM::new(&resolver); + let vm = AptosVM::new( + &resolver, /*override_is_delayed_field_optimization_capable=*/ None, + ); let (_status, output, gas_profiler) = vm.execute_user_transaction_with_custom_gas_meter( &resolver, @@ -689,8 +691,11 @@ impl FakeExecutor { } /// Verifies the given transaction by running it through the VM verifier. - pub fn verify_transaction(&self, txn: SignedTransaction) -> VMValidatorResult { - let vm = AptosVM::new(&self.get_state_view().as_move_resolver()); + pub fn validate_transaction(&self, txn: SignedTransaction) -> VMValidatorResult { + let vm = AptosVM::new( + &self.get_state_view().as_move_resolver(), + /*override_is_delayed_field_optimization_capable=*/ None, + ); vm.validate_transaction(txn, &self.data_store) } @@ -809,6 +814,7 @@ impl FakeExecutor { self.features.clone(), timed_features, &resolver, + false, ) .unwrap(); @@ -886,6 +892,7 @@ impl FakeExecutor { a2.lock().unwrap().push(expression); }), &resolver, + /*aggregator_v2_type_tagging=*/ false, ) .unwrap(); let mut session = vm.new_session(&resolver, SessionId::void()); @@ -959,6 +966,7 @@ impl FakeExecutor { self.features.clone(), timed_features, &resolver, + false, ) .unwrap(); let mut session = vm.new_session(&resolver, SessionId::void()); @@ -1022,6 +1030,7 @@ impl FakeExecutor { features.clone(), timed_features, &resolver, + features.is_aggregator_v2_delayed_fields_enabled(), ) .unwrap(); let mut session = vm.new_session(&resolver, SessionId::void()); @@ -1077,6 +1086,7 @@ impl FakeExecutor { // FIXME: should probably read the timestamp from storage. TimedFeaturesBuilder::enable_all().build(), &resolver, + false, ) .unwrap(); let mut session = vm.new_session(&resolver, SessionId::void()); diff --git a/aptos-move/e2e-testsuite/src/tests/failed_transaction_tests.rs b/aptos-move/e2e-testsuite/src/tests/failed_transaction_tests.rs index 8edcbf60a8a53..11446d98d514b 100644 --- a/aptos-move/e2e-testsuite/src/tests/failed_transaction_tests.rs +++ b/aptos-move/e2e-testsuite/src/tests/failed_transaction_tests.rs @@ -26,7 +26,10 @@ fn failed_transaction_cleanup_test() { executor.add_account_data(&sender); let log_context = AdapterLogSchema::new(executor.get_state_view().id(), 0); - let aptos_vm = AptosVM::new(&executor.get_state_view().as_move_resolver()); + let aptos_vm = AptosVM::new( + &executor.get_state_view().as_move_resolver(), + /*override_is_delayed_field_optimization_capable=*/ None, + ); let data_cache = executor.get_state_view().as_move_resolver(); let txn_data = TransactionMetadata { diff --git a/aptos-move/e2e-testsuite/src/tests/verify_txn.rs b/aptos-move/e2e-testsuite/src/tests/verify_txn.rs index 1d03cf1d53609..2ca7a3dc76788 100644 --- a/aptos-move/e2e-testsuite/src/tests/verify_txn.rs +++ b/aptos-move/e2e-testsuite/src/tests/verify_txn.rs @@ -45,7 +45,7 @@ fn verify_signature() { ); assert_prologue_parity!( - executor.verify_transaction(signed_txn.clone()).status(), + executor.validate_transaction(signed_txn.clone()).status(), executor.execute_transaction(signed_txn).status(), StatusCode::INVALID_SIGNATURE ); @@ -76,7 +76,7 @@ fn verify_multi_agent_invalid_sender_signature() { None, ); assert_prologue_parity!( - executor.verify_transaction(signed_txn.clone()).status(), + executor.validate_transaction(signed_txn.clone()).status(), executor.execute_transaction(signed_txn).status(), StatusCode::INVALID_SIGNATURE ); @@ -106,7 +106,7 @@ fn verify_multi_agent_invalid_secondary_signature() { None, ); assert_prologue_parity!( - executor.verify_transaction(signed_txn.clone()).status(), + executor.validate_transaction(signed_txn.clone()).status(), executor.execute_transaction(signed_txn).status(), StatusCode::INVALID_SIGNATURE ); @@ -148,7 +148,7 @@ fn verify_multi_agent_duplicate_secondary_signer() { None, ); assert_prologue_parity!( - executor.verify_transaction(signed_txn.clone()).status(), + executor.validate_transaction(signed_txn.clone()).status(), executor.execute_transaction(signed_txn).status(), StatusCode::SIGNERS_CONTAIN_DUPLICATES ); @@ -171,7 +171,7 @@ fn verify_reserved_sender() { ); assert_prologue_parity!( - executor.verify_transaction(signed_txn.clone()).status(), + executor.validate_transaction(signed_txn.clone()).status(), executor.execute_transaction(signed_txn).status(), StatusCode::SENDING_ACCOUNT_DOES_NOT_EXIST ); @@ -201,7 +201,7 @@ fn verify_simple_payment() { )) .sequence_number(10) .sign(); - assert_eq!(executor.verify_transaction(txn).status(), None); + assert_eq!(executor.validate_transaction(txn).status(), None); // Create a new transaction that has the bad auth key. let txn = receiver @@ -217,7 +217,7 @@ fn verify_simple_payment() { .into_inner(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::INVALID_AUTH_KEY ); @@ -230,7 +230,7 @@ fn verify_simple_payment() { .sequence_number(1) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::SEQUENCE_NUMBER_TOO_OLD ); @@ -243,7 +243,7 @@ fn verify_simple_payment() { .sequence_number(11) .sign(); assert_prologue_disparity!( - executor.verify_transaction(txn.clone()).status() => None, + executor.validate_transaction(txn.clone()).status() => None, executor.execute_transaction(txn).status() => TransactionStatus::Discard(StatusCode::SEQUENCE_NUMBER_TOO_NEW) ); @@ -258,7 +258,7 @@ fn verify_simple_payment() { .gas_unit_price(1) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::INSUFFICIENT_BALANCE_FOR_TRANSACTION_FEE ); @@ -272,7 +272,7 @@ fn verify_simple_payment() { .sequence_number(10) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::SENDING_ACCOUNT_DOES_NOT_EXIST ); @@ -294,7 +294,7 @@ fn verify_simple_payment() { .max_gas_amount(1_000_000) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::GAS_UNIT_PRICE_ABOVE_MAX_BOUND ); @@ -335,7 +335,7 @@ fn verify_simple_payment() { .gas_unit_price(txn_gas_params.max_price_per_gas_unit.into()) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS ); @@ -349,7 +349,7 @@ fn verify_simple_payment() { .gas_unit_price((txn_gas_params.max_price_per_gas_unit).into()) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::MAX_GAS_UNITS_EXCEEDS_MAX_GAS_UNITS_BOUND ); @@ -367,7 +367,7 @@ fn verify_simple_payment() { .gas_unit_price((txn_gas_params.max_price_per_gas_unit).into()) .sign(); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::EXCEEDED_MAX_TRANSACTION_SIZE ); @@ -414,7 +414,7 @@ pub fn test_arbitrary_script_execution() { .max_gas_amount(100_000) .gas_unit_price(1) .sign(); - assert_eq!(executor.verify_transaction(txn.clone()).status(), None); + assert_eq!(executor.validate_transaction(txn.clone()).status(), None); let status = executor.execute_transaction(txn).status().clone(); assert!(!status.is_discarded()); assert_eq!( @@ -443,7 +443,7 @@ fn verify_expiration_time() { None, /* max_gas_amount */ ); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::TRANSACTION_EXPIRED ); @@ -461,7 +461,7 @@ fn verify_expiration_time() { None, /* max_gas_amount */ ); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::TRANSACTION_EXPIRED ); @@ -482,7 +482,7 @@ fn verify_chain_id() { ChainId::new(ChainId::test().id() + 1), ); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::BAD_CHAIN_ID ); @@ -505,7 +505,7 @@ fn verify_max_sequence_number() { None, /* max_gas_amount */ ); assert_prologue_parity!( - executor.verify_transaction(txn.clone()).status(), + executor.validate_transaction(txn.clone()).status(), executor.execute_transaction(txn).status(), StatusCode::SEQUENCE_NUMBER_TOO_BIG ); @@ -612,7 +612,7 @@ fn test_script_dependency_fails_verification() { .sign(); // As of now, we verify module/script dependencies. This will result in an // invariant violation as we try to load `Test` - assert_eq!(executor.verify_transaction(txn.clone()).status(), None); + assert_eq!(executor.validate_transaction(txn.clone()).status(), None); match executor.execute_transaction(txn).status() { TransactionStatus::Keep(ExecutionStatus::MiscellaneousError(status)) => { assert_eq!(status, &Some(StatusCode::UNEXPECTED_VERIFIER_ERROR)); @@ -664,7 +664,7 @@ fn test_type_tag_dependency_fails_verification() { .sign(); // As of now, we verify module/script dependencies. This will result in an // invariant violation as we try to load `Test` - assert_eq!(executor.verify_transaction(txn.clone()).status(), None); + assert_eq!(executor.validate_transaction(txn.clone()).status(), None); match executor.execute_transaction(txn).status() { TransactionStatus::Keep(ExecutionStatus::MiscellaneousError(status)) => { assert_eq!(status, &Some(StatusCode::UNEXPECTED_VERIFIER_ERROR)); @@ -715,7 +715,7 @@ fn test_script_transitive_dependency_fails_verification() { .sign(); // As of now, we verify module/script dependencies. This will result in an // invariant violation as we try to load `Test` - assert_eq!(executor.verify_transaction(txn.clone()).status(), None); + assert_eq!(executor.validate_transaction(txn.clone()).status(), None); match executor.execute_transaction(txn).status() { TransactionStatus::Keep(ExecutionStatus::MiscellaneousError(status)) => { assert_eq!(status, &Some(StatusCode::UNEXPECTED_VERIFIER_ERROR)); @@ -772,7 +772,7 @@ fn test_type_tag_transitive_dependency_fails_verification() { .sign(); // As of now, we verify module/script dependencies. This will result in an // invariant violation as we try to load `Test` - assert_eq!(executor.verify_transaction(txn.clone()).status(), None); + assert_eq!(executor.validate_transaction(txn.clone()).status(), None); match executor.execute_transaction(txn).status() { TransactionStatus::Keep(ExecutionStatus::MiscellaneousError(status)) => { assert_eq!(status, &Some(StatusCode::UNEXPECTED_VERIFIER_ERROR)); diff --git a/aptos-move/vm-genesis/src/lib.rs b/aptos-move/vm-genesis/src/lib.rs index 39622dfd4e415..a8661920af65d 100644 --- a/aptos-move/vm-genesis/src/lib.rs +++ b/aptos-move/vm-genesis/src/lib.rs @@ -119,6 +119,7 @@ pub fn encode_aptos_mainnet_genesis_transaction( Features::default(), TimedFeaturesBuilder::enable_all().build(), &data_cache, + false, ) .unwrap(); let id1 = HashValue::zero(); @@ -230,6 +231,7 @@ pub fn encode_genesis_change_set( Features::default(), TimedFeaturesBuilder::enable_all().build(), &data_cache, + false, ) .unwrap(); let id1 = HashValue::zero(); @@ -976,6 +978,7 @@ pub fn test_genesis_module_publishing() { Features::default(), TimedFeaturesBuilder::enable_all().build(), &data_cache, + false, ) .unwrap(); let id1 = HashValue::zero(); diff --git a/aptos-move/writeset-transaction-generator/src/writeset_builder.rs b/aptos-move/writeset-transaction-generator/src/writeset_builder.rs index 98363671c95ac..c9923c513d0c3 100644 --- a/aptos-move/writeset-transaction-generator/src/writeset_builder.rs +++ b/aptos-move/writeset-transaction-generator/src/writeset_builder.rs @@ -118,6 +118,7 @@ where Features::default(), TimedFeaturesBuilder::enable_all().build(), &resolver, + false, ) .unwrap(); let change_set = { diff --git a/experimental/execution/ptx-executor/src/runner.rs b/experimental/execution/ptx-executor/src/runner.rs index e16417dff4c51..ee3fc58d4b9b6 100644 --- a/experimental/execution/ptx-executor/src/runner.rs +++ b/experimental/execution/ptx-executor/src/runner.rs @@ -235,7 +235,10 @@ impl<'scope, 'view: 'scope, BaseView: StateView + Sync> Worker<'view, BaseView> // TODO(ptx): maybe warm up vm like done in AptosExecutorTask let vm = { let _timer = PER_WORKER_TIMER.timer_with(&[&idx, "vm_init"]); - AptosVM::new(&self.base_view.as_move_resolver()) + AptosVM::new( + &self.base_view.as_move_resolver(), + /*override_is_delayed_field_optimization_capable=*/ None, + ) }; loop { diff --git a/vm-validator/src/vm_validator.rs b/vm-validator/src/vm_validator.rs index 98d3a6dab555e..cd42ba223f07a 100644 --- a/vm-validator/src/vm_validator.rs +++ b/vm-validator/src/vm_validator.rs @@ -55,7 +55,10 @@ impl VMValidator { AdapterLogSchema::new(state_view.id(), 0), "AptosVM created for Validation" ); - AptosVM::new(&state_view.as_move_resolver()) + AptosVM::new( + &state_view.as_move_resolver(), + /*override_is_delayed_field_optimization_capable=*/ None, + ) } pub fn new(db_reader: Arc) -> Self {