witnet-rust icon indicating copy to clipboard operation
witnet-rust copied to clipboard

Ensure consistency in data request execution across libraries

Open tmpolaczyk opened this issue 4 years ago • 7 comments

PR https://github.com/witnet/witnet-rust/pull/2139 fixes a mismatch between the execution of data requests by the node and the execution of data requests using the witnet-toolkit.

We should ensure that there are no more issues like this, by unifying all the "precondition/postcondition" logic in one place and adding tests in all the places that use witnet_rad as a library: node, wallet, cli, toolkit, node tests, ...

tmpolaczyk avatar Dec 16 '21 14:12 tmpolaczyk

For example this function is missing the precondition logic, used in data request tests:

https://github.com/witnet/witnet-rust/blob/65049271c91abb75fc3430ee0c9feb45df31698a/node/tests/data_request_examples.rs#L47

tmpolaczyk avatar Dec 27 '21 14:12 tmpolaczyk

Another example is the retrieval timeout: the witnet-toolkit does not implement that feature so sometimes it can "hang", breaking the bridge. See https://github.com/witnet/price_feed_poller/pull/34

tmpolaczyk avatar Dec 28 '21 08:12 tmpolaczyk

Here witnet nodes ensure that less than 20% of the data sources are errors:

https://github.com/witnet/witnet-rust/blob/2fa9a2fdae4501967d739d9884aaaef1882b02da/node/src/actors/rad_manager/handlers.rs#L80

But the witnet-toolkit seems to use a different percentage, right @guidiaz ?

tmpolaczyk avatar Nov 14 '22 09:11 tmpolaczyk

But the witnet-toolkit seems to use a different percentage, right @guidiaz ?

Indeed. Witnet-toolkit solved successfully a 7-source pf, when 2 of them were emitting errors. That is, a 28% of failing sources passed through.

guidiaz avatar Nov 14 '22 11:11 guidiaz

It seems that the toolkit is using witnet_rad::try_data_request to execute the data requests, and that function does implement the same 20% check as the node, here:

https://github.com/witnet/witnet-rust/blob/2fa9a2fdae4501967d739d9884aaaef1882b02da/rad/src/lib.rs#L121

So not sure what could be the cause of the observed behavior.

tmpolaczyk avatar Nov 14 '22 14:11 tmpolaczyk

Here witnet nodes ensure that less than 20% of the data sources are errors:

This is not true, that 0.2 is the minimum_consensus: at least 20% of the data sources are not errors. This is equivalent to 80% of the data sources being errors, so it is unlikely to be what's happening here. In that case the data request would resolve to RadError::InsufficientConsensus, so by looking at the specific error we can guess the cause of the inconsistency. But it looks like both the toolkit and the node use the same logic here.

tmpolaczyk avatar Nov 15 '22 08:11 tmpolaczyk

Found a possible explanation, see #2306

tmpolaczyk avatar Nov 15 '22 14:11 tmpolaczyk