libplanet
libplanet copied to clipboard
Validate timestamp and `VoteFlag` of Votes
In PBFT, The vote is for sending whether a proposed/locked block for a round is valid (PreVote) or ready to commit the block (PreCommit).
Timestamp (the actual time)
ConsensusMessage should have a lifespan for preventing unexpected messages.[^1] A timestamp of a message should be verified before handling the message. (see Libplanet.Net.Consensus.Context.ProcessMessage())
A lifespan of a vote can be derived by getting a timeout duration of the round and step or a timestamp of the previous block. https://github.com/planetarium/libplanet/blob/80543e9a13f6aca3ac2725b7960c06343d68c179/Libplanet.Net/Consensus/Context.cs#L332-L357
Let's say a lifespan of ConsensusVote, it would be like $$timestamp_{propose}^{round} < timestamp_{prevote}^{round} <= timestamp_{propose}^{round} + timeout_{propose}^{round} + timeout_{prevote}^{round} + timeout_{precommit}^{round}$$
VoteFlag
VoteFlag should be checked for data integrity. A vote has a flag for validator status within an enum of VoteFlag and this should be matched with a message type if a validator sends correctly.[^2] Note that the Unknown and Null is reserved for the case when a validator is not responding.
[^1]: > The Partial synchrony model (see DLS88) aims to find a middle ground between these two models. The assumption is that there exists some known finite time bound Δ and a special event called GST (Global Stabilization Time) such that: The adversary must cause the GST event to eventually happen after some unknown finite time. Any message sent at time x must be delivered by time Δ+max(x,GST). https://decentralizedthoughts.github.io/2019-06-01-2019-5-31-models/
[^2]: (e.g., ConsensusVote = VoteFlag.Absent, ConsensusCommit = VoteFlag.Commit)