-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: new grpc call for subscribring alerts such as low balance (#864) #1984
Conversation
Looks like the right approach, next step is actually firing the alerts and making sure |
8702ea0
to
c7cc394
Compare
To answer your question about this @raladev : an |
Depends on this I suggest several changes:
|
Thanks for the proposal! One small nit: I don't think channelpoint is very informative, so I'd rather go with xud peer_alias
|
|
But if we're implementing something generic below json doesn't seem generic at all:
In general I'm populating an alert with type and message. Don't know how to make it more generic. On the other hand as a UI developer it's much more simpler to read two fields from json and print message to screen and show an icon regarding to type, wdyt? For: This's about wallet and channel balance I guess, so in this case we should check if my wallet balance is lowered %10 of channel balance then we fire alert? @raladev |
if we agree that this call if only for xud-ui, im ok with this approach (json - with type and text message)
but if this call is not only for xud ui it would be better to change structure to :
nope, it is only about channel balance, you dont need to check wallet balance at all.
|
|
In short: I don't agree. Albeit only xud-ui using these errors for display in a human-readable format right now, I expect tools like an automated channel rebalancer to use these alerts (and data in it!) to actually do things, like balancing channels back. For that it should be able to extract minimum
For simplicity we can just go for the channelpoint, agreed on that @raladev . And let's not forget about connext vector here, it has to work for both. I just asked the connext team how channelpoints in vector look like.
|
Update: connext channel's are represented by their unique multisig address, I'd had to try a bit to find the endpoint delivering this from the connext client though. @sangaman @erkarl ? |
I was thinking just an enum
That way if we have new alerts that we want structured formats in the future, we can just add to the As for Connext channel identifiers, it seems to me like it'd be sufficient just to specify the token, right? Since we should only have one channel per token? |
Sufficient for xud-ui, but not for future purposes, see #1984 (comment).
That's nice, let's use this! Give it a shot and you can use the
Correct as of now, but that will definitely change, hence we want to add a channel identifier here. |
c7cc394
to
13f0a81
Compare
The test cases look good. Nice work! |
Added alert for total balance for LND, but I'm unsure how it would be for connext since there're no multi channels there and there's no total capacity. Also what's left for this PR from my side is this: #1984 (comment) |
The total capacity for connext would be the capacity of the 1 channel that it has. |
uhm, so what's the difference between |
Practically none now, but there will be in the near future where connext can have multiple channels too. |
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.
- change subscribealerts to streamalerts (to keep naming policy - streamorders)
- change time of alert throwing to 30s (for now they appear too often) , in future we can add the parameter to the call.
- change satoshi to user readable format in text message
- IDK what means 0 and 1 in text messages but it looks like incorrect side balance calculation
- change LowBalance to LowTradingBalance (because LowBalance looks like alert for on-chain balance)
- change text of assertion:
LowChannelBalance: 0 channel balance is lower than 990950 for BTC by 10%
LowBalance: 0 balance is lower than 980950 for BTC by 10%
LowChannelBalance: 1 channel balance is lower than 599963800 for LTC by 10%
LowBalance: 1 balance is lower than 587963800 for LTC by
to
LowChannelBalance: (Remote/Local) channel balance (0.1 BTC) of one of the channels is lower than 10% of channel capacity (2 BTC).
LowBalance: (Remote/Local) trading balance (0.1 BTC) is lower than 10% of trading capacity (2 BTC).
OR maybe anyone can suggest something more readable. @kilrau @sangaman
- also it seems u use different values for LowChannelBalance and LowBalance alerts. (see total balance values on previous screen)
Changed the name in terms of grpc command, on the other hand in terms of code it's still subscribe because streamorders have same naming.
To achieve this, I defined a new timer which works every 30s.
I had to add a util import to Service layer for this, but it makes sense to me since message is the most important for this command due to xud-ui.
I fixed the 0,1 stuff. But what do you mean by incorrect calculation? @raladev
It's because |
checked it. LowChannelBalance contains reserved amount, but LowTradingBalance does not.
|
b6fcc5a
to
28defd0
Compare
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 am thinking it would probably make sense to split this into two PRs.
- A framework for alerts via rpc
- Balance alerts
The scope is pretty large and there are multiple concerns to address. I can try to continue reviewing as 1 PR but I think it would be cleaner and easier as 2.
I am second guessing this, mainly because it seems outside the scope of xud. There are channel rebalancer tools out there, and I think generally speaking xud should not be too concerned with the workings of the swap clients it's using. I'd be fine with only alerts for total balance levels - e.g. when we run low on balance (or inbound capacity) of a certain currency overall (relative to our total capacity - although that concept doesn't apply to connext - or to some configured threshold). |
Fair. To clarify: it will definitely be an external/separate tool doing the re-balancing, not xud itself.
Thinking about this, I tend to agree. Especially with MPP on the horizon.
Connext will eventually behave the same with vector: multiple channels to multiple channel partners, so I'd want to treat it equally from now on.
Agree on that. So shall we do that @rsercano ?
|
Yes, I'll create 2 seperate PRs and close this one by taking @sangaman 's reviews into consideration. On the other hand, if I understood correctly : |
Only of total balance across all channels per currency, not for single channels. |
Please continue with #2023 |
attempts to resolve #864
This's a draft PR, I didn't want to waste time if I'm not in a right direction, so can you please check this one @sangaman?
In short; I created a copy of streamorders (
ensureConnection
could be in utils but reinitializing client is challenging since it's recursive and client should stay immutable if I take it as a function arg.)Main idea is to trigger alert events from anywhere (for now only from Lnd and Connext) and catch and merge them to pipeline just like in the
streamorders