Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Staking miner: Check the queue one last time before submission #3740

Closed
kianenigma opened this issue Aug 30, 2021 · 1 comment
Closed

Staking miner: Check the queue one last time before submission #3740

kianenigma opened this issue Aug 30, 2021 · 1 comment
Assignees
Labels
U1-asap No need to stop dead in your tracks, however issue should be addressed as soon as possible.

Comments

@kianenigma
Copy link
Contributor

kianenigma commented Aug 30, 2021

Such submissions are failing because the miner checks the queue once (which is empty), and then computes a solution for 20 seconds, and then submits it, assuming that the queue is still empty. It should check one last time, after the mining is finish, if the anything exists in the queue or not.

The root cause of this is that the current code requires a full ext to check the queue:

async fn ensure_no_previous_solution<

And the ext that we are accessing is simply outdated, because it was fetched some 20 seconds ago.

The way to solve this is to:

  • rewrite ensure_no_previous_solution such that it directly query the chain state, not requiring an ext, so that we can be sure that no other solution from us lives in the queue.
  • add ensure_no_better_solution that works in the same manner, but checks that no better solution exists in the queue.
  • add a configuration enum to configure what we should do about the second check if it does NOT pass, because we might still want to be greedy and submit anyways, even though a better solution is queued. The most simple reason for this could be because we believe the the claimed better solution is fake.
enum SubmissionStrategy {
    /// Only submit if at the time, we are the best.
    OnlySubmitIfLeading,
    // Always submit. 
    AlwaysSubmit,
    /// Submit if we are leading, or if the solution that's leading is more that the given `Perbill`
    /// better than us. This helps detect obviously fake solutions and still combat them.
    SubmitIfClaimBetterThan(Perbill)
}
@niklasad1
Copy link
Member

Closed by #4819

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
U1-asap No need to stop dead in your tracks, however issue should be addressed as soon as possible.
Projects
None yet
Development

No branches or pull requests

2 participants