Mint Websockets (NUT-17) #394
No reviewers
Labels
No labels
DB & Storage
Deployment
Error Handling & Logging
Maintenance
Payment Backend
backport
backport v0.13.x
backport v0.14.x
backport v0.15.x
bindings
blocked
bug
cdk-sql
ci
cli
deps
documentation
duplicate
enhancement
good first issue
help wanted
invalid
keep-open
ldk-node-ui
migrations
mint
mutation-testing
needs rebase
needs review
new nut
nut change
question
ready
rust-version
rustfmt
stacked hold
stale
testing
wallet
weekly-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cashubtc/cdk!394
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "nut-17-ws-subscription"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Very early stage nonfunctional prototype to add support for any subscriptions, aiming for NUT-17 support, #203 .
TODO:
Hey, haven't done a very through review but it looks like a good approach so far, thank you for you work. If there is a specific part you would like me to look at let me know.
@thesimplekid I have no idea where the events are being generated, and any other feedback is more than welcome.
Nice work, think were just missing sending updates in a few places for the proofs some I was able to note in line. This one i couldn't note inline so will note it here, when we swap we need to send an update for the state of the proofs that are spent as part of the swap. Think line 171 of
mint/swap.rs@ -0,0 +1,123 @@use crate::MintState;Think I would prefer select usage here
This is only run at mint start up so there will be no ws subs at this point so we dont need to send notifications here.
Since only the mint knows the quote id at this point and it hasn't been returned, its not possible for anyone to have subscribed to updates for it so we don't need to seed ws updates here.
In addition to sending an update when it is paid as is done here, we also need to send one when the quote is pending, think this is best done in the
verify_melt_requestfn above. In both cases we also need to send updates for the proof states when those are moved to pending and then spent.@ -0,0 +1,123 @@use crate::MintState;I'm also familiar with
tokio::select!but there was a clippy warning, so I learned how it was done in the earlier days. I'll gladly switch totokio::select!.@ -0,0 +1,123 @@use crate::MintState;Fixed in e30f732025f88ae9fb7a22ed704453523aa042fa
@ -0,0 +1,123 @@use crate::MintState;Yeah for some reason clippy thinks it breaks msrv when it doesn't, so we can use
#[allow(clippy::incompatible_msrv)]to suppress the warningFixed in 101b1c5
Fixed in d7f5791
In the
verify_meltfn we need to broadcast the proof state and the quote state when they are changed to pending.I think you have all the other state changes. What else do you feel is missing from this PR before you would like to see it merged?
Do you mean like as a feature flag? I don't think it is and we should just have the mint always support it.
I'll make it happen.
I want to add an end-to-end test and an external web socket client with rust or typescript. If it is in Rust, it should connect to the WebSocket through TCP, even if using the same process. That's the last missing bit to have peace of mind that it works as expected.
Overall really nice work. Just a few small things i noticed when testing vs Nutshell
@ -0,0 +1,123 @@use crate::MintState;What do you think of using an if let to log the error here?
Same as above use an If let to log the error?
@ -0,0 +14,4 @@pub struct Response {status: String,#[serde(rename = "subId")]sub_id: SubId,@ -0,0 +1,30 @@use super::{handler::WsHandle, WsContext, WsError};sub id should be snake case
@ -0,0 +1,333 @@//! Specific Subscription for the cdk crateShould we also have a proof state helper here for constancy?
@ -0,0 +1,311 @@//! Publish–subscribe pattern.@ -0,0 +1,333 @@//! Specific Subscription for the cdk crateWe have from MeltQuote in nut05, lets move this to NUT05.
github.com/cashubtc/cdk@d9fb5f814a/crates/cdk/src/nuts/nut05.rs (L198-L213)@ -0,0 +1,333 @@//! Specific Subscription for the cdk crateWe have this in NUT04 lets move this there.
github.com/cashubtc/cdk@d9fb5f814a/crates/cdk/src/nuts/nut04.rs (L95-L105)@ -0,0 +1,311 @@//! Publish–subscribe pattern.Thank you for fixing my broken English
@ -0,0 +1,333 @@//! Specific Subscription for the cdk crateFixed in
fcae992@ -0,0 +1,333 @@//! Specific Subscription for the cdk crateFixed in
fcae992@ -0,0 +1,333 @@//! Specific Subscription for the cdk crateFixed in
fcae992Think the merge got messed up here this route shouldn't be deleted
Fixed in 9d99d6d
@ -295,6 +300,7 @@ impl Mint {.update_mint_quote_state(&mint_request.quote, MintQuoteState::Paid)I'm not sure that we should send the state here, to the wallet this is not a change in state as the quote was already paid as there is not
pendingstate for the mint quote on the wallet. So they would have already received the paid quote update above in thepay_mint_quote_for_request_id. The reason we need to update it in the database is we set it to pending to avoid a race condition where a wallet attempts to mint twice at the same time but this pending state isnt known to the wallet. See how minting in nutshell gets a duplicate message.@ -295,6 +300,7 @@ impl Mint {.update_mint_quote_state(&mint_request.quote, MintQuoteState::Paid)Fixed in
54f5ab9Great work thanks for this.