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

refactor(iota-core): Remove deprecated AuthorityPerpetualTables/AuthorityStore related code #3829

Merged
merged 20 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3ab726d
Remove deprecated code
bingyanglin Oct 31, 2024
764d7b0
Clean code
bingyanglin Oct 31, 2024
6b78b45
Clean code
bingyanglin Oct 31, 2024
e639ac3
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Oct 31, 2024
23168c6
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Oct 31, 2024
b6a1b55
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Oct 31, 2024
cd3b945
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Oct 31, 2024
126a0c9
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Nov 1, 2024
3aaca9e
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Nov 1, 2024
151e7cd
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Nov 1, 2024
6a375f9
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Nov 4, 2024
f3437a8
Add PrintTransaction DbToolCommand
bingyanglin Nov 4, 2024
4a7da08
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Nov 4, 2024
a5046e2
Merge branch 'develop' of github.com:iotaledger/iota into core-node/f…
muXxer Nov 4, 2024
31d94d6
fix(node): pop and flatten the result instead of indexing
muXxer Nov 4, 2024
43151a8
Merge branch 'develop' of github.com:iotaledger/iota into core-node/f…
muXxer Nov 4, 2024
d8f2182
fix(node): removed `into_iter().collect()`
muXxer Nov 4, 2024
f697668
fix(node): fix epoch_db in print_transaction
muXxer Nov 4, 2024
59bd114
Merge branch 'develop' of github.com:iotaledger/iota into core-node/f…
muXxer Nov 4, 2024
fad0e8a
Merge branch 'develop' into core-node/fix/remove-deprecated-authority…
bingyanglin Nov 5, 2024
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
28 changes: 6 additions & 22 deletions crates/iota-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ use crate::{
consensus_adapter::ConsensusAdapter,
epoch::committee_store::CommitteeStore,
execution_cache::{
CheckpointCache, ExecutionCacheCommit, ExecutionCacheReconfigAPI,
ExecutionCacheTraitPointers, ExecutionCacheWrite, ObjectCacheRead, StateSyncAPI,
TransactionCacheRead,
ExecutionCacheCommit, ExecutionCacheReconfigAPI, ExecutionCacheTraitPointers,
ExecutionCacheWrite, ObjectCacheRead, StateSyncAPI, TransactionCacheRead,
},
execution_driver::execution_process,
metrics::{LatencyObserver, RateTracker},
Expand Down Expand Up @@ -2736,10 +2735,6 @@ impl AuthorityState {
&self.execution_cache_trait_pointers.accumulator_store
}

pub fn get_checkpoint_cache(&self) -> &Arc<dyn CheckpointCache> {
&self.execution_cache_trait_pointers.checkpoint_cache
}

pub fn get_state_sync_store(&self) -> &Arc<dyn StateSyncAPI> {
&self.execution_cache_trait_pointers.state_sync_store
}
Expand Down Expand Up @@ -4986,15 +4981,6 @@ impl TransactionKeyValueStoreTrait for AuthorityState {
Ok((summaries, contents, summaries_by_digest, contents_by_digest))
}

async fn deprecated_get_transaction_checkpoint(
&self,
digest: TransactionDigest,
) -> IotaResult<Option<CheckpointSequenceNumber>> {
self.get_checkpoint_cache()
.deprecated_get_transaction_checkpoint(&digest)
.map(|res| res.map(|(_epoch, checkpoint)| checkpoint))
}

async fn get_object(
&self,
object_id: ObjectID,
Expand All @@ -5010,13 +4996,11 @@ impl TransactionKeyValueStoreTrait for AuthorityState {
digests: &[TransactionDigest],
) -> IotaResult<Vec<Option<CheckpointSequenceNumber>>> {
let res = self
.get_checkpoint_cache()
.deprecated_multi_get_transaction_checkpoint(digests)?;
.epoch_store
.load()
.multi_get_transaction_checkpoint(digests)?;

Ok(res
.into_iter()
.map(|maybe| maybe.map(|(_epoch, checkpoint)| checkpoint))
.collect())
Ok(res.into_iter().collect())
DaughterOfMars marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
7 changes: 7 additions & 0 deletions crates/iota-core/src/authority/authority_per_epoch_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,13 @@ impl AuthorityEpochTables {
Ok(())
}

pub fn get_transaction_checkpoint(
&self,
digest: &TransactionDigest,
) -> IotaResult<Option<CheckpointSequenceNumber>> {
Ok(self.executed_transactions_to_checkpoint.get(digest)?)
}

/// WARNING: This method is very subtle and can corrupt the database if used
/// incorrectly. It should only be used in one-off cases or tests after
/// fully understanding the risk.
Expand Down
44 changes: 0 additions & 44 deletions crates/iota-core/src/authority/authority_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,50 +542,6 @@ impl AuthorityStore {
Ok(result)
}

// DEPRECATED -- use function of same name in AuthorityPerEpochStore
pub fn deprecated_insert_finalized_transactions(
&self,
digests: &[TransactionDigest],
epoch: EpochId,
sequence: CheckpointSequenceNumber,
) -> IotaResult {
let mut batch = self
.perpetual_tables
.executed_transactions_to_checkpoint
.batch();
batch.insert_batch(
&self.perpetual_tables.executed_transactions_to_checkpoint,
digests.iter().map(|d| (*d, (epoch, sequence))),
)?;
batch.write()?;
trace!("Transactions {digests:?} finalized at checkpoint {sequence} epoch {epoch}");
Ok(())
}

// DEPRECATED -- use function of same name in AuthorityPerEpochStore
pub fn deprecated_get_transaction_checkpoint(
&self,
digest: &TransactionDigest,
) -> IotaResult<Option<(EpochId, CheckpointSequenceNumber)>> {
Ok(self
.perpetual_tables
.executed_transactions_to_checkpoint
.get(digest)?)
}

// DEPRECATED -- use function of same name in AuthorityPerEpochStore
pub fn deprecated_multi_get_transaction_checkpoint(
&self,
digests: &[TransactionDigest],
) -> IotaResult<Vec<Option<(EpochId, CheckpointSequenceNumber)>>> {
Ok(self
.perpetual_tables
.executed_transactions_to_checkpoint
.multi_get(digests)?
.into_iter()
.collect())
}

/// Returns true if there are no objects in the database
pub fn database_is_empty(&self) -> IotaResult<bool> {
self.perpetual_tables.database_is_empty()
Expand Down
4 changes: 0 additions & 4 deletions crates/iota-core/src/authority/authority_store_pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ impl AuthorityStorePruner {

perpetual_batch.delete_batch(&perpetual_db.transactions, transactions.iter())?;
perpetual_batch.delete_batch(&perpetual_db.executed_effects, transactions.iter())?;
perpetual_batch.delete_batch(
&perpetual_db.executed_transactions_to_checkpoint,
transactions,
)?;

let mut effect_digests = vec![];
for effects in effects_to_prune {
Expand Down
17 changes: 0 additions & 17 deletions crates/iota-core/src/authority/authority_store_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ pub struct AuthorityPerpetualTables {
#[default_options_override_fn = "events_table_default_config"]
pub(crate) events: DBMap<(TransactionEventsDigest, usize), Event>,

/// DEPRECATED in favor of the table of the same name in
/// authority_per_epoch_store. Please do not add new
/// accessors/callsites. When transaction is executed via checkpoint
/// executor, we store association here
pub(crate) executed_transactions_to_checkpoint:
DBMap<TransactionDigest, (EpochId, CheckpointSequenceNumber)>,

// Finalized root state accumulator for epoch, to be included in CheckpointSummary
// of last checkpoint of epoch. These values should only ever be written once
// and never changed
Expand Down Expand Up @@ -363,15 +356,6 @@ impl AuthorityPerpetualTables {
Ok(self.effects.get(&effect_digest)?)
}

// DEPRECATED as the backing table has been moved to authority_per_epoch_store.
// Please do not add new accessors/callsites.
pub fn get_checkpoint_sequence_number(
&self,
digest: &TransactionDigest,
) -> IotaResult<Option<(EpochId, CheckpointSequenceNumber)>> {
Ok(self.executed_transactions_to_checkpoint.get(digest)?)
}

pub fn get_newer_object_keys(
&self,
object: &(ObjectID, SequenceNumber),
Expand Down Expand Up @@ -441,7 +425,6 @@ impl AuthorityPerpetualTables {
self.live_owned_object_markers.unsafe_clear()?;
self.executed_effects.unsafe_clear()?;
self.events.unsafe_clear()?;
self.executed_transactions_to_checkpoint.unsafe_clear()?;
self.root_state_hash_by_epoch.unsafe_clear()?;
self.epoch_start_configuration.unsafe_clear()?;
self.pruned_checkpoint.unsafe_clear()?;
Expand Down
9 changes: 0 additions & 9 deletions crates/iota-core/src/checkpoints/checkpoint_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,15 +1304,6 @@ async fn finalize_checkpoint(
debug!("finalizing checkpoint");
epoch_store.insert_finalized_transactions(tx_digests, checkpoint.sequence_number)?;

// TODO remove once we no longer need to support this table for read RPC
state
.get_checkpoint_cache()
.deprecated_insert_finalized_transactions(
tx_digests,
epoch_store.epoch(),
checkpoint.sequence_number,
)?;

let checkpoint_acc =
accumulator.accumulate_checkpoint(effects, checkpoint.sequence_number, epoch_store)?;

Expand Down
54 changes: 0 additions & 54 deletions crates/iota-core/src/execution_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub struct ExecutionCacheTraitPointers {
pub object_store: Arc<dyn ObjectStore + Send + Sync>,
pub reconfig_api: Arc<dyn ExecutionCacheReconfigAPI>,
pub accumulator_store: Arc<dyn AccumulatorStore>,
pub checkpoint_cache: Arc<dyn CheckpointCache>,
pub state_sync_store: Arc<dyn StateSyncAPI>,
pub cache_commit: Arc<dyn ExecutionCacheCommit>,
pub testing_api: Arc<dyn TestingAPI>,
Expand All @@ -80,7 +79,6 @@ impl ExecutionCacheTraitPointers {
+ ObjectStore
+ ExecutionCacheReconfigAPI
+ AccumulatorStore
+ CheckpointCache
+ StateSyncAPI
+ ExecutionCacheCommit
+ TestingAPI
Expand All @@ -95,7 +93,6 @@ impl ExecutionCacheTraitPointers {
object_store: cache.clone(),
reconfig_api: cache.clone(),
accumulator_store: cache.clone(),
checkpoint_cache: cache.clone(),
state_sync_store: cache.clone(),
cache_commit: cache.clone(),
testing_api: cache.clone(),
Expand Down Expand Up @@ -658,29 +655,6 @@ pub trait ExecutionCacheWrite: Send + Sync {
) -> BoxFuture<'a, IotaResult>;
}

pub trait CheckpointCache: Send + Sync {
// TODO: In addition to the deprecated methods below, this will eventually
// include access to the CheckpointStore

// DEPRECATED METHODS
fn deprecated_get_transaction_checkpoint(
&self,
digest: &TransactionDigest,
) -> IotaResult<Option<(EpochId, CheckpointSequenceNumber)>>;

fn deprecated_multi_get_transaction_checkpoint(
&self,
digests: &[TransactionDigest],
) -> IotaResult<Vec<Option<(EpochId, CheckpointSequenceNumber)>>>;

fn deprecated_insert_finalized_transactions(
&self,
digests: &[TransactionDigest],
epoch: EpochId,
sequence: CheckpointSequenceNumber,
) -> IotaResult;
}

pub trait ExecutionCacheReconfigAPI: Send + Sync {
fn insert_genesis_object(&self, object: Object) -> IotaResult;
fn bulk_insert_genesis_objects(&self, objects: &[Object]) -> IotaResult;
Expand Down Expand Up @@ -826,33 +800,6 @@ macro_rules! implement_storage_traits {
// store.
macro_rules! implement_passthrough_traits {
($implementor: ident) => {
impl CheckpointCache for $implementor {
fn deprecated_get_transaction_checkpoint(
&self,
digest: &TransactionDigest,
) -> IotaResult<Option<(EpochId, CheckpointSequenceNumber)>> {
self.store.deprecated_get_transaction_checkpoint(digest)
}

fn deprecated_multi_get_transaction_checkpoint(
&self,
digests: &[TransactionDigest],
) -> IotaResult<Vec<Option<(EpochId, CheckpointSequenceNumber)>>> {
self.store
.deprecated_multi_get_transaction_checkpoint(digests)
}

fn deprecated_insert_finalized_transactions(
&self,
digests: &[TransactionDigest],
epoch: EpochId,
sequence: CheckpointSequenceNumber,
) -> IotaResult {
self.store
.deprecated_insert_finalized_transactions(digests, epoch, sequence)
}
}

impl ExecutionCacheReconfigAPI for $implementor {
fn insert_genesis_object(&self, object: Object) -> IotaResult {
self.store.insert_genesis_object(object)
Expand Down Expand Up @@ -953,7 +900,6 @@ pub trait ExecutionCacheAPI:
+ ExecutionCacheWrite
+ ExecutionCacheCommit
+ ExecutionCacheReconfigAPI
+ CheckpointCache
+ StateSyncAPI
{
}
5 changes: 2 additions & 3 deletions crates/iota-core/src/execution_cache/passthrough_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ use tracing::instrument;
use typed_store::Map;

use super::{
CheckpointCache, ExecutionCacheCommit, ExecutionCacheMetrics, ExecutionCacheReconfigAPI,
ExecutionCacheWrite, ObjectCacheRead, StateSyncAPI, TestingAPI, TransactionCacheRead,
implement_passthrough_traits,
ExecutionCacheCommit, ExecutionCacheMetrics, ExecutionCacheReconfigAPI, ExecutionCacheWrite,
ObjectCacheRead, StateSyncAPI, TestingAPI, TransactionCacheRead, implement_passthrough_traits,
};
use crate::{
authority::{
Expand Down
27 changes: 1 addition & 26 deletions crates/iota-core/src/execution_cache/proxy_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use iota_types::{
use parking_lot::RwLock;

use super::{
CheckpointCache, ExecutionCacheCommit, ExecutionCacheConfigType, ExecutionCacheMetrics,
ExecutionCacheCommit, ExecutionCacheConfigType, ExecutionCacheMetrics,
ExecutionCacheReconfigAPI, ExecutionCacheWrite, ObjectCacheRead, PassthroughCache,
StateSyncAPI, TestingAPI, TransactionCacheRead, WritebackCache,
};
Expand Down Expand Up @@ -317,31 +317,6 @@ impl ExecutionCacheCommit for ProxyCache {
}
}

impl CheckpointCache for ProxyCache {
fn deprecated_get_transaction_checkpoint(
&self,
digest: &TransactionDigest,
) -> IotaResult<Option<(EpochId, CheckpointSequenceNumber)>> {
delegate_method!(self.deprecated_get_transaction_checkpoint(digest))
}

fn deprecated_multi_get_transaction_checkpoint(
&self,
digests: &[TransactionDigest],
) -> IotaResult<Vec<Option<(EpochId, CheckpointSequenceNumber)>>> {
delegate_method!(self.deprecated_multi_get_transaction_checkpoint(digests))
}

fn deprecated_insert_finalized_transactions(
&self,
digests: &[TransactionDigest],
epoch: EpochId,
sequence: CheckpointSequenceNumber,
) -> IotaResult {
delegate_method!(self.deprecated_insert_finalized_transactions(digests, epoch, sequence))
}
}

impl ExecutionCacheReconfigAPI for ProxyCache {
fn insert_genesis_object(&self, object: Object) -> IotaResult {
delegate_method!(self.insert_genesis_object(object))
Expand Down
7 changes: 3 additions & 4 deletions crates/iota-core/src/execution_cache/writeback_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ use tap::TapOptional;
use tracing::{debug, info, instrument, trace, warn};

use super::{
CheckpointCache, ExecutionCacheAPI, ExecutionCacheCommit, ExecutionCacheMetrics,
ExecutionCacheReconfigAPI, ExecutionCacheWrite, ObjectCacheRead, StateSyncAPI, TestingAPI,
TransactionCacheRead, cache_types::CachedVersionMap, implement_passthrough_traits,
object_locks::ObjectLocks,
ExecutionCacheAPI, ExecutionCacheCommit, ExecutionCacheMetrics, ExecutionCacheReconfigAPI,
ExecutionCacheWrite, ObjectCacheRead, StateSyncAPI, TestingAPI, TransactionCacheRead,
cache_types::CachedVersionMap, implement_passthrough_traits, object_locks::ObjectLocks,
};
use crate::{
authority::{
Expand Down
Loading
Loading