diff --git a/aptos-move/vm-genesis/src/lib.rs b/aptos-move/vm-genesis/src/lib.rs index 05b6b69560cbd..af0142a32d522 100644 --- a/aptos-move/vm-genesis/src/lib.rs +++ b/aptos-move/vm-genesis/src/lib.rs @@ -118,7 +118,7 @@ pub fn encode_aptos_mainnet_genesis_transaction( // On-chain genesis process. let consensus_config = OnChainConsensusConfig::default(); - let execution_config = OnChainExecutionConfig::default(); + let execution_config = OnChainExecutionConfig::default_for_genesis(); let gas_schedule = default_gas_schedule(); initialize( &mut session, @@ -794,7 +794,7 @@ pub fn generate_test_genesis( employee_vesting_period_duration: 5 * 60, // 5 minutes }, &OnChainConsensusConfig::default(), - &OnChainExecutionConfig::default(), + &OnChainExecutionConfig::default_for_genesis(), &default_gas_schedule(), ); (genesis, test_validators) @@ -816,7 +816,7 @@ pub fn generate_mainnet_genesis( ChainId::test(), &mainnet_genesis_config(), &OnChainConsensusConfig::default(), - &OnChainExecutionConfig::default(), + &OnChainExecutionConfig::default_for_genesis(), &default_gas_schedule(), ); (genesis, test_validators) diff --git a/consensus/src/epoch_manager.rs b/consensus/src/epoch_manager.rs index 881bcd2469bf8..80a23281cbf62 100644 --- a/consensus/src/epoch_manager.rs +++ b/consensus/src/epoch_manager.rs @@ -816,7 +816,8 @@ impl EpochManager { match self.storage.start() { LivenessStorageData::FullRecoveryData(initial_data) => { let consensus_config = onchain_consensus_config.unwrap_or_default(); - let execution_config = onchain_execution_config.unwrap_or_default(); + let execution_config = onchain_execution_config + .unwrap_or_else(|_| OnChainExecutionConfig::default_if_missing()); self.quorum_store_enabled = self.enable_quorum_store(&consensus_config); self.recovery_mode = false; self.start_round_manager( diff --git a/crates/aptos-genesis/src/builder.rs b/crates/aptos-genesis/src/builder.rs index 8650a46d0183b..0ac082ed291f3 100644 --- a/crates/aptos-genesis/src/builder.rs +++ b/crates/aptos-genesis/src/builder.rs @@ -27,10 +27,7 @@ use aptos_keygen::KeyGen; use aptos_logger::prelude::*; use aptos_types::{ chain_id::ChainId, - on_chain_config::{ - ExecutionConfigV1, GasScheduleV2, OnChainConsensusConfig, OnChainExecutionConfig, - TransactionShufflerType, - }, + on_chain_config::{GasScheduleV2, OnChainConsensusConfig, OnChainExecutionConfig}, transaction::Transaction, waypoint::Waypoint, }; @@ -613,10 +610,7 @@ impl Builder { employee_vesting_start: None, employee_vesting_period_duration: None, consensus_config: OnChainConsensusConfig::default(), - // Enable transaction shuffling by default in integration tests and Forge. - execution_config: OnChainExecutionConfig::V1(ExecutionConfigV1 { - transaction_shuffler_type: TransactionShufflerType::SenderAwareV2(32), - }), + execution_config: OnChainExecutionConfig::default_for_genesis(), gas_schedule: default_gas_schedule(), }; if let Some(init_genesis_config) = &self.init_genesis_config { diff --git a/crates/aptos/src/genesis/mod.rs b/crates/aptos/src/genesis/mod.rs index a16204c460f35..5b8ff77a4e4f2 100644 --- a/crates/aptos/src/genesis/mod.rs +++ b/crates/aptos/src/genesis/mod.rs @@ -34,9 +34,7 @@ use aptos_genesis::{ use aptos_logger::info; use aptos_types::{ account_address::{AccountAddress, AccountAddressWithChecks}, - on_chain_config::{ - ExecutionConfigV1, OnChainConsensusConfig, OnChainExecutionConfig, TransactionShufflerType, - }, + on_chain_config::{OnChainConsensusConfig, OnChainExecutionConfig}, }; use aptos_vm_genesis::{default_gas_schedule, AccountBalance, EmployeePool}; use async_trait::async_trait; @@ -257,7 +255,7 @@ pub fn fetch_mainnet_genesis_info(git_options: GitOptions) -> CliTypedResult CliTypedResult TransactionShufflerType { match &self { + OnChainExecutionConfig::Missing => TransactionShufflerType::NoShuffling, OnChainExecutionConfig::V1(config) => config.transaction_shuffler_type.clone(), OnChainExecutionConfig::V2(config) => config.transaction_shuffler_type.clone(), OnChainExecutionConfig::V3(config) => config.transaction_shuffler_type.clone(), @@ -27,6 +32,7 @@ impl OnChainExecutionConfig { /// The per-block gas limit being used. pub fn block_gas_limit(&self) -> Option { match &self { + OnChainExecutionConfig::Missing => None, OnChainExecutionConfig::V1(_config) => None, OnChainExecutionConfig::V2(config) => config.block_gas_limit, OnChainExecutionConfig::V3(config) => config.block_gas_limit, @@ -36,17 +42,28 @@ impl OnChainExecutionConfig { /// The type of the transaction deduper being used. pub fn transaction_deduper_type(&self) -> TransactionDeduperType { match &self { + // Note, this behavior was enabled before OnChainExecutionConfig was registered. + OnChainExecutionConfig::Missing => TransactionDeduperType::TxnHashAndAuthenticatorV1, OnChainExecutionConfig::V1(_config) => TransactionDeduperType::NoDedup, OnChainExecutionConfig::V2(_config) => TransactionDeduperType::NoDedup, OnChainExecutionConfig::V3(config) => config.transaction_deduper_type.clone(), } } -} -/// This is used when on-chain config is not initialized. -impl Default for OnChainExecutionConfig { - fn default() -> Self { - OnChainExecutionConfig::V3(ExecutionConfigV3::default()) + /// The default values to use for new networks, e.g., devnet, forge. + /// Features that are ready for deployment can be enabled here. + pub fn default_for_genesis() -> Self { + OnChainExecutionConfig::V3(ExecutionConfigV3 { + transaction_shuffler_type: TransactionShufflerType::SenderAwareV2(32), + block_gas_limit: Some(35000), + transaction_deduper_type: TransactionDeduperType::TxnHashAndAuthenticatorV1, + }) + } + + /// The default values to use when on-chain config is not initialized. + /// This value should not be changed, for replay purposes. + pub fn default_if_missing() -> Self { + OnChainExecutionConfig::Missing } } @@ -73,29 +90,12 @@ pub struct ExecutionConfigV1 { pub transaction_shuffler_type: TransactionShufflerType, } -impl Default for ExecutionConfigV1 { - fn default() -> Self { - Self { - transaction_shuffler_type: TransactionShufflerType::NoShuffling, - } - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] pub struct ExecutionConfigV2 { pub transaction_shuffler_type: TransactionShufflerType, pub block_gas_limit: Option, } -impl Default for ExecutionConfigV2 { - fn default() -> Self { - Self { - transaction_shuffler_type: TransactionShufflerType::NoShuffling, - block_gas_limit: None, - } - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] pub struct ExecutionConfigV3 { pub transaction_shuffler_type: TransactionShufflerType, @@ -103,16 +103,6 @@ pub struct ExecutionConfigV3 { pub transaction_deduper_type: TransactionDeduperType, } -impl Default for ExecutionConfigV3 { - fn default() -> Self { - Self { - transaction_shuffler_type: TransactionShufflerType::NoShuffling, - block_gas_limit: None, - transaction_deduper_type: TransactionDeduperType::TxnHashAndAuthenticatorV1, - } - } -} - #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] #[serde(rename_all = "snake_case")] // cannot use tag = "type" as nested enums cannot work, and bcs doesn't support it pub enum TransactionShufflerType { @@ -137,7 +127,7 @@ mod test { #[test] fn test_config_yaml_serialization() { - let config = OnChainExecutionConfig::default(); + let config = OnChainExecutionConfig::default_for_genesis(); let s = serde_yaml::to_string(&config).unwrap(); serde_yaml::from_str::(&s).unwrap(); @@ -145,7 +135,7 @@ mod test { #[test] fn test_config_bcs_serialization() { - let config = OnChainExecutionConfig::default(); + let config = OnChainExecutionConfig::default_for_genesis(); let s = bcs::to_bytes(&config).unwrap(); bcs::from_bytes::(&s).unwrap();