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

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

@kianenigma

Description

@kianenigma

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)
}

Metadata

Metadata

Assignees

Labels

U1-asapNo need to stop dead in your tracks, however issue should be addressed as soon as possible.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions