-
Notifications
You must be signed in to change notification settings - Fork 83
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
Database & Resume Swap #81
Conversation
Database and recovery done :) For completion we should add balance checks to the |
Let's not forget to squash the earlier commits on this branch 😬 |
The tests pass locally when run individually. When running in CI there was a failure when running the tests that are in same file. Previously those tests had already passed, when there was just one test per file. It could be an initialization issue with the containers, but needs more investigation. I split the tests into multiple files for now to see if that resolves the issue. Maybe @thomaseizinger has an idea what could cause this? Given that it fails early:
I would guess it is a setup issue, maybe related to using the same port for listening, |
Yeah you can't have them listen on the same port :) Note: I did not read any of 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.
I don't think "recovery" is a good terminology because if possible, the swap will continue. I suggest "Resume" instead.
Also, my work was on #83 I will see if I can combine our changes.
Can you please clean-up your commit tree?
@@ -10,6 +10,7 @@ use futures::{ | |||
}; | |||
use libp2p::request_response::ResponseChannel; |
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.
Why the file name change? this does more than just negotiation.
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.
Does it? I think negotiate is more accurate than execute. We can rename it again, but I think it is not the execution.
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.
It provides an abstraction that allows to do one function call per step for the protocol execution.
Look at the functions present in the file, they are not related to "negotiation":
wait_for_locked_bitcoin
lock_xmr
- etc
would steps.rs
make more sense to you?
|
||
recover(bitcoin_wallet, monero_wallet, state).await?; | ||
} | ||
Options::Recover { .. } => todo!("implement 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.
What is recover
for? Do you mean, resume
?
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 terminology that was previously used in the project. I am happy to rename both the CLI option and the function to resume
.
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 terminology previously used represented a different feature.
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.
my vote goes for resume
// Bob locks btc and Alice locks xmr. Alice fails to act so Bob refunds. Alice | ||
// then also refunds. | ||
#[tokio::test] | ||
async fn both_refund() { |
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 only tests for Alice to restart and refund. We need a test for Bob to restart to ensure that database save/restore works as expected.
); | ||
let t1_timeout = state3.wait_for_t1(bitcoin_wallet.as_ref()); | ||
|
||
tokio::select! { |
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.
In my try I replaced this with futures::future::select
. It allows to return a value, the state, removing the triplicate db save and run_until
call.
38a1287
to
1d9aac9
Compare
Closing this PR in favor of #85 |
Rebased @D4nte work on the database onto current master.
Update tests to use event-loop and properly restart.
Notable changes:
[role]::recover
function next to[role]::swap
, (used in tests, to be plugged into CLI so we can recover :)