From f56448f8c41dafcf92499701ea0081a2ed67b249 Mon Sep 17 00:00:00 2001 From: Bing-Yang Lin Date: Tue, 20 May 2025 15:09:10 +0800 Subject: [PATCH 1/3] Enable writeback cache by default --- crates/iota-config/src/node.rs | 13 +- crates/iota-core/src/authority.rs | 5 +- .../src/authority/authority_test_utils.rs | 8 +- .../src/authority/test_authority_builder.rs | 6 + crates/iota-core/src/execution_cache.rs | 20 +-- .../src/execution_cache/object_locks.rs | 1 - .../src/execution_cache/passthrough_cache.rs | 8 ++ .../src/execution_cache/writeback_cache.rs | 18 +++ crates/iota-core/src/test_utils.rs | 4 +- .../src/unit_tests/authority_tests.rs | 130 +++++++++++++----- .../src/unit_tests/transaction_deny_tests.rs | 19 ++- ...ests__network_config_snapshot_matches.snap | 28 +++- crates/iota-types/src/transaction.rs | 24 +++- 13 files changed, 218 insertions(+), 66 deletions(-) diff --git a/crates/iota-config/src/node.rs b/crates/iota-config/src/node.rs index c2cfed3b94a..329387caf44 100644 --- a/crates/iota-config/src/node.rs +++ b/crates/iota-config/src/node.rs @@ -254,16 +254,25 @@ pub struct NodeConfig { pub iota_names_config: Option, } -#[derive(Clone, Debug, Deserialize, Serialize, Default)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "kebab-case")] pub enum ExecutionCacheConfig { - #[default] PassthroughCache, WritebackCache { + /// Maximum number of entries in each cache. (There are several + /// different caches). If None, the default of 10000 is used. max_cache_size: Option, }, } +impl Default for ExecutionCacheConfig { + fn default() -> Self { + ExecutionCacheConfig::WritebackCache { + max_cache_size: None, + } + } +} + #[derive(Clone, Copy, Debug, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] pub enum ServerType { diff --git a/crates/iota-core/src/authority.rs b/crates/iota-core/src/authority.rs index 20b50e831c3..c0f5910f863 100644 --- a/crates/iota-core/src/authority.rs +++ b/crates/iota-core/src/authority.rs @@ -4829,7 +4829,8 @@ impl AuthorityState { pub(crate) fn iter_live_object_set_for_testing( &self, ) -> impl Iterator + '_ { - self.get_accumulator_store().iter_live_object_set() + self.get_accumulator_store() + .iter_cached_live_object_set_for_testing() } #[cfg(test)] @@ -4849,6 +4850,8 @@ impl AuthorityState { .bulk_insert_genesis_objects(objects)?; self.get_object_cache_reader() .force_reload_system_packages(&BuiltInFramework::all_package_ids()); + self.get_reconfig_api() + .clear_state_end_of_epoch(&self.execution_lock_for_reconfiguration().await); Ok(()) } } diff --git a/crates/iota-core/src/authority/authority_test_utils.rs b/crates/iota-core/src/authority/authority_test_utils.rs index 0a6f164406d..06fed5987a4 100644 --- a/crates/iota-core/src/authority/authority_test_utils.rs +++ b/crates/iota-core/src/authority/authority_test_utils.rs @@ -516,7 +516,7 @@ pub async fn publish_package_on_single_authority( dep_original_addresses: impl IntoIterator, dep_ids: Vec, state: &Arc, -) -> IotaResult<(ObjectID, ObjectRef)> { +) -> IotaResult<(TransactionDigest, (ObjectID, ObjectRef))> { let mut build_config = BuildConfig::new_for_testing(); for (addr_name, obj_id) in dep_original_addresses { build_config @@ -558,7 +558,7 @@ pub async fn publish_package_on_single_authority( .find(|c| matches!(c.1, Owner::AddressOwner(..))) .unwrap() .0; - Ok((package_id, cap_object)) + Ok((*effects.transaction_digest(), (package_id, cap_object))) } pub async fn upgrade_package_on_single_authority( @@ -571,7 +571,7 @@ pub async fn upgrade_package_on_single_authority( dep_original_addresses: impl IntoIterator, dep_id_mapping: impl IntoIterator, state: &Arc, -) -> IotaResult { +) -> IotaResult<(TransactionDigest, ObjectID)> { let package = build_test_modules_with_dep_addr(path, dep_original_addresses, dep_id_mapping); let with_unpublished_deps = false; @@ -603,5 +603,5 @@ pub async fn upgrade_package_on_single_authority( .unwrap() .0 .0; - Ok(package_id) + Ok((*effects.transaction_digest(), package_id)) } diff --git a/crates/iota-core/src/authority/test_authority_builder.rs b/crates/iota-core/src/authority/test_authority_builder.rs index 2da75600f44..cb90e7f1fda 100644 --- a/crates/iota-core/src/authority/test_authority_builder.rs +++ b/crates/iota-core/src/authority/test_authority_builder.rs @@ -365,6 +365,12 @@ impl<'a> TestAuthorityBuilder<'a> { .await .unwrap(); + state + .get_cache_commit() + .commit_transaction_outputs(epoch_store.epoch(), &[*genesis.transaction().digest()]) + .await + .unwrap(); + // We want to insert these objects directly instead of relying on genesis // because genesis process would set the previous transaction field for // these objects, which would change their object digest. This makes it diff --git a/crates/iota-core/src/execution_cache.rs b/crates/iota-core/src/execution_cache.rs index 2ea779f3d9e..002f8661684 100644 --- a/crates/iota-core/src/execution_cache.rs +++ b/crates/iota-core/src/execution_cache.rs @@ -104,7 +104,7 @@ impl ExecutionCacheTraitPointers { } } -static ENABLE_WRITEBACK_CACHE_ENV_VAR: &str = "ENABLE_WRITEBACK_CACHE"; +static DISABLE_WRITEBACK_CACHE_ENV_VAR: &str = "DISABLE_WRITEBACK_CACHE"; #[derive(Debug)] pub enum ExecutionCacheConfigType { @@ -130,12 +130,12 @@ pub fn choose_execution_cache(config: &ExecutionCacheConfig) -> ExecutionCacheCo } } - if std::env::var(ENABLE_WRITEBACK_CACHE_ENV_VAR).is_ok() - || matches!(config, ExecutionCacheConfig::WritebackCache { .. }) + if std::env::var(DISABLE_WRITEBACK_CACHE_ENV_VAR).is_ok() + || matches!(config, ExecutionCacheConfig::PassthroughCache) { - ExecutionCacheConfigType::WritebackCache - } else { ExecutionCacheConfigType::PassthroughCache + } else { + ExecutionCacheConfigType::WritebackCache } } @@ -159,13 +159,13 @@ pub fn build_execution_cache_from_env( ) -> ExecutionCacheTraitPointers { let execution_cache_metrics = Arc::new(ExecutionCacheMetrics::new(prometheus_registry)); - if std::env::var(ENABLE_WRITEBACK_CACHE_ENV_VAR).is_ok() { + if std::env::var(DISABLE_WRITEBACK_CACHE_ENV_VAR).is_ok() { ExecutionCacheTraitPointers::new( - WritebackCache::new(store.clone(), execution_cache_metrics).into(), + PassthroughCache::new(store.clone(), execution_cache_metrics).into(), ) } else { ExecutionCacheTraitPointers::new( - PassthroughCache::new(store.clone(), execution_cache_metrics).into(), + WritebackCache::new(store.clone(), execution_cache_metrics).into(), ) } } @@ -867,11 +867,11 @@ macro_rules! implement_passthrough_traits { impl ExecutionCacheReconfigAPI for $implementor { fn insert_genesis_object(&self, object: Object) -> IotaResult { - self.store.insert_genesis_object(object) + self.insert_genesis_object_impl(object) } fn bulk_insert_genesis_objects(&self, objects: &[Object]) -> IotaResult { - self.store.bulk_insert_genesis_objects(objects) + self.bulk_insert_genesis_objects_impl(objects) } fn revert_state_update(&self, digest: &TransactionDigest) -> IotaResult { diff --git a/crates/iota-core/src/execution_cache/object_locks.rs b/crates/iota-core/src/execution_cache/object_locks.rs index 3e7ab8d84a9..c861fbdbe42 100644 --- a/crates/iota-core/src/execution_cache/object_locks.rs +++ b/crates/iota-core/src/execution_cache/object_locks.rs @@ -133,7 +133,6 @@ impl ObjectLocks { let live_digest = live_object.digest(); if obj_ref.2 != live_digest { - debug!("object digest mismatch: {:?} vs {:?}", obj_ref, live_digest); return Err(IotaError::UserInput { error: UserInputError::InvalidObjectDigest { object_id: obj_ref.0, diff --git a/crates/iota-core/src/execution_cache/passthrough_cache.rs b/crates/iota-core/src/execution_cache/passthrough_cache.rs index 0261942423a..ba7670b44de 100644 --- a/crates/iota-core/src/execution_cache/passthrough_cache.rs +++ b/crates/iota-core/src/execution_cache/passthrough_cache.rs @@ -80,6 +80,14 @@ impl PassthroughCache { }) .ok(); } + + fn bulk_insert_genesis_objects_impl(&self, objects: &[Object]) -> IotaResult { + self.store.bulk_insert_genesis_objects(objects) + } + + fn insert_genesis_object_impl(&self, object: Object) -> IotaResult { + self.store.insert_genesis_object(object) + } } impl ObjectCacheRead for PassthroughCache { diff --git a/crates/iota-core/src/execution_cache/writeback_cache.rs b/crates/iota-core/src/execution_cache/writeback_cache.rs index e27a634a80e..a72490f7712 100644 --- a/crates/iota-core/src/execution_cache/writeback_cache.rs +++ b/crates/iota-core/src/execution_cache/writeback_cache.rs @@ -1158,10 +1158,12 @@ impl WritebackCache { self.packages.invalidate(object_id); } self.cached.object_by_id_cache.invalidate(object_id); + self.cached.object_cache.invalidate(object_id); } for ObjectKey(object_id, _) in outputs.deleted.iter().chain(outputs.wrapped.iter()) { self.cached.object_by_id_cache.invalidate(object_id); + self.cached.object_cache.invalidate(object_id); } // Note: individual object entries are removed when @@ -1169,6 +1171,22 @@ impl WritebackCache { Ok(()) } + fn bulk_insert_genesis_objects_impl(&self, objects: &[Object]) -> IotaResult { + self.store.bulk_insert_genesis_objects(objects)?; + for obj in objects { + dbg!("invalidagted!", obj.id()); + self.cached.object_cache.invalidate(&obj.id()); + self.cached.object_by_id_cache.invalidate(&obj.id()); + } + Ok(()) + } + + fn insert_genesis_object_impl(&self, object: Object) -> IotaResult { + self.cached.object_by_id_cache.invalidate(&object.id()); + self.cached.object_cache.invalidate(&object.id()); + self.store.insert_genesis_object(object) + } + pub fn clear_caches_and_assert_empty(&self) { info!("clearing caches"); self.cached.clear_and_assert_empty(); diff --git a/crates/iota-core/src/test_utils.rs b/crates/iota-core/src/test_utils.rs index 17904f6d4c2..a151a7c9630 100644 --- a/crates/iota-core/src/test_utils.rs +++ b/crates/iota-core/src/test_utils.rs @@ -79,9 +79,9 @@ pub async fn send_and_confirm_transaction( // We also check the incremental effects of the transaction on the live object // set against StateAccumulator for testing and regression detection let state_acc = StateAccumulator::new_for_tests(authority.get_accumulator_store().clone()); - let mut state = state_acc.accumulate_live_object_set(); + let mut state = state_acc.accumulate_cached_live_object_set_for_testing(); let (result, _execution_error_opt) = authority.try_execute_for_test(&certificate).await?; - let state_after = state_acc.accumulate_live_object_set(); + let state_after = state_acc.accumulate_cached_live_object_set_for_testing(); let effects_acc = state_acc.accumulate_effects(vec![result.inner().data().clone()]); state.union(&effects_acc); diff --git a/crates/iota-core/src/unit_tests/authority_tests.rs b/crates/iota-core/src/unit_tests/authority_tests.rs index 2226c26a1ba..0af7bc373af 100644 --- a/crates/iota-core/src/unit_tests/authority_tests.rs +++ b/crates/iota-core/src/unit_tests/authority_tests.rs @@ -3419,23 +3419,25 @@ async fn test_store_revert_transfer_iota() { .await .unwrap(); - let db = &authority_state.database_for_testing(); - db.revert_state_update(&tx_digest).unwrap(); + let cache = authority_state.get_object_cache_reader(); + let tx_cache = authority_state.get_transaction_cache_reader(); + let reconfig_api = authority_state.get_reconfig_api(); + reconfig_api.revert_state_update(&tx_digest).unwrap(); + reconfig_api + .clear_state_end_of_epoch(&authority_state.execution_lock_for_reconfiguration().await); assert_eq!( - db.get_object(&gas_object_id).unwrap().unwrap().owner, + cache.get_object(&gas_object_id).unwrap().unwrap().owner, Owner::AddressOwner(sender), ); assert_eq!( - db.get_latest_object_ref_or_tombstone(gas_object_id) + cache + .get_latest_object_ref_or_tombstone(gas_object_id) .unwrap() .unwrap(), gas_object_ref ); - // Transaction should not be deleted on revert in case it's needed - // to execute a future state sync checkpoint. - assert!(db.get_transaction_block(&tx_digest).unwrap().is_some()); - assert!(!db.is_tx_already_executed(&tx_digest).unwrap()); + assert!(!tx_cache.is_tx_already_executed(&tx_digest).unwrap()); } #[tokio::test] @@ -3456,6 +3458,15 @@ async fn test_store_revert_wrap_move_call() { .await .unwrap(); + authority_state + .get_cache_commit() + .commit_transaction_outputs( + authority_state.epoch_store_for_testing().epoch(), + &[*create_effects.transaction_digest()], + ) + .await + .unwrap(); + assert!(create_effects.status().is_ok()); assert_eq!(create_effects.created().len(), 1); @@ -3492,18 +3503,21 @@ async fn test_store_revert_wrap_move_call() { let wrapper_v0 = wrap_effects.created()[0].0; - let db = &authority_state.database_for_testing(); - db.revert_state_update(&wrap_digest).unwrap(); + let cache = &authority_state.get_object_cache_reader(); + let reconfig_api = authority_state.get_reconfig_api(); + reconfig_api.revert_state_update(&wrap_digest).unwrap(); + reconfig_api + .clear_state_end_of_epoch(&authority_state.execution_lock_for_reconfiguration().await); // The wrapped object is unwrapped once again (accessible from storage). - let object = db.get_object(&object_v0.0).unwrap().unwrap(); + let object = cache.get_object(&object_v0.0).unwrap().unwrap(); assert_eq!(object.version(), object_v0.1); // The wrapper doesn't exist - assert!(db.get_object(&wrapper_v0.0).unwrap().is_none()); + assert!(cache.get_object(&wrapper_v0.0).unwrap().is_none()); // The gas is uncharged - let gas = db.get_object(&gas_object_id).unwrap().unwrap(); + let gas = cache.get_object(&gas_object_id).unwrap().unwrap(); assert_eq!(gas.version(), create_effects.gas_object().0.1); } @@ -3541,6 +3555,18 @@ async fn test_store_revert_unwrap_move_call() { .await .unwrap(); + authority_state + .get_cache_commit() + .commit_transaction_outputs( + authority_state.epoch_store_for_testing().epoch(), + &[ + *create_effects.transaction_digest(), + *wrap_effects.transaction_digest(), + ], + ) + .await + .unwrap(); + assert!(wrap_effects.status().is_ok()); assert_eq!(wrap_effects.created().len(), 1); assert_eq!(wrap_effects.wrapped().len(), 1); @@ -3578,21 +3604,25 @@ async fn test_store_revert_unwrap_move_call() { assert_eq!(unwrap_effects.unwrapped().len(), 1); assert_eq!(unwrap_effects.unwrapped()[0].0.0, object_v0.0); - let db = &authority_state.database_for_testing(); + let cache = &authority_state.get_object_cache_reader(); + let reconfig_api = authority_state.get_reconfig_api(); - db.revert_state_update(&unwrap_digest).unwrap(); + reconfig_api.revert_state_update(&unwrap_digest).unwrap(); + reconfig_api + .clear_state_end_of_epoch(&authority_state.execution_lock_for_reconfiguration().await); // The unwrapped object is wrapped once again - assert!(db.get_object(&object_v0.0).unwrap().is_none()); + assert!(cache.get_object(&object_v0.0).unwrap().is_none()); // The wrapper exists - let wrapper = db.get_object(&wrapper_v0.0).unwrap().unwrap(); + let wrapper = cache.get_object(&wrapper_v0.0).unwrap().unwrap(); assert_eq!(wrapper.version(), wrapper_v0.1); // The gas is uncharged - let gas = db.get_object(&gas_object_id).unwrap().unwrap(); + let gas = cache.get_object(&gas_object_id).unwrap().unwrap(); assert_eq!(gas.version(), wrap_effects.gas_object().0.1); } + #[tokio::test] async fn test_store_get_dynamic_object() { let (_, fields) = create_and_retrieve_df_info(ident_str!("add_ofield")).await; @@ -3805,6 +3835,18 @@ async fn test_store_revert_add_ofield() { let outer_v0 = create_outer_effects.created()[0].0; let inner_v0 = create_inner_effects.created()[0].0; + authority_state + .get_cache_commit() + .commit_transaction_outputs( + authority_state.epoch_store_for_testing().epoch(), + &[ + *create_outer_effects.transaction_digest(), + *create_inner_effects.transaction_digest(), + ], + ) + .await + .unwrap(); + let add_txn = to_sender_signed_transaction( TransactionData::new_move_call( sender, @@ -3839,27 +3881,31 @@ async fn test_store_revert_add_ofield() { let outer_v1 = find_by_id(&add_effects.mutated(), outer_v0.0).unwrap(); let inner_v1 = find_by_id(&add_effects.mutated(), inner_v0.0).unwrap(); - let db = &authority_state.database_for_testing(); + let cache = authority_state.get_object_cache_reader(); + let reconfig_api = &authority_state.get_reconfig_api(); - let outer = db.get_object(&outer_v0.0).unwrap().unwrap(); + let outer = cache.get_object(&outer_v0.0).unwrap().unwrap(); assert_eq!(outer.version(), outer_v1.1); - let field = db.get_object(&field_v0.0).unwrap().unwrap(); + let field = cache.get_object(&field_v0.0).unwrap().unwrap(); assert_eq!(field.owner, Owner::ObjectOwner(outer_v0.0.into())); - let inner = db.get_object(&inner_v0.0).unwrap().unwrap(); + let inner = cache.get_object(&inner_v0.0).unwrap().unwrap(); assert_eq!(inner.version(), inner_v1.1); assert_eq!(inner.owner, Owner::ObjectOwner(field_v0.0.into())); - db.revert_state_update(&add_digest).unwrap(); + reconfig_api.revert_state_update(&add_digest).unwrap(); + + reconfig_api + .clear_state_end_of_epoch(&authority_state.execution_lock_for_reconfiguration().await); - let outer = db.get_object(&outer_v0.0).unwrap().unwrap(); + let outer = cache.get_object(&outer_v0.0).unwrap().unwrap(); assert_eq!(outer.version(), outer_v0.1); // Field no longer exists - assert!(db.get_object(&field_v0.0).unwrap().is_none()); + assert!(cache.get_object(&field_v0.0).unwrap().is_none()); - let inner = db.get_object(&inner_v0.0).unwrap().unwrap(); + let inner = cache.get_object(&inner_v0.0).unwrap().unwrap(); assert_eq!(inner.version(), inner_v0.1); assert_eq!(inner.owner, Owner::AddressOwner(sender)); } @@ -3916,6 +3962,19 @@ async fn test_store_revert_remove_ofield() { assert!(add_effects.status().is_ok()); assert_eq!(add_effects.created().len(), 1); + authority_state + .get_cache_commit() + .commit_transaction_outputs( + authority_state.epoch_store_for_testing().epoch(), + &[ + *create_outer_effects.transaction_digest(), + *create_inner_effects.transaction_digest(), + *add_effects.transaction_digest(), + ], + ) + .await + .unwrap(); + let field_v0 = add_effects.created()[0].0; let outer_v1 = find_by_id(&add_effects.mutated(), outer_v0.0).unwrap(); let inner_v1 = find_by_id(&add_effects.mutated(), inner_v0.0).unwrap(); @@ -3951,24 +4010,29 @@ async fn test_store_revert_remove_ofield() { let outer_v2 = find_by_id(&remove_effects.mutated(), outer_v0.0).unwrap(); let inner_v2 = find_by_id(&remove_effects.mutated(), inner_v0.0).unwrap(); - let db = &authority_state.database_for_testing(); + let cache = &authority_state.get_object_cache_reader(); + let reconfig_api = &authority_state.get_reconfig_api(); - let outer = db.get_object(&outer_v0.0).unwrap().unwrap(); + let outer = cache.get_object(&outer_v0.0).unwrap().unwrap(); assert_eq!(outer.version(), outer_v2.1); - let inner = db.get_object(&inner_v0.0).unwrap().unwrap(); + let inner = cache.get_object(&inner_v0.0).unwrap().unwrap(); assert_eq!(inner.owner, Owner::AddressOwner(sender)); assert_eq!(inner.version(), inner_v2.1); - db.revert_state_update(&remove_ofield_digest).unwrap(); + reconfig_api + .revert_state_update(&remove_ofield_digest) + .unwrap(); + reconfig_api + .clear_state_end_of_epoch(&authority_state.execution_lock_for_reconfiguration().await); - let outer = db.get_object(&outer_v0.0).unwrap().unwrap(); + let outer = cache.get_object(&outer_v0.0).unwrap().unwrap(); assert_eq!(outer.version(), outer_v1.1); - let field = db.get_object(&field_v0.0).unwrap().unwrap(); + let field = cache.get_object(&field_v0.0).unwrap().unwrap(); assert_eq!(field.owner, Owner::ObjectOwner(outer_v0.0.into())); - let inner = db.get_object(&inner_v0.0).unwrap().unwrap(); + let inner = cache.get_object(&inner_v0.0).unwrap().unwrap(); assert_eq!(inner.owner, Owner::ObjectOwner(field_v0.0.into())); assert_eq!(inner.version(), inner_v1.1); } diff --git a/crates/iota-core/src/unit_tests/transaction_deny_tests.rs b/crates/iota-core/src/unit_tests/transaction_deny_tests.rs index 003183e20cb..f0495b27c48 100644 --- a/crates/iota-core/src/unit_tests/transaction_deny_tests.rs +++ b/crates/iota-core/src/unit_tests/transaction_deny_tests.rs @@ -305,7 +305,7 @@ async fn test_package_denied() { // Publish 3 packages, where b depends on c, and a depends on b. // Also upgrade c to c', and upgrade b to b' (which will start using c' instead // of c as dependency). - let (package_c, cap_c) = publish_package_on_single_authority( + let (tx_c, (package_c, cap_c)) = publish_package_on_single_authority( &path.join("src/unit_tests/data/package_deny/c"), accounts[0].0, &accounts[0].1, @@ -316,7 +316,7 @@ async fn test_package_denied() { ) .await .unwrap(); - let (package_b, cap_b) = publish_package_on_single_authority( + let (tx_b, (package_b, cap_b)) = publish_package_on_single_authority( &path.join("src/unit_tests/data/package_deny/b"), accounts[0].0, &accounts[0].1, @@ -327,7 +327,7 @@ async fn test_package_denied() { ) .await .unwrap(); - let (package_a, cap_a) = publish_package_on_single_authority( + let (tx_a, (package_a, cap_a)) = publish_package_on_single_authority( &path.join("src/unit_tests/data/package_deny/a"), accounts[0].0, &accounts[0].1, @@ -338,7 +338,7 @@ async fn test_package_denied() { ) .await .unwrap(); - let package_c_prime = upgrade_package_on_single_authority( + let (tx_c_prime, package_c_prime) = upgrade_package_on_single_authority( &path.join("src/unit_tests/data/package_deny/c"), accounts[0].0, &accounts[0].1, @@ -351,7 +351,7 @@ async fn test_package_denied() { ) .await .unwrap(); - let package_b_prime = upgrade_package_on_single_authority( + let (tx_b_prime, package_b_prime) = upgrade_package_on_single_authority( &path.join("src/unit_tests/data/package_deny/b"), accounts[0].0, &accounts[0].1, @@ -365,6 +365,15 @@ async fn test_package_denied() { .await .unwrap(); + state + .get_cache_commit() + .commit_transaction_outputs( + state.epoch_store_for_testing().epoch(), + &[tx_c, tx_b, tx_a, tx_c_prime, tx_b_prime], + ) + .await + .unwrap(); + // Re-create the state such that we could deny package c. let state = reload_state_with_new_deny_config( &network_config, diff --git a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap index ce79a296342..ad73069e3e4 100644 --- a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap +++ b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__network_config_snapshot_matches.snap @@ -122,7 +122,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ @@ -249,7 +251,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ @@ -376,7 +380,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ @@ -503,7 +509,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ @@ -630,7 +638,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ @@ -757,7 +767,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ @@ -884,7 +896,9 @@ validator_configs: check-system-overload-at-signing: true max-transaction-manager-queue-length: 100000 max-transaction-manager-per-object-queue-length: 100 - execution-cache: passthrough-cache + execution-cache: + writeback-cache: + max_cache_size: ~ enable-validator-tx-finalizer: true verifier-signing-config: max-per-fun-meter-units: ~ diff --git a/crates/iota-types/src/transaction.rs b/crates/iota-types/src/transaction.rs index 531440d129b..e9eb45acb8e 100644 --- a/crates/iota-types/src/transaction.rs +++ b/crates/iota-types/src/transaction.rs @@ -2739,7 +2739,7 @@ pub struct ObjectReadResult { pub object: ObjectReadResultKind, } -#[derive(Clone, Debug)] +#[derive(Clone)] pub enum ObjectReadResultKind { Object(Object), // The version of the object that the transaction intended to read, and the digest of the tx @@ -2749,6 +2749,22 @@ pub enum ObjectReadResultKind { CancelledTransactionSharedObject(SequenceNumber), } +impl std::fmt::Debug for ObjectReadResultKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ObjectReadResultKind::Object(obj) => { + write!(f, "Object({:?})", obj.compute_object_reference()) + } + ObjectReadResultKind::DeletedSharedObject(seq, digest) => { + write!(f, "DeletedSharedObject({}, {:?})", seq, digest) + } + ObjectReadResultKind::CancelledTransactionSharedObject(seq) => { + write!(f, "CancelledTransactionSharedObject({})", seq) + } + } + } +} + impl From for ObjectReadResultKind { fn from(object: Object) -> Self { Self::Object(object) @@ -2895,6 +2911,12 @@ pub struct InputObjects { objects: Vec, } +impl std::fmt::Debug for InputObjects { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_list().entries(self.objects.iter()).finish() + } +} + // An InputObjects new-type that has been verified by iota-transaction-checks, // and can be safely passed to execution. pub struct CheckedInputObjects(InputObjects); From 78f5a2ccee14bcaa636ea89778debb3fe800c820 Mon Sep 17 00:00:00 2001 From: Bing-Yang Lin Date: Tue, 20 May 2025 15:19:12 +0800 Subject: [PATCH 2/3] Add the DISABLE_WRITEBACK_CACHE flag in docker compose file --- dev-tools/iota-network/docker-compose-antithesis.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev-tools/iota-network/docker-compose-antithesis.yaml b/dev-tools/iota-network/docker-compose-antithesis.yaml index 4020a58e436..7457f506ff3 100644 --- a/dev-tools/iota-network/docker-compose-antithesis.yaml +++ b/dev-tools/iota-network/docker-compose-antithesis.yaml @@ -65,6 +65,7 @@ services: container_name: validator3 hostname: validator3 environment: + - DISABLE_WRITEBACK_CACHE=1 - RUST_BACKTRACE=1 - RUST_LOG=info,iota_core=debug,iota_network=debug,iota_node=debug,consensus=debug,jsonrpsee=error - RPC_WORKER_THREAD=12 @@ -92,6 +93,7 @@ services: container_name: validator4 hostname: validator4 environment: + - DISABLE_WRITEBACK_CACHE=1 - RUST_BACKTRACE=1 - RUST_LOG=info,iota_core=debug,iota_network=debug,iota_node=debug,consensus=debug,jsonrpsee=error - RPC_WORKER_THREAD=12 From 8c8721ce285e33b14a7bb86ea486d82ad640859c Mon Sep 17 00:00:00 2001 From: jkrvivian Date: Mon, 26 May 2025 20:34:40 +0800 Subject: [PATCH 3/3] Remove debug output --- crates/iota-core/src/execution_cache/writeback_cache.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/iota-core/src/execution_cache/writeback_cache.rs b/crates/iota-core/src/execution_cache/writeback_cache.rs index a72490f7712..751b06ccc72 100644 --- a/crates/iota-core/src/execution_cache/writeback_cache.rs +++ b/crates/iota-core/src/execution_cache/writeback_cache.rs @@ -1174,7 +1174,6 @@ impl WritebackCache { fn bulk_insert_genesis_objects_impl(&self, objects: &[Object]) -> IotaResult { self.store.bulk_insert_genesis_objects(objects)?; for obj in objects { - dbg!("invalidagted!", obj.id()); self.cached.object_cache.invalidate(&obj.id()); self.cached.object_by_id_cache.invalidate(&obj.id()); }