Repository navigation
Block validation rules impossible error paths refactor #1182
Description
Activity
See the comments on PR #1306 which attempted to remove some of these for more details, however, an important takeaway is that these comments which were in the tests are not necessarily accurate. A full analysis of each case needs to be done rather than assuming they are correct.
- addednon-forking consensusChanges that involve modifying consensus code without causing any forking changes.Changes that involve modifying consensus code without causing any forking changes.
on Dec 28, 2019 Having another go at this.
- I have started to work on this last few days ago.…On Thu, Jul 9, 2020 at 1:21 AM Donald Adu-Poku ***@***.***> wrote: Having another go at this. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#1182 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEOKU7JWADUYSVZ6L32RZFTR2ULSDANCNFSM4E6AAX3Q> .
@AnNiran alright, I'll post my findings to start the discussion on what error codes should stay or get removed, will leave any removals to you. @davecgh please assert the following when you can, thanks.
-
ErrStakeBelowMinimum: This is already covered by block bsd1 in the full block tests. -
ErrInvalidSSGenInput: This was renamed toErrInvalidVoteInputin multi: Cleanup and optimize tx input check code. #1468 and is impossible to hit becauseisNullOutpointcurrently (erroneously?) classifies outpoints from the regular tree as null outpoints.ErrBadTxInputgets triggered when the vote input is changed to prevOut on the regular tree. This should not be removed since its call sites assert the expected relationship between a ticket and its associated vote with regards to the index position of the first output of the ticket. -
ErrSStxInImmature: This was renamed toErrImmatureTicketSpendin multi: Cleanup and optimize tx input check code. #1468 and is impossible to hit without being able to set a ticket as a winning ticket since those are the only tickets that's can be used to generate a vote. This should not be removed since its call sites asserting the stake output can be spent. -
ErrSStxInScrType: This was renamed in multi: Cleanup and optimize tx input check code. #1468 toErrTicketInputScript, This is currently impossible to hit because setting a bad script triggersErrRegTxCreateStakeOut, yet to conclude on the reason why since its a stake tx's first output pk script being modified in the test. This should not be removed however since it asserts the expected inputs for a ticket. -
ErrInvalidSSRtxInput: This was renamed toErrInvalidRevokeInputin multi: Cleanup and optimize tx input check code. #1468 and is currently impossible to hit becauseErrRegTxCreateStakeOutalready accounts for using non-stake outputs in creating a stake transaction. This should not be removed since its call sites assert the expected relationship for a revocation's input. -
ErrBadStakebaseValue: The test for this is currently failing and returningErrBadCoinbaseValueeven though a stake tree value is getting modified in the test. Yet to find out why. -
ErrStakeFees: This currently is impossible to hit because to increase fees of of a vote for example the stake base amount or the ticket value will have to be increased.ErrBadStakebaseAmountIngets triggered when the stake base is increased whileErrFraudAmountInis triggered when the ticket value is increased. This should not be removed since its call sites assert the expected behaviour of stake fees being the remaining amount when outputs are subtracted from the stake inputs.
-
@dnldd I started to analyze the errors and the stake logic more thoroughly a week ago and understood parts of what you are saying. Thank you for sharing this, it is helpful for me to match with someone else's findings.
I am starting with working with the code and I am much slower than rest of the people, so it takes me longer to realize some of the aspects.
Reacted by DApologies for not being active on this issue; I have managed to find time to work on it now and in the future on others.
PRs #1060, #1095, and #1141 resolved issue #1030 by porting all of the block validation consensus rule tests which previously were in the
blockchainpackage test function namedTestBlockValidationRulesto the newerfullblocktestsframework which programmatically generates a fully valid chain on the fly and only munges the blocks to cause a very specific condition to be tested while ensuring the block is otherwise entirely valid.However, the
TestBlockValidationRulesfunction also contained several comments regarding error paths which are not possible to hit.I'm copying those comments here as ideally the code should be refactored to avoid having impossible to hit error code paths unless they are assertions.