From 75443e047393e688e95e77a30f70c4a1426b48b5 Mon Sep 17 00:00:00 2001 From: Joshua Primero Date: Sat, 10 Aug 2024 17:04:49 -0500 Subject: [PATCH] Remove Executable::mock --- .../tests/kernel/kernel_open_substate.rs | 2 +- radix-engine-tests/tests/vm/native_vm.rs | 4 +-- .../object_modules/role_assignment/package.rs | 6 ++++- radix-engine/src/system/payload_validation.rs | 8 +++++- radix-engine/src/system/system.rs | 26 +++++++++---------- radix-engine/src/system/system_callback.rs | 3 +-- .../src/system/system_callback_api.rs | 2 +- radix-transactions/src/model/executable.rs | 10 ------- .../ledger_simulator/inject_costing_err.rs | 8 +++--- 9 files changed, 34 insertions(+), 35 deletions(-) diff --git a/radix-engine-tests/tests/kernel/kernel_open_substate.rs b/radix-engine-tests/tests/kernel/kernel_open_substate.rs index 597ecc363e9..42b22717b51 100644 --- a/radix-engine-tests/tests/kernel/kernel_open_substate.rs +++ b/radix-engine-tests/tests/kernel/kernel_open_substate.rs @@ -53,7 +53,7 @@ pub fn test_open_substate_of_invisible_package_address() { // Create kernel let mut system = System { - executable: Executable::mock(), + executable: (), blueprint_cache: NonIterMap::new(), auth_cache: NonIterMap::new(), schema_cache: NonIterMap::new(), diff --git a/radix-engine-tests/tests/vm/native_vm.rs b/radix-engine-tests/tests/vm/native_vm.rs index c449efc3f7e..80d8395eed7 100644 --- a/radix-engine-tests/tests/vm/native_vm.rs +++ b/radix-engine-tests/tests/vm/native_vm.rs @@ -73,7 +73,7 @@ fn panics_can_be_caught_in_the_native_vm_and_converted_into_results() { let intent_hash = Hash([0; 32]); let mut system = System { - executable: Executable::mock(), + executable: (), blueprint_cache: NonIterMap::new(), auth_cache: NonIterMap::new(), schema_cache: NonIterMap::new(), @@ -155,7 +155,7 @@ fn any_panics_can_be_caught_in_the_native_vm_and_converted_into_results() { let intent_hash = Hash([0; 32]); let mut system = System { - executable: Executable::mock(), + executable: (), blueprint_cache: NonIterMap::new(), auth_cache: NonIterMap::new(), schema_cache: NonIterMap::new(), diff --git a/radix-engine/src/object_modules/role_assignment/package.rs b/radix-engine/src/object_modules/role_assignment/package.rs index b0d7c65f5f6..69115414d53 100644 --- a/radix-engine/src/object_modules/role_assignment/package.rs +++ b/radix-engine/src/object_modules/role_assignment/package.rs @@ -334,7 +334,11 @@ impl RoleAssignmentNativePackage { Ok(ResolvedPermission::AccessRule(rule)) } - fn resolve_update_role_method_permission>, V: SystemCallbackObject, E>( + fn resolve_update_role_method_permission< + Y: KernelApi>, + V: SystemCallbackObject, + E, + >( receiver: &NodeId, module: ModuleId, role_key: &RoleKey, diff --git a/radix-engine/src/system/payload_validation.rs b/radix-engine/src/system/payload_validation.rs index b4de7f0bf03..5137cf68924 100644 --- a/radix-engine/src/system/payload_validation.rs +++ b/radix-engine/src/system/payload_validation.rs @@ -49,7 +49,13 @@ pub enum SchemaOrigin { // SYSTEM ADAPTERS //================== -pub struct SystemServiceTypeInfoLookup<'s, 'a, Y: KernelApi>, V: SystemCallbackObject, E> { +pub struct SystemServiceTypeInfoLookup< + 's, + 'a, + Y: KernelApi>, + V: SystemCallbackObject, + E, +> { system_service: RefCell<&'s mut SystemService<'a, Y, V, E>>, schema_origin: SchemaOrigin, allow_ownership: bool, diff --git a/radix-engine/src/system/system.rs b/radix-engine/src/system/system.rs index 2b74d41a387..c585cafee1c 100644 --- a/radix-engine/src/system/system.rs +++ b/radix-engine/src/system/system.rs @@ -52,7 +52,7 @@ pub const BOOT_LOADER_SYSTEM_VERSION_FIELD_KEY: FieldKey = 1u8; /// Provided to upper layer for invoking lower layer service pub struct SystemService<'a, Y: KernelApi>, V: SystemCallbackObject, E> { pub api: &'a mut Y, - pub phantom: PhantomData<(V,E)>, + pub phantom: PhantomData<(V, E)>, } enum ActorStateRef { @@ -1583,8 +1583,8 @@ impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemObjectApi feature = "std", catch_unwind(crate::utils::catch_unwind_system_panic_transformer) )] -impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemKeyValueEntryApi - for SystemService<'a, Y, V, E> +impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> + SystemKeyValueEntryApi for SystemService<'a, Y, V, E> { // Costing through kernel #[trace_resources] @@ -1720,8 +1720,8 @@ impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemKeyValueE feature = "std", catch_unwind(crate::utils::catch_unwind_system_panic_transformer) )] -impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemKeyValueStoreApi - for SystemService<'a, Y, V, E> +impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> + SystemKeyValueStoreApi for SystemService<'a, Y, V, E> { // Costing through kernel #[trace_resources] @@ -2004,8 +2004,8 @@ impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemActorInde feature = "std", catch_unwind(crate::utils::catch_unwind_system_panic_transformer) )] -impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemActorSortedIndexApi - for SystemService<'a, Y, V, E> +impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> + SystemActorSortedIndexApi for SystemService<'a, Y, V, E> { // Costing through kernel #[trace_resources] @@ -2650,8 +2650,8 @@ impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemActorApi< feature = "std", catch_unwind(crate::utils::catch_unwind_system_panic_transformer) )] -impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemActorKeyValueEntryApi - for SystemService<'a, Y, V, E> +impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> + SystemActorKeyValueEntryApi for SystemService<'a, Y, V, E> { // Costing through kernel #[trace_resources] @@ -2741,8 +2741,8 @@ impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemActorKeyV feature = "std", catch_unwind(crate::utils::catch_unwind_system_panic_transformer) )] -impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemExecutionTraceApi - for SystemService<'a, Y, V, E> +impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> + SystemExecutionTraceApi for SystemService<'a, Y, V, E> { // No costing should be applied #[trace_resources] @@ -2759,8 +2759,8 @@ impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemExecution feature = "std", catch_unwind(crate::utils::catch_unwind_system_panic_transformer) )] -impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> SystemTransactionRuntimeApi - for SystemService<'a, Y, V, E> +impl<'a, Y: KernelApi>, V: SystemCallbackObject, E> + SystemTransactionRuntimeApi for SystemService<'a, Y, V, E> { #[trace_resources] fn get_transaction_hash(&mut self) -> Result { diff --git a/radix-engine/src/system/system_callback.rs b/radix-engine/src/system/system_callback.rs index 61e682380e3..7a2b8b5c8b3 100644 --- a/radix-engine/src/system/system_callback.rs +++ b/radix-engine/src/system/system_callback.rs @@ -198,7 +198,7 @@ impl System { destination_blueprint_id, }), })) - .map(|_| ()) + .map(|_| ()) } else { Ok(()) } @@ -772,7 +772,6 @@ impl System { println!("{:-^120}", "Finish"); } - /// Checks that references exist in the store fn check_references( &mut self, diff --git a/radix-engine/src/system/system_callback_api.rs b/radix-engine/src/system/system_callback_api.rs index 5fc31b4027d..55e98aa3916 100644 --- a/radix-engine/src/system/system_callback_api.rs +++ b/radix-engine/src/system/system_callback_api.rs @@ -20,7 +20,7 @@ pub trait SystemCallbackObject: Sized { + KernelInternalApi> + KernelNodeApi + KernelSubstateApi, - E + E, >( package_address: &PackageAddress, package_export: PackageExport, diff --git a/radix-transactions/src/model/executable.rs b/radix-transactions/src/model/executable.rs index 2ca77966d12..975daa19bb9 100644 --- a/radix-transactions/src/model/executable.rs +++ b/radix-transactions/src/model/executable.rs @@ -172,16 +172,6 @@ impl Executable { } } - pub fn mock() -> Self { - Self { - encoded_instructions: Default::default(), - references: Default::default(), - blobs: Default::default(), - context: ExecutionContext::mock(), - system: false, - } - } - // Consuming builder-like customization methods: pub fn is_system(&self) -> bool { diff --git a/scrypto-test/src/ledger_simulator/inject_costing_err.rs b/scrypto-test/src/ledger_simulator/inject_costing_err.rs index 6dc3848bb52..c216032d93e 100644 --- a/scrypto-test/src/ledger_simulator/inject_costing_err.rs +++ b/scrypto-test/src/ledger_simulator/inject_costing_err.rs @@ -471,8 +471,8 @@ impl<'a, M: SystemCallbackObject + 'a, K: KernelApi>> Kern } } -impl<'a, M: SystemCallbackObject, K: KernelApi>> KernelInternalApi> - for WrappedKernelApi<'a, M, K> +impl<'a, M: SystemCallbackObject, K: KernelApi>> + KernelInternalApi> for WrappedKernelApi<'a, M, K> { fn kernel_get_system_state(&mut self) -> SystemState<'_, System> { let state = self.api.kernel_get_system_state(); @@ -500,8 +500,8 @@ impl<'a, M: SystemCallbackObject, K: KernelApi>> KernelInt } } -impl<'a, M: SystemCallbackObject, K: KernelApi>> KernelApi> - for WrappedKernelApi<'a, M, K> +impl<'a, M: SystemCallbackObject, K: KernelApi>> + KernelApi> for WrappedKernelApi<'a, M, K> { }