livepeer / livepeer/go-livepeer

pm: recipient redeems old valid winning tickets on start up

Open
#632 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: icebox type: feature
Dominant language
Go
Stars
586
Forks
226
Avg merge
1d 17h
Merged PRs (30d)
19

Description

Is your feature request related to a problem? Please describe.

If O crashes prior to a redeeming a winning ticket on-chain, it will lose out on the pay out from the ticket unless O has a way to persist the ticket data such that it can try to redeem the ticket at a later point in time.

Describe the solution you'd like

Once #621 is implemented, O will always store winning ticket data in its DB at least until the ticket is successfully redeemed on-chain.

On start up, O can do the following:

  • Query its DB for all winning tickets [1]
  • For each winning ticket check that it is still valid (given expiration requirements) and that it has not already been redeemed on-chain. We perform the last check because it might have been the case that O submitted a tx, crashed and then the tx confirmed.
  • Redeem each valid winning ticket on-chain

[1] After observing a successful on-chain tx we can either clear the winning ticket from the DB or mark the winning ticket as redeemed by storing the confirmation block number in the relevant row of the winning tickets table. If we do the former, we can just query for all rows in the table here. If we do the latter, we can query for rows that do not have a confirmation block number.

Describe alternatives you've considered

O does not necessarily need to redeem the old valid winning tickets on start up, but it is unclear if there is a better time to do so at least in the MVS setting where we are not yet implementing any smarter strategy ticket redemption timing (i.e. O could only redeem tickets when the average gas price is at some level and if that level is not met by X blocks prior to the ticket's expiration O will redeem the ticket on-chain). Since we are leaving alternative ticket redemption strategies for the future, redeeming old valid winning tickets on start up seems like the simplest solution for now.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the winning-ticket persistence work described in #621 and locate the recipient startup path and winning-tickets database handling. Trace how ticket expiration and on-chain redemption status can be checked, then verify that valid unredeemed tickets are retried on startup and that completed tickets are not retried.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, blockchain, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.