Skip to content

Commit fe42630

Browse files
coax1dclangenb
andauthored
Detect extrinsic failures on untrusted side (#1329)
* waiting for extrinsic success * fixes for clippy --------- Co-authored-by: clangenb <[email protected]>
1 parent 0b09588 commit fe42630

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

service/src/main.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use log::*;
7272
use my_node_runtime::{Hash, Header, RuntimeEvent};
7373
use sgx_types::*;
7474
use substrate_api_client::{
75-
rpc::HandleSubscription, GetHeader, SubmitAndWatch, SubscribeChain, SubscribeEvents, XtStatus,
75+
rpc::HandleSubscription, GetHeader, SubmitAndWatchUntilSuccess, SubscribeChain, SubscribeEvents,
7676
};
7777

7878
#[cfg(feature = "dcap")]
@@ -785,12 +785,18 @@ fn send_extrinsic(
785785
}
786786

787787
println!("[>] Register the TCB info (send the extrinsic)");
788-
let register_qe_block_hash = api
789-
.submit_and_watch_opaque_extrinsic_until(extrinsic.into(), XtStatus::Finalized)
790-
.unwrap()
791-
.block_hash;
792-
println!("[<] Extrinsic got finalized. Block hash: {:?}\n", register_qe_block_hash);
793-
register_qe_block_hash
788+
789+
match api.submit_and_watch_opaque_extrinsic_until_success(extrinsic.into(), true) {
790+
Ok(xt_report) => {
791+
let register_qe_block_hash = xt_report.block_hash;
792+
println!("[<] Extrinsic got finalized. Block hash: {:?}\n", register_qe_block_hash);
793+
register_qe_block_hash
794+
},
795+
Err(e) => {
796+
error!("ExtrinsicFailed {:?}", e);
797+
None
798+
},
799+
}
794800
}
795801

796802
/// Subscribe to the node API finalized heads stream and trigger a parent chain sync

0 commit comments

Comments
 (0)