AntelopeIO / spring

C++ implementation of the Antelope protocol with Savanna consensus
Other
5 stars 2 forks source link

Do not vote on old blocks #418

Closed arhag closed 1 month ago

arhag commented 1 month ago

Relevant checks we already have: https://github.com/AntelopeIO/spring/blob/e2f0e9000f21edf3b65197914ac0938a048a301a/libraries/chain/controller.cpp#L3299 https://github.com/AntelopeIO/spring/blob/e2f0e9000f21edf3b65197914ac0938a048a301a/libraries/chain/controller.cpp#L4005 https://github.com/AntelopeIO/spring/blob/e2f0e9000f21edf3b65197914ac0938a048a301a/libraries/chain/include/eosio/chain/finality/finalizer.hpp#L96-L99

What we want is to not ever vote on old blocks (more than 30 seconds old relative to the wall clock time) regardless of the status of enable_voting and where the finalizers are active.

greg7mdp commented 1 month ago

Maybe we should check if our local finalizer is a member of the block's active or pending finalizer_policy before posting, instead of that we just have a local finalizer?

heifner commented 1 month ago

is_recent() is checked here: https://github.com/AntelopeIO/spring/blob/b250b477cf153c0fea99279e85da7daf70f10e9f/libraries/chain/include/eosio/chain/finality/finalizer.hpp#L97-L97

The || is correct as you want to check enable_voting flag in my_finalizers_t::maybe_vote. Granted we could add a comment, but the logic is correct.