snarkOS
snarkOS copied to clipboard
[Cleanup] Discrepancy in block request removals.
There is a discrepancy between remove_block_request_to_peer() (singular 'request') and remove_block_requests_to_peer() (plural 'requests') in how they treat a particular situation. (I would expect the two to do the same thing for each height, the singular just for the given height, and the plural for all heights.)
The situation:
- The
requestsmap has an entry for heighthwith a singleton set{ip}of peer socket addresses. - The
responsesmap has an entry for heighthwith some block.
The discrepancy:
- The "singular" function, when called on
h, removes thehentry from therequestsmap, because:peek_next_block()returnsNone, becauseis_request_completeis false — theiphas not been removed yet.can_revokeis thus true.- After removing the
ipfrom the map,can_revokestays true.
- The "plural" function, when deciding whether to retain or remove the
hentry from therequestsmap, it retains it, because:retainis true, because theresponsesmap has a block at h.
@acoglio which behaviour do you consider correct?
I'm not sure which behavior is better. I haven't done a detailed study of the liveness properties of the implementation yet, which is what these behaviors may affect (not safety). Perhaps others have more context/ideas on this.