Skip to content

Claim the reward on a mempool order the account won - #42

Open
kabla1696-ctrl wants to merge 1 commit into
QuipNetwork:mainfrom
kabla1696-ctrl:feat/claim-mempool-reward
Open

kabla1696-ctrl wants to merge 1 commit into
QuipNetwork:mainfrom
kabla1696-ctrl:feat/claim-mempool-reward

Conversation

@kabla1696-ctrl

Copy link
Copy Markdown

The coordinator submits a solution for a mempool order and never claims the
reward, so a solver that wins an order is paid nothing.

What the pallet does

QuantumComputeMempool pays a won order only when the winner asks for it:

  1. submit_solution accepts a solution. The order records
    first_solution_at and emits BlockWaitStarted { first_solution_at, closes_at }.
  2. The order waits out its block_wait, which is a handful of blocks.
  3. The winner calls claim_reward(order_id). That transfers the reward
    from the proposer to the winner, credits
    Solvers[account].rewards_earned, and closes the order.
  4. If nobody claims, the proposer calls reclaim_order and the reward
    goes back to the proposer.

So nothing is paid automatically. A solver that submits a solution and
stops there is paid nothing.

What the coordinator does

submit_mempool_result submits the solution and logs it. There is no
claim_reward anywhere in the coordinator: the call does not exist in the
chain client, it is not encoded, and it is never made.

What it looks like on the chain

Decoding every order in QuantumComputeMempool.JobOrders at the head
block on Aglais:

orders total        139
status Opened        0
status Expired      96
status Closed       43

All ninety-six of the expired orders have a first_solution_at, so a
solution was accepted on every one of them, and together they carry 1447
accepted solutions. Each was worth 1 AGLS, so ninety-six AGLS of reward
was earned by solvers and never collected. The only orders that paid are
the forty-three that closed.

The expired orders are not unusually hard either. Their node counts run
from 2 to 96, ninety-six of the hundred and thirty-nine have no energy
gate at all, and all of them are Open mode, which admits any registered
solver. The block wait on them is 5 or 10 blocks, so the reward became
claimable long before the orders expired.

The change

  • encode_claim_reward_call builds the call body: the pallet index, the
    call index, and the order id.
  • The chain client gains claim_reward. It reads the order first and
    only submits the call once the order's wait has elapsed. The order's
    own timing is on chain, so the coordinator does not have to guess when
    the wait is over, and a claim made too early is never submitted and
    costs no fee.
  • The session records the order when a solution is accepted, and the
    feeder tries the claim on a later poll. A claim that is not ready yet
    comes back retryable and is tried again.

All 541 of the coordinator's tests pass with the change, and the
encoding has a test of its own.

Worth

To a solver that wins an order, the whole reward. On the testnet that
is one AGLS per order, and the market is thin, but the difference is
between being paid and not being paid at all.

The pallet does not pay a won order on its own. A solver submits a
solution, the order waits out its block wait, and then the winner has
to call `claim_reward` to collect the reward. The coordinator submits
the solution and never claims, so a solver that wins an order is paid
nothing and the proposer reclaims the order instead.

On the Aglais testnet, decoding every order in
`QuantumComputeMempool.JobOrders` at the head block gives 139 orders:
none open, 96 expired and 43 closed. All ninety-six of the expired
ones have a `first_solution_at`, so a solution was accepted on every
one of them, and together they carry 1447 accepted solutions. Each was
worth 1 AGLS, so ninety-six AGLS of reward was earned by solvers and
never collected. The only orders that paid are the forty-three that
closed. Those orders are not unusually hard either: their node counts
run from 2 to 96, ninety-six of them have no energy gate at all, and
all of them are `Open` mode, which admits any registered solver.

The chain client now reads the order first and only submits the claim
once the order's wait has elapsed. The order's own timing is on chain,
so the coordinator does not have to guess when the wait is over, and a
claim made too early is never submitted and costs no fee.

The session records the order when a solution is accepted, and the
feeder tries the claim on a later poll. A claim that is not ready yet
comes back retryable and is tried again.

All 541 of the coordinator's tests pass with the change, and the
encoding has a test of its own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant