unit-e
unit-e copied to clipboard
Validate full blocks before storing them to disk and maybe ban peers
Bitcoin implementation is a bit loose when performing validation before storing blocks to disk. This behavior is defendable since it can check the proof of stake correctness. Whenever a new block is received the following happens:
ProcessNewBlock() -> AcceptBlock() -> store on disk
if any of those calls fail the block is not stored but the peer is not punished (as it should). Unfortunately there is no check for signature correctness nor for the stake to not be already spent. Those checks are happening at a later time when:
ConnectBlock() -> CheckTxInputs()
checks for the scriptSig validity (executing it).
Since we can't rely on PoW to guard our resources we have to validate thoroughly any block before storing it to disk and in case somebody relays something invalid we should proceed and ban him, as it's expected to perform all the validations before relaying a block.
Good catch! To be implemented/verified with the help of @amiller. Who disclosed disk attacks in some PoS currencies
Some fixes / responses to the vulnerabilities:
- https://www.dropbox.com/s/nw6uipvjxo0ujrs/NLC2-PoS-Vulnerabilities-20190124.pdf?dl=0
- https://github.com/Galilel-Project/galilel/commit/1fe39e9ca036f915f27322dfb575da78c0163984