Skip to content

Commit

Permalink
Remove Executable::mock
Browse files Browse the repository at this point in the history
  • Loading branch information
talekhinezh committed Aug 10, 2024
1 parent c735b6c commit 75443e0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion radix-engine-tests/tests/kernel/kernel_open_substate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions radix-engine-tests/tests/vm/native_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 5 additions & 1 deletion radix-engine/src/object_modules/role_assignment/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ impl RoleAssignmentNativePackage {
Ok(ResolvedPermission::AccessRule(rule))
}

fn resolve_update_role_method_permission<Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>(
fn resolve_update_role_method_permission<
Y: KernelApi<System<V, E>>,
V: SystemCallbackObject,
E,
>(
receiver: &NodeId,
module: ModuleId,
role_key: &RoleKey,
Expand Down
8 changes: 7 additions & 1 deletion radix-engine/src/system/payload_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ pub enum SchemaOrigin {
// SYSTEM ADAPTERS
//==================

pub struct SystemServiceTypeInfoLookup<'s, 'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> {
pub struct SystemServiceTypeInfoLookup<
's,
'a,
Y: KernelApi<System<V, E>>,
V: SystemCallbackObject,
E,
> {
system_service: RefCell<&'s mut SystemService<'a, Y, V, E>>,
schema_origin: SchemaOrigin,
allow_ownership: bool,
Expand Down
26 changes: 13 additions & 13 deletions radix-engine/src/system/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<System<V, E>>, V: SystemCallbackObject, E> {
pub api: &'a mut Y,
pub phantom: PhantomData<(V,E)>,
pub phantom: PhantomData<(V, E)>,
}

enum ActorStateRef {
Expand Down Expand Up @@ -1583,8 +1583,8 @@ impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemObjectApi
feature = "std",
catch_unwind(crate::utils::catch_unwind_system_panic_transformer)
)]
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemKeyValueEntryApi<RuntimeError>
for SystemService<'a, Y, V, E>
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>
SystemKeyValueEntryApi<RuntimeError> for SystemService<'a, Y, V, E>
{
// Costing through kernel
#[trace_resources]
Expand Down Expand Up @@ -1720,8 +1720,8 @@ impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemKeyValueE
feature = "std",
catch_unwind(crate::utils::catch_unwind_system_panic_transformer)
)]
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemKeyValueStoreApi<RuntimeError>
for SystemService<'a, Y, V, E>
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>
SystemKeyValueStoreApi<RuntimeError> for SystemService<'a, Y, V, E>
{
// Costing through kernel
#[trace_resources]
Expand Down Expand Up @@ -2004,8 +2004,8 @@ impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemActorInde
feature = "std",
catch_unwind(crate::utils::catch_unwind_system_panic_transformer)
)]
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemActorSortedIndexApi<RuntimeError>
for SystemService<'a, Y, V, E>
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>
SystemActorSortedIndexApi<RuntimeError> for SystemService<'a, Y, V, E>
{
// Costing through kernel
#[trace_resources]
Expand Down Expand Up @@ -2650,8 +2650,8 @@ impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemActorApi<
feature = "std",
catch_unwind(crate::utils::catch_unwind_system_panic_transformer)
)]
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemActorKeyValueEntryApi<RuntimeError>
for SystemService<'a, Y, V, E>
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>
SystemActorKeyValueEntryApi<RuntimeError> for SystemService<'a, Y, V, E>
{
// Costing through kernel
#[trace_resources]
Expand Down Expand Up @@ -2741,8 +2741,8 @@ impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemActorKeyV
feature = "std",
catch_unwind(crate::utils::catch_unwind_system_panic_transformer)
)]
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemExecutionTraceApi<RuntimeError>
for SystemService<'a, Y, V, E>
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>
SystemExecutionTraceApi<RuntimeError> for SystemService<'a, Y, V, E>
{
// No costing should be applied
#[trace_resources]
Expand All @@ -2759,8 +2759,8 @@ impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemExecution
feature = "std",
catch_unwind(crate::utils::catch_unwind_system_panic_transformer)
)]
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E> SystemTransactionRuntimeApi<RuntimeError>
for SystemService<'a, Y, V, E>
impl<'a, Y: KernelApi<System<V, E>>, V: SystemCallbackObject, E>
SystemTransactionRuntimeApi<RuntimeError> for SystemService<'a, Y, V, E>
{
#[trace_resources]
fn get_transaction_hash(&mut self) -> Result<Hash, RuntimeError> {
Expand Down
3 changes: 1 addition & 2 deletions radix-engine/src/system/system_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<C: SystemCallbackObject, E> System<C, E> {
destination_blueprint_id,
}),
}))
.map(|_| ())
.map(|_| ())
} else {
Ok(())
}
Expand Down Expand Up @@ -772,7 +772,6 @@ impl<C: SystemCallbackObject> System<C, Executable> {
println!("{:-^120}", "Finish");
}


/// Checks that references exist in the store
fn check_references<S: BootStore + CommitableSubstateStore>(
&mut self,
Expand Down
2 changes: 1 addition & 1 deletion radix-engine/src/system/system_callback_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait SystemCallbackObject: Sized {
+ KernelInternalApi<System<Self, E>>
+ KernelNodeApi
+ KernelSubstateApi<SystemLockData>,
E
E,
>(
package_address: &PackageAddress,
package_export: PackageExport,
Expand Down
10 changes: 0 additions & 10 deletions radix-transactions/src/model/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions scrypto-test/src/ledger_simulator/inject_costing_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ impl<'a, M: SystemCallbackObject + 'a, K: KernelApi<InjectCostingError<M>>> Kern
}
}

impl<'a, M: SystemCallbackObject, K: KernelApi<InjectCostingError<M>>> KernelInternalApi<System<M, Executable>>
for WrappedKernelApi<'a, M, K>
impl<'a, M: SystemCallbackObject, K: KernelApi<InjectCostingError<M>>>
KernelInternalApi<System<M, Executable>> for WrappedKernelApi<'a, M, K>
{
fn kernel_get_system_state(&mut self) -> SystemState<'_, System<M, Executable>> {
let state = self.api.kernel_get_system_state();
Expand Down Expand Up @@ -500,8 +500,8 @@ impl<'a, M: SystemCallbackObject, K: KernelApi<InjectCostingError<M>>> KernelInt
}
}

impl<'a, M: SystemCallbackObject, K: KernelApi<InjectCostingError<M>>> KernelApi<System<M, Executable>>
for WrappedKernelApi<'a, M, K>
impl<'a, M: SystemCallbackObject, K: KernelApi<InjectCostingError<M>>>
KernelApi<System<M, Executable>> for WrappedKernelApi<'a, M, K>
{
}

Expand Down

0 comments on commit 75443e0

Please sign in to comment.