poanetwork / hbbft

An implementation of the paper "Honey Badger of BFT Protocols" in Rust. This is a modular library of consensus.
Other
356 stars 96 forks source link

Infinite loop in QueueingHoneyBadger #432

Closed UnitylChaos closed 4 years ago

UnitylChaos commented 4 years ago

I'm trying to use the library, and seem to have encountered an infinite loop when calling handle_input on an instance of QueueingHoneyBadger with a single validator, in particular in the propose function. https://github.com/poanetwork/hbbft/blob/4857b7f9c7a0f513caca97c308d352c6a77fe5c2/src/queueing_honey_badger/mod.rs#L341-L353

The can_propose function keeps returning true even after the step is extended with the contents of the current queue. It seems that the items proposed are not removed from the queue, and this is intended behavior, but the dyn_hb.has_input() isn't returning true properly. https://github.com/poanetwork/hbbft/blob/4857b7f9c7a0f513caca97c308d352c6a77fe5c2/src/queueing_honey_badger/mod.rs#L333-L338

This seems to be because the internal HoneyBadger instance in dyn_hb is setting has_input when proposing, but is then unsetting it and advancing the epoch during try_output_batches and QHB and DHB expect it to still be set. https://github.com/poanetwork/hbbft/blob/4857b7f9c7a0f513caca97c308d352c6a77fe5c2/src/honey_badger/honey_badger.rs#L88-L95

https://github.com/poanetwork/hbbft/blob/4857b7f9c7a0f513caca97c308d352c6a77fe5c2/src/honey_badger/honey_badger.rs#L164-L185

afck commented 4 years ago

Thank you for the analysis! Good catch! Could you take a look at #433 — that should fix it, I think?