-
Notifications
You must be signed in to change notification settings - Fork 116
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
[events API 1/2]: Add new send and receive streaming RPCs #836
Conversation
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.
BTW, CI failed on RPC and lint check.
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.
Looks great! Seems to expose all the relevant info. Just had a few notes + nits.
WHERE addrs.taproot_output_key = $1 | ||
) | ||
SELECT | ||
addr_events.id, creation_time, status, asset_proof_id, asset_id, |
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.
Why expose addr_events.id
here? I didn't spot a use of it later on (may be in some follow-on 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.
It's part of the address.Event
struct. It looks like it's currently only used in unit tests... Didn't want to also refactor them, as the PR was already growing quite a bit. But it looks like we could probably un-export the address.Event.ID
field.
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.
Re-reviewed, LGTM! Rebase looks correct, I think it needs another.
To avoid pending streams attempting to remove the same subscribers on stopping the daemon, we hold the corresponding mutex during the whole time and not just for each iteration.
This commit ensures that we only notify subscribers after we've actually updated the database to complete an event.
With this commit we skip inspecting on-chain addresses for inbound asset transfers that have already fully completed. Previously, if there was an incomplete inbound transfer for a certain block height, we would go through all transactions in blocks after that height and notify for all inbound transfers found, even if they already were fully complete.
With this commit we change the AssetReceiveCompleteEvent into a more generic AddressReceive event and publish more granular events. To not change the behavior of the developer RPC, we filter the events and only forward the completed event. All other events will be notified on the new RPC that is going to be added a couple of commits later.
With this commit we create "deep" copy methods for items we will send out as events. We need these to make sure the objects we notify about aren't changed by the main thread while we're serializing them to the RPC notification interface.
Because the loop that sends out the notifications for each send state terminates before reaching the SendStateComplete state, we manually need to send out that event once we've sent out all proofs to the receivers. We also want to unify how and when we send out notifications, so we move the event creation to _after_ executing an event.
With this commit we add a new RPC that allows users to subscribe to address receive events in general or filtered by a specific address. This RPC notifies more granularly about the different states an inbound asset goes through, but hides some of the implementation details the previous (now development only) RPC showed (namely the proof courier backoff events).
In this commit we slightly refactor the event stream subscription handling in the send integration test to make sure we correctly time out in case we don't receive the required events.
We want to make sure the new receive and send events RPC notifies on the correct events during the send process. We don't need to assert every single case, so we just add the new assertion to our main send test cases.
Re-reviewed after rebases, still LGTM. |
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.
LGTM 🦊
Replaces #773.
Fixes #781.
Fixes #806.
Fixes #739.
This PR adds new RPCs for being notified about inbound and outbound asset transfers.
The existing
SubscribeSendAssetEventNtfns
andSubscribeReceiveAssetEventNtfns
were mostly built for asserting the internal state during integration tests and weren't super helpful for app builders. That's why these old RPCs were moved to thetapdevrpc
package and are now only used in the integration tests.The new RPCs notify on all send and receive states instead of only a few of them. The events also contain way more information that's useful to map them to the user action. And both RPCs allow the events to be filtered (either by address for receive events and by script key for send events).
This is part 1 of the "events API" saga. The follow-up PRs will base on this one and address: