diff --git a/Cargo.lock b/Cargo.lock
index f12a14b..472e0e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5235,7 +5235,7 @@ dependencies = [
[[package]]
name = "origintrail-parachain-runtime"
-version = "1.0.0"
+version = "1.0.1"
dependencies = [
"cumulus-pallet-aura-ext",
"cumulus-pallet-dmp-queue",
diff --git a/README.md b/README.md
index bf21c2f..e06c5b9 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,17 @@
# OriginTrail Parachain Node
-
-
+
-
+
+
+[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
+[![Substrate version](https://img.shields.io/badge/Substrate-3.0.0-brightgreen?logo=Parity%20Substrate)](https://substrate.io)
+[![Twitter URL](https://img.shields.io/twitter/follow/OT_Parachain?style=social)](https://twitter.com/OT_Parachain)
+[![Telegram](https://img.shields.io/endpoint?color=neon&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Forigintrail)](https://t.me/origintrail)
+[![Medium](https://badgen.net/badge/icon/medium?icon=medium&label)](https://medium.com/origintrail)
+[![Discord](https://img.shields.io/badge/Discord-gray?logo=discord)](https://discord.gg/FCgYk2S)
+
+
The OriginTrail Parachain is the next-generation L1 blockchain designed to tightly integrate with the OriginTrail DKG. As an OriginTrail-tailored blockchain it is optimized for maximum performance and usability in the OriginTrail consensus layer. It leverages the strong trust model and inherent interoperability of Polkadot, enabling smooth integration with other Polkadot ecosystem projects.
diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs
index e156c8f..7043ce1 100644
--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -222,5 +222,7 @@ fn testnet_genesis(
// Assign network admin rights.
key: Some(root_key),
},
+ vesting: Default::default(),
+ treasury: Default::default(),
}
}
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index cbf8d03..8dfe539 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "origintrail-parachain-runtime"
-version = "1.0.0"
+version = "1.0.2"
authors = ["TraceLabs"]
description = "OriginTrail Parachain Runtime - Cumulus FRAME-based Substrate Runtime"
license = "GPL-3.0-only"
@@ -15,10 +15,14 @@ targets = ["x86_64-unknown-linux-gnu"]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
[dependencies]
-codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
+codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
+ "derive",
+] }
hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.14", default-features = false }
-scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
+scale-info = { version = "2.0.0", default-features = false, features = [
+ "derive",
+] }
serde = { version = "1.0.132", optional = true, features = ["derive"] }
smallvec = "1.6.1"
@@ -42,6 +46,8 @@ pallet-sudo = { git = "https://github.com/paritytech/substrate", default-feature
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
+pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
+pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.18" }
@@ -64,22 +70,20 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.18" }
# Cumulus
-cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
-parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-primitives-timestamp = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+cumulus-primitives-utility = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
+parachain-info = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.18" }
[features]
-default = [
- "std",
-]
+default = ["std"]
std = [
"codec/std",
"log/std",
@@ -108,6 +112,8 @@ std = [
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
+ "pallet-treasury/std",
+ "pallet-vesting/std",
"pallet-xcm/std",
"parachain-info/std",
"polkadot-parachain/std",
@@ -139,6 +145,8 @@ runtime-benchmarks = [
"pallet-collator-selection/runtime-benchmarks",
"pallet-template/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
+ "pallet-treasury/runtime-benchmarks",
+ "pallet-vesting/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
@@ -146,7 +154,4 @@ runtime-benchmarks = [
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
]
-try-runtime = [
- "frame-executive/try-runtime",
- "frame-try-runtime",
-]
+try-runtime = ["frame-executive/try-runtime", "frame-try-runtime"]
diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs
index 00f9687..79c4156 100644
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -13,7 +13,7 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
- traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
+ traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, IdentifyAccount, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
};
@@ -25,7 +25,7 @@ use sp_version::RuntimeVersion;
use frame_support::{
construct_runtime, parameter_types,
- traits::Everything,
+ traits::{Everything, Currency as PalletCurrency, OnUnbalanced, Imbalance},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND},
DispatchClass, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
@@ -38,7 +38,7 @@ use frame_system::{
EnsureRoot,
};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
-pub use sp_runtime::{MultiAddress, Perbill, Permill};
+pub use sp_runtime::{MultiAddress, Perbill, Permill, traits::AccountIdConversion };
pub use frame_support::traits::EqualPrivilegeOnly;
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};
@@ -171,7 +171,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("origintrail-parachain"),
impl_name: create_runtime_str!("origintrail-parachain"),
authoring_version: 1,
- spec_version: 100,
+ spec_version: 102,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
@@ -250,6 +250,15 @@ parameter_types! {
pub const SS58Prefix: u16 = 101;
}
+// Pallet accounts of runtime
+parameter_types! {
+ pub const TreasuryPalletId: PalletId = PalletId(*b"otp/trea");
+ pub const DkgIncentivesPalletId: PalletId = PalletId(*b"otp/dkgi");
+ pub const FutureAuctionsPalletId: PalletId = PalletId(*b"otp/fauc");
+ pub const CollatorsIncentivesPalletId: PalletId = PalletId(*b"otp/coli");
+ pub const PotId: PalletId = PalletId(*b"PotStake");
+}
+
// Configure FRAME pallets to include in runtime.
impl frame_system::Config for Runtime {
@@ -345,6 +354,57 @@ impl pallet_balances::Config for Runtime {
type ReserveIdentifier = [u8; 8];
}
+pub struct ToStakingPot;
+impl OnUnbalanced for ToStakingPot {
+ fn on_nonzero_unbalanced(amount: NegativeImbalance) {
+ let staking_pot = PotId::get().into_account();
+ Balances::resolve_creating(&staking_pot, amount);
+ }
+}
+
+pub struct FutureAuctionsPot;
+impl OnUnbalanced for FutureAuctionsPot {
+ fn on_nonzero_unbalanced(amount: NegativeImbalance) {
+ let future_auctions_pot = FutureAuctionsPalletId::get().into_account();
+ Balances::resolve_creating(&future_auctions_pot, amount);
+ }
+}
+
+pub struct DkgIncentivesPot;
+impl OnUnbalanced for DkgIncentivesPot {
+ fn on_nonzero_unbalanced(amount: NegativeImbalance) {
+ let dkg_incentives_pot = DkgIncentivesPalletId::get().into_account();
+ Balances::resolve_creating(&dkg_incentives_pot, amount);
+ }
+}
+
+type NegativeImbalance = >::NegativeImbalance;
+
+pub struct DealWithFees;
+impl OnUnbalanced for DealWithFees {
+ fn on_unbalanceds(mut fees_then_tips: impl Iterator- ) {
+ if let Some(mut fees) = fees_then_tips.next() {
+ if let Some(tips) = fees_then_tips.next() {
+ tips.merge_into(&mut fees);
+ }
+ // for fees and tips:
+ // - 30% to DKG Incentives pool
+ // - 30% to Collators Incentives pool (currently staking_pot)
+ // - 30% to Future Auctions pool
+ // - 10% to Treasury
+ let split = fees.ration(60, 40);
+ let (dkg_incentives_fees, collators_incentives_fees) = split.0.ration(50, 50);
+ let (future_auctions_fees, treasury_fees) = split.1.ration(75, 25);
+
+
+ Treasury::on_unbalanced(treasury_fees);
+ >::on_unbalanced(collators_incentives_fees);
+ >::on_unbalanced(future_auctions_fees);
+ >::on_unbalanced(dkg_incentives_fees);
+ }
+ }
+}
+
parameter_types! {
/// Relay Chain `TransactionByteFee` / 10
pub const TransactionByteFee: Balance = 10 * MICROOTP;
@@ -352,7 +412,7 @@ parameter_types! {
}
impl pallet_transaction_payment::Config for Runtime {
- type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter;
+ type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = WeightToFee;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate;
@@ -423,7 +483,6 @@ impl pallet_aura::Config for Runtime {
}
parameter_types! {
- pub const PotId: PalletId = PalletId(*b"PotStake");
pub const MaxCandidates: u32 = 1000;
pub const MinCandidates: u32 = 5;
pub const SessionLength: BlockNumber = 6 * HOURS;
@@ -476,6 +535,48 @@ impl pallet_sudo::Config for Runtime {
type Call = Call;
}
+parameter_types! {
+ pub const MinVestedTransfer: Balance = 15 * OTP;
+}
+
+impl pallet_vesting::Config for Runtime {
+ type Event = Event;
+ type Currency = Balances;
+ type BlockNumberToBalance = ConvertInto;
+ type MinVestedTransfer = MinVestedTransfer;
+ type WeightInfo = pallet_vesting::weights::SubstrateWeight;
+ // `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the
+ // highest number of schedules that encodes less than 2^10.
+ const MAX_VESTING_SCHEDULES: u32 = 28;
+}
+
+parameter_types! {
+ pub const ProposalBond: Permill = Permill::from_percent(5);
+ pub const ProposalBondMinimum: Balance = 100 * OTP;
+ pub const ProposalBondMaximum: Balance = 500 * OTP;
+ pub const SpendPeriod: BlockNumber = 24 * DAYS;
+ pub const MaxApprovals: u32 = 100;
+}
+
+
+impl pallet_treasury::Config for Runtime {
+ type PalletId = TreasuryPalletId;
+ type Currency = Balances;
+ type ApproveOrigin = EnsureRoot;
+ type RejectOrigin = EnsureRoot;
+ type Event = Event;
+ type OnSlash = ();
+ type ProposalBond = ProposalBond;
+ type ProposalBondMinimum = ProposalBondMinimum;
+ type ProposalBondMaximum = ProposalBondMaximum;
+ type SpendPeriod = SpendPeriod;
+ type Burn = ();
+ type BurnDestination = ();
+ type SpendFunds = ();
+ type WeightInfo = pallet_treasury::weights::SubstrateWeight;
+ type MaxApprovals = MaxApprovals;
+}
+
/// Configure the pallet template in pallets/template.
impl pallet_template::Config for Runtime {
type Event = Event;
@@ -499,6 +600,8 @@ construct_runtime!(
// Monetary stuff.
Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11,
+ Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 12,
+ Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 13,
// Collator support. The order of these 4 are important and shall not change.
Authorship: pallet_authorship::{Pallet, Call, Storage} = 20,