Add looser block deadline in order rewards query #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am tempted to say that there is a bug in the order rewards query. Specifically, it seems that the following case might happen:
start_block
and anend_block
in the trade_hashes table.order_surplus
table. But in that table, which contains information from thesettlement_scores
table, we ask that the deadline of the settlements we look into isend_block
. I think this can cause some information to be lost, because we do a left outer join of the trade_hashes table with everything else, so every trade executed betweenstart_block
andend_block
will be included in our result, while not all information about these trades will have been recovered, due to the restrictedblock_deadline
. This is because a trade can execute at blockx
, while its deadline might be up tox+9
, i believe.To address this, we propose to add some very generous buffer in the block_deadline considered, so as to ensure all relevant info about the trades are pulled together and joined in the final table.
Note: this was first noticed when i was trying to fix the integration test for PR #94 , and because of that, I opened issue #95. This PR addresses this issue.
As a final comment, an alternative would be to actually not do the above and try to only use block_deadline, similar to the batch rewards query.