|
2 | 2 | // Copyright (c) Mysten Labs, Inc. |
3 | 3 | // SPDX-License-Identifier: Apache-2.0 |
4 | 4 |
|
| 5 | +use crate::accumulators::AccumulatorSettlementTxBuilder; |
5 | 6 | use crate::accumulators::balance_read::AccountBalanceRead; |
6 | 7 | use crate::checkpoints::CheckpointBuilderError; |
7 | 8 | use crate::checkpoints::CheckpointBuilderResult; |
@@ -1288,6 +1289,8 @@ impl AuthorityState { |
1288 | 1289 | return Err(SuiErrorKind::ValidatorHaltedAtEpochEnd.into()); |
1289 | 1290 | } |
1290 | 1291 |
|
| 1292 | + transaction.validity_check(&epoch_store.tx_validity_check_context())?; |
| 1293 | + |
1291 | 1294 | let checked_input_objects = |
1292 | 1295 | self.handle_transaction_deny_checks(transaction, epoch_store)?; |
1293 | 1296 |
|
@@ -3909,6 +3912,66 @@ impl AuthorityState { |
3909 | 3912 | Ok(new_epoch_store) |
3910 | 3913 | } |
3911 | 3914 |
|
| 3915 | + pub async fn settle_transactions_for_testing( |
| 3916 | + &self, |
| 3917 | + ckpt_seq: CheckpointSequenceNumber, |
| 3918 | + effects: &[TransactionEffects], |
| 3919 | + ) { |
| 3920 | + let builder = AccumulatorSettlementTxBuilder::new( |
| 3921 | + Some(self.get_transaction_cache_reader().as_ref()), |
| 3922 | + effects, |
| 3923 | + ckpt_seq, |
| 3924 | + 0, |
| 3925 | + ); |
| 3926 | + let epoch_store = self.epoch_store_for_testing(); |
| 3927 | + let epoch = epoch_store.epoch(); |
| 3928 | + let (settlements, barrier) = builder.build_tx( |
| 3929 | + epoch_store.protocol_config(), |
| 3930 | + epoch, |
| 3931 | + epoch_store |
| 3932 | + .epoch_start_config() |
| 3933 | + .accumulator_root_obj_initial_shared_version() |
| 3934 | + .unwrap(), |
| 3935 | + ckpt_seq, |
| 3936 | + ckpt_seq, |
| 3937 | + ); |
| 3938 | + |
| 3939 | + let mut settlements: Vec<_> = settlements |
| 3940 | + .into_iter() |
| 3941 | + .map(|tx| { |
| 3942 | + VerifiedExecutableTransaction::new_system( |
| 3943 | + VerifiedTransaction::new_system_transaction(tx), |
| 3944 | + epoch, |
| 3945 | + ) |
| 3946 | + }) |
| 3947 | + .collect(); |
| 3948 | + let barrier = VerifiedExecutableTransaction::new_system( |
| 3949 | + VerifiedTransaction::new_system_transaction(barrier), |
| 3950 | + epoch, |
| 3951 | + ); |
| 3952 | + |
| 3953 | + settlements.push(barrier); |
| 3954 | + |
| 3955 | + let assigned_versions = epoch_store |
| 3956 | + .assign_shared_object_versions_for_tests( |
| 3957 | + self.get_object_cache_reader().as_ref(), |
| 3958 | + &settlements, |
| 3959 | + ) |
| 3960 | + .unwrap(); |
| 3961 | + |
| 3962 | + let version_map = assigned_versions.into_map(); |
| 3963 | + |
| 3964 | + for tx in settlements { |
| 3965 | + let env = ExecutionEnv::new() |
| 3966 | + .with_assigned_versions(version_map.get(&tx.key()).unwrap().clone()); |
| 3967 | + let (effects, _) = self |
| 3968 | + .try_execute_immediately(&tx, env, &epoch_store) |
| 3969 | + .await |
| 3970 | + .unwrap(); |
| 3971 | + assert!(effects.status().is_ok()); |
| 3972 | + } |
| 3973 | + } |
| 3974 | + |
3912 | 3975 | /// Advance the epoch store to the next epoch for testing only. |
3913 | 3976 | /// This only manually sets all the places where we have the epoch number. |
3914 | 3977 | /// It doesn't properly reconfigure the node, hence should be only used for testing. |
|
0 commit comments