Skip to content

Commit

Permalink
Merge pull request #2196 from subspace/permissioned-instantiate-domain
Browse files Browse the repository at this point in the history
Make the instantiate_domain call permissioned
  • Loading branch information
NingLin-P authored Nov 3, 2023
2 parents d529f02 + 2b8da57 commit 22d5e48
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ mod pallet {

/// Randomness source.
type Randomness: RandomnessT<Self::Hash, BlockNumberFor<Self>>;

/// The sudo account id
#[pallet::constant]
type SudoId: Get<Self::AccountId>;
}

#[pallet::pallet]
Expand Down Expand Up @@ -1044,7 +1048,9 @@ mod pallet {
origin: OriginFor<T>,
domain_config: DomainConfig<T::AccountId>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure_root(origin)?;

let who = T::SudoId::get();

let created_at = frame_system::Pallet::<T>::current_block_number();

Expand Down
3 changes: 2 additions & 1 deletion crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl pallet_domains::Config for Test {
type MaxPendingStakingOperation = MaxPendingStakingOperation;
type MaxNominators = MaxNominators;
type Randomness = MockRandomness;
type SudoId = ();
}

impl domain_pallet_executive::Config for Test {
Expand Down Expand Up @@ -476,7 +477,7 @@ pub(crate) fn register_genesis_domain(creator: u64, operator_ids: Vec<OperatorId
+ <Test as pallet_balances::Config>::ExistentialDeposit::get(),
);
crate::Pallet::<Test>::instantiate_domain(
RawOrigin::Signed(creator).into(),
RawOrigin::Root.into(),
DomainConfig {
domain_name: "evm-domain".to_owned(),
runtime_id: 0,
Expand Down
2 changes: 2 additions & 0 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ parameter_types! {
pub const MaxPendingStakingOperation: u32 = 100;
// TODO: reset `MaxNominators` back to `100` once the gemini-3g chain spec is created
pub const MaxNominators: u32 = 0;
pub SudoId: AccountId = Sudo::key().expect("Sudo account must exist");
}

impl pallet_domains::Config for Runtime {
Expand Down Expand Up @@ -632,6 +633,7 @@ impl pallet_domains::Config for Runtime {
type MaxPendingStakingOperation = MaxPendingStakingOperation;
type MaxNominators = MaxNominators;
type Randomness = Subspace;
type SudoId = SudoId;
}

pub struct StakingOnReward;
Expand Down
2 changes: 2 additions & 0 deletions test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ parameter_types! {
pub TreasuryAccount: AccountId = PalletId(*b"treasury").into_account_truncating();
pub const MaxPendingStakingOperation: u32 = 100;
pub const MaxNominators: u32 = 100;
pub SudoId: AccountId = Sudo::key().expect("Sudo account must exist");
}

impl pallet_domains::Config for Runtime {
Expand Down Expand Up @@ -664,6 +665,7 @@ impl pallet_domains::Config for Runtime {
type MaxPendingStakingOperation = MaxPendingStakingOperation;
type MaxNominators = MaxNominators;
type Randomness = Subspace;
type SudoId = SudoId;
}

parameter_types! {
Expand Down

0 comments on commit 22d5e48

Please sign in to comment.