Skip to content

Bug when claiming bonds in the case of multiple answers on reality #310

@kongzii

Description

@kongzii

According to Realitio docs, only the latest history hash is stored in the question struct:

Empty  Bytes32 + Answer + Bond + Answerer + False -> History Hash 1
History Hash 1 + Answer + Bond + Answerer + False -> History Hash 2
History Hash 2 + Answer + Bond + Answerer + False -> History Hash 3 <- stored in Questions struct

If multiple answers were submitted, and we query them on subgraph, we can see it:

Screenshot by Dropbox Capture

All the returned history hashes are the same. (it's this question)

And that's why the following code https://github.com/kongzii/trader/blob/main/packages/valory/skills/market_manager_abci/graph_tooling/requests.py#L297:

answers = [
            {
                "args": {
                    "answer": bytes.fromhex(answer["answer"][2:]),
                    "question_id": bytes.fromhex(answer["question"]["questionId"][2:]),
                    "history_hash": bytes.fromhex(
                        answer["question"]["historyHash"][2:]
                    ),
                    "user": Web3.to_checksum_address(answer["question"]["user"]),
                    "bond": int(answer["bondAggregate"]),
                    "timestamp": int(answer["timestamp"]),
                    "is_commitment": False,
                }
            }
            for answer in raw_answers
]

submits invalid hashes if there are multiple different answers and claiming of bonds fails.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions