forked from tari-project/tari
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove orphan validation and only validate on insertion (tari-p…
…roject#5601) Description --- Currently, block validation is done in two steps orphan check and full check. An orphan check is done when a block is first inserted into the DB (all blocks are). But before this is done, the block must pass an internal integrity check (checking signatures, rangeproofs, etc) The blocks are then stored in the orphan pool. When they are added to the main chain, a full check is done on the blocks to ensure the mmr's are correct, no double spends + another integrity check. Bad blocks are also only tracked when syncing. This PR removes the orphan check and only does validation on the block when we add it to the main chain. But to ensure a node is not spammed by useless blocks, it makes sure the block received at least has a min difficulty. The orphan pool will clean out the oldest blocks and this stored amount is configurable via the config. As soon as we can track a block to the main chain, we will do a full Proof of work check. Then as when a chain/block proof of work is higher than the current chain the blocks will be added to the main chain. This is then when we do the full validation of the block. Changed up how the bad blocks are handled, and we now properly keep track of all bad blocks. When a block fails any part of the validation it will be added to the bad_block list. When we receive a new request for a block, this will be one of the first things we check, before we spent resources validation it again. Motivation and Context --- TARI-0003 A base node waste resources validating a block more than once. From testing, the most expensive tests to run are(in order): Rangeproofs, Metadatasignature, Scriptsignature, kernel signature. These tests are all run on orphan blocks. Its very easy to put junk data in these blocks and spam a node to keep wasting resources and validated these fake blocks. By using the tests added in tari-project#5599, this PR improves `add_block` time by almost 100%. How Has This Been Tested? --- Unit tests. What process can a PR reviewer use to test or verify this change? --- Checking that we have not changed or removed any required validation rules.
- Loading branch information
1 parent
2205b1e
commit 41244a3
Showing
14 changed files
with
181 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.