-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(miner): ignore lastWork when selecting the best mining candidate + tests #12659
Conversation
NOTE: This is the smallest possible fix for this bug. An ideal fix would have some other properties:
In other words, this fix should be no worse than the current code. |
Previously, we only took the new head if it's heavier than the last head. Unfortunately, this meant that F3 finalization wasn't properly propagated to the miner. In terms of impact: 1. It seems likely that this check was simply defensive as, prior to F3, the new head should never have a lower weight (unless you're talking to multiple lotus nodes, I guess...). 2. The `lastWork` field is mostly used to track null blocks. Worst-case scenario, if we switch heads, we'll attempt to re-mine previous heights. However, that should be relatively fast and, due to the slash filter, we won't attempt to re-broadcast any of those blocks.
704855e
to
e1a0572
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM based on standup discussion. As far as I can tell the previous implementation is due to a whole bunch of historical reasons that no longer apply.
We looked into history a bit more, it looks like this check was a part of the very first WIP commit and just stuck the entire way. |
Well, it kind of works. But our slash-filter handling is bonkers. If we hit the slash filter, we'll keep trying to re-mine the same height until someone wins which obviously won't work. So now I'm trying to fix that. |
Hm. So, I don't think that'll work because mining on a "different fork" would be slashable, IIRC. In practice this isn't an issue because, while we can't mine until someone else does, someone else will eventually mine on a different height. So I'm just going to setup a test with an additional miner. |
Ok, the handling of null blocks with respect to slashed blocks broke everything (that and our syncing logic has some issues). I've pushed a WIP commit with a test and hacky fixes that make the test "pass", but I don't think they're 100% correct. Issues:
|
246f88c
to
0c0b158
Compare
This test still doesn't pass and I'm not sure why: 1. Sync is a bit broken because it can't figure out that we already have all the data locally. 2. But with 2 nodes, it should work. Except that, if I add some logging, I see that sync works until the libp2p nodes just flat-out disconnect from eachother.
0c0b158
to
4404614
Compare
Ok, I think my fix for the mining loop might be ok, but someone should look at it. However, we still need to fix the sync issue to get the tests to pass:
So I think the sync issue is ultimately some libp2p strangeness. |
We also perform this check inside `SyncSubmitBlock` so we did have an effective filter, but this was still wrong.
We have some cases where we submit a tipset to ourselves, from ourselves and end up calling `AddPeer` with our own ID. Ignore this case.
A side-effect of InformNewHead is to record the peer for future chain-sync sessions. If we don't pass blocks to InformNewHead here, we can have some difficulty bootstrapping networks.
log.Debugf("Got new tipset through Hello: %s from %s", ts.Cids(), s.Conn().RemotePeer()) | ||
hs.syncer.InformNewHead(s.Conn().RemotePeer(), ts) | ||
} | ||
// don't bother informing about genesis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// don't bother informing about genesis |
I think this is replaced by the now merged #12690 |
Related Issues
fixes filecoin-project/go-f3#730
Proposed Changes
Ignore
lastWork
when selecting the best mining candidate.Previously, we only took the new head if it's heavier than the last head. Unfortunately, this meant that F3 finalization wasn't properly propagated to the miner.
In terms of impact:
lastWork
field is mostly used to track null blocks. Worst-case scenario, if we switch heads, we'll attempt to re-mine previous heights. However, that should be relatively fast and, due to the slash filter, wewon't attempt to re-broadcast any of those blocks.
Checklist
Before you mark the PR ready for review, please make sure that: