diff --git a/pallets/tee-worker/src/functions.rs b/pallets/tee-worker/src/functions.rs index fc6d29dc..c0ba2fd0 100644 --- a/pallets/tee-worker/src/functions.rs +++ b/pallets/tee-worker/src/functions.rs @@ -32,7 +32,7 @@ impl Pallet { let mut weight: Weight = Weight::zero(); if let Some(first_holder) = MasterKeyFirstHolder::::get() { - ensure!(first_holder != pbk, Error::::CannotRemoveLastKeyfairy); + ensure!(first_holder != pbk, Error::::CannotExitMasterKeyHolder); } weight = weight.saturating_add(T::DbWeight::get().reads(1)); diff --git a/pallets/tee-worker/src/lib.rs b/pallets/tee-worker/src/lib.rs index a856ae13..b284c92f 100644 --- a/pallets/tee-worker/src/lib.rs +++ b/pallets/tee-worker/src/lib.rs @@ -123,6 +123,10 @@ pub mod pallet { MasterKeyLaunched, + MasterKeyApplied { + worker_pubkey: WorkerPublicKey, + }, + WorkerAdded { pubkey: WorkerPublicKey, attestation_provider: Option, @@ -149,31 +153,13 @@ pub mod pallet { #[pallet::error] pub enum Error { - /// Already registered - AlreadyRegistration, - /// Not a controller account - NotStash, - /// The scheduled error report has been reported once - AlreadyReport, /// Boundedvec conversion error BoundedVecError, - /// Error indicating that the storage has reached its limit - StorageLimitReached, - /// data overrun error - Overflow, NotBond, - NotController, - NonTeeWorker, - VerifyCertFailed, - - TeePodr2PkNotInitialized, - - Existed, - CesealRejected, InvalidIASSigningCert, @@ -195,7 +181,7 @@ pub mod pallet { WrongTeeType, InvalidSender, - InvalidPubKey, + InvalidWorkerPubKey, MalformedSignature, InvalidSignatureLength, InvalidSignature, @@ -207,16 +193,14 @@ pub mod pallet { MasterKeyAlreadyLaunched, MasterKeyLaunching, MasterKeyMismatch, - InvalidMasterPubkey, MasterKeyUninitialized, InvalidMasterKeyApplySigningTime, /// Ceseal related CesealAlreadyExists, - CesealNotFound, - /// Additional - NotImplemented, - CannotRemoveLastKeyfairy, - /// Endpoint related + CesealBinNotFound, + + CannotExitMasterKeyHolder, + EmptyEndpoint, InvalidEndpointSigningTime, @@ -645,7 +629,7 @@ pub mod pallet { ); // Validate the public key - ensure!(Workers::::contains_key(endpoint_payload.pubkey), Error::::InvalidPubKey); + ensure!(Workers::::contains_key(endpoint_payload.pubkey), Error::::InvalidWorkerPubKey); Endpoints::::insert(endpoint_payload.pubkey, endpoint); @@ -677,10 +661,10 @@ pub mod pallet { ); // Validate the public key - ensure!(Workers::::contains_key(payload.pubkey), Error::::InvalidPubKey); - - Self::push_message(MasterKeyApply::Apply(payload.pubkey, payload.ecdh_pubkey)); + ensure!(Workers::::contains_key(payload.pubkey), Error::::InvalidWorkerPubKey); + Self::push_message(MasterKeyApply::Apply(payload.pubkey.clone(), payload.ecdh_pubkey)); + Self::deposit_event(Event::::MasterKeyApplied { worker_pubkey: payload.pubkey }); Ok(()) } @@ -713,7 +697,7 @@ pub mod pallet { T::GovernanceOrigin::ensure_origin(origin)?; let mut allowlist = CesealBinAllowList::::get(); - ensure!(allowlist.contains(&ceseal_hash), Error::::CesealNotFound); + ensure!(allowlist.contains(&ceseal_hash), Error::::CesealBinNotFound); allowlist.retain(|h| *h != ceseal_hash); CesealBinAllowList::::put(allowlist); @@ -951,7 +935,7 @@ impl TeeWorkerHandler, BlockNumberFor> for Pallet } fn get_master_publickey() -> Result { - let pk = MasterPubkey::::try_get().map_err(|_| Error::::TeePodr2PkNotInitialized)?; + let pk = MasterPubkey::::try_get().map_err(|_| Error::::MasterKeyUninitialized)?; Ok(pk) }