-
Notifications
You must be signed in to change notification settings - Fork 94
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
[r2r] Include maker/taker pubkeys in MM2.db stats_swaps table #1665
Conversation
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
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.
Thank you for the great enhancement! I have one important question
mm2src/mm2_main/src/lp_swap.rs
Outdated
taker_coin_swap_contract: Vec<u8>, | ||
maker_coin_htlc_pub: Vec<u8>, | ||
taker_coin_htlc_pub: Vec<u8>, | ||
persistent_pubkey: Vec<u8>, |
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.
Please try to avoid adding NegotiationDataV4
message. I even think this new variant might break backwards compatibility.
I personally think it's better to store maker_coin_htlc_pub
as maker_pubkey
and taker_coin_htlc_pub
as taker_pubkey
. @shamardy what do you think?
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.
waiting for @shamardy feedback on this...
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 agree with @sergeyboyko0791 here. Using persistent_pubkey
also leaks private information for private ARRR swaps.
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.
@borngraced is this PR ready for review? NegotiationDataV4
is still not removed from the code.
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.
Oh sorry, I missed that! and yes it's ready for review.
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, 1 question
"ALTER TABLE stats_swaps ADD COLUMN maker_pubkey VARCHAR(255);", | ||
"ALTER TABLE stats_swaps ADD COLUMN taker_pubkey VARCHAR(255);", |
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't just "ALTER TABLE stats_swaps ADD COLUMN maker_pubkey VARCHAR(255), ADD COLUMN taker_pubkey VARCHAR(255);
work?
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.
yes thanks.. it could be this also, but I followed a convention that I already used before https://github.com/KomodoPlatform/atomicDEX-API/blob/54081307cd093cce321939b618a684ad16c915a7/mm2src/mm2_main/src/database/stats_swaps.rs#L49-L52
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
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.
Good start :)
First review iteration, we just need to be all inline about implementation details at this point.
const TAKER_PAYMENT_SPEND_SEARCH_INTERVAL: f64 = 10.; | ||
|
||
pub const TAKER_SUCCESS_EVENTS: [&str; 11] = [ | ||
"Started", | ||
"Negotiated", | ||
"TakerFeeSent", | ||
"TakerPaymentInstructionsReceived", | ||
"TakerPaymentInstructionscReceived", |
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.
You seem to have changed this event unintentionally
@@ -1702,6 +1704,7 @@ impl MakerSwapStatusChanged { | |||
#[derive(Debug, Default, PartialEq, Serialize, Deserialize)] | |||
pub struct MakerSavedSwap { | |||
pub uuid: Uuid, | |||
pub my_persistence_pub: Option<H264Json>, |
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 please explain why you added my_persistence_pub
to MakerSavedSwap
/TakerSavedSwap
. Isn't it available in TakerSwapData
/MakerSwapData
https://github.com/KomodoPlatform/atomicDEX-API/blob/f39c52dff9bdad9b1b600722b88c8823f8bd0147/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L513 https://github.com/KomodoPlatform/atomicDEX-API/blob/f39c52dff9bdad9b1b600722b88c8823f8bd0147/mm2src/mm2_main/src/lp_swap/maker_swap.rs#L143 I really just think we should add maker_coin_htlc_pubkey
and taker_coin_htlc_pubkey
to the DB as is, there should be 4 pubkeys in this case (maker_pubkey_for_maker_coin, maker_pubkey_for_taker_coin, taker_pubkey_for_maker_coin, taker_pubkey_for_taker_coin), please note that these 4 can be different when using HD wallet functionality, we can get @sergeyboyko0791 input on this.
@cipig which exact pubkey do you parse from the json files? I can see that in stats_swaps
in seednodes there will be either a MakerSavedSwap
or TakerSavedSwap
so I guess you use my_persistence_pub
and one of maker_coin_htlc_pubkey
/taker_coin_htlc_pubkey
from MakerNegotiationData
/TakerNegotiationData
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.
@shamardy, with the help of Sergey's input, I got this context
There can be multiple cases. Let's consider the Maker side only:
- Maker sends
NegotiationDataV1
orNegotiationDataV2
whereNegotiationDataV1/2::persistent_pubkey
is considered asmaker_pubkey
(its persistent pubkey that identifiers him uniquely) - Maker sends
NegotiationDataV3
whereNegotiationDataV3::maker_coin_htlc_pub
andNegotiationDataV3::taker_coin_htlc_pub
are the same. If the maker_coin and taker_coin tickers are notARRR
(or other private coin), we can considerNegotiationDataV3::m/taker_coin_htlc_pub
asmaker_pubkey
(its persistent pubkey that identifiers him uniquely) Make
r sendsNegotiationDataV3
whereNegotiationDataV3::maker_coin_htlc_pub
andNegotiationDataV3::taker_coin_htlc_pub
are different. In that case we probably should try to figure out what coin is private in the swap, and what coin is not. The private coin pubkey should have a randomm/taker_coin_htlc_pub
that is unique between all swaps. But the public coin should have the same public key as thepersistent_pubkey
and also the data in
pub my_persistence_pub: Option<H264Json>,
Is the persistence_pub
from T/MakerSwap
https://github.com/KomodoPlatform/atomicDEX-API/blob/a6f9a0ea383d6f87f2157bb6598a76eb7fa10071/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L464
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.
As we discussed DM, there can be the case when it's better not to share the persistent public key. For example, when you exchange two private coins (like ARRR).
But on the other hand, I am not sure if maker_coin_maker_htlc_pubkey
, maker_coin_taker_htlc_pubkey
, taker_coin_maker_htlc_pubkey
, taker_coin_taker_htlc_pubkey
pubkeys can be useful as they can be different, and we can't recognise a node that performed the swaps.
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.
Is the
persistence_pub
fromT/MakerSwap
@borngraced what I meant is that you can use the one from these events https://github.com/KomodoPlatform/atomicDEX-API/blob/f39c52dff9bdad9b1b600722b88c8823f8bd0147/mm2src/mm2_main/src/lp_swap/maker_swap.rs#L1538
https://github.com/KomodoPlatform/atomicDEX-API/blob/f39c52dff9bdad9b1b600722b88c8823f8bd0147/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L635 instead of adding it to MakerSavedSwap
/TakerSavedSwap
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.
As we discussed DM, there can be the case when it's better not to share the persistent public key. For example, when you exchange two private coins (like ARRR).
But on the other hand, I am not sure if maker_coin_maker_htlc_pubkey, maker_coin_taker_htlc_pubkey, taker_coin_maker_htlc_pubkey, taker_coin_taker_htlc_pubkey pubkeys can be useful as they can be different, and we can't recognise a node that performed the swaps.
@smk762 @ca333 We need your inputs on this, it all comes down to if we want to track one pubkey for all swap operations related to a node, or track the pubkeys related to the used HD account for the swap. This can be considered another issue different from the current one. As for the current one I think we should just use the pubkeys @cipig used to parse from the json files.
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.
Perhaps we can use the PeerID for private coins?
The reason for the request was to gather stats on most active users (and able to delineate maker/taker activity), so for HD perhaps a single identifier for the node would be best.
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
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.
Next iteration! We need a unit test added to make sure that the right pubkeys are saved.
swap_pubkeys.maker = Some(started.my_persistent_pub); | ||
swap_pubkeys.taker = started.maker_coin_htlc_pubkey; |
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.
Aren't those 2 pubkeys the maker's? can you please add a unit test to test that the right pubkeys are saved to DB? you should use 3 nodes for the test (taker/maker/seednode) and use stats_swap_status
RPC to check that the right pubkeys are saved to the seednode's DB.
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.
ok
swap_pubkeys.maker = started.maker_coin_htlc_pubkey; | ||
swap_pubkeys.taker = Some(started.my_persistent_pub); |
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.
Same for those 2 pubkeys, aren't they both the taker's?
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.
@shamardy this is ready for another round of review!
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
# Conflicts: # mm2src/mm2_main/src/lp_swap/maker_swap.rs # mm2src/mm2_main/src/lp_swap/taker_swap.rs
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.
Next iteration! Probably the last one :)
Signed-off-by: borngraced <[email protected]>
Signed-off-by: borngraced <[email protected]>
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.
Final review :)
Just some minor stuff left, otherwise everything else looks good.
Signed-off-by: borngraced <[email protected]>
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.
Thank you for your patience on this PR. LGTM!
* add change logs for PRs merged to dev only * remove {version} - {date} and add dev branch instead * add ibc transfer change logs * add lightning PR #1655 to change logs * add changelog for #1706 * add changelog for #1694, #1665 --------- Reviewed-by: laruh, caglaryucekaya <[email protected]>
resolves: #1646