-
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] Extend swap watcher node functionality for UTXO #1496
Conversation
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.
Thanks for the fixes! Just a few notes
@@ -616,6 +598,56 @@ impl SwapOps for SolanaCoin { | |||
fn validate_other_pubkey(&self, _raw_pubkey: &[u8]) -> MmResult<(), ValidateOtherPubKeyErr> { unimplemented!() } | |||
} | |||
|
|||
#[allow(clippy::forget_ref, clippy::forget_copy, clippy::cast_ref_to_mut)] |
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 this required? If I'm not mistaken, it's needed if a trait or a struct is mockable
, but not sure
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.
Could you please also check the other places where #[allow(clippy::forget_ref, clippy::forget_copy, clippy::cast_ref_to_mut)]
is used.
@@ -786,6 +769,56 @@ impl SwapOps for TendermintCoin { | |||
fn validate_other_pubkey(&self, _raw_pubkey: &[u8]) -> MmResult<(), ValidateOtherPubKeyErr> { todo!() } | |||
} | |||
|
|||
#[async_trait] | |||
#[allow(unused_variables)] |
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.
How about marking unused variables with _
prefix?
let duration = (self.r().data.lock_duration * 4) / 5; | ||
let timeout = self.r().data.started_at + duration; | ||
|
||
let timeout = wait_for_taker_payment_conf_until(self.r().data.started_at, self.r().data.lock_duration); |
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.
This is the reason why I thought about step_1
, step_2
initially. At the spend_taker_payment
we should have gotten the required taker payment confirmations already, and wait_for_taker_payment_conf_until
looks a bit weird.
Let's leave it as it is, but I think it's worth to rename this function somehow.
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.
step_1/step_2/...
is not informative and possible cause for a mess in the future: if a step is added or deleted, one can have a hard time figuring out the renumbering of the steps.
But I agree that wait_for_taker_payment_conf_until
is not a good match to use in spend_taker_payment
. I assume an appropriate name would be like taker_payment_spend_deadline
.
self.w().taker_spends_maker_payment_preimage = preimage_hex | ||
TakerSwapEvent::WatcherMessageSent(taker_spends_maker_payment, taker_refunds_payment) => { | ||
self.w().taker_spends_maker_payment_preimage = taker_spends_maker_payment; | ||
self.w().taker_refunds_payment = taker_refunds_payment; |
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.
Shouldn't taker_refunds_payment
name similarly to taker_spends_maker_payment_preimage
? I mean taker_refunds_payment_preimage
.
@caglaryucekaya As I can see, only minor notes are left. Could you please push the current state of this PR and add leftover items to the checklist, similar to #1432 (comment)? UPD Link to the checklist: #1431 (comment) |
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.
Approving with one TODO for the next sprint.
let mut attempts = 0; | ||
let taker_fee_hash = H256Json::from(taker_fee_hash.as_slice()); | ||
loop { | ||
let taker_fee_tx = match coin |
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 add more validations that are done in utxo_common::validate_fee
on the next iteration. As of now, a trading party can submit any transaction signed by its pubkey, and it will pass the validation. It might be not even a dex fee transaction.
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.
Alright you can merge the current state. I was working on making the watchers periodically check if the taker already spent the maker payment, thought I could make it in this sprint but that also requires some review so it's better I leave it to the next sprint, together with the final notes here I didn't work on.
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 should also check for the transaction time or block height since a trading party can reuse an old fee transaction signed by his pub and it will also pass validation without this check.
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.
Great Work! Only 2 comments for next sprint :)
@@ -271,6 +271,10 @@ where | |||
} | |||
|
|||
pub fn contains(&mut self, key: &Key) -> bool { self.0.contains_key(key) } | |||
|
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 guess #[allow(dead_code)]
can be removed from here https://github.com/KomodoPlatform/atomicDEX-API/blob/ca8e435a9e3361dd9b7190970ce1fee4a72db3cb/mm2src/common/time_cache.rs#L250-L254 Now that DuplicateCache
is used.
let mut attempts = 0; | ||
let taker_fee_hash = H256Json::from(taker_fee_hash.as_slice()); | ||
loop { | ||
let taker_fee_tx = match coin |
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 should also check for the transaction time or block height since a trading party can reuse an old fee transaction signed by his pub and it will also pass validation without this check.
@ozkanonur @sergeyboyko0791 @borngraced Could you please check if you have something to add? |
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.
@caglaryucekaya @artemii235 I don't have more notes. Please fix the comments from the last review at the next iteration.
Anyway, the last comments are more cosmetic, so great job 🔥
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!! 👏👏👏
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.
Looks good to me! 🚀
@caglaryucekaya IRIS swaps PR is merged. Could you solve git conflicts, please? |
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.
🔥
3519e4b
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! 🔥
The second PR for the swap watcher nodes adds the following improvements as part of #1431:
TimeCache
ValidatePaymentError