• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 6627435623
60%

Build:
DEFAULT BRANCH: development
Ran 24 Oct 2023 04:54PM UTC
Jobs 1
Files 722
Run time 25s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

24 Oct 2023 01:20PM UTC coverage: 75.362% (+0.3%) from 75.035%
6627435623

push

github

web-flow
feat: consistent handling of edge cases for header sync (#5837)

Description
---
This PR fixes an edge case for header sync where the local node has more
headers, but the remote node has better proof-of-work (accumulated
difficulty), thus higher actual blockchain height. It also simplifies
the attempted header sync logic and error handling when a peer does not
return headers and introduces consistent naming, variable re-use and use
of information

Supersedes #5756

Motivation and Context
---
When doing header sync, and determining from which peer to sync, we need
to consider our actual blockchain state when comparing chains. It is
possible that our node has valid block headers that will translate into
a higher proof of work when fully synced than the remote syncing peer,
but lacking the blocks to back the block headers, thus the remote chain
has an actual higher proof of work blockchain.
With the current implementation, race conditions can exist when
determining if the peer is misbehaving, i.e. lying about their
proof-of-work or not wanting to supply block headers, due to a mismatch
in tip height used for the check.

This PR fixes the race conditions by always using the latest local chain
metadata and block headers, ignoring all sync peers that do not exceed
our own accumulated difficulty and using consistent information in all
the checks.

How Has This Been Tested?
---
Added integration-level unit tests:
- `test_header_sync_happy_path`
- `test_header_sync_with_fork_happy_path`
- `test_header_sync_uneven_headers_and_blocks_happy_path`
-
`test_header_sync_uneven_headers_and_blocks_peer_lies_about_pow_no_ban`
-
`test_header_sync_even_headers_and_blocks_peer_lies_about_pow_with_ban`
-
`test_header_sync_even_headers_and_blocks_peer_metadata_improve_with_reorg`

What process can a PR reviewer use to test or verify this change?
---
- Code walk-through
- Review unit tests

<!-- Checklist -->
<!-- 1. Is the titl... (continued)

173 of 173 new or added lines in 5 files covered. (100.0%)

73733 of 97839 relevant lines covered (75.36%)

202505.72 hits per line

Jobs
ID Job ID Ran Files Coverage
1 6627435623.1 24 Oct 2023 04:54PM UTC 0
75.36
GitHub Action Run
Source Files on build 6627435623
Detailed source file information is not available for this build.
  • Back to Repo
  • Github Actions Build #6627435623
  • 3e1ec1f1 on github
  • Prev Build on development (#6623906960)
  • Next Build on development (#6637300970)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc