HydraDX-node
HydraDX-node copied to clipboard
Price-fetch: One time price evaluation with off-chain workers
The general assumption is that the PoS nodes (can) run offchain workers themselves who publish data (e.g. price feeds) as oracles so that this data can be used on-chain. To make sure that the offchain workers report their data correctly, we can repurpose the stake they have for validating the blocks themselves. In its simplest iteration such a system could work like this:
- PoS validators each run an offchain worker that gets and reports data, they include it in a block
- The blocks are collected over some time (in the order of minutes) and then compared by an on-chain averaging module
- The averaging module calculates the average (or median or mean or modus) and detects outliers in the data
- If the outliers are "too far apart" (to be defined), the validator set can execute rules to punish the reporters of this outlying data.
- If there are different data source families, it could be viable to see each of them as a separate data source so that an error in the off-chain feed does not punish the well-behaving reporters. Instead a warning can be issued if two or more oracle systems differ too much (e.g. DIA reports a price of 1 and another oracle a price of 2, but all DIA nodes are around 1 and all nodes from the other data provider report around 2, nobody in the reporter crowd should be punished)
credit @kaythxbye @martinfridrich @jak-pan
Ideas | PRs welcome
to do:
- [ ] Better parsing of oracle data #37
- [ ] Include POS in the runtime #39