-
Notifications
You must be signed in to change notification settings - Fork 988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync on discovering a "longer" chain #412
Comments
This was referenced Dec 1, 2017
You're right, this is bogus:
And this later on should match for a
Forks do not require a head. They just need to have some previous block that's findable. Does that make sense? |
ignopeverell
added a commit
that referenced
this issue
Dec 1, 2017
sesam
pushed a commit
to sesam/grin
that referenced
this issue
Dec 13, 2017
ignopeverell
pushed a commit
that referenced
this issue
Dec 13, 2017
* Very quick peer banning endpoint, helps with #406 * Ping heights (#407) * add height to ping/ping * reformat output * fix p2p test * Fix orphan handling, not related to current head. Fixes #412 * Check before borrow, fixes #267 * Not finding an output commit in pos is an AlreadySpent * Fix race condition, sending before conn is ready * Explicit error for unknown pos of a forked block * Remove config outdated tests. Fix #333 * Check ref and try before borrow, fix #400 * We do not want to sync with old peers anyway * Hide cargo compiler warning for unused NoopAdapter and unused test code. Add TODOs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the scenario (contrived example, I believe this happened over a larger number of blocks on both forks of the chain) -
We're happily processing blocks on the current chain -
A new peer joins the network and advertises a previously unknown longer chain (both in terms of total_difficulty and height) -
head
points atb4
.header_head
points atb4
.head
remains atb4
sync_head
points now atb6'
header_head
is updated tob6'
(header with most work)b4
has greater total_difficulty than bothb4'
andb5'
We now build a
Locator
to go request blocks[b3', b4', b5', b6']
.Processing blocks
b3'
,b4'
b5'
are all fine -head
remains pointing originalb4
, still block with most workProcessing block
b6
fails validation (and is flagged anOrphan
)because while
b6'
has more total_difficulty thanb4
it is more than one block higher than the originalb4
. There is nob5'
betweenb4
andb6'
.It actually fails validation twice.
Once in
validate_header
(and if this were to pass) again invalidate_block
-Q1) Should
header_head
be updated during sync if we process a new header on the longest chain (at which point it diverges from the currentbody_head
)? These can be on divergent forks as in the above scenario.Q2) When processing a block we validate both the header and the block. If the
header_head
and thebody_head
can diverge then this necessitates passing in two separate contexts toprocess_block
(for the two divergent chain heads)?Q3) How can we robustly handle
Orphan
detection in this case where we jump suddenly from one fork to another and the heights are not strictly sequential?The text was updated successfully, but these errors were encountered: