zeitgeist icon indicating copy to clipboard operation
zeitgeist copied to clipboard

[prediction-markets] Make oracle/dispute deadlines used-controlled

Open maltekliemann opened this issue 2 years ago • 10 comments

Just a short summary of the plan I discussed yesterday.

Motivation

The problem that we're facing: Suppose you want to create a market: "How many gold medals will XYZ win at the Olympic Games?" You want to use the information to made a decision before the Olympic Games start, so you decide to close the market when the games start. In addition to that, you don't feel like getting rekt by traders who are watching the coverage and and will eventuall buy out the correct token.

But currently, the time the oracle has (DisputePeriod) is set to 24h, meaning that after closing the market, the oracle has 24h to report the outcome. If it doesn't, you (the market creator) get punished for having an unconscientious oracle, and anyone from the community can report the market. Which means that 24h into the Olympic Games, people are already able to submit reports about the event that hasn't even happened yet.

So you might think: "Why not just increate the DisputePeriod?" My theory is that, no matter how we set this value, there's always going to be a situation where this lack of flexibility causes a problem. So, instead, we want to make these values parameters of market creation.

Implementation Details

We need to add a deadlines: Deadlines parameter to create_market (and the functions that call create_market). The Deadlines struct should contain the following fields (might need better names):

  • oracle_delay: The delay between the point where the market closes and the point where the oracle may report.
  • oracle_duration: The duration the oracle has to submit its report.
  • dispute_duration: The duration users have to dispute the oracle support.

The best solution would be to Deadlines a generic so we can use both Moment (for Timestamps) and BlockNumber (for blocks) as measurement. I think that blocks would be sufficient for now. So let's just say that all of these have type Option<BlockNumber>. If they are None, we default to the current values, i.e. oracle_delay is zero, and oracle_duration and dispute_duration are equal to DisputePeriod.

For example, in case of the Olympic events of 2024, I'd set the market close to 26. July, 0:00 (that's when the games start). The games run for 16 days, so oracle_delay is 16 * 24 * 60 * 60 / 12 (number of blocks we produce in 16 days). During these 16 days (assuming chain doesn't stall or skip blocks), no one can submit a report for this market.

Next, we set oracle_duration to None, so it defaults to the current 24h. This means that after the 16 days of Olympic Games, the oracle now has 24h to report what happened. If it fails, the community takes over. Finally, we set dispute_duration to None, so it default to the current 24h. So the market resolves 24h after the last report/dispute.

Conversely, maybe we want to made high-speed market. So we set no delay and an oracle and dispute duration of 1h, so everybody get's their money back quickly to bet on the next hight-speed market.

We do not need an extra market state for this. The report function should just ensure! if the current time/block is at least the time/block at which the market closed plus the delay.

Remarks

You might argue that we can just set the oracle duration of the Olympic Games market to 17 days and fix the problem this way. However, if the oracle (by accident) reports the market before the end of the games, this will cause havok.

maltekliemann avatar Aug 04 '22 08:08 maltekliemann

silly question but shouldn't these durations be starting from market.period ? or it should be started from block_number at which market is created?

vivekvpandya avatar Aug 04 '22 09:08 vivekvpandya

What do you mean by "starting from market.period"? The market period has a start and end field. Which one are you refering to?

maltekliemann avatar Aug 04 '22 09:08 maltekliemann

What do you mean by "starting from market.period"? The market period has a start and end field. Which one are you refering to?

as per above example it should be market.period.end + 16 days_blocks right?

vivekvpandya avatar Aug 04 '22 09:08 vivekvpandya

What duration are you referring to here?

maltekliemann avatar Aug 04 '22 09:08 maltekliemann

is following understanding correct? oracle_delay = market.end + user_specified_duration oracle_duration = user_specified_value (but this will be used only after oracle_delay has ended) dispute_duration = user_specified_value (but this will be used only once oracle_duration has ended)

vivekvpandya avatar Aug 04 '22 09:08 vivekvpandya

So the market resolves 24h after the last report/dispute.

is it possible that oracle did not report and no community member disputed and dispute_duration is over? very unlikely but what will happen in such case?

vivekvpandya avatar Aug 04 '22 10:08 vivekvpandya

The oracle delay starts when the market closes (i.e. at period.end). That's why it's set to 16 days in the example given above. The oracle duration starts when the oracle delay has ended, and the dispute duration starts everytime a report or dispute is submitted).

For that reason it's not possible for the dispute period to end before someone reports.

maltekliemann avatar Aug 04 '22 10:08 maltekliemann

Mr. Malicious could now use a dispute_duration of zero as market creator to deny any disputes. That's why I would propose a constant MinDisputePeriod, which should be at least some amount of time. (for advised markets it could be rejected, but for permissionless markets it's a different game)

Chralt98 avatar Aug 15 '22 10:08 Chralt98

Mr. Malicious could now use a dispute_duration of zero as market creator to deny any disputes. That's why I would propose a constant MinDisputePeriod, which should be at least some amount of time. (for advised markets it could be rejected, but for permissionless markets it's a different game)

This can be a Rust constant or , we need a runtime config constant ?

vivekvpandya avatar Aug 16 '22 05:08 vivekvpandya

I would suggest a trait Config constant for this.

Chralt98 avatar Aug 16 '22 07:08 Chralt98

Reopen for MinOracleDuration

vivekvpandya avatar Oct 05 '22 07:10 vivekvpandya