-
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] lightning ordermatching wip + library updates and more unit tests #1655
Conversation
…e chain, test is failing for now
…e not routes between swap parties
…check in lightning protocol info check
…bled and channel is closed before funding tx is confirmed
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.
Amazing work! My notes from the partial review
mm2src/coins/lightning/ln_p2p.rs
Outdated
let expect_msg = "for the foreseeable future this shouldn't happen"; | ||
let current_time: u32 = get_local_duration_since_epoch() | ||
.expect(expect_msg) | ||
.as_secs() | ||
.try_into() | ||
.expect(expect_msg); |
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.
let expect_msg = "for the foreseeable future this shouldn't happen"; | |
let current_time: u32 = get_local_duration_since_epoch() | |
.expect(expect_msg) | |
.as_secs() | |
.try_into() | |
.expect(expect_msg); | |
let current_time: u32 = get_local_duration_since_epoch() | |
.map_to_mm(|e| EnableLightningError::Internal(e.to_string()))? | |
.as_secs() | |
.try_into() | |
.map_to_mm(|e| EnableLightningError::Internal(format!("{:?}", e)))?; |
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.
Done
/// Get some of the coin config info in serialized format for p2p messaging. | ||
fn coin_protocol_info(&self) -> Vec<u8>; | ||
/// Get some of the coin protocol related info in serialized format for p2p messaging. | ||
fn coin_protocol_info(&self, amount_to_receive: Option<MmNumber>) -> 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.
Some of the implementations returning empty byte array, and this value is usually passed as Option
type to the target. I am not sure if Some(Vec::new())
is handled properly. I would rather update the return type into Option<Vec<u8>>
here and return None
for functions that are returning Vec::new()
.
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.
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 I think in most cases, an empty vec
== None
...what I'm saying it's unnecessary to use Option<Vec<_>>
but instead just Vec<_>
.
seems this is how optional keys
field are mostly stored in structures mm2
so no problem ):
Cargo.lock
Outdated
[[package]] | ||
name = "bech32" | ||
version = "0.9.1" | ||
source = "registry+https://github.com/rust-lang/crates.io-index" | ||
checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" |
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.
Only dependency that is still using 0.8.1
was KomodoPlatform/librustzcash
, I upgraded bech32
to 0.9.1
there in k-1.0.0
tag. So we can avoid having 2 versions of bech32
that are almost identical.
You can apply the following patch for the version migration:
diff --git a/mm2src/coins/Cargo.toml b/mm2src/coins/Cargo.toml
index f35490716..1aa4824dc 100644
--- a/mm2src/coins/Cargo.toml
+++ b/mm2src/coins/Cargo.toml
@@ -125,10 +125,10 @@ tokio = { version = "1.7" }
tokio-rustls = { version = "0.23" }
tonic = { version = "0.7", features = ["tls", "tls-webpki-roots", "compression"] }
webpki-roots = { version = "0.22" }
-zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
-zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
-zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git" }
-zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
+zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
+zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
+zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
+zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
[target.'cfg(windows)'.dependencies]
winapi = "0.3"
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 a lot for upgrading librustzcash
. Patch applied.
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! Some questions and comments
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! just one suggestion
…ed due to a network error (all electrums were down, etc..)
I fixed 2 issues I discovered while executing a KMD/LNBTC swap, they were:
@caglaryucekaya @ozkanonur can you please review the new commits? |
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 can you please approve if there are no more issues with this PR? |
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! Just two comments
if !e.get_inner().is_network_error() { | ||
break; | ||
} | ||
Timer::sleep(TRY_LOOP_INTERVAL).await; |
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.
Should this loop repeat infinitely if the network error keeps coming?
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 for now. When broadcasting transaction through p2p network is implemented, a loop to check if the transaction is on-chain or not can be added instead.
error!("Converting transaction to bytes error:{}", e); | ||
break; | ||
}, | ||
}; |
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 you can take this out of the loop, there's no need to repeat it in case of network failure
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.
done
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 🔥
@@ -57,7 +57,7 @@ fn insert_saved_swap_sql(swap: SavedSwap) -> Option<(&'static str, Vec<String>)> | |||
#[derive(Debug)] | |||
pub enum SelectRecentSwapsUuidsErr { | |||
Sql(SqlError), | |||
Parse(uuid::parser::ParseError), | |||
Parse(uuid::Error), |
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.
uuid::Error
is used in multiple places already so it's better to import once
use uuid::Error as UuidError;
and use everywhere
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.
Done
@@ -68,8 +68,8 @@ impl From<SqlError> for SelectRecentSwapsUuidsErr { | |||
fn from(err: SqlError) -> Self { SelectRecentSwapsUuidsErr::Sql(err) } | |||
} | |||
|
|||
impl From<uuid::parser::ParseError> for SelectRecentSwapsUuidsErr { | |||
fn from(err: uuid::parser::ParseError) -> Self { SelectRecentSwapsUuidsErr::Parse(err) } | |||
impl From<uuid::Error> for SelectRecentSwapsUuidsErr { |
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.
UuidError
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.
Done
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! just a note and suggestion.
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 job and welldone!
* 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>
Intermediate PR as part of #1045
current_confirmations
andrequired_confirmations
(which are easy to retrieve after the above update) to channel details RPCs.uuid
for internal channel id instead ofu64
after rust-lightning update since they now useu128
foruser_channel_id
uuid
lib to latest version to use conversion from/tou128
featuresprotocol_info
fields are used to check if an order can be matched or not depending on if a route is found between maker/taker for a lightning payment.To be done in next PRs: