Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cherry-pick] Fix epoch flag logic for state accum v2 (#18448) #18449

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/sui-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,9 +916,12 @@ impl AuthorityPerEpochStore {
}

pub fn state_accumulator_v2_enabled(&self) -> bool {
self.epoch_start_configuration
.flags()
.contains(&EpochFlag::StateAccumulatorV2Enabled)
let flag = match self.get_chain_identifier().chain() {
Chain::Unknown | Chain::Testnet => EpochFlag::StateAccumulatorV2EnabledTestnet,
Chain::Mainnet => EpochFlag::StateAccumulatorV2EnabledMainnet,
};

self.epoch_start_configuration.flags().contains(&flag)
}

/// Returns `&Arc<EpochStartConfiguration>`
Expand Down
22 changes: 19 additions & 3 deletions crates/sui-core/src/authority/epoch_start_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ pub enum EpochFlag {
_ObjectLockSplitTablesDeprecated,

WritebackCacheEnabled,
StateAccumulatorV2Enabled,

// 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
_StateAccumulatorV2EnabledDeprecated,

StateAccumulatorV2EnabledTestnet,
StateAccumulatorV2EnabledMainnet,
}

impl EpochFlag {
Expand All @@ -78,7 +84,9 @@ impl EpochFlag {
}

if enable_state_accumulator_v2 {
new_flags.push(EpochFlag::StateAccumulatorV2Enabled);
new_flags.push(EpochFlag::StateAccumulatorV2EnabledTestnet);
// TODO: enable on mainnet
// new_flags.push(EpochFlag::StateAccumulatorV2EnabledMainnet);
}

new_flags
Expand All @@ -99,7 +107,15 @@ impl fmt::Display for EpochFlag {
write!(f, "ObjectLockSplitTables (DEPRECATED)")
}
EpochFlag::WritebackCacheEnabled => write!(f, "WritebackCacheEnabled"),
EpochFlag::StateAccumulatorV2Enabled => write!(f, "StateAccumulatorV2Enabled"),
EpochFlag::_StateAccumulatorV2EnabledDeprecated => {
write!(f, "StateAccumulatorV2EnabledDeprecated (DEPRECATED)")
}
EpochFlag::StateAccumulatorV2EnabledTestnet => {
write!(f, "StateAccumulatorV2EnabledTestnet")
}
EpochFlag::StateAccumulatorV2EnabledMainnet => {
write!(f, "StateAccumulatorV2EnabledMainnet")
}
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions crates/sui-core/src/state_accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use itertools::Itertools;
use mysten_metrics::monitored_scope;
use prometheus::{register_int_gauge_with_registry, IntGauge, Registry};
use serde::Serialize;
use sui_protocol_config::{Chain, ProtocolConfig};
use sui_protocol_config::ProtocolConfig;
use sui_types::base_types::{ObjectID, ObjectRef, SequenceNumber, VersionNumber};
use sui_types::committee::EpochId;
use sui_types::digests::{ObjectDigest, TransactionDigest};
Expand Down Expand Up @@ -389,9 +389,7 @@ impl StateAccumulator {
epoch_store: &Arc<AuthorityPerEpochStore>,
metrics: Arc<StateAccumulatorMetrics>,
) -> Self {
if epoch_store.state_accumulator_v2_enabled()
&& epoch_store.get_chain_identifier().chain() != Chain::Mainnet
{
if epoch_store.state_accumulator_v2_enabled() {
StateAccumulator::V2(StateAccumulatorV2::new(store, metrics))
} else {
StateAccumulator::V1(StateAccumulatorV1::new(store, metrics))
Expand Down
Loading