-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(
peer_loop
): Reject responses with fishy difficulties
In the message-handler for `ChallengeSyncResponse`, add a check to verify that the proven difficulties of the response blocks sum up to a larger number than our own current tip's difficulty. Otherwise, the sync challenge is rejected and the peer is punished for a fishy response. Also: - Factor out parameters for genesis block header in `BlockHeader::genesis`. - Relativize `check_pow` to network, implying that different networks allow different proof-of-work evolutions. - Refactor various things to improve readability. - Add test that `max_cumulative_pow_after` works for zero `num_blocks`. - Add epsilon margin to `max_cumulative_pow_after` to tolerate small floating point rounding errors. - Document heuristic being used to reject sync challenge responses. Co-authored-by: Alan Szepieniec <[email protected]>
- Loading branch information
1 parent
aa42608
commit 05ad1be
Showing
6 changed files
with
161 additions
and
50 deletions.
There are no files selected for viewing
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.