Skip to content

Commit

Permalink
feat: enable bounty implementation for litentry (#2031)
Browse files Browse the repository at this point in the history
* feat: enable bounty implementation for litentry

* debug: fix bug

* add: bump runtime version
  • Loading branch information
wangminqi authored Aug 20, 2023
1 parent 52741f6 commit 90fa4c2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
28 changes: 23 additions & 5 deletions runtime/litentry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU128, ConstU32, ConstU64, ConstU8, Contains, Everything, InstanceFilter,
ConstU128, ConstU32, ConstU64, ConstU8, Contains, EnsureOrigin, Everything, InstanceFilter,
SortedMembers, WithdrawReasons,
},
weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight},
Expand Down Expand Up @@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("litentry-parachain"),
authoring_version: 1,
// same versioning-mechanism as polkadot: use last digit for minor updates
spec_version: 9167,
spec_version: 9168,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -543,6 +543,21 @@ parameter_types! {
pub const MaximumReasonLength: u32 = 8192;
}

pub struct EnsureRootOrTwoThirdsCouncilWrapper;
impl EnsureOrigin<RuntimeOrigin> for EnsureRootOrTwoThirdsCouncilWrapper {
type Success = Balance;
fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
match EnsureRootOrTwoThirdsCouncil::try_origin(o) {
Ok(_) => Ok(Balance::max_value()),
Err(o) => Err(o),
}
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
Ok(RuntimeOrigin::root())
}
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
Expand All @@ -553,12 +568,13 @@ impl pallet_treasury::Config for Runtime {
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Once passed, at most all is allowed to be spent
type SpendOrigin = EnsureRootOrTwoThirdsCouncilWrapper;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
// Bounties is not enabled yet
type SpendFunds = ();
// Bounties is enabled now
type SpendFunds = Bounties;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type MaxApprovals = ConstU32<100>;
}
Expand Down Expand Up @@ -943,6 +959,8 @@ impl Contains<RuntimeCall> for NormalModeFilter {
RuntimeCall::Vesting(pallet_vesting::Call::vest { .. }) |
// ChainBridge
RuntimeCall::ChainBridge(_) |
// Bounties
RuntimeCall::Bounties(_) |
// BridgeTransfer
RuntimeCall::BridgeTransfer(_) |
// Utility
Expand Down
2 changes: 1 addition & 1 deletion runtime/litmus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("litmus-parachain"),
authoring_version: 1,
// same versioning-mechanism as polkadot: use last digit for minor updates
spec_version: 9167,
spec_version: 9168,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
26 changes: 22 additions & 4 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use frame_support::{
construct_runtime, ord_parameter_types, parameter_types,
traits::{
ConstU128, ConstU32, ConstU64, ConstU8, Contains, ContainsLengthBound, Everything,
InstanceFilter, SortedMembers, WithdrawReasons,
ConstU128, ConstU32, ConstU64, ConstU8, Contains, ContainsLengthBound, EnsureOrigin,
Everything, InstanceFilter, SortedMembers, WithdrawReasons,
},
weights::{constants::RocksDbWeight, ConstantMultiplier, IdentityFee, Weight},
PalletId, RuntimeDebug,
Expand Down Expand Up @@ -152,7 +152,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("rococo-parachain"),
authoring_version: 1,
// same versioning-mechanism as polkadot: use last digit for minor updates
spec_version: 9167,
spec_version: 9168,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -560,6 +560,21 @@ parameter_types! {
pub const MaximumReasonLength: u32 = 8192;
}

pub struct EnsureRootOrTwoThirdsCouncilWrapper;
impl EnsureOrigin<RuntimeOrigin> for EnsureRootOrTwoThirdsCouncilWrapper {
type Success = Balance;
fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
match EnsureRootOrTwoThirdsCouncil::try_origin(o) {
Ok(_) => Ok(Balance::max_value()),
Err(o) => Err(o),
}
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
Ok(RuntimeOrigin::root())
}
}

impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
Expand All @@ -570,7 +585,8 @@ impl pallet_treasury::Config for Runtime {
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
// Once passed, at most all is allowed to be spent
type SpendOrigin = EnsureRootOrTwoThirdsCouncilWrapper;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
Expand Down Expand Up @@ -1051,6 +1067,8 @@ impl Contains<RuntimeCall> for NormalModeFilter {
RuntimeCall::Vesting(pallet_vesting::Call::vest { .. }) |
// ChainBridge
RuntimeCall::ChainBridge(_) |
// Bounties
RuntimeCall::Bounties(_) |
// BridgeTransfer
RuntimeCall::BridgeTransfer(_) |
// XTokens::transfer for normal users
Expand Down

0 comments on commit 90fa4c2

Please sign in to comment.