[r2r] Include maker/taker pubkeys in MM2.db stats_swaps table#1665
[r2r] Include maker/taker pubkeys in MM2.db stats_swaps table#1665
Conversation
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
sergeyboyko0791
left a comment
There was a problem hiding this comment.
Thank you for the great enhancement! I have one important question
| 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.
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.
I agree with @sergeyboyko0791 here. Using persistent_pubkey also leaks private information for private ARRR swaps.
There was a problem hiding this comment.
@borngraced is this PR ready for review? NegotiationDataV4 is still not removed from the code.
There was a problem hiding this comment.
Oh sorry, I missed that! and yes it's ready for review.
| "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.
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.
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 <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
shamardy
left a comment
There was a problem hiding this comment.
Good start :)
First review iteration, we just need to be all inline about implementation details at this point.
| "Negotiated", | ||
| "TakerFeeSent", | ||
| "TakerPaymentInstructionsReceived", | ||
| "TakerPaymentInstructionscReceived", |
There was a problem hiding this comment.
You seem to have changed this event unintentionally
| #[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.
Can you please explain why you added my_persistence_pub to MakerSavedSwap/TakerSavedSwap. Isn't it available in TakerSwapData/MakerSwapDatahttps://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_pubkeyand 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.
@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
NegotiationDataV1orNegotiationDataV2whereNegotiationDataV1/2::persistent_pubkeyis considered asmaker_pubkey(its persistent pubkey that identifiers him uniquely) - Maker sends
NegotiationDataV3whereNegotiationDataV3::maker_coin_htlc_pubandNegotiationDataV3::taker_coin_htlc_pubare the same. If the maker_coin and taker_coin tickers are notARRR(or other private coin), we can considerNegotiationDataV3::m/taker_coin_htlc_pubasmaker_pubkey(its persistent pubkey that identifiers him uniquely) Maker sendsNegotiationDataV3whereNegotiationDataV3::maker_coin_htlc_pubandNegotiationDataV3::taker_coin_htlc_pubare 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_pubthat 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.
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.
Is the
persistence_pubfromT/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.
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.
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 <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
Signed-off-by: borngraced <samiodev@icloud.com>
shamardy
left a comment
There was a problem hiding this comment.
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.
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.
| swap_pubkeys.maker = started.maker_coin_htlc_pubkey; | ||
| swap_pubkeys.taker = Some(started.my_persistent_pub); |
There was a problem hiding this comment.
Same for those 2 pubkeys, aren't they both the taker's?
There was a problem hiding this comment.
@shamardy this is ready for another round of review!
Signed-off-by: borngraced <samuelonoja970@gmail.com>
Signed-off-by: borngraced <samuelonoja970@gmail.com>
Signed-off-by: borngraced <samuelonoja970@gmail.com>
# Conflicts: # mm2src/mm2_main/src/lp_swap/maker_swap.rs # mm2src/mm2_main/src/lp_swap/taker_swap.rs
shamardy
left a comment
There was a problem hiding this comment.
Next iteration! Probably the last one :)
Signed-off-by: borngraced <samuelonoja970@gmail.com>
Signed-off-by: borngraced <samuelonoja970@gmail.com>
shamardy
left a comment
There was a problem hiding this comment.
Final review :)
Just some minor stuff left, otherwise everything else looks good.
Signed-off-by: borngraced <samuelonoja970@gmail.com>
shamardy
left a comment
There was a problem hiding this comment.
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 <caglaryucekaya@gmail.com>
resolves: #1646