Skip to content

Commit

Permalink
Merge pull request #276 from zeitgeistpm/caio-c8
Browse files Browse the repository at this point in the history
Integrate Court into the Runtime
  • Loading branch information
c410-f3r authored Sep 7, 2021
2 parents fce7719 + 9de7cb6 commit 270d24f
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 124 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ sp-finality-grandpa = { branch = "polkadot-v0.9.8", default-features = false, gi
# Zeitgeist

zeitgeist-primitives = { default-features = false, path = "../primitives" }
zrml-court = { default-features = false, path = "../zrml/court" }
zrml-liquidity-mining = { default-features = false, path = "../zrml/liquidity-mining" }
zrml-market-commons = { default-features = false, path = "../zrml/market-commons" }
zrml-orderbook-v1 = { default-features = false, path = "../zrml/orderbook-v1" }
Expand Down Expand Up @@ -112,22 +113,23 @@ parachain = [
"xcm",
]
runtime-benchmarks = [
"pallet-utility/runtime-benchmarks",
"zrml-swaps/runtime-benchmarks",
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking",
"frame-system/runtime-benchmarks",
"hex-literal",
"pallet-balances/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"zrml-court/runtime-benchmarks",
"zrml-liquidity-mining/runtime-benchmarks",
"zrml-orderbook-v1/runtime-benchmarks",
"zrml-prediction-markets/runtime-benchmarks",
"zrml-simple-disputes/runtime-benchmarks",
"zrml-swaps/runtime-benchmarks",
]
std = [
"frame-executive/std",
Expand Down Expand Up @@ -199,6 +201,7 @@ std = [
# Zeitgeist

"zeitgeist-primitives/std",
"zrml-court/std",
"zrml-liquidity-mining/std",
"zrml-market-commons/std",
"zrml-orderbook-v1/std",
Expand Down
24 changes: 19 additions & 5 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ macro_rules! create_zeitgeist_runtime {
Orderbook: zrml_orderbook_v1::{Call, Event<T>, Pallet, Storage} = 41,

MarketCommons: zrml_market_commons::{Pallet, Storage} = 42,
Swaps: zrml_swaps::{Call, Event<T>, Pallet, Storage} = 43,
SimpleDisputes: zrml_simple_disputes::{Event<T>, Pallet, Storage} = 44,
PredictionMarkets: zrml_prediction_markets::{Call, Event<T>, Pallet, Storage} = 45,
Court: zrml_court::{Event<T>, Pallet, Storage} = 43,
Swaps: zrml_swaps::{Call, Event<T>, Pallet, Storage} = 44,
SimpleDisputes: zrml_simple_disputes::{Event<T>, Pallet, Storage} = 45,
PredictionMarkets: zrml_prediction_markets::{Call, Event<T>, Pallet, Storage} = 46,

$($additional_pallets)*
}
Expand Down Expand Up @@ -323,7 +324,7 @@ impl orml_tokens::Config for Runtime {
type Event = Event;
type ExistentialDeposits = ExistentialDeposits;
type MaxLocks = MaxLocks;
type OnDust = ();
type OnDust = orml_tokens::TransferDust<Runtime, DustAccount>;
type WeightInfo = ();
}

Expand Down Expand Up @@ -389,6 +390,17 @@ impl pallet_utility::Config for Runtime {
#[cfg(feature = "parachain")]
impl parachain_info::Config for Runtime {}

impl zrml_court::Config for Runtime {
type CourtCaseDuration = CourtCaseDuration;
type Event = Event;
type MarketCommons = MarketCommons;
type PalletId = CourtPalletId;
type Random = RandomnessCollectiveFlip;
type StakeWeight = StakeWeight;
type TreasuryPalletId = TreasuryPalletId;
type WeightInfo = zrml_court::weights::WeightInfo<Runtime>;
}

impl zrml_liquidity_mining::Config for Runtime {
type Currency = Balances;
type Event = Event;
Expand All @@ -415,12 +427,13 @@ impl zrml_orderbook_v1::Config for Runtime {
impl zrml_prediction_markets::Config for Runtime {
type AdvisoryBond = AdvisoryBond;
type ApprovalOrigin = EnsureRoot<AccountId>;
type Court = Court;
type DisputeBond = DisputeBond;
type DisputeFactor = DisputeFactor;
type DisputePeriod = DisputePeriod;
type Event = Event;
type MarketCommons = MarketCommons;
type LiquidityMining = LiquidityMining;
type MarketCommons = MarketCommons;
type MaxCategories = MaxCategories;
type MaxDisputes = MaxDisputes;
type MinCategories = MinCategories;
Expand Down Expand Up @@ -528,6 +541,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, zrml_swaps, Swaps);
add_benchmark!(params, batches, zrml_court, Court);
add_benchmark!(params, batches, zrml_prediction_markets, PredictionMarkets);
add_benchmark!(params, batches, zrml_liquidity_mining, LiquidityMining);
add_benchmark!(params, batches, zrml_orderbook_v1, Orderbook);
Expand Down
7 changes: 7 additions & 0 deletions zrml/court/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[dependencies]
arrayvec = { default-features = false, version = "0.7" }
frame-benchmarking = { branch = "polkadot-v0.9.8", default-features = false, optional = true, git = "https://github.com/paritytech/substrate" }
frame-support = { branch = "polkadot-v0.9.8", default-features = false, git = "https://github.com/paritytech/substrate" }
frame-system = { branch = "polkadot-v0.9.8", default-features = false, git = "https://github.com/paritytech/substrate" }
parity-scale-codec = { default-features = false, features = ["derive"], version = "2.0" }
Expand All @@ -16,7 +17,13 @@ sp-io = { branch = "polkadot-v0.9.8", git = "https://github.com/paritytech/subst

[features]
default = ["std"]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks"
]
std = [
'frame-benchmarking?/std',
'frame-support/std',
'frame-system/std',
'parity-scale-codec/std',
Expand Down
52 changes: 52 additions & 0 deletions zrml/court/src/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#![allow(
// Auto-generated code is a no man's land
clippy::integer_arithmetic
)]
#![cfg(feature = "runtime-benchmarks")]

#[cfg(test)]
use crate::Pallet as Court;
use crate::{BalanceOf, Call, Config, CurrencyOf, Pallet};
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_support::{dispatch::UnfilteredDispatchable, traits::Currency};
use frame_system::RawOrigin;
use sp_runtime::traits::Bounded;
use zeitgeist_primitives::types::OutcomeReport;

fn deposit<T>(caller: &T::AccountId)
where
T: Config,
{
let _ = CurrencyOf::<T>::deposit_creating(caller, BalanceOf::<T>::max_value());
}

fn deposit_and_join_court<T>(caller: &T::AccountId)
where
T: Config,
{
deposit::<T>(caller);
Call::<T>::join_court()
.dispatch_bypass_filter(RawOrigin::Signed(caller.clone()).into())
.unwrap();
}

benchmarks! {
exit_court {
let caller: T::AccountId = whitelisted_caller();
deposit_and_join_court::<T>(&caller);
}: _(RawOrigin::Signed(caller))

join_court {
let caller: T::AccountId = whitelisted_caller();
deposit::<T>(&caller);
}: _(RawOrigin::Signed(caller))

vote {
let caller: T::AccountId = whitelisted_caller();
let market_id = Default::default();
let outcome = OutcomeReport::Scalar(u128::MAX);
deposit_and_join_court::<T>(&caller);
}: _(RawOrigin::Signed(caller), market_id, outcome)
}

impl_benchmark_test_suite!(Court, crate::mock::ExtBuilder::default().build(), crate::mock::Runtime);
5 changes: 3 additions & 2 deletions zrml/court/src/court_pallet_api.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/// Court - Pallet Api
pub trait CourtPalletApi {}
use zeitgeist_primitives::traits::DisputeApi;

pub trait CourtPalletApi: DisputeApi {}
3 changes: 1 addition & 2 deletions zrml/court/src/juror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::JurorStatus;
///
/// * `B`: Balance
#[derive(Debug, PartialEq, parity_scale_codec::Decode, parity_scale_codec::Encode)]
pub struct Juror<B> {
pub(crate) staked: B,
pub struct Juror {
pub(crate) status: JurorStatus,
}
Loading

0 comments on commit 270d24f

Please sign in to comment.