Skip to content

Persistence follow ups#638

Merged
DanGould merged 2 commits intopayjoin:masterfrom
arminsabouri:persistence-followups
Apr 15, 2025
Merged

Persistence follow ups#638
DanGould merged 2 commits intopayjoin:masterfrom
arminsabouri:persistence-followups

Conversation

@arminsabouri
Copy link
Collaborator

@coveralls
Copy link
Collaborator

coveralls commented Apr 10, 2025

Pull Request Test Coverage Report for Build 14446204931

Details

  • 21 of 24 (87.5%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.007%) to 81.609%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/receive/v2/persist.rs 3 4 75.0%
payjoin/src/send/multiparty/persist.rs 15 16 93.75%
payjoin/src/send/v2/persist.rs 3 4 75.0%
Files with Coverage Reduction New Missed Lines %
payjoin/src/send/mod.rs 2 94.46%
Totals Coverage Status
Change from base Build 14387071460: 0.007%
Covered Lines: 5254
Relevant Lines: 6438

💛 - Coveralls

Comment on lines 41 to 49
impl Receiver {
/// Loads a [`Receiver`] from the provided persister using the storage token.
pub fn load<P: Persister<Receiver>>(
token: P::Token,
persister: &P,
) -> Result<Self, ImplementationError> {
persister.load(token).map_err(ImplementationError::from)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if splitting the implementation of a type across multiple files for organization is worth the increased complexity for navigating the code. There is a clippy lint for it though it's allowed by default https://rust-lang.github.io/rust-clippy/master/#multiple_inherent_impl

@DanGould thoughts?

Copy link
Contributor

@DanGould DanGould Apr 12, 2025

Choose a reason for hiding this comment

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

I prefer to typestate transitions in the file that defines the type. If it were a utility maybe I could come around to splitting impl but in this circumstance I prefer to unite the typestate impls in the main mod file. From<ReceiverToken> and the ReceiverToken in persist submod makes sense to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't understand why multiparty can't reuse send/persist.rs? Implementations look pretty much the same afaict

Copy link
Contributor

Choose a reason for hiding this comment

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

It's got a different token. You wouldn't want to load one from the other table and vice versa

@arminsabouri arminsabouri force-pushed the persistence-followups branch from 1d1629f to 936ee20 Compare April 14, 2025 12:53
Move persistence-related code out of `v2::Sender` and `v2::Receiver`
into dedicated `persist.rs` files. This refactor helps declutter the
core API and separates unrelated concerns.

This change addresses a follow-up item from the [PR that introduced
persistence](payjoin#552 (comment)).
These were indentical storage tokens and can be reconciled.

This was a follow up item from the [PR that introduce
persistence](payjoin#552 (comment))
Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

ACK 744c661

@DanGould
Copy link
Contributor

Wait, what happened here in 744c661? If the SenderTokens are not distinct types then the comment in #638 (comment) becomes a problem because you can use the same token to get a different type from your DB. Should the tokens not have some differentiator?

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

uTACK 744c661

According to Armin, v2 sessions retrieved from storage will have no difference in their resumption whether multiparty or not, so they may use the same token. I'm skeptical but see no reason to block progress.

@arminsabouri
Copy link
Collaborator Author

uTACK 744c661

According to Armin, v2 sessions retrieved from storage will have no difference in their resumption whether multiparty or not, so they may use the same token. I'm skeptical but see no reason to block progress.

One way to think about it is that all senders start as v2 sessions. If there is an optimistic merge oppurtunity then they will evolve in to NS1R senders. But in this framework they would share the same storage token. Under the session event log frame work they also start as v2 senders and by replaying the session events they will also transition to a multi party sender that will expect an additional round of comms. Either way I can't think of a concrete reason why they need to be stored seperately.

@DanGould DanGould merged commit 9d08812 into payjoin:master Apr 15, 2025
7 checks passed
benalleng added a commit to benalleng/rust-payjoin that referenced this pull request Apr 16, 2025
After removing the as_ref method for the RecieverToken in payjoin#638 we
no longer needed an assert that prevented a mutant from cropping up.
This was missed prior to push and caused some failing lints.
benalleng added a commit to benalleng/rust-payjoin that referenced this pull request Apr 16, 2025
After removing the as_ref method for the RecieverToken in payjoin#638 we
needed to modify an assert that prevented a mutant from cropping up.
This was missed prior to push and caused some failing lints.
benalleng added a commit to benalleng/rust-payjoin that referenced this pull request Apr 16, 2025
After removing the as_ref method for the RecieverToken in payjoin#638 we
needed to modify an assert that prevented a mutant from cropping up.
This was missed prior to push and caused some failing lints.
Johnosezele pushed a commit to Johnosezele/rust-payjoin that referenced this pull request Apr 18, 2025
After removing the as_ref method for the RecieverToken in payjoin#638 we
needed to modify an assert that prevented a mutant from cropping up.
This was missed prior to push and caused some failing lints.
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