It does not make any critical problems if validator set is static, but when it varies, can be a matter.
Since Context cannot be generated without validator set, and validator set cannot be decided without actual block appending, Context should not be created through this path, IMO.
For Context, ValidatorSet does not needed, since it has BlockChain, also.
Removing ValidatorSet field and replacing them with BlockChain[Height].GetValidatorSet() would resolve this problem.
If
ConsensusContext
receives a message with higher height than current height, it tries to create a newContext
with height of received message viaConsensusContext.CreateContext()
. https://github.com/planetarium/libplanet/blob/690a98c0664abf024c89dc52a04b14e9f6943eaa/Libplanet.Net/Consensus/ConsensusContext.cs#L250-L253But
ConsensusContext.CreateContext()
createsContext
with validator set ofConsensusContext.Height - 1
, so validator set of createdContext
is different from actual one, ifConsensusMessage.Height != ConsensusContext.Height
. https://github.com/planetarium/libplanet/blob/690a98c0664abf024c89dc52a04b14e9f6943eaa/Libplanet.Net/Consensus/ConsensusContext.cs#L442-L444It does not make any critical problems if validator set is static, but when it varies, can be a matter.
Since
Context
cannot be generated without validator set, and validator set cannot be decided without actual block appending,Context
should not be created through this path, IMO.