kaspanet / kaspad

Kaspad was the reference full node Kaspa implementation written in Go (golang), now rewritten in Rust: https://github.com/kaspanet/rusty-kaspa
ISC License
456 stars 230 forks source link

IsValidPruningPoint should calculate the expected pruning point and compare, instead of complex validation logic #1433

Open svarogg opened 3 years ago

svarogg commented 3 years ago

Currently IsValidPruningPoint does various checks to make sure that the proposed pruning point is the valid one.

This was done because finding the pruningPoint has been a costly affair at the time. The downside is that this validation logic error-prone. It might be possible to construct such a block that fits all the validation requirements, but is not the pruning point expected by our node.

Since headersSelectedChainStore was introduced, finding the expected pruningPoint should be no harder then a binary search on the headers selected chain.

This should be done in a way that the day-to-day moving of the pruning point uses the same routine to calculate the pruning point.

elichai commented 3 years ago

Approximately 1 day of work