-
Notifications
You must be signed in to change notification settings - Fork 42
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 subscribing alerts and low balance alert (#864) #2023
base: master
Are you sure you want to change the base?
Conversation
e006009
to
8e794da
Compare
a9fbc51
to
368167f
Compare
368167f
to
b7a77f6
Compare
Since alerts are not specific to swaps/swapclients actually it was @sangaman's idea to create a new class, which I think makes more sense because in a further time we can add more alerts to xud flow's different places. |
@rsercano can u please rebase it ? (need to get connext changes for vector from master). |
…at/subscribealerts-rework � Conflicts: � test/simulation/xudrpc/xudrpc.pb.go
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.
-
u dont need to throw alert for remote balance of connext currencies because this value is not user controllable, and depends on collateralization
(Tue Dec 08 2020 11:20:58 GMT+0000) LowTradingBalance: Remote trading balance (0 ETH) is lower than 10% of trading capacity (15 ETH)
-
we need to decide how it will look for connext or we just should support this alert only for lnd (looks correct for me) @rsercano @sangaman @kilrau
-
text message contains time, but json does not contain timestamp, would be good to add.
(Tue Dec 08 2020 11:21:22 GMT+0000) LowTradingBalance: Remote trading balance (0 ETH) is lower than 10% of trading capacity (15 ETH)
^Csimnet > streamalerts -j
Successfully connected, streaming
{
"type": "LowTradingBalance",
"payload": {
"totalBalance": 1500000000,
"side": "Remote",
"sideBalance": 0,
"bound": 10,
"currency": "ETH"
}
}
The user will be able to influence this. At the moment the |
…at/subscribealerts-rework � Conflicts: � lib/Logger.ts � lib/connextclient/ConnextClient.ts � lib/service/Service.ts � test/jest/Service.spec.ts
004c937
to
0f95df4
Compare
I pushed a commit to do some refactoring and to preserve type checking. As a general rule I really think we ought to preserve types whenever possible, which are lost with declaring My last concern is in regards to the proto file field naming & comments/description for purposes of API documentation. See my comments on the unresolved issues above. |
also keep an eye on the failing builds |
da42e0a
to
3469df2
Compare
Thanks, just a linting issue. Fixed. |
I guess @sangaman already pushed a commit for this review: #2023 (comment) Is there anything to do for me here? @raladev @sangaman |
|
…at/subscribealerts-rework � Conflicts: � lib/swaps/SwapClient.ts � test/simulation/xudrpc/xudrpc.pb.go
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.
The proto file still needs work unfortunately. The bound
field is not in the proto definition currently, but it's being used in the xud code. I also still have some open questions for the naming and commenting of the balance alert fields in the proto file, we need to make sure they are clear.
Once that's done we can squash and merge everything. I'm taking care of the merge conflicts, but we need another commit to address the proto file concerns. See if my questions make sense to you @kilrau, I can also take care of the final changes once it's clear to me which exactly which fields we want on the balance alert message.
proto/xudrpc.proto
Outdated
// The bound of the low balance in percentage. | ||
uint32 bound = 3 [json_name = "bound"]; | ||
// The current side balance. | ||
uint64 side_balance = 4 [json_name = "side_balance"]; |
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 think we still need an answer here and I'm not sure what it is.
if (serviceAlert.type === AlertType.LowTradingBalance) { | ||
const balanceServiceAlert = serviceAlert as Alert; | ||
const balanceAlert = new xudrpc.BalanceAlert(); | ||
balanceAlert.setBound(balanceServiceAlert.bound); |
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.
Bound is not in the xudrpc.proto definition currently. Regenerating the protos results in compile errors currently. Do we want this 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.
fixed
proto/xudrpc.proto
Outdated
Side side = 2 [json_name = "side"]; | ||
// The bound of the low balance in percentage. | ||
uint32 bound = 3 [json_name = "bound"]; | ||
// The current side balance. |
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.
Can you change this or would you like me to?
…at/subscribealerts-rework
I synced with @michael1011 about this and we will not use this information for a channel rebalancer any time soon, the UI will rather use it to display a notification about a general imbalance on a certain asset (not even a specific channel). I think the fields in this PR deliver this, so if if passed your review with that in mind, we can merge as is @sangaman |
Resolves #864
This adds a new middleware between alerts that are being thrown during xud flows and grpc level as we discussed @sangaman But I haven't created two separate PRs, it doesn't make sense since we add a single alert instead of two as in the previous PR (#1984)
Alerts
class.Alerts
class, it's because we need a clear mechanism there for the map.This requires a full re-test sorry @raladev