diff --git a/crates/sui-core/src/authority/epoch_start_configuration.rs b/crates/sui-core/src/authority/epoch_start_configuration.rs index f2e4512cdc8fd..0c6271429b11c 100644 --- a/crates/sui-core/src/authority/epoch_start_configuration.rs +++ b/crates/sui-core/src/authority/epoch_start_configuration.rs @@ -3,7 +3,7 @@ use enum_dispatch::enum_dispatch; use serde::{Deserialize, Serialize}; -use sui_config::{ExecutionCacheConfig, NodeConfig}; +use sui_config::NodeConfig; use std::fmt; use sui_types::authenticator_state::get_authenticator_state_obj_initial_shared_version; @@ -19,8 +19,6 @@ use sui_types::sui_system_state::epoch_start_sui_system_state::{ EpochStartSystemState, EpochStartSystemStateTrait, }; -use crate::execution_cache::{choose_execution_cache, ExecutionCacheConfigType}; - #[enum_dispatch] pub trait EpochStartConfigTrait { fn epoch_digest(&self) -> CheckpointDigest; @@ -32,14 +30,6 @@ pub trait EpochStartConfigTrait { fn bridge_obj_initial_shared_version(&self) -> Option; fn bridge_committee_initiated(&self) -> bool; - fn execution_cache_type(&self) -> ExecutionCacheConfigType { - if self.flags().contains(&EpochFlag::WritebackCacheEnabled) { - ExecutionCacheConfigType::WritebackCache - } else { - ExecutionCacheConfigType::PassthroughCache - } - } - fn use_version_assignment_tables_v3(&self) -> bool { self.flags() .contains(&EpochFlag::UseVersionAssignmentTablesV3) @@ -57,46 +47,34 @@ pub trait EpochStartConfigTrait { #[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)] pub enum EpochFlag { // The deprecated flags have all been in production for long enough that - // we can have deleted the old code paths they were guarding. + // we have deleted the old code paths they were guarding. // We retain them here in order not to break deserialization. _InMemoryCheckpointRootsDeprecated = 0, _PerEpochFinalizedTransactionsDeprecated = 1, _ObjectLockSplitTablesDeprecated = 2, - - WritebackCacheEnabled = 3, - - // This flag was "burned" because it was deployed with a broken version of the code. The - // new flags below are required to enable state accumulator v2 + _WritebackCacheEnabledDeprecated = 3, _StateAccumulatorV2EnabledDeprecated = 4, _StateAccumulatorV2EnabledTestnetDeprecated = 5, _StateAccumulatorV2EnabledMainnetDeprecated = 6, - _ExecutedInEpochTableDeprecated = 7, UseVersionAssignmentTablesV3 = 8, } impl EpochFlag { - pub fn default_flags_for_new_epoch(config: &NodeConfig) -> Vec { - Self::default_flags_impl(&config.execution_cache) + pub fn default_flags_for_new_epoch(_config: &NodeConfig) -> Vec { + // NodeConfig arg is not currently used, but we keep it here for future + // flags that might depend on the config. + Self::default_flags_impl() } /// For situations in which there is no config available (e.g. setting up a downloaded snapshot). pub fn default_for_no_config() -> Vec { - Self::default_flags_impl(&Default::default()) + Self::default_flags_impl() } - fn default_flags_impl(cache_config: &ExecutionCacheConfig) -> Vec { - let mut new_flags = vec![EpochFlag::UseVersionAssignmentTablesV3]; - - if matches!( - choose_execution_cache(cache_config), - ExecutionCacheConfigType::WritebackCache - ) { - new_flags.push(EpochFlag::WritebackCacheEnabled); - } - - new_flags + fn default_flags_impl() -> Vec { + vec![EpochFlag::UseVersionAssignmentTablesV3] } } @@ -113,7 +91,9 @@ impl fmt::Display for EpochFlag { EpochFlag::_ObjectLockSplitTablesDeprecated => { write!(f, "ObjectLockSplitTables (DEPRECATED)") } - EpochFlag::WritebackCacheEnabled => write!(f, "WritebackCacheEnabled"), + EpochFlag::_WritebackCacheEnabledDeprecated => { + write!(f, "WritebackCacheEnabled (DEPRECATED)") + } EpochFlag::_StateAccumulatorV2EnabledDeprecated => { write!(f, "StateAccumulatorV2EnabledDeprecated (DEPRECATED)") } diff --git a/crates/sui-core/src/authority/test_authority_builder.rs b/crates/sui-core/src/authority/test_authority_builder.rs index 256ef7b4980de..7d704dcdcaa6c 100644 --- a/crates/sui-core/src/authority/test_authority_builder.rs +++ b/crates/sui-core/src/authority/test_authority_builder.rs @@ -236,7 +236,6 @@ impl<'a> TestAuthorityBuilder<'a> { let cache_traits = build_execution_cache( &Default::default(), - &epoch_start_configuration, ®istry, &authority_store, backpressure_manager.clone(), diff --git a/crates/sui-core/src/execution_cache.rs b/crates/sui-core/src/execution_cache.rs index 0a66cbfc34dc4..561aa8720fc2d 100644 --- a/crates/sui-core/src/execution_cache.rs +++ b/crates/sui-core/src/execution_cache.rs @@ -4,8 +4,8 @@ use crate::authority::authority_per_epoch_store::AuthorityPerEpochStore; use crate::authority::authority_store::{ExecutionLockWriteGuard, SuiLockResult}; use crate::authority::backpressure::BackpressureManager; +use crate::authority::epoch_start_configuration::EpochFlag; use crate::authority::epoch_start_configuration::EpochStartConfiguration; -use crate::authority::epoch_start_configuration::{EpochFlag, EpochStartConfigTrait}; use crate::authority::AuthorityStore; use crate::state_accumulator::AccumulatorStore; use crate::transaction_outputs::TransactionOutputs; @@ -36,7 +36,7 @@ use sui_types::{ object::Owner, storage::InputKey, }; -use tracing::{error, instrument}; +use tracing::instrument; pub(crate) mod cache_types; pub mod metrics; @@ -101,68 +101,23 @@ impl ExecutionCacheTraitPointers { } } -static DISABLE_WRITEBACK_CACHE_ENV_VAR: &str = "DISABLE_WRITEBACK_CACHE"; - -#[derive(Debug)] -pub enum ExecutionCacheConfigType { - WritebackCache, - PassthroughCache, -} - -pub fn choose_execution_cache(_: &ExecutionCacheConfig) -> ExecutionCacheConfigType { - if std::env::var(DISABLE_WRITEBACK_CACHE_ENV_VAR).is_ok() { - error!("DISABLE_WRITEBACK_CACHE is no longer respected. WritebackCache is the default."); - } - - ExecutionCacheConfigType::WritebackCache -} - pub fn build_execution_cache( cache_config: &ExecutionCacheConfig, - epoch_start_config: &EpochStartConfiguration, prometheus_registry: &Registry, store: &Arc, backpressure_manager: Arc, ) -> ExecutionCacheTraitPointers { let execution_cache_metrics = Arc::new(ExecutionCacheMetrics::new(prometheus_registry)); - match epoch_start_config.execution_cache_type() { - ExecutionCacheConfigType::WritebackCache => ExecutionCacheTraitPointers::new( - WritebackCache::new( - cache_config, - store.clone(), - execution_cache_metrics, - backpressure_manager, - ) - .into(), - ), - ExecutionCacheConfigType::PassthroughCache => { - fatal!("PassthroughCache is no longer supported") - } - } -} - -/// Should only be used for sui-tool or tests. Nodes must use build_execution_cache which -/// uses the epoch_start_config to prevent cache impl from switching except at epoch boundaries. -pub fn build_execution_cache_from_env( - prometheus_registry: &Registry, - store: &Arc, -) -> ExecutionCacheTraitPointers { - let execution_cache_metrics = Arc::new(ExecutionCacheMetrics::new(prometheus_registry)); - - if std::env::var(DISABLE_WRITEBACK_CACHE_ENV_VAR).is_ok() { - fatal!("PassthroughCache is no longer supported"); - } else { - ExecutionCacheTraitPointers::new( - WritebackCache::new( - &Default::default(), - store.clone(), - execution_cache_metrics, - BackpressureManager::new_for_tests(), - ) - .into(), + ExecutionCacheTraitPointers::new( + WritebackCache::new( + cache_config, + store.clone(), + execution_cache_metrics, + backpressure_manager, ) - } + .into(), + ) } pub trait ExecutionCacheCommit: Send + Sync { diff --git a/crates/sui-node/src/lib.rs b/crates/sui-node/src/lib.rs index a650c51b2dc2e..ef50376d4a3ab 100644 --- a/crates/sui-node/src/lib.rs +++ b/crates/sui-node/src/lib.rs @@ -495,7 +495,6 @@ impl SuiNode { let cache_traits = build_execution_cache( &config.execution_cache, - &epoch_start_configuration, &prometheus_registry, &store, backpressure_manager.clone(),