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

[Global Disputes] Fix issues after first battery station live test #912

Merged
merged 414 commits into from
Aug 23, 2023

Conversation

Chralt98
Copy link
Member

@Chralt98 Chralt98 commented Dec 15, 2022

Fixes #928

  • Add possession which can be either Shared or Paid
    • this allows to distinguish between the extrinsic call add_vote_outcome, which is always paid with a VotingOutcomeFee and the private API call push_vote_outcome, which allows multiple (shared) owners
  • add new storage item GlobalDisputesInfo and put the content of Winners inside this
    • rename was necessary, because Winners doesn't suit the point of this storage item anymore
    • prepared to get Winners storage item removed after the runtime upgrade
  • Storage Migrations were necessary to adapt to the new possession enum field
  • add_vote_outcome now checks for the outcome type now
    • for example: on scalar markets, the global dispute should only allow scalar outcomes
  • allow to destroy a global dispute to unlock and return all user funds
  • return NoFundsToReward error for reward_outcome_owner, when add_vote_outcome was never called (so no funds available)
  • Added AddOutcomePeriod and VotePeriod to allow the addition of vote outcomes only before the voting starts
    • the benefit is to make it harder to get clone outcomes (for scalar markets), because voters have the full and unchangeable set of vote outcomes in front of them

@Chralt98 Chralt98 added the s:review-needed The pull request requires reviews label Dec 15, 2022
@Chralt98 Chralt98 self-assigned this Dec 15, 2022
@maltekliemann maltekliemann added this to the v0.3.8 milestone Dec 15, 2022
Copy link
Member

@maltekliemann maltekliemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job.

I guess the fact that global-disputes didn't rely on actually working with a market should have tipped us off sooner. No harm done, though. But I have one question regarding this pallet: I find it difficult to tell at which point a global dispute actually starts. The Winners map tracks the status of the global-dispute, which is initialize when the first voting outcome is pushed, correct?

I think it might be easier to expose a function start_global_dispute which creates an object which then tracks the status of the global dispute (could be the Winners object) and which performs all the necessary checks that need to be made in order to start the dispute (for example, there exists a market, the market has the correct state, etc.), much like create_pool (note that create_pool is not an extrinsic). It's definitely not ideal to combine the creation of a global dispute with push_voting_outcome. It's a design smell, and you're also doing a lot of unnecessary work (checking the validity of the market everytime someone adds a new outcome).

zrml/global-disputes/src/tests.rs Outdated Show resolved Hide resolved
@@ -221,6 +225,9 @@ mod pallet {
) -> DispatchResultWithPostInfo {
let owner = ensure_signed(origin)?;

let market = T::MarketCommons::market(&market_id)?;
ensure!(market.matches_outcome_report(&outcome), Error::<T>::OutcomeMismatch);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make more sense to me to put this into push_vote_outcome. If you call push_vote_outcome from some other function and forget to verify that the outcome types match, then we'll have another bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_vote_outcome is different to push_voting_outcome. add_vote_outcome is controlled by a user. So, I would be in favour of blocking a user to put in a combinatoric outcome instead of a scalar outcome.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But add_vote_outcome is implemented using push_voting_outcome. That's why I suggested it. You have a clean API, i.e. other pallets can't accidentally push incorrect outcomes, and neither can users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now decoupled

Self::update_winner(&market_id, &outcome, voting_outcome_fee);
let possession =
Some(Possession::Paid { owner: owner.clone(), fee: voting_outcome_fee });
let outcome_info = OutcomeInfo { outcome_sum: voting_outcome_fee, possession };
<Outcomes<T>>::insert(market_id, outcome.clone(), outcome_info);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after this change I suspect time complexity of this extrinsic has changed, and perhaps weight computation is also changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what was done to resolve this problem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just I said above. add_vote_outcome did use push_vote_outcome, but now it's decoupled, so the logic of add_vote_outcome is now independent from push_vote_outcome with this

Self::update_winner(&market_id, &outcome, voting_outcome_fee);
let possession =
Some(Possession::Paid { owner: owner.clone(), fee: voting_outcome_fee });
let outcome_info = OutcomeInfo { outcome_sum: voting_outcome_fee, possession };
<Outcomes<T>>::insert(market_id, outcome.clone(), outcome_info);

Comment on lines 143 to 149
GlobalDisputes::push_voting_outcome(
&market_id,
OutcomeReport::Scalar(0),
&ALICE,
10 * BASE,
)
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fail. I mean... why would it be okay to push an outcome for a non-existent market?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it is just like, that we are in full control of the private API calls like push_voting_outcome and determine_voting_winner. So it's not really needed, because the market check is always inside prediction-markets before the private API calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on what you mean by private, I guess. If you think of zrml_global_disputes as the object, then the object exposes an API to other pallets. These pallets are now able to push different types of outcome tokens to a global dispute, which is a violation of the rules of zrml_global_disputes. Fans of OOP will tell you that's dangerous. In general, I would agree with that sentiment.

That being said, OOP isn't always perfect. There are reasons why an API would not check the input. Sometimes its too costly, sometimes virtually impossible. It's your call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zrml/global-disputes/src/tests.rs Outdated Show resolved Hide resolved
@maltekliemann maltekliemann added s:revision-needed The pull requests must be revised and removed s:review-needed The pull request requires reviews labels Dec 17, 2022
@maltekliemann
Copy link
Member

By the way, how does global-disputes react when a market for which a global dispute is currently under way is destroyed?

@Chralt98
Copy link
Member Author

By the way, how does global-disputes react when a market for which a global dispute is currently under way is destroyed?

Good question. I did not think about this scenario. It seems fatal. Maybe good to have this in this PR.

When a global dispute is already started and the market is destroyed afterwards, it would block add_vote_outcome now. All other extrinsics in the pallet are not stopped. The problem comes, when we don't resolve the market, because the global dispute never finishes then. This means, that all funds are locked in the destroyed market.

let market = <zrml_market_commons::Pallet<T>>::market(id)?;

We can fix this by calling T::GlobalDisputes::determine_voting_winner(market_id) inside admin_destroy_market. Or we should probably add another private API call to immediately stop a global dispute and return all funds. Thanks for this nice thought experiment. Loved that

@Chralt98 Chralt98 added s:in-progress The pull requests is currently being worked on and removed s:revision-needed The pull requests must be revised labels Dec 19, 2022
@Chralt98
Copy link
Member Author

Chralt98 commented Dec 20, 2022

Should we rather return an error here ? I think this makes more sense. Added commit 8d6bcac

@Chralt98 Chralt98 changed the title [Global Disputes] Fail for outcome mismatch in add_vote_outcome [Global Disputes] Fix issues after first battery station live test Dec 20, 2022
@maltekliemann
Copy link
Member

Should we rather return an error here ? I think this makes more sense. Added commit 8d6bcac

Sorry, not quite sure what you're asking. Can you provide some context to the whole ownership thing? I just glanced over it. Looks like it might require a storage migration.

Generally regarding destroying markets: It's quite possible that there's no more need to destroy markets. Markets with corrupted storage can be fixed via migration/democracy and unwanted markets will be dealt with via blacklisting. But we should wait until the proposal is done and we've had a chance to review the consequences of removing admin_destroy_market. So right now, it's definitely the cleanest solution to make this pallet "resistant" to destroying markets.

@Chralt98
Copy link
Member Author

Chralt98 commented Jan 2, 2023

Sorry, not quite sure what you're asking. Can you provide some context to the whole ownership thing?

We have the users, who add outcomes with the extrinsic. These users pay a voting outcome fee.

There can only be one owner for a particular outcome. So, we don't need to handle a list of owners.

On the other hand we have outcomes from the disputes, which can have multiple owners. For one disputed outcome, there could be two disputors in the current implementation of prediction-markets.

I just glanced over it. Looks like it might require a storage migration.

True, it requires a storage migration. I had no time so far for this.

@Chralt98 Chralt98 added s:review-needed The pull request requires reviews and removed s:in-progress The pull requests is currently being worked on labels Jan 3, 2023
@Chralt98 Chralt98 added s:in-progress The pull requests is currently being worked on s:review-needed The pull request requires reviews i:spec-changed ⚠️ Implies change in spec version i:transactions-changed ⚠️ Implies change in transaction version and removed s:review-needed The pull request requires reviews s:in-progress The pull requests is currently being worked on labels Jan 4, 2023
@Chralt98 Chralt98 removed this from the v0.3.8 milestone Jan 5, 2023
@Chralt98 Chralt98 added s:review-needed The pull request requires reviews and removed s:review-needed The pull request requires reviews labels Aug 23, 2023
@Chralt98 Chralt98 added s:review-needed The pull request requires reviews and removed s:review-needed The pull request requires reviews labels Aug 23, 2023
Makefile Outdated Show resolved Hide resolved
&Self::reward_account(&market_id),
&owner,
fee,
ExistenceRequirement::AllowDeath,
Copy link
Member Author

@Chralt98 Chralt98 Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pallets.push(GlobalDisputesPalletId::get());
if let Some(pallet_id) = frame_support::PalletId::try_from_sub_account::<u128>(ai) {
return pallets.contains(&pallet_id.0);
}
for pallet_id in pallets {
let pallet_acc: AccountId = pallet_id.into_account_truncating();
if pallet_acc == *ai {
return true;
yes.

@@ -221,6 +225,9 @@ mod pallet {
) -> DispatchResultWithPostInfo {
let owner = ensure_signed(origin)?;

let market = T::MarketCommons::market(&market_id)?;
ensure!(market.matches_outcome_report(&outcome), Error::<T>::OutcomeMismatch);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just I said above. add_vote_outcome did use push_vote_outcome, but now it's decoupled, so the logic of add_vote_outcome is now independent from push_vote_outcome with this

Self::update_winner(&market_id, &outcome, voting_outcome_fee);
let possession =
Some(Possession::Paid { owner: owner.clone(), fee: voting_outcome_fee });
let outcome_info = OutcomeInfo { outcome_sum: voting_outcome_fee, possession };
<Outcomes<T>>::insert(market_id, outcome.clone(), outcome_info);

}
// Storage: GlobalDisputes Winners (r:1 w:1)
// Storage: GlobalDisputes GlobalDisputesInfo (r:1 w:1)
// Storage: GlobalDisputes Outcomes (r:3 w:2)
fn purge_outcomes(k: u32, _o: u32) -> Weight {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the parameter _o ignored here?

Copy link
Member Author

@Chralt98 Chralt98 Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow the benchmark doesn't recognise the dynamic vector of owners as significant enough..

for i in 1..=o {
let owner = account("winners_owner", i, 0);
owners.push(owner);
}
let owners = BoundedVec::try_from(owners.clone()).unwrap();
let winner_outcome = OutcomeReport::Scalar(0);
let possession = Possession::Shared { owners };

Although it is read here.

T: Config,
{
let mut total_weight = T::DbWeight::get().reads(1);
let gd_version = StorageVersion::get::<GDPallet<T>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STORAGE_VERSION was previously undefined, not sure if it returns 0 in that case (probably it does).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base automatically changed from chralt98-court-overhaul to release-dispute-system August 23, 2023 14:06
@mergify
Copy link
Contributor

mergify bot commented Aug 23, 2023

This pull request is now in conflicts. Could you fix it @Chralt98? 🙏

@mergify mergify bot added s:revision-needed The pull requests must be revised and removed s:review-needed The pull request requires reviews labels Aug 23, 2023
@Chralt98 Chralt98 added s:review-needed The pull request requires reviews s:accepted This pull request is ready for merge and removed s:revision-needed The pull requests must be revised s:review-needed The pull request requires reviews labels Aug 23, 2023
@Chralt98 Chralt98 merged commit 6e27186 into release-dispute-system Aug 23, 2023
18 of 23 checks passed
@Chralt98 Chralt98 deleted the chralt98-fix-global-disputes branch August 23, 2023 14:24
Chralt98 added a commit that referenced this pull request Aug 26, 2023
* ZIP-0 Part II (#938)

* move disputes to simple-disputes

* move more to simple-disputes

* wip

* wip

* some mock preparation

* wip

* fix tests

* taplo fmt

* update court authorized mdms

* add dispute bond to market storage

* mdm funds flow

* fix clippy

* fix pm benchmarks

* add migration

* simplify migration

* correct migration

* migration fixes and call filter

* correct admin_destroy_market benchmark

* improve simple-disputes mock

* benchmark reserve_outcome

* benchmark reserve_outcome

* fix weights file

* fix after merge

* add migration tests

* add migration reserve id test

* apply review suggestions

* rename reserve_outcome to suggest_outcome

* separate resolve_disputed_market into parts

* edit exchange API documentation

* slash dispute bond

* add empty commit

* correct admin_destroy_market test

* remove gd dependency from simple disputes

* Update zrml/simple-disputes/src/mock.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/simple-disputes/src/mock.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/prediction-markets/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* add doc string

* add doc strings

* Reduce settle_bonds LOC

* cargo fmt

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Harald Heckmann <[email protected]>

* apply review suggestion

* add correct mdm benchmarking on_dispute

* use on_dispute_weight inside api

* improve mdm weight technique

* add mdm weights to on_resolution

* add tests for pm

* modify migration logs, fix try-runtime

* little benchmark fix

* Update zrml/authorized/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/authorized/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* use result with weight struct

* improve dispute api weight system

* Use accurate dispute weight instead of max

* fix clippy

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Malte Kliemann <[email protected]>

* add copyrights

---------

Co-authored-by: Harald Heckmann <[email protected]>
Co-authored-by: Malte Kliemann <[email protected]>

* fix clippy

* fix clippy

* Update dependencies to v0.9.38

* More dependency updates

* Update standalone runtimes

* Fix build with feature runtime-benchmark

* Update Zeitgeist parachain runtime

* Update Battery Station parachain runtime

* Deduplicated dependencies

* Make tests succeed for parachain runtime

* Partially fix Zeitgeist xcm tests

* Make all runtime tests succeed

* Update standalone client

* Update parachain node

* Add migrations

* Cargo fmt

* Satisfy Clippy

* Cargo fmt

* Taplo format

* Update licenses

* remove outsider bond from migration

* Reduce runtime test dependencies by half

* small changes

* Add missing runtime-benchmark feature

* Use upper case copyright name

Strange, locally the copyright script says: "All copyright notices are up to date! 🍉"
On GH pipeline: "error: zrml/prediction-markets/src/benchmarks.rs: no copyright notice for Forecasting Technologies LTD found"

* Remove test logger

* Implement Production Court (#976)

* apply review suggestions

* rename reserve_outcome to suggest_outcome

* separate resolve_disputed_market into parts

* add debug asserts

* document types

* modify sort check

* avoid double remove

* clarify docs

* avoid mut

* binary search by account id

* Revert "binary search by account id"

This reverts commit c04d5ff.

* make pool item key unique

* use secure random number generator

* add tests

* add tests

* found bug in exit court

* correct slashable

* fix exit court

* correct tests

* fix bug, add tests

* fix second get_winner bug

* modify tests

* fix draw active lock bug, add tests

* rename total_slashable to consumed_stake

* update config parameters, tests

* modify params and add tests

* add denounce tests

* increase code safety

* add tests

* add tests

* edit exchange API documentation

* slash dispute bond

* add empty commit

* correct admin_destroy_market test

* revert get_resolution_outcome to on_resolution

* remove gd dependency from simple disputes

* use appealed outcomes for global dispute

* modify appeal bond formula

* remove slash percentages

* benchmark court

* Update zrml/court/src/types.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/types.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/mock_storage.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/tests.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/tests.rs

Co-authored-by: Malte Kliemann <[email protected]>

* periods to round timing, modify tests

* modify doc comments

* use onunbalanced

* improve RequestInterval documentation

* improve consumed_stake documentation

* remove court from filter

* add treasury to court

* correct errors

* update comment

* update get_pool_item comment

* update get_pool_item comment

* comment juror pool

* improve doc comments

* cargo fmt

* rename constants

* edit court pallet doc

* update tests

* rename secret to commitment

* make commit reveal failsafer

* outsource commitment function

* update doc comments

* merge punish tardy jurors reassign juror stakes

* outsource get_n_random_numbers

* correct logs

* rename default to get

* improve extrinsic comments

* simplify choose_multiple_weighted

* improve naming

* remove back_global_dispute

* unlock jurors from last draws

* improve error description

* shorten mock periods

* document private functions

* add assert to check max appeals

* add stake to juror joined event

* correct test

* improve test

* update reassigned event comment

* correct test

* add assert check

* improve tests for draws

* add reveal vote invalid salt fails test

* denounce slash inside reassign_juror_stakes

* improve test readibility

* rename periods to cycle_ends

* add select jurors test

* change randomness source in court tests

* fix clippy

* imrpove tests

* remove cccount lookup in tests

* improve test setup

* add API tests, add missing unlockings

* add full cycle court tests

* remove invalid test

* add missing WeightInfo

* add inflation inside court

* improve benchmarking and testing

* add integrity_test

* Update zrml/simple-disputes/src/mock.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/simple-disputes/src/mock.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/prediction-markets/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* add doc string

* add doc strings

* Reduce settle_bonds LOC

* cargo fmt

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Harald Heckmann <[email protected]>

* apply review suggestion

* add GDItem integration

* add delegations

* improve code structure

* fix benchmarks

* optimize logic

* add correct mdm benchmarking on_dispute

* use on_dispute_weight inside api

* improve mdm weight technique

* add mdm weights to on_resolution

* add tests for pm

* modify migration logs, fix try-runtime

* adjust tests for binary search

* improve benchmarking

* do small change

* little benchmark fix

* Update zrml/authorized/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/authorized/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* use result with weight struct

* improve code

* update benchmark and weights

* improve dispute api weight system

* test delegations for reassign

* correct benchmarks and test

* remove comment

* add API benchmarks

* update weights

* use generic vote item instead of outcome report

* update to court id and generic court

* fix stuff and add documentation

* add court readme, use new parameters

* improve naming, weighting

* Use accurate dispute weight instead of max

* take random ranges without replacement

* switch get_random_number algo

* integrate court and reject simple disputes

* update start_global_dispute bench

* fix clippy

* use efficient draw without replacement algorithm

* small edits

* round to min juror stake, use other draw algo

* use partial fisher yates algorithm

* improve naming and comments

* update changelog for devs

* improve dispute api documentation

* correct call filters

* add copyright notice

* remove is_outcome and is_binary

* remove unnecessary "Court" prefix

* update copyright notices

* remove front end comment

* Update zrml/court/README.md

Co-authored-by: Malte Kliemann <[email protected]>

* npx prettier court readme

* improve style of terminology

* update readme

* remove unnecessary impl block

* update comment

* remove todo

* make reward_pot package private

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* update integrity test

* improve join court doc

* improve extrinsic documentation

* update delegate doc

* make some types package private

* fix struct comment

* update readme

* update readme

* remove commitment matcher

* fix doc string

* remove unnecessary error

* improve import

* improve test case

* fix inflation misbehaviour

* improve round timing structure

* improve error names

* fix get_valid_delegated_juror

* remove wrong break

* update weight for select jurors

* allow rejoin after exit preparation

* remove unnecessary apis

* improve naming and docs

* fix clippy

* fix copyrights

* update changelog for devs

* Update runtime/common/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* comment benchmark components

* comment benchmark component

* Update zrml/court/README.md

Co-authored-by: Harald Heckmann <[email protected]>

* add terminology for court

* Update zrml/prediction-markets/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* restructure import

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* use mul_floor and reduce indentation

* safe guard inflation emission

* use imbalance for minting

* use saturated div

* logging if inflation period mint too high

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* reduce court InflationPeriod for Battery Station

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* fmt

* fix tests

* fix issue tokens without burn

* remove unnecessary error return

* allow equal amount to previous stake

---------

Co-authored-by: Malte Kliemann <[email protected]>
Co-authored-by: Harald Heckmann <[email protected]>

* [Global Disputes] Fix issues after first battery station live test (#912)

* apply review suggestions

* use keep alive

* cargo fmt

* use function instead of raw

* improve documentation

* improve 2 outcome check

* start gd requires two unqiue outcomes

* fix error

* add empty commit

* correct admin_destroy_market test

* revert get_resolution_outcome to on_resolution

* remove gd dependency from simple disputes

* fix clippy

* use appealed outcomes for global dispute

* fix tests and benchmarks

* modify appeal bond formula

* remove slash percentages

* test default toolchain

* benchmark court

* Update zrml/court/src/types.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/types.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/mock_storage.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/tests.rs

Co-authored-by: Malte Kliemann <[email protected]>

* Update zrml/court/src/tests.rs

Co-authored-by: Malte Kliemann <[email protected]>

* periods to round timing, modify tests

* modify doc comments

* use onunbalanced

* improve RequestInterval documentation

* improve consumed_stake documentation

* remove court from filter

* add treasury to court

* correct errors

* update comment

* update get_pool_item comment

* update get_pool_item comment

* comment juror pool

* improve doc comments

* cargo fmt

* rename constants

* edit court pallet doc

* update tests

* rename secret to commitment

* make commit reveal failsafer

* outsource commitment function

* Update scripts/tests/misc.sh

* update doc comments

* merge punish tardy jurors reassign juror stakes

* outsource get_n_random_numbers

* correct logs

* rename default to get

* improve extrinsic comments

* simplify choose_multiple_weighted

* improve naming

* remove back_global_dispute

* unlock jurors from last draws

* improve error description

* shorten mock periods

* document private functions

* add assert to check max appeals

* add stake to juror joined event

* correct test

* improve test

* update reassigned event comment

* correct test

* add assert check

* improve tests for draws

* add reveal vote invalid salt fails test

* denounce slash inside reassign_juror_stakes

* improve test readibility

* rename periods to cycle_ends

* add select jurors test

* change randomness source in court tests

* fix clippy

* imrpove tests

* remove cccount lookup in tests

* improve test setup

* add API tests, add missing unlockings

* add full cycle court tests

* remove invalid test

* add missing WeightInfo

* add inflation inside court

* improve benchmarking and testing

* add integrity_test

* Update zrml/simple-disputes/src/mock.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/simple-disputes/src/mock.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/prediction-markets/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* add doc string

* add doc strings

* Reduce settle_bonds LOC

* cargo fmt

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/prediction-markets/src/migrations.rs

Co-authored-by: Harald Heckmann <[email protected]>

* apply review suggestion

* add GDItem integration

* add delegations

* improve code structure

* fix benchmarks

* optimize logic

* add correct mdm benchmarking on_dispute

* use on_dispute_weight inside api

* improve mdm weight technique

* add mdm weights to on_resolution

* add tests for pm

* modify migration logs, fix try-runtime

* adjust tests for binary search

* improve benchmarking

* do small change

* little benchmark fix

* Update zrml/authorized/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/authorized/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* use result with weight struct

* improve code

* update benchmark and weights

* improve dispute api weight system

* test delegations for reassign

* correct benchmarks and test

* remove comment

* add API benchmarks

* update weights

* use generic vote item instead of outcome report

* update to court id and generic court

* fix stuff and add documentation

* add court readme, use new parameters

* improve naming, weighting

* Use accurate dispute weight instead of max

* take random ranges without replacement

* add start_global_dispute tests

* add test

* fix typo

* switch get_random_number algo

* integrate court and reject simple disputes

* update start_global_dispute bench

* fix clippy

* use efficient draw without replacement algorithm

* small edits

* round to min juror stake, use other draw algo

* use partial fisher yates algorithm

* improve naming and comments

* update changelog for devs

* improve dispute api documentation

* correct call filters

* add copyright notice

* remove is_outcome and is_binary

* remove unnecessary "Court" prefix

* update copyright notices

* remove front end comment

* Update zrml/court/README.md

Co-authored-by: Malte Kliemann <[email protected]>

* npx prettier court readme

* improve style of terminology

* update readme

* remove unnecessary impl block

* update comment

* remove todo

* make reward_pot package private

* Update zrml/court/src/lib.rs

Co-authored-by: Malte Kliemann <[email protected]>

* update integrity test

* improve join court doc

* improve extrinsic documentation

* update delegate doc

* make some types package private

* fix struct comment

* update readme

* update readme

* remove commitment matcher

* fix doc string

* remove unnecessary error

* improve import

* improve test case

* fix inflation misbehaviour

* improve round timing structure

* improve error names

* fix get_valid_delegated_juror

* remove wrong break

* update weight for select jurors

* allow rejoin after exit preparation

* remove unnecessary apis

* improve naming and docs

* fix clippy

* correct migrations

* fix copyrights

* fmt

* fix clippy

* fix copyrights

* update changelog for devs

* Update runtime/common/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* comment benchmark components

* comment benchmark component

* Update zrml/court/README.md

Co-authored-by: Harald Heckmann <[email protected]>

* add terminology for court

* Update zrml/prediction-markets/src/benchmarks.rs

Co-authored-by: Harald Heckmann <[email protected]>

* restructure import

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* use mul_floor and reduce indentation

* safe guard inflation emission

* use imbalance for minting

* use saturated div

* logging if inflation period mint too high

* fix after merge

* update changelog for devs

* use imperative

* fmt

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* reduce court InflationPeriod for Battery Station

* Update zrml/court/src/lib.rs

Co-authored-by: Harald Heckmann <[email protected]>

* fmt

* fix tests

* fix issue tokens without burn

* remove unnecessary error return

* Update Makefile

* allow equal amount to previous stake

---------

Co-authored-by: Malte Kliemann <[email protected]>
Co-authored-by: Harald Heckmann <[email protected]>

* activate court and GD on battery station

* bump storage version of market commons

* Update runtime/zeitgeist/src/lib.rs

* Update runtime/zeitgeist/src/lib.rs

* Revert "Reduce runtime test dependencies by half"

This reverts commit fe589a5.

* Update weight templates

* Use header option for benchmarks

Also format benchmark script and moves header file into HEADER_GPL3.

* Update rust-toolchain

* Satisfy clippy

* Use patched wasm-builder for new rustc

* Format

* Update licenses

---------

Co-authored-by: Harald Heckmann <[email protected]>
Co-authored-by: Malte Kliemann <[email protected]>
@sea212 sea212 added this to the v0.4.0 milestone Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i:config-values 💻 New/changed config values i:needs-audit The changes contained in this PR require an audit i:spec-changed ⚠️ Implies change in spec version i:transactions-changed ⚠️ Implies change in transaction version s:accepted This pull request is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix global dispute issues after first battery station test run
5 participants