-
Notifications
You must be signed in to change notification settings - Fork 78
Update receiver typestate documentation for functions shared between v1 and v2 (and some InputPair documentation) #769
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
Conversation
Pull Request Test Coverage Report for Build 16186272882Details
💛 - Coveralls |
4f9fe46 to
0ddb4b7
Compare
nothingmuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs an update after #750 was merged, since a lot has changed.
I especially appreciate that the tone/phrasing is consistent, that helps reduce mental overhead when parsing docs, trying to figure out what something is for, this is a welcome change. In some places perhaps it goes a bit far, e.g. "and moves on to the next typestate" is mostly self evident if the typestate pattern is itself mentioned and briefly described (and with Receiver now being generic over that as in the usual convention, there's a logical place to document that).
Some nits: there's a few capitalization or formatting nits, e.g. TxIn vs. txin, or scriptPubKey vs. scriptpubkey which IMO can help readability a bit. Things like the numbered list of steps on finalize_proposal could also use markdown list formatting.
c1a143c to
7b1caef
Compare
|
@nothingmuch Made the changes so that reference to PSBT Input vs. TxIn are clearer and removed all of the redundant documentation. I added a new docstring for the new Receiver construct as well, but not touching the session-related v2 specific functions for now to keep the scope of the PR smaller. I'm going to do the same for OHTTP/session related functions, and also for the sender functions/structs later. |
7b1caef to
63df38b
Compare
nothingmuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks (again!) for such a valuable contribution. IMO this is an important PR, I hope others also review it with the care it deserves.
I posted a few comments on v1 stuff that also apply to the corresponding v2 methods.
Apart from the specific comments I've made, I think the docs for all of the v2 typestates, e.g.
/// Foo
pub struct Foo {
...should all be moved to the corresponding impl block:
/// Foo
impl Receiver<Foo> {
...
because that way they will be displayed next to the methods that they relate to in the Receiver docs.
payjoin/src/receive/v1/mod.rs
Outdated
| /// Additionally, this function also checks whether the sender did not point to an output | ||
| /// which pays to the receiver when specifying an output the receiver can reduce the value of | ||
| /// to increase the fees the transaction pays. If the parameter does point to a output which | ||
| /// pays to the receiver, this function sets the parameter to None before letting the receive | ||
| /// process continue to the next steps, protecting the receiver from accidentally subtracting fees | ||
| /// from their own outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a few tries to parse the compound sentence opening this paragraph, but I'm not sure how to phrase it more simply... @DanGould how would you phrase this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nothingmuch Changed this to be more readable in the current version of the PR.
|
crap, i absentmindedly pressed the green button instead of the scary click-outside-the-dialog-which-feels-like-it'd-lose-typed-text and ended up posting my review prematurely... i'm not fully done with the v2 side, so i may post additional comments. sorry! |
53c7551 to
8e57c2c
Compare
230399c to
205de56
Compare
nothingmuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not re-reviewing in a timely manner after the last changes, I added a merge commit resolving the conflict but honestly I think you would have better judgement about how to integrate these two concerns (using the API vs. the OHTTP warning) into the top level module docs.
Other than that I think this is good to go, if my conflict resolution is acceptable then it should just be rebased out of existence since that extra merge commit just adds noise.
@DanGould, @arminsabouri for consistency not only in the API but also the docs? IMO having the state machine enumerated under the main struct in the "implementations" subsection is much more intuitive and browsable, the difference between the v1 and the v2 docs on this branch is pretty stark IMO
|
to be clear if we change v1 to also use the generics based typestate pattern and update the docs, that should be in a followup issue & PR, not this one |
I think the original was right, because there is no documentation for |
|
My last comment is just wrong. It just shows up in the impl block and not the structs. Doh! |
DanGould
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sincerely appreciate this effort. it improves the readability significantly.
I've got some changes to request. This would be easier to rebase/review if it were split into modules, not sure if that's possible. This isn't too far off though.
Just noting: We may want some sort of script/macro (outside of rust, by necessity) to add these docs to payjoin-ffi eventually.
| .ok_or(AddressTypeError::UnknownAddressType) | ||
| } | ||
|
|
||
| /// Returns the expected weight of this input based on the address type of the UTXO it is pointing to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true at the time of writing, but will need to change when #583 is addressed to handle weight to specify that additional info other than the address type is used to describe it.
| /// interactive (where the receiver takes manual actions to respond to the | ||
| /// payjoin proposal) or a non-interactive (ex. a donation page which automatically generates a new QR code | ||
| /// for each visit) payment receiver. For the latter, you should call [`Self::check_broadcast_suitability`] to check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the word "interactive" bugs me because all payjoin is interactive. You can tell this vocab is insufficient because it requries 2 parentheticals to explain. I think "automated" or "automatic" payment processor / receiver is more descriptive. however, this is the language of bip 78 and so I'm ok leaving it as-is in our docs for now.
payjoin/src/core/receive/v2/mod.rs
Outdated
| //! This Payjoin v2 module, in addition to what is described above, also provides tools to leverage | ||
| //! Oblivious HTTP to make collaboratively building a Payjoin transaction asynchronous between the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OHTTP does not make payjoin asynchronous, the store-and-forward directory server does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah not sure why I made that connection there. I'll give a better definition for both OHTTP and the store-and-forward directory while revising this.
| /// A checked proposal that the receiver may contribute inputs to to make a payjoin | ||
| /// | ||
| /// Call [`Receiver<WantsOutputs>::commit_inputs`] to proceed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm skeptical that we want to delete the original sentence. Seems like some documentation is better than none here, even if the Call [\Receiver::commit_input`] to proceed.` typestate info is moved to the impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want documentation on both the structs and the Receiver<...> implementation definitions? I can add that if we do, but currently I'm just moving the entire thing as is (with minor modifications) to impl Receiver<WantsInputs>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah my mistake. I meant the first sentence of the original
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! There are some modifications with that one, but the theme of moving all documentation from the structs is common in the commit. Are you saying that we should still keep the documentation in both the implementation and the struct itself, or something else? I want to make sure that I understood correctly :D
I cleaned up the PR with the rest of the changes and will update the remote branch soon and re-publish the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having something on the State struct is better than nothing. What you've done moving to impls is more appropriate but I'd rather not completely delete the state docs.
Happy to merge what you have for now and follow up after the main module comment about OHTTP being used for async (it's not, as you recognized) is fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! All changes are added 👍🏻
DanGould
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cursory look suggests that my concerns were addressed and that this is ready to go. However it requires a rebase.
4741f1f to
ac341b7
Compare
|
@DanGould Conflict resolved! |
nothingmuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK
DanGould
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ac341b7
|
I edited the PR text, removing some stuff that no longer applies, I hope you don't mind @mehmetefeumit |
I am reading through the PDK code base, and thought that one of the better ways I could contribute and learn at the same time would be to update the documentation so that it is easier for both people who're reading through the typestate progression and AI models who are doing the same.
This has a focus on the public functions so that documentation is detailed and up-to-date. I'll do the same for the sender when I read through that, and also want to make sure that session context and other parts (i.e. struct fields, etc.) also have a baseline documentation which posterity can build upon.
Do let me know if there are parts which you think are to detailed, can be refined, or simply incorrect, even though I tried to make sure that the latter will unlikely be the case :)
The updates in v1 and v2 are exactly the same.