Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pm: Add README #1099

Merged
merged 2 commits into from
Jun 1, 2023
Merged

pm: Add README #1099

merged 2 commits into from
Jun 1, 2023

Conversation

yondonfu
Copy link
Member

@yondonfu yondonfu commented Sep 20, 2019

What does this pull request do? Explain your changes. (required)

This PR adds:

  • A brief README for the pm package that references the full PM protocol specification and also highlights a few things that the package implements to ensure fair winning ticket selection.
  • A payment doc in doc/payments.md that includes links to resources for the PM protocol as well as notes on fee estimation

Specific updates (required)

See above.

How did you test each of these updates (required)

N/A

Checklist:

  • README and other documentation updated
  • Node runs in OSX and devenv
  • All tests in ./test.sh pass

@j0sh
Copy link
Collaborator

j0sh commented Sep 24, 2019

The first part looks pretty good to me. The RNG part feels a little ad hoc / incomplete without some more context around PM. Even though there is a link to the full PM spec, it might not be immediately clear to a new reader where the RNG part fits in and the reasoning for certain behaviors.

Eg, from a quick glance, the writeup mentions that winning recipientRand values are only persisted in memory. A sharp reader might ask why "in memory" is a sufficient defense, and the reader needs to connect a few dots themselves within the full spec (or via reading the code) to figure out it's because O.secret is generated fresh at each start-up time.

Not really sure yet how/where to improve this without a closer read of the PM spec.


The `abi.encodePacked()` Solidity built-in is used to match the behavior of the contract implementing the `TicketBroker` interface. `senderSig` is a signature produced by `Sender` over the hash of the ticket and `recipientRand` is the pre-image of the `recipientRandHash` that is included in the ticket.

Before a `Sender` can start creating and sending tickets, it must first fetch ticket parameters from a `Recipient`. When generating ticket parameters, a `Recipient` will generate a random number `recipientRand`, compute the hash of `recipientRand` as `recipientRandHash` and include the hash with the ticket parameters. Once a `Sender` has a set of ticket parameters with a `recipientRandHash`, the `Sender` will use a monontonically increasing `senderNonce` with each new ticket that it creates.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to provide some extra context around TicketParams here , perhaps we can use the commented protobuf definitions to provide more clarity here?


The `pm` package contains a client implementation of the [Livepeer PM protocol](https://github.com/livepeer/wiki/blob/master/spec/streamflow/pm.md). The main areas of interest are:

- A `Ticket` type which defines the ticket format that both senders and recipients accept.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a good idea to provide some extra context around this type as its fieldnames are used extensively in the RNG part of the README. WDYT?

@thomshutt
Copy link
Contributor

@yondonfu Is this documentation still worth getting merged or can we close the PR?

@yondonfu yondonfu requested review from thomshutt and removed request for j0sh May 31, 2023 19:52
@yondonfu
Copy link
Member Author

Reviving this PR! Updated the pm package docs with some tweaks based on recent changes (i.e. #1383 and #2710) as well as an additional payments doc with links to PM resources and some notes on fee estimation. These docs are by no means comprehensive and can certainly be improved, but think it should be a 0 -> 1 upgrade that will be a good start for now!

@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Merging #1099 (f93938d) into master (1af0a51) will increase coverage by 0.01572%.
The diff coverage is n/a.

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #1099         +/-   ##
===================================================
+ Coverage   56.63383%   56.64955%   +0.01572%     
===================================================
  Files             88          88                 
  Lines          19084       19084                 
===================================================
+ Hits           10808       10811          +3     
+ Misses          7682        7679          -3     
  Partials         594         594                 

see 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1af0a51...f93938d. Read the comment docs.

see 1 file with indirect coverage changes

Copy link
Contributor

@thomshutt thomshutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks Yondon! I think you also win longest time between PR opening and getting merged 🏆

@yondonfu
Copy link
Member Author

yondonfu commented Jun 1, 2023

Made a few small changes:

  • Moved diagram into pm/assets folder and included a text file with the sequence diagram in UML so that it can be updated later if needed
  • Moved the diagram PNG file into git LFS

The above changes align with the convention used for assets in docs seen in doc/assets. They also seem to fix a weird dirty git diff error I was encountering in CI builds...

@yondonfu yondonfu merged commit dc1643c into master Jun 1, 2023
@yondonfu yondonfu deleted the yf/pm-readme branch June 1, 2023 18:29
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.

4 participants