-
Notifications
You must be signed in to change notification settings - Fork 458
Unit test review: BFT #7957
Comments
As far as the research by @AndreasKendziorra , the division is deterministic although there will be an rounding error when using floating number
This is because
yes. those should be covered in
I think in the BFT, it is not considering genesis height. the logic is if the bft info is empty, store maxHeightPrevoted + 1 which only happens in genesis block case? |
No, in this case the genesis height is used, see the function |
I think we missed to update this, ill try to address it in different PR |
I was double checking and currently we store genesis height as maxHeightPrevoted in https://github.com/LiskHQ/lisk-sdk/blob/development/framework/src/engine/bft/module.ts#L49-L60 Therefore, when we use in the empty case https://github.com/LiskHQ/lisk-sdk/blob/development/framework/src/engine/bft/method.ts#L222, the maxHeightPrevoted is genesis height |
bft_processing.spec.ts
floor
andceil
on floating point numbers and instead only use integer arithmetic. Concretely,Math.floor((scenario.config.activeValidators * 2) / 3) + 1;
could be replaced with integer division.expect(bftInfo?.prevoteWeight).toBeUndefined();
andexpect(bftInfo?.precommitWeight).toBeUndefined();
. I am not sure why why expect the weight to be undefined. Isn't it the case that thebftInfo
array does not contain an object at that height in the first place.bft_votes.spec.ts
maxHeightPrevoted == 103
, but the block at height 149 has prevote weight 68. This can happen, of course, after callingupdatePrevotesPrecommits
and before then callingupdateMaxHeightPrevoted
. But in the BFT protocol no other function is called in between those two functions. Probably that does not create an issue with the test, but in principle it could have undesired side-effects and it would be best to test with a consistent state of BFT votes.maxHeightGenerated == 0
would not be added to the chain as it contradicts the block at height 149 by the same generator. Maybe this is still fine for the tests, but it could be better to have a valid block.prevoteThreshold: BigInt(69)
, i.e., exactly just increment the minimal amount to get a different result, instead of choosing an extreme.aggregateCommit.height == bftVotes.maxHeightCertified
. This validation is not defined in LIP 58, but part of the aggregate commit validation.method.spec.ts
areHeadersContradicting
: These tests only cover the easy cases, but not the cases depending onmaxHeightPrevoted
andmaxHeightGenerated
. I guess we assume here those tests are covered by the functionareDistinctHeadersContradicting
.isHeaderContradictingChain
: The initializationmaxHeightPrevoted: 10,
does not make sense. This probably does not affect the test.29
and30
.19
the function returns20
.genesisHeight + 1
in this case (note that only after processing the genesis block, blockBFTInfo should be empty and then we actually havemaxHeightPrevoted == genesisHeight
).utils.spec.ts
maxHeightGenerated
ormaxHeightPrevoted
for the block headers (I assume they are then just some random value). I think it would be better to also define those, to be sure that the headers are not considered contradicting for other reasons. Currently, it is also difficult to see that all cases in the function are covered.General comment
getGeneratorAtTimestamp
andgetSlotNumber
. They are maybe not directly part of the BFT protocol, but are defined in LIP 0058.The text was updated successfully, but these errors were encountered: