Skip to content

Commit

Permalink
feat: 🎸 add Treasury and Bounties at bifrost runtime (#224)
Browse files Browse the repository at this point in the history
* feat: 🎸 add Treasury and Bounties at bifrost runtime

* style: 💄 modify Cargo.toml format
  • Loading branch information
yooml committed Aug 16, 2021
1 parent 4c4e1eb commit f25ff2c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/service/src/chain_spec/bifrost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub fn bifrost_genesis(
},
balances: BalancesConfig { balances },
indices: IndicesConfig { indices: vec![] },
treasury: Default::default(),
sudo: SudoConfig { key: root_key.clone() },
parachain_info: ParachainInfoConfig { parachain_id: id },
collator_selection: CollatorSelectionConfig {
Expand Down
43 changes: 25 additions & 18 deletions runtime/bifrost/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,68 @@ build = "build.rs"

[dependencies]
# third-party dependencies
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [
"derive",
"max-encoded-len",
] }
log = { version = "0.4.14", default-features = false }
# primitives
node-primitives = { default-features = false, path = "../../node/primitives" }
sp-block-builder = { default-features = false, version = "3.0.0"}
sp-api = { version = "3.0.0", default-features = false }
sp-arithmetic = { version = "3.0.0", default-features = false }
sp-block-builder = { default-features = false, version = "3.0.0" }
sp-consensus-aura = { version = "0.9.0", default-features = false }
sp-core = { version = "3.0.0", default-features = false }
sp-inherents = { version = "3.0.0", default-features = false }
sp-offchain = { version = "3.0.0", default-features = false }
sp-core = { version = "3.0.0", default-features = false }
sp-std = { version = "3.0.0", default-features = false }
sp-api = { version = "3.0.0", default-features = false }
sp-runtime = { version = "3.0.0", default-features = false }
sp-session = { version = "3.0.0", default-features = false }
sp-std = { version = "3.0.0", default-features = false }
sp-transaction-pool = { version = "3.0.0", default-features = false }
sp-version = { version = "3.0.0", default-features = false }
sp-consensus-aura = { version = "0.9.0", default-features = false }

# frame dependencies
frame-benchmarking = { version = "3.0.0", default-features = false, optional = true }
frame-try-runtime = { version = "0.9.0", default-features = false, optional = true }
frame-executive = { version = "3.0.0", default-features = false }
frame-support = { version = "3.0.0", default-features = false }
frame-system = { version = "3.0.0", default-features = false }
frame-system-rpc-runtime-api = { version = "3.0.0", default-features = false }
frame-try-runtime = { version = "0.9.0", default-features = false, optional = true }
pallet-aura = { version = "3.0.0", default-features = false }
pallet-authorship = { version = "3.0.0", default-features = false }
pallet-balances = { version = "3.0.0", default-features = false }
pallet-bounties = { version = "3.0.0", default-features = false }
pallet-collective = { version = "3.0.0", default-features = false }
pallet-democracy = { version = "3.0.0", default-features = false }
pallet-indices = { version = "3.0.0", default-features = false }
pallet-randomness-collective-flip = { version = "3.0.0", default-features = false }
pallet-scheduler = { version = "3.0.0", default-features = false }
pallet-session = { version = "3.0.0", default-features = false }
pallet-sudo = { version = "3.0.0", default-features = false }
pallet-timestamp = { version = "3.0.0", default-features = false }
pallet-transaction-payment = { version = "3.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "3.0.0", default-features = false }
pallet-treasury = { version = "3.0.0", default-features = false }
pallet-utility = { version = "3.0.0", default-features = false }
pallet-scheduler = { version = "3.0.0", default-features = false }
pallet-aura = { version = "3.0.0", default-features = false }

# Cumulus dependencies
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }

# Polkadot dependencies
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }

# Bifrost
pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false }
Expand All @@ -78,7 +84,6 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran

[features]
default = ["std"]
with-tracing = [ "frame-executive/with-tracing" ]
std = [
"codec/std",
"log/std",
Expand All @@ -97,14 +102,15 @@ std = [
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"sp-consensus-aura/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-inherents/std",
"sp-offchain/std",
"sp-core/std",
"sp-std/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
"sp-session/std",
"sp-transaction-pool/std",
"parachain-info/std",
Expand All @@ -127,6 +133,7 @@ std = [
"orml-traits/std",
"orml-tokens/std",
]
with-tracing = ["frame-executive/with-tracing"]

runtime-benchmarks = [
"frame-benchmarking",
Expand Down
52 changes: 52 additions & 0 deletions runtime/bifrost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use frame_system::limits::{BlockLength, BlockWeights};
pub use pallet_balances::Call as BalancesCall;
pub use pallet_timestamp::Call as TimestampCall;
use sp_api::impl_runtime_apis;
use sp_arithmetic::Percent;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::OpaqueMetadata;
#[cfg(any(feature = "std", test))]
Expand Down Expand Up @@ -548,6 +549,55 @@ impl orml_tokens::Config for Runtime {
type WeightInfo = ();
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 50 * DOLLARS;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");

pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
pub const DataDepositPerByte: Balance = 10 * CENTS;
pub const BountyDepositBase: Balance = 1 * DOLLARS;
pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
pub const MaximumReasonLength: u32 = 16384;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: Balance = 10 * DOLLARS;
pub const MaxApprovals: u32 = 100;
}

impl pallet_treasury::Config for Runtime {
type ApproveOrigin = EnsureRoot<AccountId>;
type Burn = Burn;
type BurnDestination = Treasury;
type Currency = Balances;
type Event = Event;
type MaxApprovals = MaxApprovals;
type OnSlash = Treasury;
type PalletId = TreasuryPalletId;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type RejectOrigin = EnsureRoot<AccountId>;
type SpendFunds = Bounties;
type SpendPeriod = SpendPeriod;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
}

impl pallet_bounties::Config for Runtime {
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyValueMinimum = BountyValueMinimum;
type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = pallet_bounties::weights::SubstrateWeight<Runtime>;
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -578,6 +628,8 @@ construct_runtime! {
// Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,
// Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 31,
// TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 32,
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 36,
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>} = 37,

// XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 40,
Expand Down

0 comments on commit f25ff2c

Please sign in to comment.