Skip to content
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
26 changes: 1 addition & 25 deletions crates/iota-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,25 +1471,6 @@ impl AuthorityState {

let output_keys = inner_temporary_store.get_output_keys(effects);

// Only need to sign effects if we are a validator, and if the
// executed_in_epoch_table is not yet enabled. TODO: once
// executed_in_epoch_table is enabled everywhere, we can remove the code below
// entirely.
Comment on lines -1476 to -1477
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have this assurance because we removed executed_in_epoch_table completely and the node is running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's the default setting since a long time in upstream, and for us it's enabled from the start.

let should_sign_effects =
self.is_validator(epoch_store) && !epoch_store.executed_in_epoch_table_enabled();

let effects_sig = if should_sign_effects {
Some(AuthoritySignInfo::new(
epoch_store.epoch(),
effects,
Intent::iota_app(IntentScope::TransactionEffects),
self.name,
&*self.secret,
))
} else {
None
};

// index certificate
let _ = self
.post_process_one_tx(certificate, effects, &inner_temporary_store, epoch_store)
Expand All @@ -1502,12 +1483,7 @@ impl AuthorityState {
// The insertion to epoch_store is not atomic with the insertion to the
// perpetual store. This is OK because we insert to the epoch store
// first. And during lookups we always look up in the perpetual store first.
epoch_store.insert_tx_key_and_effects_signature(
&tx_key,
tx_digest,
&effects.digest(),
effects_sig.as_ref(),
)?;
epoch_store.insert_tx_key_and_digest(&tx_key, tx_digest)?;

// Allow testing what happens if we crash here.
fail_point_async!("crash");
Expand Down
40 changes: 3 additions & 37 deletions crates/iota-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,6 @@ pub struct AuthorityPerEpochStore {
pub(crate) metrics: Arc<EpochMetrics>,
epoch_start_configuration: Arc<EpochStartConfiguration>,

executed_in_epoch_table_enabled: once_cell::sync::OnceCell<bool>,

/// Execution state that has to restart at each epoch change
execution_component: ExecutionComponents,

Expand Down Expand Up @@ -935,7 +933,6 @@ impl AuthorityPerEpochStore {
epoch_close_time: Default::default(),
metrics,
epoch_start_configuration,
executed_in_epoch_table_enabled: once_cell::sync::OnceCell::new(),
execution_component,
chain_identifier,
jwk_aggregator,
Expand Down Expand Up @@ -1044,14 +1041,6 @@ impl AuthorityPerEpochStore {
self.epoch_start_configuration.flags().contains(&flag)
}

pub fn executed_in_epoch_table_enabled(&self) -> bool {
*self.executed_in_epoch_table_enabled.get_or_init(|| {
self.epoch_start_configuration
.flags()
.contains(&EpochFlag::ExecutedInEpochTable)
})
}

/// Returns `&Arc<EpochStartConfiguration>`
/// User can treat this `Arc` as `&EpochStartConfiguration`, or clone the
/// Arc to pass as owned object
Expand Down Expand Up @@ -1267,28 +1256,15 @@ impl AuthorityPerEpochStore {
}

#[instrument(level = "trace", skip_all)]
pub fn insert_tx_key_and_effects_signature(
pub fn insert_tx_key_and_digest(
&self,
tx_key: &TransactionKey,
tx_digest: &TransactionDigest,
effects_digest: &TransactionEffectsDigest,
effects_signature: Option<&AuthoritySignInfo>,
) -> IotaResult {
let tables = self.tables()?;
let mut batch = self.tables()?.effects_signatures.batch();

if self.executed_in_epoch_table_enabled() {
batch.insert_batch(&tables.executed_in_epoch, [(tx_digest, ())])?;
}

if let Some(effects_signature) = effects_signature {
batch.insert_batch(&tables.effects_signatures, [(tx_digest, effects_signature)])?;

batch.insert_batch(&tables.signed_effects_digests, [(
tx_digest,
effects_digest,
)])?;
}
batch.insert_batch(&tables.executed_in_epoch, [(tx_digest, ())])?;

if !matches!(tx_key, TransactionKey::Digest(_)) {
batch.insert_batch(&tables.transaction_key_to_digest, [(tx_key, tx_digest)])?;
Expand Down Expand Up @@ -1332,11 +1308,7 @@ impl AuthorityPerEpochStore {
digests: impl IntoIterator<Item = &'a TransactionDigest>,
) -> IotaResult<Vec<bool>> {
let tables = self.tables()?;
if self.executed_in_epoch_table_enabled() {
Ok(tables.executed_in_epoch.multi_contains_keys(digests)?)
} else {
Ok(tables.effects_signatures.multi_contains_keys(digests)?)
}
Ok(tables.executed_in_epoch.multi_contains_keys(digests)?)
}

pub fn get_effects_signature(
Expand Down Expand Up @@ -4062,12 +4034,6 @@ impl AuthorityPerEpochStore {
}

pub(crate) fn check_all_executed_transactions_in_checkpoint(&self) {
if !self.executed_in_epoch_table_enabled() {
error!(
"Cannot check executed transactions in checkpoint because executed_in_epoch table is not enabled"
);
return;
}
let tables = self.tables().unwrap();

info!("Verifying that all executed transactions are in a checkpoint");
Expand Down
35 changes: 5 additions & 30 deletions crates/iota-core/src/authority/epoch_start_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,10 @@ pub trait EpochStartConfigTrait {
// inconsistent with the released branch, and must be fixed.
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
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 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
_StateAccumulatorV2EnabledDeprecated = 4,
StateAccumulatorV2EnabledTestnet = 5,
StateAccumulatorV2EnabledMainnet = 6,

ExecutedInEpochTable = 7,
WritebackCacheEnabled = 0,

StateAccumulatorV2EnabledTestnet = 1,
StateAccumulatorV2EnabledMainnet = 2,
}

impl EpochFlag {
Expand All @@ -87,7 +75,7 @@ impl EpochFlag {
cache_config: &ExecutionCacheConfig,
enable_state_accumulator_v2: bool,
) -> Vec<Self> {
let mut new_flags = vec![EpochFlag::ExecutedInEpochTable];
let mut new_flags = vec![];

if matches!(
choose_execution_cache(cache_config),
Expand All @@ -110,20 +98,7 @@ impl fmt::Display for EpochFlag {
// Important - implementation should return low cardinality values because this
// is used as metric key
match self {
EpochFlag::_InMemoryCheckpointRootsDeprecated => {
write!(f, "InMemoryCheckpointRoots (DEPRECATED)")
}
EpochFlag::_PerEpochFinalizedTransactionsDeprecated => {
write!(f, "PerEpochFinalizedTransactions (DEPRECATED)")
}
EpochFlag::_ObjectLockSplitTablesDeprecated => {
write!(f, "ObjectLockSplitTables (DEPRECATED)")
}
EpochFlag::WritebackCacheEnabled => write!(f, "WritebackCacheEnabled"),
EpochFlag::_StateAccumulatorV2EnabledDeprecated => {
write!(f, "StateAccumulatorV2EnabledDeprecated (DEPRECATED)")
}
EpochFlag::ExecutedInEpochTable => write!(f, "ExecutedInEpochTable"),
EpochFlag::StateAccumulatorV2EnabledTestnet => {
write!(f, "StateAccumulatorV2EnabledTestnet")
}
Expand Down
16 changes: 2 additions & 14 deletions crates/iota-core/src/checkpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2467,15 +2467,14 @@ mod tests {
use iota_protocol_config::{Chain, ProtocolConfig};
use iota_types::{
base_types::{ObjectID, SequenceNumber, TransactionEffectsDigest},
crypto::{AuthoritySignInfo, Signature},
crypto::Signature,
digests::TransactionEventsDigest,
effects::{TransactionEffects, TransactionEvents},
messages_checkpoint::SignedCheckpointSummary,
move_package::MovePackage,
object,
transaction::{GenesisObject, VerifiedTransaction},
};
use shared_crypto::intent::{Intent, IntentScope};
use tokio::sync::mpsc;

use super::*;
Expand Down Expand Up @@ -2845,18 +2844,7 @@ mod tests {
let effects = e(digest, dependencies, gas_used);
store.insert(digest, effects.clone());
epoch_store
.insert_tx_key_and_effects_signature(
&TransactionKey::Digest(digest),
&digest,
&effects.digest(),
Some(&AuthoritySignInfo::new(
epoch_store.epoch(),
&effects,
Intent::iota_app(IntentScope::TransactionEffects),
state.name,
&*state.secret,
)),
)
.insert_tx_key_and_digest(&TransactionKey::Digest(digest), &digest)
.expect("Inserting cert fx and sigs should not fail");
}
}
Loading