Skip to content

Commit

Permalink
replace omni-executor check with TEEOrigin (#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
kziemianek authored Nov 6, 2024
1 parent 6220c44 commit 183deab
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 34 deletions.
31 changes: 1 addition & 30 deletions parachain/pallets/omni-account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ pub mod pallet {

/// Convert an `Identity` to OmniAccount type
type OmniAccountConverter: OmniAccountConverter<OmniAccount = Self::AccountId>;

type SetOmniExecutorOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
}

pub type MemberAccounts<T> = BoundedVec<MemberAccount, <T as Config>::MaxAccountStoreLength>;
Expand All @@ -124,10 +122,6 @@ pub mod pallet {
pub type MemberAccountHash<T: Config> =
StorageMap<Hasher = Blake2_128Concat, Key = H256, Value = T::AccountId>;

#[pallet::storage]
#[pallet::getter(fn omni_executor)]
pub type OmniExecutor<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
Expand All @@ -149,8 +143,6 @@ pub mod pallet {
IntentRequested { who: T::AccountId, intent: Intent },
/// Intent is executed
IntentExecuted { who: T::AccountId, intent: Intent, result: IntentExecutionResult },
/// Omni executor is set
OmniExecutorSet { omni_executor: T::AccountId },
}

#[pallet::error]
Expand All @@ -161,7 +153,6 @@ pub mod pallet {
InvalidAccount,
UnknownAccountStore,
EmptyAccount,
RequireOmniExecutor,
}

#[pallet::call]
Expand Down Expand Up @@ -363,22 +354,10 @@ pub mod pallet {
intent: Intent,
result: IntentExecutionResult,
) -> DispatchResult {
Self::ensure_omni_executor(origin)?;
let _ = T::TEECallOrigin::ensure_origin(origin.clone())?;
Self::deposit_event(Event::IntentExecuted { who, intent, result });
Ok(())
}

#[pallet::call_index(9)]
#[pallet::weight((195_000_000, DispatchClass::Normal, Pays::No))]
pub fn set_omni_executor(
origin: OriginFor<T>,
new_omni_executor: T::AccountId,
) -> DispatchResult {
T::SetOmniExecutorOrigin::ensure_origin(origin)?;
OmniExecutor::<T>::put(new_omni_executor.clone());
Self::deposit_event(Event::OmniExecutorSet { omni_executor: new_omni_executor });
Ok(())
}
}

impl<T: Config> Pallet<T> {
Expand Down Expand Up @@ -416,14 +395,6 @@ pub mod pallet {

Ok(member_accounts)
}

fn ensure_omni_executor(origin: OriginFor<T>) -> DispatchResult {
ensure!(
Some(ensure_signed(origin)?) == Self::omni_executor(),
Error::<T>::RequireOmniExecutor
);
Ok(())
}
}
}

Expand Down
1 change: 0 additions & 1 deletion parachain/pallets/omni-account/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ impl pallet_omni_account::Config for TestRuntime {
type MaxAccountStoreLength = ConstU32<3>;
type OmniAccountOrigin = EnsureOmniAccount<Self::AccountId>;
type OmniAccountConverter = DefaultOmniAccountConverter;
type SetOmniExecutorOrigin = EnsureRoot<Self::AccountId>;
}

pub fn get_tee_signer() -> SystemAccountId {
Expand Down
1 change: 0 additions & 1 deletion parachain/runtime/litentry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,6 @@ impl pallet_omni_account::Config for Runtime {
type MaxAccountStoreLength = ConstU32<64>;
type OmniAccountOrigin = EnsureOmniAccount;
type OmniAccountConverter = DefaultOmniAccountConverter;
type SetOmniExecutorOrigin = EnsureRootOrHalfCouncil;
}

impl pallet_bitacross::Config for Runtime {
Expand Down
1 change: 0 additions & 1 deletion parachain/runtime/paseo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,6 @@ impl pallet_omni_account::Config for Runtime {
type MaxAccountStoreLength = ConstU32<64>;
type OmniAccountOrigin = EnsureOmniAccount;
type OmniAccountConverter = DefaultOmniAccountConverter;
type SetOmniExecutorOrigin = EnsureRootOrAllCouncil;
}

impl pallet_bitacross::Config for Runtime {
Expand Down
1 change: 0 additions & 1 deletion parachain/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,6 @@ impl pallet_omni_account::Config for Runtime {
type MaxAccountStoreLength = ConstU32<64>;
type OmniAccountOrigin = EnsureOmniAccount;
type OmniAccountConverter = DefaultOmniAccountConverter;
type SetOmniExecutorOrigin = EnsureRootOrAllCouncil;
}

impl pallet_bitacross::Config for Runtime {
Expand Down

0 comments on commit 183deab

Please sign in to comment.