From 0ae78c1bd81e07b62e60096b6b00b072c3791137 Mon Sep 17 00:00:00 2001 From: ytqaljn <2716693942@qq.com> Date: Tue, 7 Nov 2023 17:53:31 -0800 Subject: [PATCH] feat: add end point param in tee register interface --- c-pallets/tee-worker/src/lib.rs | 9 +++++---- c-pallets/tee-worker/src/types.rs | 2 +- primitives/common/src/lib.rs | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/c-pallets/tee-worker/src/lib.rs b/c-pallets/tee-worker/src/lib.rs index d9016098..6e57d7d7 100644 --- a/c-pallets/tee-worker/src/lib.rs +++ b/c-pallets/tee-worker/src/lib.rs @@ -143,10 +143,10 @@ pub mod pallet { pub fn register( origin: OriginFor, stash_account: AccountOf, - node_key: NodePublicKey, peer_id: PeerId, podr2_pbk: Podr2Key, sgx_attestation_report: SgxAttestationReport, + end_point: EndPoint, ) -> DispatchResult { let sender = ensure_signed(origin)?; //Even if the primary key is not present here, panic will not be caused @@ -159,6 +159,7 @@ pub mod pallet { let mut identity = Vec::new(); identity.append(&mut peer_id.to_vec()); identity.append(&mut podr2_pbk.to_vec()); + identity.append(&mut end_point.to_vec()); let identity_hashing = sp_io::hashing::sha2_256(&identity); let _ = verify_miner_cert( &sgx_attestation_report.sign, @@ -170,8 +171,8 @@ pub mod pallet { let tee_worker_info = TeeWorkerInfo:: { controller_account: sender.clone(), peer_id: peer_id.clone(), - node_key, stash_account: stash_account, + end_point, }; if TeeWorkerMap::::count() == 0 { @@ -251,16 +252,16 @@ pub mod pallet { origin: OriginFor, stash_account: AccountOf, controller_account: AccountOf, - node_key: NodePublicKey, peer_id: PeerId, + end_point: EndPoint, ) -> DispatchResult { let _ = ensure_root(origin)?; let tee_worker_info = TeeWorkerInfo:: { controller_account: controller_account.clone(), peer_id: peer_id.clone(), - node_key, stash_account: stash_account, + end_point, }; TeeWorkerMap::::insert(&controller_account, tee_worker_info); diff --git a/c-pallets/tee-worker/src/types.rs b/c-pallets/tee-worker/src/types.rs index e3b25601..95f394d1 100644 --- a/c-pallets/tee-worker/src/types.rs +++ b/c-pallets/tee-worker/src/types.rs @@ -6,8 +6,8 @@ use super::*; pub struct TeeWorkerInfo { pub controller_account: AccountOf, pub peer_id: PeerId, - pub node_key: NodePublicKey, pub stash_account: AccountOf, + pub end_point: EndPoint, } #[derive(PartialEq, Eq, Encode, Decode, Clone, RuntimeDebug, Default, MaxEncodedLen, TypeInfo)] diff --git a/primitives/common/src/lib.rs b/primitives/common/src/lib.rs index f1220ea8..d98e9477 100644 --- a/primitives/common/src/lib.rs +++ b/primitives/common/src/lib.rs @@ -108,6 +108,7 @@ pub type Mrenclave = [u8; 32]; pub type PeerId = [u8; 38]; pub type Podr2Key = [u8; 270]; pub type TeeRsaSignature = [u8; 256]; +pub type EndPoint = BoundedVec>; pub const M_BYTE: u128 = 1_048_576; pub const G_BYTE: u128 = 1_048_576 * 1024;