From 34d1a7b0d5bda5d2bfc701a9657716a49061028b Mon Sep 17 00:00:00 2001 From: yooml Date: Mon, 16 Aug 2021 11:42:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20Treasury=20and?= =?UTF-8?q?=20Bounties=20at=20bifrost=20runtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 3 ++ node/service/src/chain_spec/bifrost.rs | 1 + runtime/bifrost/Cargo.toml | 4 ++ runtime/bifrost/src/lib.rs | 52 ++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 77d62bd4d0..0cabadb15b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -754,6 +754,7 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-bounties", "pallet-collator-selection", "pallet-collective", "pallet-democracy", @@ -765,12 +766,14 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-utility", "pallet-xcm", "parachain-info", "parity-scale-codec", "polkadot-parachain", "sp-api", + "sp-arithmetic", "sp-block-builder", "sp-consensus-aura", "sp-core", diff --git a/node/service/src/chain_spec/bifrost.rs b/node/service/src/chain_spec/bifrost.rs index 070c50c091..2e8612f9f8 100644 --- a/node/service/src/chain_spec/bifrost.rs +++ b/node/service/src/chain_spec/bifrost.rs @@ -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 { diff --git a/runtime/bifrost/Cargo.toml b/runtime/bifrost/Cargo.toml index 8251134adb..5094e4da44 100644 --- a/runtime/bifrost/Cargo.toml +++ b/runtime/bifrost/Cargo.toml @@ -22,6 +22,7 @@ sp-session = { 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 } +sp-arithmetic = { version = "3.0.0", default-features = false } # frame dependencies frame-benchmarking = { version = "3.0.0", default-features = false, optional = true } @@ -44,6 +45,8 @@ pallet-transaction-payment-rpc-runtime-api = { version = "3.0.0", default-featur 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 } +pallet-treasury = { version = "3.0.0", default-features = false } +pallet-bounties = { 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" } @@ -107,6 +110,7 @@ std = [ "sp-runtime/std", "sp-session/std", "sp-transaction-pool/std", + "sp-arithmetic/std", "parachain-info/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index 3781c67488..758464358a 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -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))] @@ -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; + 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; + type SpendFunds = Bounties; + type SpendPeriod = SpendPeriod; + type WeightInfo = pallet_treasury::weights::SubstrateWeight; +} + +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; +} + construct_runtime! { pub enum Runtime where Block = Block, @@ -578,6 +628,8 @@ construct_runtime! { // Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event} = 30, // Council: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 31, // TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 32, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 36, + Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 37, // XCM helpers. XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 40, From a684f131e445ce7cc415c49338ed46460f6cf8e4 Mon Sep 17 00:00:00 2001 From: yooml Date: Mon, 16 Aug 2021 13:55:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?style:=20=F0=9F=92=84=20modify=20Cargo.toml?= =?UTF-8?q?=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runtime/bifrost/Cargo.toml | 47 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/runtime/bifrost/Cargo.toml b/runtime/bifrost/Cargo.toml index 5094e4da44..8c160a24be 100644 --- a/runtime/bifrost/Cargo.toml +++ b/runtime/bifrost/Cargo.toml @@ -7,65 +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 } -sp-arithmetic = { version = "3.0.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-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 } pallet-treasury = { version = "3.0.0", default-features = false } -pallet-bounties = { version = "3.0.0", default-features = false } +pallet-utility = { 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 } @@ -81,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", @@ -100,17 +102,17 @@ 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", - "sp-arithmetic/std", "parachain-info/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", @@ -131,6 +133,7 @@ std = [ "orml-traits/std", "orml-tokens/std", ] +with-tracing = ["frame-executive/with-tracing"] runtime-benchmarks = [ "frame-benchmarking",