Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove obsolete trigger_parentchain_block ffi
  • Loading branch information
clangenb committed Nov 29, 2023
commit 1ab60ee4627de70380a8db01ed9d251f02203b36
7 changes: 0 additions & 7 deletions core-primitives/enclave-api/ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ extern "C" {
shard_size: u32,
) -> sgx_status_t;

pub fn trigger_parentchain_block_import(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
parentchain_id: *const u8,
parentchain_id_size: u32,
) -> sgx_status_t;

pub fn execute_trusted_calls(eid: sgx_enclave_id_t, retval: *mut sgx_status_t) -> sgx_status_t;

pub fn sync_parentchain(
Expand Down
26 changes: 0 additions & 26 deletions core-primitives/enclave-api/src/enclave_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ pub trait EnclaveBase: Send + Sync + 'static {
/// Initialize a new shard vault account and register enclave signer as its proxy.
fn init_proxied_shard_vault(&self, shard: &ShardIdentifier) -> EnclaveResult<()>;

/// Trigger the import of parentchain block explicitly. Used when initializing a light-client
/// with a triggered import dispatcher.
fn trigger_parentchain_block_import(&self, parentchain_id: &ParentchainId)
-> EnclaveResult<()>;

fn set_nonce(&self, nonce: u32, parentchain_id: ParentchainId) -> EnclaveResult<()>;

fn set_node_metadata(
Expand Down Expand Up @@ -202,27 +197,6 @@ mod impl_ffi {

Ok(())
}
fn trigger_parentchain_block_import(
&self,
parentchain_id: &ParentchainId,
) -> EnclaveResult<()> {
let mut retval = sgx_status_t::SGX_SUCCESS;
let parentchain_id_enc = parentchain_id.encode();

let result = unsafe {
ffi::trigger_parentchain_block_import(
self.eid,
&mut retval,
parentchain_id_enc.as_ptr(),
parentchain_id_enc.len() as u32,
)
};

ensure!(result == sgx_status_t::SGX_SUCCESS, Error::Sgx(result));
ensure!(retval == sgx_status_t::SGX_SUCCESS, Error::Sgx(retval));

Ok(())
}

fn set_nonce(&self, nonce: u32, parentchain_id: ParentchainId) -> EnclaveResult<()> {
let mut retval = sgx_status_t::SGX_SUCCESS;
Expand Down
4 changes: 0 additions & 4 deletions enclave-runtime/Enclave.edl
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ enclave {
[in, size=shard_size] uint8_t* shard, uint32_t shard_size
);

public sgx_status_t trigger_parentchain_block_import(
[in, size=parentchain_id_size] uint8_t* parentchain_id, uint32_t parentchain_id_size
);

public sgx_status_t execute_trusted_calls();

public sgx_status_t sync_parentchain(
Expand Down
86 changes: 0 additions & 86 deletions enclave-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,92 +604,6 @@ fn validate_events(
Ok(())
}

/// Triggers the import of parentchain blocks when using a queue to sync parentchain block import
/// with sidechain block production.
///
/// This trigger is only useful in combination with a `TriggeredDispatcher` and sidechain. In case no
/// sidechain and the `ImmediateDispatcher` are used, this function is obsolete.
#[no_mangle]
pub unsafe extern "C" fn trigger_parentchain_block_import(
parentchain_id: *const u8,
parentchain_id_size: u32,
) -> sgx_status_t {
let parentchain_id =
match ParentchainId::decode_raw(parentchain_id, parentchain_id_size as usize) {
Ok(id) => id,
Err(e) => {
error!("Could not decode parentchain id: {:?}", e);
return sgx_status_t::SGX_ERROR_UNEXPECTED
},
};

match internal_trigger_parentchain_block_import(&parentchain_id) {
Ok(()) => sgx_status_t::SGX_SUCCESS,
Err(e) => {
error!("Failed to trigger import of parentchain blocks: {:?}", e);
sgx_status_t::SGX_ERROR_UNEXPECTED
},
}
}

fn internal_trigger_parentchain_block_import(id: &ParentchainId) -> Result<()> {
let _maybe_latest_block = match id {
ParentchainId::Integritee => {
if let Ok(handler) = GLOBAL_INTEGRITEE_SOLOCHAIN_HANDLER_COMPONENT.get() {
handler
.import_dispatcher
.triggered_dispatcher()
.ok_or(Error::ExpectedTriggeredImportDispatcher)?
.import_all()?
} else if let Ok(handler) = GLOBAL_INTEGRITEE_PARACHAIN_HANDLER_COMPONENT.get() {
handler
.import_dispatcher
.triggered_dispatcher()
.ok_or(Error::ExpectedTriggeredImportDispatcher)?
.import_all()?
} else {
return Err(Error::NoIntegriteeParentchainAssigned)
}
},
ParentchainId::TargetA => {
if let Ok(handler) = GLOBAL_TARGET_A_SOLOCHAIN_HANDLER_COMPONENT.get() {
handler
.import_dispatcher
.triggered_dispatcher()
.ok_or(Error::ExpectedTriggeredImportDispatcher)?
.import_all()?
} else if let Ok(handler) = GLOBAL_TARGET_A_PARACHAIN_HANDLER_COMPONENT.get() {
handler
.import_dispatcher
.triggered_dispatcher()
.ok_or(Error::ExpectedTriggeredImportDispatcher)?
.import_all()?
} else {
return Err(Error::NoTargetAParentchainAssigned)
}
},
ParentchainId::TargetB => {
if let Ok(handler) = GLOBAL_TARGET_B_SOLOCHAIN_HANDLER_COMPONENT.get() {
handler
.import_dispatcher
.triggered_dispatcher()
.ok_or(Error::ExpectedTriggeredImportDispatcher)?
.import_all()?
} else if let Ok(handler) = GLOBAL_TARGET_B_PARACHAIN_HANDLER_COMPONENT.get() {
handler
.import_dispatcher
.triggered_dispatcher()
.ok_or(Error::ExpectedTriggeredImportDispatcher)?
.import_all()?
} else {
return Err(Error::NoTargetBParentchainAssigned)
}
},
};

Ok(())
}

// This is required, because `ring` / `ring-xous` would not compile without it non-release (debug) mode.
// See #1200 for more details.
#[cfg(debug_assertions)]
Expand Down
4 changes: 0 additions & 4 deletions service/src/tests/mocks/enclave_api_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ impl EnclaveBase for EnclaveMock {
unimplemented!()
}

fn trigger_parentchain_block_import(&self, _: &ParentchainId) -> EnclaveResult<()> {
unimplemented!()
}

fn set_nonce(&self, _: u32, _: ParentchainId) -> EnclaveResult<()> {
unimplemented!()
}
Expand Down