Skip to content
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] cosmos swap p.o.c #1468

Merged
merged 118 commits into from
Oct 26, 2022
Merged

[r2r] cosmos swap p.o.c #1468

merged 118 commits into from
Oct 26, 2022

Conversation

onur-ozkan
Copy link
Member

@onur-ozkan onur-ozkan commented Sep 12, 2022

This PR includes implementations of Cosmos based coin/token activations and swap implementations using Iris Network's HTLCs.

p.s: Rest of the todos, and P.o.C work will be refactored/implemented in the next PR. Also, PR requires lots of optimizations(had to rush on this implementation because of cosmosverse event) which I am aware of, in my opinion optimizations should also be part of the next PR.

Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
@onur-ozkan onur-ozkan changed the title cosmos swap p.o.c [wip] cosmos swap p.o.c Sep 12, 2022
Signed-off-by: Onur Özkan <work@onurozkan.dev>
@artemii235
Copy link
Member

@ozkanonur I converted this to draft to prevent additional CI checks.

@artemii235 artemii235 marked this pull request as draft September 13, 2022 07:30
Signed-off-by: Onur Özkan <work@onurozkan.dev>
@onur-ozkan
Copy link
Member Author

@ozkanonur I converted this to draft to prevent additional CI checks.

Pipelines are still getting triggered. Seems like CI definitions needs to be updated for that. I will close the PR for now and re-open once it's ready.

An addition, we can also read the PR title and ignore running CI if title starts with [wip]

@onur-ozkan onur-ozkan closed this Sep 13, 2022
artemii235 and others added 21 commits September 13, 2022 19:54
# Conflicts:
#	mm2src/coins/lp_coins.rs
#	mm2src/mm2_main/src/mm2_tests.rs
#	mm2src/mm2_test_helpers/src/for_tests.rs
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
@artemii235 artemii235 changed the title [r2r] cosmos swap p.o.c [wip] cosmos swap p.o.c Oct 18, 2022
Artem Vitae and others added 6 commits October 18, 2022 17:44
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few notes from my side.

mm2src/coins/tendermint/tendermint_coin.rs Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_coin.rs Outdated Show resolved Hide resolved
mm2src/coins/tendermint/tendermint_token.rs Outdated Show resolved Hide resolved
onur-ozkan and others added 7 commits October 21, 2022 18:21
Signed-off-by: Onur Özkan <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
# Conflicts:
#	mm2src/coins/tendermint/tendermint_coin.rs
#	mm2src/coins_activation/src/tendermint_with_assets_activation.rs
#	mm2src/mm2_main/src/mm2_tests.rs
Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: ozkanonur <work@onurozkan.dev>
@artemii235 artemii235 mentioned this pull request Oct 25, 2022
@artemii235 artemii235 changed the title [wip] cosmos swap p.o.c [r2r] cosmos swap p.o.c Oct 25, 2022
artemii235
artemii235 previously approved these changes Oct 25, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link

@sergeyboyko0791 sergeyboyko0791 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@artemii235 artemii235 dismissed stale reviews from sergeyboyko0791 and themself via 384904f October 25, 2022 17:19
shamardy
shamardy previously approved these changes Oct 25, 2022
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge Work 🚀 ! Only 3 comments :)

fee,
}
}

pub fn new_max(coin: String, to: String) -> WithdrawRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this new_max function also, it's used only once in testing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there are some other functions like this as well. Not used or used only once. We can exclude them from source code as another task in another PR.

EthCoinType::Erc20 { .. } => "erc20Payment",
EthCoinType::Eth => {
if secret_hash.len() == 32 {
"ethPaymentSha256"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we really need these new functions ethPaymentSha256 and erc20PaymentSha256 since the H160 secret hash is equal to ripemd160(sha256(secret)) and sha256(secret) is shared in the NegotiationDataMsg if either coins are Tendermint. The H160 secret hash can always be used by the other side of the swap that's not a TendermintCoin and it can be derived at the TendermintCoin side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a very good note 🙂 With this, we might avoid updating swap smart contracts at all, and make API code simpler. Added to checklist.

.push_opcode(Opcode::OP_EQUALVERIFY);

if secret_hash.len() == 32 {
builder = builder.push_opcode(Opcode::OP_SHA256);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, no need for SHA256 secret hash on utxo side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to checklist, thanks!

Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving.

@artemii235 artemii235 merged commit 4de3cf2 into dev Oct 26, 2022
@artemii235 artemii235 deleted the iris-swap-poc branch October 26, 2022 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants