holochain / holochain-rust

DEPRECATED. The Holochain framework implemented in rust with a redux style internal state-model.
GNU General Public License v3.0
1.12k stars 267 forks source link

Sim2h WireMessage Receipts #2120

Closed lucksus closed 4 years ago

lucksus commented 4 years ago

PR summary

This intends to make the channel between nodes and the Sim2h server resilient against data/connection loss on the level of Lib3hMessages. (in the direction: Sim2hWorker -> Sim2h server)

This resilience is actually an assumption that code in core holds, but that wasn't met by the Sim2h/Sim2hWorker implementation yet. A connection dropped just after a message was sent would leave the disconnected node without track of that lost message. It would continue to function after a reconnect, but the message sent before would be lost, if it wasn't received by the server before the disconnect.

With this PR we add a receipt message type WireMessage::Ack(u64) that the Sim2h server sends back, including a hash of the processed message. The Sim2hWorker now only sends one message at a time and waits for the receipt before sending the next one. If a receipt is not received within 10 seconds, it will resend the message.

testing/benchmarking notes

( if any manual testing or benchmarking was/should be done, add notes and/or screenshots here )

followups

changelog

- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)

documentation

neonphog commented 4 years ago

See for getting u8 to work: https://github.com/holochain/holochain-rust/compare/low-level-receipts

neonphog commented 4 years ago

Similarly - if you want the hashing to be consistent, I believe the problem lies in the level at which you are hashing.

On the worker side, if you hash the already serialized binary data (optimally changing the outgoing queue to have already serialized data and respective hashes), then on the server side, do the hashing before deserializing the data, then obviously they should match.

lucksus commented 4 years ago

@neonphog, @zippy, implemented both your change requests.

lucksus commented 4 years ago

@neonphog, implemented those suggestions as well :)