You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
miner: don't interrupt mining after successful sync (#21701)
* miner: exit loop when downloader Done or Failed
Following the logic of the comment at the method,
this fixes a regression introduced at 7cf56d6
, which would allow external parties to DoS with
blocks, preventing mining progress.
Signed-off-by: meows <[email protected]>
* miner: remove ineff assign (lint)
Signed-off-by: meows <[email protected]>
* miner: update test re downloader events
Signed-off-by: meows <[email protected]>
* Revert "miner: remove ineff assign (lint)"
This reverts commit eaefcd3.
* Revert "miner: exit loop when downloader Done or Failed"
This reverts commit 23abd34.
* miner: add test showing imprecise TestMiner
Signed-off-by: meows <[email protected]>
* miner: fix waitForMiningState precision
This helper function would return an affirmation
on the first positive match on a desired bool.
This was imprecise; it return false positives
by not waiting initially for an 'updated' value.
This fix causes TestMiner_2 to fail, which is
expected.
Signed-off-by: meows <[email protected]>
* miner: remove TestMiner_2 demonstrating broken test
This test demonstrated the imprecision of the test
helper function waitForMiningState. This function
has been fixed with 6d365c2, and this test test
may now be removed.
Signed-off-by: meows <[email protected]>
* miner: fix test regarding downloader event/mining expectations
See comment for logic.
Signed-off-by: meows <[email protected]>
* miner: add test describing expectations for downloader/mining events
We expect that once the downloader emits a DoneEvent,
signaling a successful sync, that subsequent StartEvents
are not longer permitted to stop the miner.
This prevents a security vulnerability where forced syncs via
fake high blocks would stall mining operation.
Signed-off-by: meows <[email protected]>
* miner: use 'canStop' state to fix downloader event handling
- Break downloader event handling into event
separating Done and Failed events. We need to
treat these cases differently since a DoneEvent
should prevent the miner from being stopped on
subsequent downloader Start events.
- Use canStop state to handle the one-off
case when a downloader first succeeds.
Signed-off-by: meows <[email protected]>
* miner: improve comment wording
Signed-off-by: meows <[email protected]>
* miner: start mining on downloader events iff not already mining
Signed-off-by: meows <[email protected]>
* miner: refactor miner update logic w/r/t downloader events
This makes mining pause/start logic regarding downloader
events more explicit. Instead of eternally handling downloader
events after the first done event, the subscription is closed
when downloader events are no longer actionable.
Signed-off-by: meows <[email protected]>
* miner: fix handling downloader events on subcription closed
Signed-off-by: meows <[email protected]>
* miner: (lint:gosimple) use range over chan instead of for/select
Signed-off-by: meows <[email protected]>
* miner: refactor update loop to remove race condition
The go routine handling the downloader events handling
vars in parallel with the parent routine, causing a
race condition.
This change, though ugly, remove the condition while
still allowing the downloader event subscription to be
closed when the miner has no further use for it (ie DoneEvent).
* miner: alternate fix for miner-flaw
Co-authored-by: meows <[email protected]>
0 commit comments