Skip to content

Commit

Permalink
Create new epoch flags for state accum v2, since the old one was alre…
Browse files Browse the repository at this point in the history
…ady written in some places. Also fix chain-specific logic
  • Loading branch information
mystenmark committed Jun 28, 2024
1 parent 9603482 commit 61e4ece
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
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 @@ -925,9 +925,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)
}

pub fn executed_in_epoch_table_enabled(&self) -> bool {
Expand Down
9 changes: 6 additions & 3 deletions crates/sui-core/src/authority/epoch_start_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ pub enum EpochFlag {
_StateAccumulatorV2EnabledDeprecated,

ExecutedInEpochTable,
StateAccumulatorV2Enabled,
StateAccumulatorV2EnabledTestnet,
StateAccumulatorV2EnabledMainnet,
}

impl EpochFlag {
Expand All @@ -84,7 +85,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 @@ -109,7 +112,7 @@ impl fmt::Display for EpochFlag {
write!(f, "StateAccumulatorV2EnabledDeprecated (DEPRECATED)")
}
EpochFlag::ExecutedInEpochTable => write!(f, "ExecutedInEpochTable"),
EpochFlag::StateAccumulatorV2Enabled => write!(f, "StateAccumulatorV2Enabled"),
EpochFlag::StateAccumulatorV2EnabledTestnet => write!(f, "StateAccumulatorV2Enabled"),
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions crates/sui-core/src/state_accumulator.rs
Original file line number Diff line number Diff line change
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

0 comments on commit 61e4ece

Please sign in to comment.