Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM] Reserve OutsiderBond for report, when the oracle fails to report #903

Merged
merged 36 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5dd2847
wip
Chralt98 Dec 9, 2022
1e80b1d
update dependent types
Chralt98 Dec 12, 2022
a0a2f8f
reward the outsider with oracle bond
Chralt98 Dec 12, 2022
a41ff0b
slash in admin_destroy_market
Chralt98 Dec 12, 2022
ad08af4
prepare storage migration
Chralt98 Dec 12, 2022
bf880e0
test new functionality
Chralt98 Dec 12, 2022
1fe1d36
revert storage changes
Chralt98 Dec 16, 2022
155029a
Merge branch 'main' into chralt98-outsider-bond
Chralt98 Jan 5, 2023
20aaaa6
add outsider bond to market storage
Chralt98 Jan 5, 2023
80167be
AddOutsiderBond migration, defensive outsider bond
Chralt98 Jan 5, 2023
89d75f8
use storage alias to avoid migration mistake
Chralt98 Jan 9, 2023
280b4fa
cargo fmt
Chralt98 Jan 9, 2023
76fadc6
log warning in impl_repatriate_bond
Chralt98 Jan 10, 2023
2399ceb
reconfigure outsider bond
Chralt98 Jan 10, 2023
57a3949
Update zrml/prediction-markets/src/lib.rs
Chralt98 Jan 10, 2023
4f90a62
bump market commons version
Chralt98 Jan 10, 2023
a8e20fa
Merge branch 'chralt98-outsider-bond' of github.com:zeitgeistpm/zeitg…
Chralt98 Jan 10, 2023
02eb35b
Apply suggestions from code review
Chralt98 Jan 10, 2023
9e42f0d
use macro for is_bond_pending
Chralt98 Jan 10, 2023
bf6920c
restructure resolve_reported_market
Chralt98 Jan 10, 2023
eaab9bd
improve tests
Chralt98 Jan 11, 2023
b85409c
improve sentinel reserve
Chralt98 Jan 11, 2023
0e44285
Merge branch 'main' into chralt98-outsider-bond
Chralt98 Jan 11, 2023
8203234
fix after merge
Chralt98 Jan 11, 2023
51aa4e4
cargo fmt
Chralt98 Jan 11, 2023
384ace5
Merge branch 'main' into chralt98-outsider-bond
Chralt98 Jan 19, 2023
9a192fc
fix after merge
Chralt98 Jan 19, 2023
758aca3
Merge branch 'main' into chralt98-outsider-bond
Chralt98 Jan 20, 2023
71356aa
remove storage read write count
Chralt98 Jan 24, 2023
745cd30
simplify assert for base asset
Chralt98 Jan 24, 2023
e7df060
remove old migration
Chralt98 Jan 24, 2023
e5633ec
add macro fucntion doc comment
Chralt98 Jan 24, 2023
3d5543e
correct comment
Chralt98 Jan 24, 2023
c1dfa81
cargo fmt
Chralt98 Jan 24, 2023
a5f184a
Update zrml/prediction-markets/src/lib.rs
Chralt98 Jan 24, 2023
4a814c6
Merge branch 'main' into chralt98-outsider-bond
Chralt98 Jan 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 60 additions & 36 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 primitives/src/constants/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ parameter_types! {
// 60_000 = 1 minute. Should be raised to something more reasonable in the future.
pub const MinSubsidyPeriod: Moment = 60_000;
pub const OracleBond: Balance = 50 * CENT;
pub const OutsiderBond: Balance = 2 * OracleBond::get();
pub const PmPalletId: PalletId = PalletId(*b"zge/pred");
pub const ValidityBond: Balance = 50 * CENT;
}
Expand Down
7 changes: 5 additions & 2 deletions primitives/src/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl<AI, BA> Bond<AI, BA> {
pub struct MarketBonds<AI, BA> {
pub creation: Option<Bond<AI, BA>>,
pub oracle: Option<Bond<AI, BA>>,
pub outsider: Option<Bond<AI, BA>>,
}

impl<AI: Ord, BA: frame_support::traits::tokens::Balance> MarketBonds<AI, BA> {
Expand All @@ -95,14 +96,16 @@ impl<AI: Ord, BA: frame_support::traits::tokens::Balance> MarketBonds<AI, BA> {
Some(bond) if bond.who == *who => bond.value,
_ => BA::zero(),
};
value_or_default(&self.creation).saturating_add(value_or_default(&self.oracle))
value_or_default(&self.creation)
.saturating_add(value_or_default(&self.oracle))
.saturating_add(value_or_default(&self.outsider))
}
}

// Used primarily for testing purposes.
impl<AI, BA> Default for MarketBonds<AI, BA> {
fn default() -> Self {
MarketBonds { creation: None, oracle: None }
MarketBonds { creation: None, oracle: None, outsider: None }
}
}

Expand Down
3 changes: 3 additions & 0 deletions runtime/battery-station/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ parameter_types! {
/// (Slashable) The orcale bond. Slashed in case the final outcome does not match the
/// outcome the oracle reported.
pub const OracleBond: Balance = 50 * CENT;
/// (Slashable) A bond for an outcome reporter, who is not the oracle.
/// Slashed in case the final outcome does not match the outcome by the outsider.
pub const OutsiderBond: Balance = 2 * OracleBond::get();
/// Pallet identifier, mainly used for named balance reserves.
pub const PmPalletId: PalletId = PM_PALLET_ID;
/// (Slashable) A bond for creation markets that do not require approval. Slashed in case
Expand Down
12 changes: 3 additions & 9 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ macro_rules! decl_common_types {
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(
pallet_parachain_staking::migrations::MigrateAtStakeAutoCompound<Runtime>,
zrml_prediction_markets::migrations::UpdateMarketsForBaseAssetAndRecordBonds<Runtime>,
zrml_prediction_markets::migrations::AddFieldToAuthorityReport<Runtime>,
),
zrml_prediction_markets::migrations::AddOutsiderBond<Runtime>,
>;

#[cfg(not(feature = "parachain"))]
Expand All @@ -72,10 +68,7 @@ macro_rules! decl_common_types {
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(
zrml_prediction_markets::migrations::UpdateMarketsForBaseAssetAndRecordBonds<Runtime>,
zrml_prediction_markets::migrations::AddFieldToAuthorityReport<Runtime>,
),
zrml_prediction_markets::migrations::AddOutsiderBond<Runtime>,
>;

pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
Expand Down Expand Up @@ -1019,6 +1012,7 @@ macro_rules! impl_config_traits {
type MaxEditReasonLen = MaxEditReasonLen;
type MaxRejectReasonLen = MaxRejectReasonLen;
type OracleBond = OracleBond;
type OutsiderBond = OutsiderBond;
type PalletId = PmPalletId;
type RejectOrigin = EnsureRootOrHalfAdvisoryCommittee;
type RequestEditOrigin = EitherOfDiverse<
Expand Down
3 changes: 3 additions & 0 deletions runtime/zeitgeist/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ parameter_types! {
/// (Slashable) The orcale bond. Slashed in case the final outcome does not match the
/// outcome the oracle reported.
pub const OracleBond: Balance = 200 * BASE;
/// (Slashable) A bond for an outcome reporter, who is not the oracle.
/// Slashed in case the final outcome does not match the outcome by the outsider.
pub const OutsiderBond: Balance = 2 * OracleBond::get();
/// Pallet identifier, mainly used for named balance reserves. DO NOT CHANGE.
pub const PmPalletId: PalletId = PM_PALLET_ID;
/// (Slashable) A bond for creation markets that do not require approval. Slashed in case
Expand Down
2 changes: 1 addition & 1 deletion zrml/court/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const DEFAULT_MARKET: MarketOf<Runtime> = Market {
resolved_outcome: None,
status: MarketStatus::Closed,
scoring_rule: ScoringRule::CPMM,
bonds: MarketBonds { creation: None, oracle: None },
bonds: MarketBonds { creation: None, oracle: None, outsider: None },
};
const DEFAULT_SET_OF_JURORS: &[(u128, Juror)] = &[
(7, Juror { status: JurorStatus::Ok }),
Expand Down
2 changes: 1 addition & 1 deletion zrml/market-commons/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mod pallet {
use zeitgeist_primitives::types::{Asset, Market, PoolId};

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
const STORAGE_VERSION: StorageVersion = StorageVersion::new(6);

type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
Expand Down
2 changes: 1 addition & 1 deletion zrml/market-commons/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const MARKET_DUMMY: Market<AccountIdTest, Balance, BlockNumber, Moment, Asset<Ma
resolved_outcome: None,
scoring_rule: ScoringRule::CPMM,
status: MarketStatus::Disputed,
bonds: MarketBonds { creation: None, oracle: None },
bonds: MarketBonds { creation: None, oracle: None, outsider: None },
};

#[test]
Expand Down
Loading