Skip to content

Commit

Permalink
Implement production dispute system (#1085)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Aug 26, 2023
1 parent 30c7414 commit 8654030
Show file tree
Hide file tree
Showing 64 changed files with 12,197 additions and 2,559 deletions.
609 changes: 261 additions & 348 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ hex-literal = { version = "0.3.4", default-features = false }
log = { version = "0.4.17", default-features = false }
num-traits = { version = "0.2.15", default-features = false }
rand = { version = "0.8.5", default-features = false }
rand_chacha = { version = "0.3.1", default-features = false }
serde = { version = "1.0.152", default-features = false }

[profile.dev.package]
Expand Down
93 changes: 86 additions & 7 deletions docs/changelog_for_devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,99 @@ and does not represent a complete changelog for the zeitgeistpm/zeitgeist
repository.

As of 0.3.9, the changelog's format is based on
https://keepachangelog.com/en/1.0.0/ and ⚠️ marks changes that might break
<https://keepachangelog.com/en/1.0.0/> and ⚠️ marks changes that might break
components which query the chain's storage, the extrinsics or the runtime
APIs/RPC interface.

## v0.4.0

[#976]: https://github.com/zeitgeistpm/zeitgeist/pull/976

### Changed

All things about Global Disputes Fix ⚠️ :

- Replace `WinnerInfo` by `GlobalDisputeInfo` with the following fields:
- `winner_outcome: OutcomeReport`
- `outcome_info: OutcomeInfo`
- `status: GdStatus`

### Removed

All things about Global Disputes Fix ⚠️ :

- Remove the following event:
- `OutcomeOwnersRewardedWithNoFunds`

### Added

- ⚠️ Add court production implementation ([#976]). Dispatchable calls are:
- `join_court` - Join the court with a stake to become a juror in order to get
the stake-weighted chance to be selected for decision making.
- `delegate` - Join the court with a stake to become a delegator in order to
delegate the voting power to actively participating jurors.
- `prepare_exit_court` - Prepare as a court participant to leave the court
system.
- `exit_court` - Exit the court system in order to get the stake back.
- `vote` - An actively participating juror votes secretely on a specific court
case, in which the juror got selected.
- `denounce_vote` - Denounce a selected and active juror, if the secret and
vote is known before the actual reveal period.
- `reveal_vote` - An actively participating juror reveals the previously
casted secret vote.
- `appeal` - After the reveal phase (aggregation period), the jurors decision
can be appealed.
- `reassign_juror_stakes` - After the appeal period is over, losers pay the
winners for the jurors and delegators.
- `set_inflation` - Set the yearly inflation rate of the court system. Events
are:
- `JurorJoined` - A juror joined the court system.
- `ExitPrepared` - A court participant prepared to exit the court system.
- `ExitedCourt` - A court participant exited the court system.
- `JurorVoted` - A juror voted on a specific court case.
- `JurorRevealedVote` - A juror revealed the previously casted secret vote.
- `DenouncedJurorVote` - A juror was denounced.
- `DelegatorJoined` - A delegator joined the court system.
- `CourtAppealed` - A court case was appealed.
- `MintedInCourt` - A court participant was rewarded with newly minted tokens.
- `StakesReassigned` - The juror and delegator stakes have been reassigned.
The losing jurors have been slashed. The winning jurors have been rewarded
by the losers. The losing jurors are those, who did not vote, or did not
vote with the plurality, were denounced or did not reveal their vote.
- `InflationSet` - The yearly inflation rate of the court system was set.

All things about Global Disputes Fix ⚠️ :

- Add new dispatchable function:
- `refund_vote_fees` - Return all vote funds and fees, when a global dispute
was destroyed.
- Add the following events:
- `OutcomeOwnerRewarded` for `Possession::Paid`
- `OutcomeOwnersRewarded` for `Possession::Shared`
- `OutcomesFullyCleaned` and `OutcomesPartiallyCleaned` for extrinsic
`refund_vote_fees`
- Add enum `Possession` with variants:
- `Paid { owner: AccountId, fee: Balance }`
- `Shared { owners: BoundedVec }`
- `OutcomeInfo` has the following fields:
- `outcome_sum: Balance`
- `possession: Possession`
- Add `GdStatus` with the following enum variants:
- `Active { add_outcome_end: BlockNumber, vote_end: BlockNumber }`
- `Finished`
- `Destroyed`

## v0.3.11

[#1049]: https://github.com/zeitgeistpm/zeitgeist/pull/1049

### Changed

- ⚠️ All tokens now use 10 fractional decimal places ([#1049]).
- Cross-consensus messages (XCM) assume the global canonical representation for token balances.
- The token metadata in the asset registry now assumes that the existential deposit and fee factor
are stored in base 10,000,000,000.
- Cross-consensus messages (XCM) assume the global canonical representation for
token balances.
- The token metadata in the asset registry now assumes that the existential
deposit and fee factor are stored in base 10,000,000,000.

## v0.3.10

Expand Down Expand Up @@ -113,7 +192,7 @@ APIs/RPC interface.
- Added xTokens pallet to transfer tokens accross chains
- Added AssetRegistry pallet to register foreign asset
- Added UnknownTokens pallet to handle unknown foreign assets
- More information at https://github.com/zeitgeistpm/zeitgeist/pull/661#top
- More information at <https://github.com/zeitgeistpm/zeitgeist/pull/661#top>

- Transformed integer scalar markets to fixed point with ten digits after the
decimal point. As soon as this update is deployed, the interpretation of the
Expand Down Expand Up @@ -212,8 +291,8 @@ APIs/RPC interface.
- The `MarketCounter` of the `market-commons` pallet is incremented by one. This
means that `MarketCounter` is now equal to the total number of markets ever
created, instead of equal to the id of the last market created. For details
regarding this fix, see https://github.com/zeitgeistpm/zeitgeist/pull/636 and
https://github.com/zeitgeistpm/zeitgeist/issues/365.
regarding this fix, see <https://github.com/zeitgeistpm/zeitgeist/pull/636>
and <https://github.com/zeitgeistpm/zeitgeist/issues/365>.

- Made the `min_asset_amount_out` and `max_price` parameters of
`swap_exact_amount_in` and the `max_asset_amount_in` and `max_price`
Expand Down
1 change: 0 additions & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ std = [
"sp-core/std",
"sp-runtime/std",
]
with-global-disputes = []

[package]
authors = ["Zeitgeist PM <[email protected]>"]
Expand Down
10 changes: 6 additions & 4 deletions primitives/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ use crate::types::{Balance, BlockNumber};
use frame_support::{parameter_types, PalletId};

// Definitions for time
pub const BLOCKS_PER_YEAR: BlockNumber = (BLOCKS_PER_DAY * 36525) / 100;
pub const BLOCKS_PER_DAY: BlockNumber = BLOCKS_PER_HOUR * 24;
pub const BLOCKS_PER_YEAR: BlockNumber = (BLOCKS_PER_DAY * 36525) / 100; // 2_629_800
pub const BLOCKS_PER_DAY: BlockNumber = BLOCKS_PER_HOUR * 24; // 7_200
pub const MILLISECS_PER_BLOCK: u32 = 12000;
pub const BLOCKS_PER_MINUTE: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const BLOCKS_PER_HOUR: BlockNumber = BLOCKS_PER_MINUTE * 60;
pub const BLOCKS_PER_MINUTE: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); // 5
pub const BLOCKS_PER_HOUR: BlockNumber = BLOCKS_PER_MINUTE * 60; // 300

// Definitions for currency
pub const BASE: u128 = 10_000_000_000;
Expand Down Expand Up @@ -70,6 +70,8 @@ pub const AUTHORIZED_PALLET_ID: PalletId = PalletId(*b"zge/atzd");
// Court
/// Pallet identifier, mainly used for named balance reserves.
pub const COURT_PALLET_ID: PalletId = PalletId(*b"zge/cout");
/// Lock identifier, mainly used for the locks on the accounts.
pub const COURT_LOCK_ID: [u8; 8] = *b"zge/colk";

// Global Disputes
pub const GLOBAL_DISPUTES_PALLET_ID: PalletId = PalletId(*b"zge/gldp");
Expand Down
21 changes: 18 additions & 3 deletions primitives/src/constants/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,33 @@ parameter_types! {

// Court
parameter_types! {
pub const CourtCaseDuration: u64 = BLOCKS_PER_DAY;
pub const AppealBond: Balance = 5 * BASE;
pub const AppealBondFactor: Balance = 2 * BASE;
pub const BlocksPerYear: BlockNumber = 10000;
pub const CourtPalletId: PalletId = PalletId(*b"zge/cout");
pub const StakeWeight: u128 = 2 * BASE;
pub const RequestInterval: BlockNumber = 15;
pub const VotePeriod: BlockNumber = 3;
pub const AggregationPeriod: BlockNumber = 4;
pub const AppealPeriod: BlockNumber = 5;
pub const LockId: LockIdentifier = *b"zge/cloc";
pub const MaxAppeals: u32 = 4;
pub const MaxDelegations: u32 = 5;
pub const MaxSelectedDraws: u32 = 510;
pub const MaxCourtParticipants: u32 = 1_000;
pub const MinJurorStake: Balance = 50 * CENT;
pub const InflationPeriod: BlockNumber = 20;
}

// Global disputes parameters
parameter_types! {
pub const AddOutcomePeriod: BlockNumber = 20;
pub const GlobalDisputeLockId: LockIdentifier = *b"zge/vote";
pub const GlobalDisputesPalletId: PalletId = PalletId(*b"zge/gldp");
pub const MaxGlobalDisputeVotes: u32 = 50;
pub const MaxOwners: u32 = 10;
pub const MinOutcomeVoteAmount: Balance = 10 * CENT;
pub const RemoveKeysLimit: u32 = 250;
pub const GdVotingPeriod: BlockNumber = 140;
pub const VotingOutcomeFee: Balance = 100 * CENT;
}

Expand All @@ -60,7 +74,6 @@ parameter_types! {
pub const AdvisoryBond: Balance = 25 * CENT;
pub const DisputeBond: Balance = 5 * BASE;
pub const DisputeFactor: Balance = 2 * BASE;
pub const GlobalDisputePeriod: BlockNumber = 7 * BLOCKS_PER_DAY;
pub const MaxCategories: u16 = 10;
pub const MaxDisputeDuration: BlockNumber = 50;
pub const MaxDisputes: u16 = 6;
Expand All @@ -85,6 +98,8 @@ parameter_types! {
// Simple disputes parameters
parameter_types! {
pub const SimpleDisputesPalletId: PalletId = PalletId(*b"zge/sedp");
pub const OutcomeBond: Balance = 5 * BASE;
pub const OutcomeFactor: Balance = 2 * BASE;
}

// Swaps parameters
Expand Down
27 changes: 25 additions & 2 deletions primitives/src/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct MarketBonds<AI, BA> {
pub creation: Option<Bond<AI, BA>>,
pub oracle: Option<Bond<AI, BA>>,
pub outsider: Option<Bond<AI, BA>>,
pub dispute: Option<Bond<AI, BA>>,
}

impl<AI: Ord, BA: frame_support::traits::tokens::Balance> MarketBonds<AI, BA> {
Expand All @@ -100,13 +101,14 @@ impl<AI: Ord, BA: frame_support::traits::tokens::Balance> MarketBonds<AI, BA> {
value_or_default(&self.creation)
.saturating_add(value_or_default(&self.oracle))
.saturating_add(value_or_default(&self.outsider))
.saturating_add(value_or_default(&self.dispute))
}
}

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

Expand Down Expand Up @@ -175,11 +177,32 @@ pub enum MarketCreation {
Advised,
}

/// Defines a global dispute item for the initialisation of a global dispute.
#[derive(Clone, Decode, Encode, MaxEncodedLen, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub struct GlobalDisputeItem<AccountId, Balance> {
/// The account that already paid somehow for the outcome.
pub owner: AccountId,
/// The outcome that was already paid for
/// and should be added as vote outcome inside global disputes.
pub outcome: OutcomeReport,
/// The initial amount added in the global dispute vote system initially for the outcome.
pub initial_vote_amount: Balance,
}

// TODO to remove, when Disputes storage item is removed
#[derive(Clone, Decode, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)]
pub struct OldMarketDispute<AccountId, BlockNumber> {
pub at: BlockNumber,
pub by: AccountId,
pub outcome: OutcomeReport,
}

#[derive(Clone, Decode, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)]
pub struct MarketDispute<AccountId, BlockNumber> {
pub struct MarketDispute<AccountId, BlockNumber, Balance> {
pub at: BlockNumber,
pub by: AccountId,
pub outcome: OutcomeReport,
pub bond: Balance,
}

/// How a market should resolve disputes
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod market_id;
mod swaps;
mod zeitgeist_multi_reservable_currency;

pub use dispute_api::{DisputeApi, DisputeResolutionApi};
pub use dispute_api::{DisputeApi, DisputeMaxWeightApi, DisputeResolutionApi};
pub use market_commons_pallet_api::MarketCommonsPalletApi;
pub use market_id::MarketId;
pub use swaps::Swaps;
Expand Down
Loading

0 comments on commit 8654030

Please sign in to comment.