Skip to content

Commit

Permalink
choir: some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
metricaez committed Nov 28, 2024
1 parent 34e2220 commit 72fb23d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 101 deletions.
102 changes: 3 additions & 99 deletions node/runtime-interfaces/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ use crate::sandbox_util::{SandboxBackend, Store};
use sp_wasm_interface::Function;
use wasmi::memory_units::Pages;
use wasmi::MemoryRef;
use wasmi::TableInstance;
use wasmi::TableRef;
use wasmi::{TableDescriptor, TableInstance};

#[cfg(feature = "std")]
use sp_externalities::{Extensions, ExternalitiesExt};
use sp_externalities::ExternalitiesExt;

pub use sp_externalities::MultiRemovalResults;

Expand Down Expand Up @@ -82,7 +82,7 @@ pub trait Sandbox {
log::info!("Going through the memory_new function");

let function_executor: FunctionExecutor = FunctionExecutor::new(initial, maximum);
self.register_extension(SandboxExt::from(function_executor));
let _ = self.register_extension(SandboxExt::from(function_executor));

log::info!("Extension should be registered");

Expand Down Expand Up @@ -200,99 +200,3 @@ impl FunctionExecutor {
}

unsafe impl Send for FunctionExecutor {}

// pub struct SandboxTest {}
//
// /// Something that provides access to the sandbox.
// pub trait SandboxT {
// /// Get sandbox memory from the `memory_id` instance at `offset` into the given buffer.
// fn memory_get(
// &mut self,
// memory_id: MemoryId,
// offset: WordSize,
// buf_ptr: Pointer<u8>,
// buf_len: WordSize,
// ) -> SandboxResult<u32>;
// /// Set sandbox memory from the given value.
// fn memory_set(
// &mut self,
// memory_id: MemoryId,
// offset: WordSize,
// val_ptr: Pointer<u8>,
// val_len: WordSize,
// ) -> SandboxResult<u32>;
// /// Delete a memory instance.
// fn memory_teardown(&mut self, memory_id: MemoryId) -> SandboxResult<()>;
// /// Create a new memory instance with the given `initial` size and the `maximum` size.
// /// The size is given in wasm pages.
// fn memory_new(&mut self, initial: u32, maximum: u32) -> SandboxResult<MemoryId>;
// /// Invoke an exported function by a name.
// fn invoke(
// &mut self,
// instance_id: u32,
// export_name: &str,
// args: &[u8],
// return_val: Pointer<u8>,
// return_val_len: WordSize,
// state: u32,
// ) -> SandboxResult<u32>;
// /// Delete a sandbox instance.
// fn instance_teardown(&mut self, instance_id: u32) -> SandboxResult<()>;
// /// Create a new sandbox instance.
// // fn instance_new(
// // &mut self,
// // dispatch_thunk_id: u32,
// // wasm: &[u8],
// // raw_env_def: &[u8],
// // state: u32,
// // ) -> Result<u32>;
//
// /// Get the value from a global with the given `name`. The sandbox is determined by the
// /// given `instance_idx` instance.
// ///
// /// Returns `Some(_)` when the requested global variable could be found.
// fn get_global_val(&self, instance_idx: u32, name: &str) -> SandboxResult<Option<Value>>;
//
// /// Instantiate a new sandbox instance with the given `wasm_code`.
// fn instantiate(
// &mut self,
// dispatch_thunk: u32,
// wasm_code: &[u8],
// env_def: &[u8],
// state_ptr: Pointer<u8>,
// ) -> u32;
// }
//
// impl SandboxT for SandboxTest {
// fn memory_get(&mut self, memory_id: MemoryId, offset: WordSize, buf_ptr: Pointer<u8>, buf_len: WordSize) -> SandboxResult<u32> {
// todo!()
// }

// fn memory_set(&mut self, memory_id: MemoryId, offset: WordSize, val_ptr: Pointer<u8>, val_len: WordSize) -> SandboxResult<u32> {
// todo!()
// }

// fn memory_teardown(&mut self, memory_id: MemoryId) -> SandboxResult<()> {
// todo!()
// }

// fn memory_new(&mut self, initial: u32, maximum: u32) -> SandboxResult<MemoryId> {
// todo!()
// }

// fn invoke(&mut self, instance_id: u32, export_name: &str, args: &[u8], return_val: Pointer<u8>, return_val_len: WordSize, state: u32) -> SandboxResult<u32> {
// todo!()
// }

// fn instance_teardown(&mut self, instance_id: u32) -> SandboxResult<()> {
// todo!()
// }

// fn get_global_val(&self, instance_idx: u32, name: &str) -> SandboxResult<Option<Value>> {
// todo!()
// }

// fn instantiate(&mut self, dispatch_thunk: u32, wasm_code: &[u8], env_def: &[u8], state_ptr: Pointer<u8>) -> u32 {
// todo!()
// }
// }
2 changes: 0 additions & 2 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ pub use cere_client::{
AbstractClient, Client, ClientHandle, ExecuteWithClient, FullBackend, FullClient,
RuntimeApiCollection,
};
use cere_runtime_interfaces::{FunctionExecutor, SandboxExt};
pub use chain_spec::{CereChainSpec, CereDevChainSpec};
pub use node_primitives::{Block, BlockNumber};
use sc_executor::{HeapAllocStrategy, DEFAULT_HEAP_ALLOC_STRATEGY};
pub use sc_service::ChainSpec;
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
pub use sp_api::ConstructRuntimeApi;
use sp_externalities::Extensions;

/// The minimum period of blocks on which justifications will be
/// imported and generated.
Expand Down

0 comments on commit 72fb23d

Please sign in to comment.