Skip to content

Receiver Session Events#760

Merged
spacebear21 merged 3 commits intopayjoin:masterfrom
arminsabouri:recv-session-event
Jun 11, 2025
Merged

Receiver Session Events#760
spacebear21 merged 3 commits intopayjoin:masterfrom
arminsabouri:recv-session-event

Conversation

@arminsabouri
Copy link
Collaborator

@arminsabouri arminsabouri commented Jun 11, 2025

This PR adds session events generated by processing the receiver
state machine. These events wrap v1 receiver types to avoid duplicating
session context learned during the initial typestate transition. To
enable serialization and deserialization of session events, we implement
serde::Serialize and serde::Deserialize on the underlying v1 types. As a
result, we must enable the bitcoin/serde feature under the v1 flag
because OptionalParameters includes a bitcoin::FeeRate field.

To enable comparisons between SessionEvents during tests,
all event types must also implement PartialEq and Eq.

Tests cover roundtrip ser/deserialization of each session event.

These commits were cherry-picked off #750 and cleaned up.

@arminsabouri
Copy link
Collaborator Author

Fixed codespell

@coveralls
Copy link
Collaborator

coveralls commented Jun 11, 2025

Pull Request Test Coverage Report for Build 15589279796

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 47 of 49 (95.92%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 85.622%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/version.rs 8 10 80.0%
Totals Coverage Status
Change from base Build 15568749747: 0.1%
Covered Lines: 7027
Relevant Lines: 8207

💛 - Coveralls

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.

Two comments from Dan's review on the other PR should be addressed here imo:

I also think it would make sense to address this comment here:

Comment on lines +45 to +48
/// Session is invalid. This is a irrecoverable error. Fallback tx should be broadcasted.
/// TODO this should be any error type that is impl std::error and works well with serde, or as a fallback can be formatted as a string
/// Reason being in some cases we still want to preserve the error b/c we can action on it. For now this is a terminal state and there is nothing to replay and is saved to be displayed.
/// b/c its a terminal state and there is nothing to replay. So serialization will be lossy and that is fine.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really understand the TODO here, maybe this needs to be reworded? Is it a TODO because it needs the rest of the SEL changes to be implemented first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No.
The TODO is saying: instead of a string repr of the error it should be any error type that plays nicely with serde. In the future we may want to take action on why a session closed. However its a TODO because we dont impl serde::serialize/deserialize on our error types.

@arminsabouri
Copy link
Collaborator Author

Two comments from Dan's review on the other PR should be addressed here imo:

Comment addressed in #750

@spacebear21 I'm not sure how to address this one here. The session history struct doesnt exist yet.

I also think it would make sense to address this comment here:

@spacebear21 can do! If its ok with you I will make this its own atomic commit.

@spacebear21
Copy link
Collaborator

@spacebear21 I'm not sure how to address this one here. The session history struct doesnt exist yet.

My bad, I meant to link to the second reply:

It's also very difficult to evaluate which of these methods are necessary because they don't seem to be consumed by the reference implementation yet, which suggests to me that they should be elided for now.

I think moving these to payjoin-test-utils basically addresses this since it's understood that those utils are meant to be consumed by anyone.

This commit adds deserialization support for the version enum so it can
be stored in the session event log.
This commit adds session events generated by processing the receiver
state machine. These events wrap v1 receiver types to avoid duplicating
session context learned during the initial typestate transition. To
enable serialization and deserialization of session events, we implement
serde::Serialize and serde::Deserialize on the underlying v1 types. As a
result, we must enable the bitcoin/serde feature under the v1 flag
because `OptionalParameters` includes a bitcoin::FeeRate field.

To enable comparisons between SessionEvents during tests,
all event types must also implement `PartialEq` and `Eq`.
This commit adds test coverage for the full
serialization/deserialization round trip for each receiver session
event.
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.

utACK c7795cd

@spacebear21 spacebear21 merged commit 8a6344e into payjoin:master Jun 11, 2025
13 checks passed
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.

3 participants