diff --git a/pallets/teerex/src/lib.rs b/pallets/teerex/src/lib.rs index 860caee0ae..3c8e331230 100644 --- a/pallets/teerex/src/lib.rs +++ b/pallets/teerex/src/lib.rs @@ -132,6 +132,10 @@ pub mod pallet { #[pallet::getter(fn enclave_count)] pub type EnclaveCount = StorageValue<_, u64, ValueQuery>; + #[pallet::storage] + #[pallet::getter(fn schedule_enclave)] + pub type ScheduleEnclave = StorageValue<_, bool, ValueQuery>; + #[pallet::storage] #[pallet::getter(fn quoting_enclave)] pub type QuotingEnclaveRegistry = StorageValue<_, QuotingEnclave, ValueQuery>; @@ -282,11 +286,15 @@ pub mod pallet { // TODO: imagine this fn is not called for the first time (e.g. when worker restarts), // should we check the current sidechain_blocknumber >= registered // sidechain_blocknumber? - #[cfg(not(feature = "skip-scheduled-enclave-check"))] - ensure!( - ScheduledEnclave::::iter_values().any(|m| m == enclave.mr_enclave), - Error::::EnclaveNotInSchedule - ); + // Dev setup -> SkipScheduledEnclave Extrinsic -> Does it make sense to set in dev + // setup? + let schedule_enclave = ScheduleEnclave::::get(); + if schedule_enclave { + ensure!( + ScheduledEnclave::::iter_values().any(|m| m == enclave.mr_enclave), + Error::::EnclaveNotInSchedule + ); + } Self::add_enclave(&sender, &enclave)?; Self::deposit_event(Event::AddedEnclave(sender, worker_url)); @@ -637,6 +645,18 @@ pub mod pallet { // Do not pay a fee Ok(Pays::No.into()) } + + #[pallet::call_index(31)] + #[pallet::weight(100)] + pub fn set_schedule_enclave( + origin: OriginFor, + schedule_enclave: bool, + ) -> DispatchResultWithPostInfo { + let sender = ensure_root(origin)?; + + >::set(schedule_enclave); + Ok(().into()) + } } #[pallet::error]