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

ZIP-0 Part I #862

Merged
merged 103 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
0c3e70d
use future resolution inside pm-pallet
Chralt98 Oct 31, 2022
7e77047
wip
Chralt98 Nov 1, 2022
b16eb03
wip
Chralt98 Nov 1, 2022
d20682d
prepare storage migration
Chralt98 Nov 1, 2022
999a2fc
add UpdateMarketIdsPerDisputeBlock migration
Chralt98 Nov 1, 2022
2d69ad2
wip
Chralt98 Nov 1, 2022
19585bf
avoid in place migration
Chralt98 Nov 2, 2022
1e7fd66
default to oracle report for authorized
Chralt98 Nov 2, 2022
c9adaf3
wip
Chralt98 Nov 2, 2022
500060d
wip
Chralt98 Nov 2, 2022
d438701
change test
Chralt98 Nov 3, 2022
26b5dde
fix benchmark
Chralt98 Nov 3, 2022
52fa258
add resolve_failed_mdm benchmarks
Chralt98 Nov 3, 2022
d74c949
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Nov 4, 2022
773fe57
correct benchmarks
Chralt98 Nov 4, 2022
8428c24
fix nightly clippy
Chralt98 Nov 4, 2022
ec9260c
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Nov 5, 2022
e724498
fix after merge
Chralt98 Nov 5, 2022
db7670d
fix admin for Authorized
Chralt98 Nov 7, 2022
8b015f7
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Nov 24, 2022
535ea00
fix global disputes
Chralt98 Nov 24, 2022
81db3ee
add migration tests
Chralt98 Nov 25, 2022
a02b3c9
delete 0.3.7 storage migration
Chralt98 Nov 25, 2022
fedd819
cargo fmt
Chralt98 Nov 25, 2022
818c68a
modify storage versions to test try-runtime
Chralt98 Nov 25, 2022
4a4f2d4
edit doc comment
Chralt98 Dec 5, 2022
722d29c
simplify doc comment
Chralt98 Dec 5, 2022
7281007
update benchmark authorize outcome
Chralt98 Dec 5, 2022
7059171
avoid indentation
Chralt98 Dec 5, 2022
39b2bbf
rename AuthorityReportPeriod to ReportPeriod
Chralt98 Dec 5, 2022
04fce1b
use ensure
Chralt98 Dec 5, 2022
55dc26c
check benchmark
Chralt98 Dec 5, 2022
e54dc31
remove where clauses
Chralt98 Dec 5, 2022
3466a73
Apply suggestions from code review
Chralt98 Dec 5, 2022
556d0f5
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Dec 5, 2022
45e51ba
add empty commit
Chralt98 Dec 6, 2022
9654780
use Weight instead of u64
Chralt98 Dec 6, 2022
27721f6
resolve doc comment
Chralt98 Dec 6, 2022
56d0319
rename MarketCommonsAuthorized to MarketCommons
Chralt98 Dec 6, 2022
6628a46
fmt
Chralt98 Dec 6, 2022
a725181
allow only one dispute for authorized
Chralt98 Dec 7, 2022
31af8e8
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Dec 7, 2022
09ab27b
clippy
Chralt98 Dec 8, 2022
02ecf9c
fix benchmarks after one dispute limit authorized
Chralt98 Dec 8, 2022
7f6bc00
fix clippy
Chralt98 Dec 8, 2022
7c7098c
add try-runtime tests
Chralt98 Dec 8, 2022
b618605
correct benchmarks
Chralt98 Dec 8, 2022
25d2cfd
down tracing-core to get try-runtime logs
Chralt98 Dec 9, 2022
5e29644
rename failed to expired
Chralt98 Dec 13, 2022
fbf45ab
rename resolution to resolve_at
Chralt98 Dec 13, 2022
b038a96
fix small nitpicks
Chralt98 Dec 13, 2022
a948faa
edit doc comment
Chralt98 Dec 13, 2022
30ce824
use reporting period from last dispute
Chralt98 Dec 13, 2022
d539bf6
modify doc string
Chralt98 Dec 13, 2022
a99b8bc
document private authorozed api
Chralt98 Dec 13, 2022
580bc07
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Dec 14, 2022
846d926
fix after merge
Chralt98 Dec 14, 2022
8a8c4b9
print market id for try-runtime tests
Chralt98 Dec 14, 2022
346d892
bump migration versions
Chralt98 Dec 14, 2022
0c00e8f
avoid storage_iter
Chralt98 Dec 14, 2022
e8761d2
add warning
Chralt98 Dec 14, 2022
ac8a7e5
set block number non-zero in migration test
Chralt98 Dec 14, 2022
e603788
move storage migration
Chralt98 Dec 14, 2022
1812e19
recalc migration markets counter
Chralt98 Dec 14, 2022
5fbec34
abstract remove auto resolve
Chralt98 Dec 14, 2022
65be714
fmt
Chralt98 Dec 14, 2022
e5d59ed
remove TODO
Chralt98 Dec 14, 2022
fb48a7e
add expired report period check
Chralt98 Dec 14, 2022
7657bf6
rename to has_failed
Chralt98 Dec 14, 2022
5f036d3
satisfy clippy
Chralt98 Dec 14, 2022
5f3fb41
check dispute resolution blocks
Chralt98 Dec 16, 2022
de1c7d2
use mock storage with unsafe
Chralt98 Dec 16, 2022
f9eb238
use MarketIdsPerDisputeBlock inside mock
Chralt98 Dec 19, 2022
0f3b1e1
prepare authority account id
Chralt98 Dec 19, 2022
9d7f8e2
correct benchmarks
Chralt98 Dec 19, 2022
ccfa04f
add mock storage
Chralt98 Dec 21, 2022
cb038d8
correct start_global_disputes benchmark
Chralt98 Dec 21, 2022
8b81a11
improve migration
Chralt98 Dec 21, 2022
eb7b533
remove fallible authority feature
Chralt98 Dec 22, 2022
05fdef7
remove fallible authority feature
Chralt98 Dec 22, 2022
9d8d3cb
avoid option storage query, handle 432 market
Chralt98 Jan 2, 2023
c127139
Update zrml/authorized/src/mock_storage.rs
Chralt98 Jan 4, 2023
9aa93c4
fix resolve_failed_mdm bug
Chralt98 Jan 4, 2023
c4b623a
Update zrml/prediction-markets/src/tests.rs
Chralt98 Jan 4, 2023
2398ce0
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Jan 4, 2023
532b686
fixes after merge
Chralt98 Jan 4, 2023
193dc1b
avoid refreshing correction period
Chralt98 Jan 4, 2023
bce0c39
add description for the changes made
Chralt98 Jan 4, 2023
ceddfa9
remove resolve_failed_mdm
Chralt98 Jan 5, 2023
29a684d
use ord_parameter_types macro
Chralt98 Jan 5, 2023
7a6eaad
check auto resolve in case of existing report
Chralt98 Jan 5, 2023
2651517
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Jan 6, 2023
33b554b
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Jan 6, 2023
c67a4a1
handle market 432
Chralt98 Jan 6, 2023
956f3f4
Merge branch 'main' into chralt98-mdm-resolution2
Chralt98 Jan 6, 2023
8c79cf6
correct pm disputes authorized benchmarks
Chralt98 Jan 6, 2023
c46c579
fix clippy
Chralt98 Jan 6, 2023
aad23fc
update pm weights
Chralt98 Jan 9, 2023
b41af6a
remove unused error
Chralt98 Jan 10, 2023
aea06f8
test only one dispute error
Chralt98 Jan 10, 2023
7ba0801
remove unused error
Chralt98 Jan 10, 2023
cfc576a
remove unused event
Chralt98 Jan 10, 2023
d328b2f
cargo fmt
Chralt98 Jan 10, 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
34 changes: 9 additions & 25 deletions zrml/prediction-markets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,9 @@ mod pallet {
.max(
T::WeightInfo::admin_move_market_to_resolved_categorical_reported(CacheSize::get())
).max(
T::WeightInfo::admin_move_market_to_resolved_scalar_disputed(
CacheSize::get(),
T::MaxDisputes::get()
)
T::WeightInfo::admin_move_market_to_resolved_scalar_disputed(CacheSize::get())
).max(
T::WeightInfo::admin_move_market_to_resolved_categorical_disputed(
CacheSize::get(),
T::MaxDisputes::get()
)
T::WeightInfo::admin_move_market_to_resolved_categorical_disputed(CacheSize::get())
),
Pays::No,
))]
Expand All @@ -370,7 +364,7 @@ mod pallet {
market.status == MarketStatus::Reported || market.status == MarketStatus::Disputed,
Error::<T>::InvalidMarketStatus,
);
let (ids_len, disputes_len) = Self::clear_auto_resolve(&market_id)?;
let (ids_len, _) = Self::clear_auto_resolve(&market_id)?;
maltekliemann marked this conversation as resolved.
Show resolved Hide resolved
let market = <zrml_market_commons::Pallet<T>>::market(&market_id)?;
let _ = Self::on_resolution(&market_id, &market)?;
let weight = match market.market_type {
Expand All @@ -379,10 +373,7 @@ mod pallet {
T::WeightInfo::admin_move_market_to_resolved_scalar_reported(ids_len)
}
MarketStatus::Disputed => {
T::WeightInfo::admin_move_market_to_resolved_scalar_disputed(
ids_len,
disputes_len,
)
T::WeightInfo::admin_move_market_to_resolved_scalar_disputed(ids_len)
}
_ => return Err(Error::<T>::InvalidMarketStatus.into()),
},
Expand All @@ -391,10 +382,7 @@ mod pallet {
T::WeightInfo::admin_move_market_to_resolved_categorical_reported(ids_len)
}
MarketStatus::Disputed => {
T::WeightInfo::admin_move_market_to_resolved_categorical_disputed(
ids_len,
disputes_len,
)
T::WeightInfo::admin_move_market_to_resolved_categorical_disputed(ids_len)
}
_ => return Err(Error::<T>::InvalidMarketStatus.into()),
},
Expand Down Expand Up @@ -2139,17 +2127,17 @@ mod pallet {
time.saturated_into::<TimeFrame>().saturating_div(MILLISECS_PER_BLOCK.into())
}

fn calculate_internal_resolve_weight(market: &MarketOf<T>, total_disputes: u32) -> Weight {
fn calculate_internal_resolve_weight(market: &MarketOf<T>) -> Weight {
if let MarketType::Categorical(_) = market.market_type {
if let MarketStatus::Reported = market.status {
T::WeightInfo::internal_resolve_categorical_reported()
} else {
T::WeightInfo::internal_resolve_categorical_disputed(total_disputes)
T::WeightInfo::internal_resolve_categorical_disputed()
}
} else if let MarketStatus::Reported = market.status {
T::WeightInfo::internal_resolve_scalar_reported()
} else {
T::WeightInfo::internal_resolve_scalar_disputed(total_disputes)
T::WeightInfo::internal_resolve_scalar_disputed()
}
}

Expand Down Expand Up @@ -2450,7 +2438,6 @@ mod pallet {
}

let mut total_weight = 0;
let disputes = Disputes::<T>::get(market_id);

let resolved_outcome = match market.status {
MarketStatus::Reported => Self::resolve_reported_market(market_id, market)?,
Expand All @@ -2476,10 +2463,7 @@ mod pallet {
MarketStatus::Resolved,
resolved_outcome,
));
Ok(total_weight.saturating_add(Self::calculate_internal_resolve_weight(
market,
disputes.len().saturated_into(),
)))
Ok(total_weight.saturating_add(Self::calculate_internal_resolve_weight(market)))
}

pub(crate) fn process_subsidy_collecting_markets(
Expand Down
Loading