From 893886c155a8e37323361efd962c288ac833aeb8 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 3 May 2022 21:36:56 -0700 Subject: [PATCH] [parallel] remove legacy configs Closes: #794 --- aptos-move/e2e-tests/src/executor.rs | 12 ---- aptos-move/vm-genesis/src/lib.rs | 33 +---------- .../src/admin_script_builder.rs | 53 ----------------- .../writeset-transaction-generator/src/lib.rs | 4 +- config/management/genesis/src/builder.rs | 2 - types/src/on_chain_config/mod.rs | 2 - .../parallel_execution_config.rs | 59 ------------------- 7 files changed, 3 insertions(+), 162 deletions(-) delete mode 100644 types/src/on_chain_config/parallel_execution_config.rs diff --git a/aptos-move/e2e-tests/src/executor.rs b/aptos-move/e2e-tests/src/executor.rs index b1e284065aa5f..c2f2af1bd9ce4 100644 --- a/aptos-move/e2e-tests/src/executor.rs +++ b/aptos-move/e2e-tests/src/executor.rs @@ -200,22 +200,10 @@ impl FakeExecutor { genesis_modules, publishing_options, validator_accounts, - false, ); Self::from_genesis(genesis.0.write_set()) } - pub fn parallel_genesis() -> Self { - let genesis = vm_genesis::generate_test_genesis( - cached_framework_packages::module_blobs(), - VMPublishingOption::open(), - None, - true, - ) - .0; - FakeExecutor::from_genesis(genesis.write_set()) - } - /// Create one instance of [`AccountData`] without saving it to data store. pub fn create_raw_account(&mut self) -> Account { Account::new_from_seed(&mut self.rng) diff --git a/aptos-move/vm-genesis/src/lib.rs b/aptos-move/vm-genesis/src/lib.rs index 4e525a8a020cd..86df70b893dfb 100644 --- a/aptos-move/vm-genesis/src/lib.rs +++ b/aptos-move/vm-genesis/src/lib.rs @@ -15,8 +15,7 @@ use aptos_types::{ chain_id::ChainId, contract_event::ContractEvent, on_chain_config::{ - ConsensusConfigV1, OnChainConsensusConfig, ReadWriteSetAnalysis, VMPublishingOption, - APTOS_MAX_KNOWN_VERSION, + ConsensusConfigV1, OnChainConsensusConfig, VMPublishingOption, APTOS_MAX_KNOWN_VERSION, }, transaction::{authenticator::AuthenticationKey, ChangeSet, Transaction, WriteSetPayload}, }; @@ -57,7 +56,6 @@ pub fn encode_genesis_transaction( vm_publishing_option: Option, consensus_config: OnChainConsensusConfig, chain_id: ChainId, - enable_parallel_execution: bool, min_price_per_gas_unit: u64, ) -> Transaction { Transaction::GenesisTransaction(WriteSetPayload::Direct(encode_genesis_change_set( @@ -67,7 +65,6 @@ pub fn encode_genesis_transaction( vm_publishing_option.unwrap_or_else(VMPublishingOption::open), consensus_config, chain_id, - enable_parallel_execution, min_price_per_gas_unit, ))) } @@ -79,7 +76,6 @@ pub fn encode_genesis_change_set( vm_publishing_option: VMPublishingOption, consensus_config: OnChainConsensusConfig, chain_id: ChainId, - enable_parallel_execution: bool, min_price_per_gas_unit: u64, ) -> ChangeSet { let mut stdlib_modules = Vec::new(); @@ -108,28 +104,6 @@ pub fn encode_genesis_change_set( create_and_initialize_validators(&mut session, validators); reconfigure(&mut session); - if enable_parallel_execution { - let payload = bcs::to_bytes(&ReadWriteSetAnalysis::V1( - read_write_set::analyze(&stdlib_modules) - .expect("Failed to get ReadWriteSet for current Aptos Framework") - .normalize_all_scripts(aptos_vm::read_write_set_analysis::add_on_functions_list()) - .trim() - .into_inner(), - )) - .expect("Failed to serialize analyze result"); - - exec_function( - &mut session, - "ParallelExecutionConfig", - "enable_parallel_execution_with_config", - vec![], - serialize_values(&vec![ - MoveValue::Signer(account_config::aptos_root_address()), - MoveValue::vector_u8(payload), - ]), - ) - } - let (mut changeset1, mut events1, _) = session.finish().unwrap().unpack(); let state_view = GenesisStateView::new(); @@ -350,7 +324,7 @@ pub fn generate_genesis_change_set_for_testing(genesis_options: GenesisOptions) GenesisOptions::Fresh => framework::aptos::module_blobs(), }; - generate_test_genesis(&modules, VMPublishingOption::open(), None, false).0 + generate_test_genesis(&modules, VMPublishingOption::open(), None).0 } pub fn test_genesis_transaction() -> Transaction { @@ -365,7 +339,6 @@ pub fn test_genesis_change_set_and_validators( cached_framework_packages::module_blobs(), VMPublishingOption::open(), count, - false, ) } @@ -436,7 +409,6 @@ pub fn generate_test_genesis( stdlib_modules: &[Vec], vm_publishing_option: VMPublishingOption, count: Option, - enable_parallel_execution: bool, ) -> (ChangeSet, Vec) { let test_validators = TestValidator::new_test_set(count); let validators_: Vec = test_validators.iter().map(|t| t.data.clone()).collect(); @@ -449,7 +421,6 @@ pub fn generate_test_genesis( vm_publishing_option, OnChainConsensusConfig::V1(ConsensusConfigV1 { two_chain: true }), ChainId::test(), - enable_parallel_execution, 0, ); (genesis, test_validators) diff --git a/aptos-move/writeset-transaction-generator/src/admin_script_builder.rs b/aptos-move/writeset-transaction-generator/src/admin_script_builder.rs index defa4e8fb6713..a423aa5a3ec75 100644 --- a/aptos-move/writeset-transaction-generator/src/admin_script_builder.rs +++ b/aptos-move/writeset-transaction-generator/src/admin_script_builder.rs @@ -5,13 +5,10 @@ use anyhow::Result; use aptos_types::{ account_address::AccountAddress, account_config::aptos_root_address, - on_chain_config::ReadWriteSetAnalysis, transaction::{Script, WriteSetPayload}, }; use handlebars::Handlebars; use move_compiler::{compiled_unit::AnnotatedCompiledUnit, Compiler, Flags}; -use move_core_types::transaction_argument::TransactionArgument; -use read_write_set::analyze; use serde::Serialize; use std::{collections::HashMap, io::Write, path::PathBuf}; use tempfile::NamedTempFile; @@ -107,53 +104,3 @@ pub fn encode_halt_network_payload() -> WriteSetPayload { execute_as: aptos_root_address(), } } - -pub fn encode_initialize_parallel_execution() -> WriteSetPayload { - let mut script = template_path(); - script.push("initialize_parallel_execution.move"); - - WriteSetPayload::Script { - script: Script::new( - compile_script(script.to_str().unwrap().to_owned()), - vec![], - vec![], - ), - execute_as: aptos_root_address(), - } -} - -pub fn encode_disable_parallel_execution() -> WriteSetPayload { - let mut script = template_path(); - script.push("disable_parallel_execution.move"); - - WriteSetPayload::Script { - script: Script::new( - compile_script(script.to_str().unwrap().to_owned()), - vec![], - vec![], - ), - execute_as: aptos_root_address(), - } -} - -pub fn encode_enable_parallel_execution_with_config() -> WriteSetPayload { - let payload = bcs::to_bytes(&ReadWriteSetAnalysis::V1( - analyze(cached_framework_packages::modules()) - .expect("Failed to get ReadWriteSet for current Framework") - .normalize_all_scripts(aptos_vm::read_write_set_analysis::add_on_functions_list()) - .trim() - .into_inner(), - )) - .expect("Failed to serialize analyze result"); - - let mut script = template_path(); - script.push("update_parallel_execution_config.move"); - WriteSetPayload::Script { - script: Script::new( - compile_script(script.to_str().unwrap().to_owned()), - vec![], - vec![TransactionArgument::U8Vector(payload)], - ), - execute_as: aptos_root_address(), - } -} diff --git a/aptos-move/writeset-transaction-generator/src/lib.rs b/aptos-move/writeset-transaction-generator/src/lib.rs index febdf3ab08906..96068be9e4464 100644 --- a/aptos-move/writeset-transaction-generator/src/lib.rs +++ b/aptos-move/writeset-transaction-generator/src/lib.rs @@ -6,9 +6,7 @@ mod admin_script_builder; mod writeset_builder; pub use admin_script_builder::{ - encode_custom_script, encode_disable_parallel_execution, - encode_enable_parallel_execution_with_config, encode_halt_network_payload, - encode_initialize_parallel_execution, encode_remove_validators_payload, + encode_custom_script, encode_halt_network_payload, encode_remove_validators_payload, }; pub use writeset_builder::{build_changeset, GenesisSession}; diff --git a/config/management/genesis/src/builder.rs b/config/management/genesis/src/builder.rs index d80b21600badd..263b0814a110a 100644 --- a/config/management/genesis/src/builder.rs +++ b/config/management/genesis/src/builder.rs @@ -224,8 +224,6 @@ impl GenesisBuilder { publishing_option, consensus_config, chain_id, - // TODO: Make this flag configurable via cli command. - false, min_price_per_gas_unit, ); diff --git a/types/src/on_chain_config/mod.rs b/types/src/on_chain_config/mod.rs index 88f5919e1d7aa..c2f2d8e6f800c 100644 --- a/types/src/on_chain_config/mod.rs +++ b/types/src/on_chain_config/mod.rs @@ -19,7 +19,6 @@ use std::{collections::HashMap, fmt, sync::Arc}; mod aptos_version; mod consensus_config; -mod parallel_execution_config; mod registered_currencies; mod validator_set; mod vm_config; @@ -30,7 +29,6 @@ pub use self::{ Version, APTOS_MAX_KNOWN_VERSION, APTOS_VERSION_2, APTOS_VERSION_3, APTOS_VERSION_4, }, consensus_config::{ConsensusConfigV1, ConsensusConfigV2, OnChainConsensusConfig}, - parallel_execution_config::{ParallelExecutionConfig, ReadWriteSetAnalysis}, registered_currencies::RegisteredCurrencies, validator_set::ValidatorSet, vm_config::VMConfig, diff --git a/types/src/on_chain_config/parallel_execution_config.rs b/types/src/on_chain_config/parallel_execution_config.rs deleted file mode 100644 index 58e9418e61cad..0000000000000 --- a/types/src/on_chain_config/parallel_execution_config.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Aptos -// SPDX-License-Identifier: Apache-2.0 - -use crate::on_chain_config::OnChainConfig; -use anyhow::{format_err, Result}; -use move_core_types::{identifier::Identifier, language_storage::ModuleId}; -use move_read_write_set_types::ReadWriteSet; -use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; - -/// Defines the operation status of parallel execution. If this `read_write_analysis_result` is not -/// None VM will execute transactions in parallel. -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub struct ParallelExecutionConfig { - pub read_write_analysis_result: Option, -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -struct ParallelExecutionConfigInner { - pub read_write_analysis_result: Option>, -} - -impl ParallelExecutionConfigInner { - fn as_analysis_result(&self) -> Result { - Ok(ParallelExecutionConfig { - read_write_analysis_result: match &self.read_write_analysis_result { - Some(bytes) => Some(bcs::from_bytes(bytes)?), - None => None, - }, - }) - } -} - -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -pub enum ReadWriteSetAnalysis { - V1(BTreeMap>), -} - -impl ReadWriteSetAnalysis { - pub fn into_inner(self) -> BTreeMap> { - match self { - Self::V1(inner) => inner, - } - } -} - -impl OnChainConfig for ParallelExecutionConfig { - const IDENTIFIER: &'static str = "ParallelExecutionConfig"; - - fn deserialize_into_config(bytes: &[u8]) -> Result { - let raw_config = bcs::from_bytes::(bytes).map_err(|e| { - format_err!( - "Failed first round of deserialization for VMConfigInner: {}", - e - ) - })?; - raw_config.as_analysis_result() - } -}