RealityETH / reality-eth-monorepo

Monorepo containing reality.eth contracts, UI code and everything else.
39 stars 20 forks source link

Small refactor, add function to verify history #134

Closed edmundedgar closed 9 months ago

edmundedgar commented 9 months ago

This PR adds the function needed to verify that an earlier bond was provided for a particular answer. We want this in Backstop to allow you to freeze an adjudicator while we wait to see if they're bad.

We are doing something similar in our fork of reality.eth v3 here: https://github.com/RealityETH/subjectivocracy/blob/main/contracts/AdjudicationFramework/MinimalAdjudicationFramework.sol#L244

We'll need to change this slightly since the function now just validates the history provided rather than validating it and returning two fields from the final entry. This is intended to be slightly more generalizable and to make it more obvious what the function does. There's a small internal change (you call a function to check the hash then revert if it's wrong) which allows us to return true/false instead of reverting or not reverting, which seems slightly cleaner.

The function name also specifies that the question must be unfinalized. This is intended to avoid making a footgun where a developer calling this doesn't realize that history validation will working if someone claims their rewards, because we delete the history when that happens. It's assumed that once the question is finalized, you can get the final answer by calling resultFor and you don't care about the history of answers that turned out to be wrong.