Skip to content

feat(eth-swap): maker tpu v2 implementation#2211

Merged
shamardy merged 48 commits intodevfrom
eth-maker-tpu-v2
Nov 8, 2024
Merged

feat(eth-swap): maker tpu v2 implementation#2211
shamardy merged 48 commits intodevfrom
eth-maker-tpu-v2

Conversation

@laruh
Copy link

@laruh laruh commented Sep 5, 2024

  • impl MakerCoinSwapOpsV2 trait for ETH
  • eth taker and maker swap v2 implementations are stored in eth_swap_v2 module
  • added taker, maker and nft_maker gas limit v2 params and consts
  • Nft swap v2 methods started to use swap address from "swap_v2_contracts" coin field

In addition, added additional wait_for_maker_payment_spend function to MakerCoinSwapOpsV2 trait. It is needed to cover "taker doesnt wait for spend maker payment tx confirmation" issue which we faced in legacy swap protocol #2175 (comment)

Later we can add wait_for_maker_payment_spend usage in MakerPaymentSpent state before changing it to Completed
https://github.com/KomodoPlatform/komodo-defi-framework/blob/8f983ec362cb00704b27582b8c0dc3e9934aa912/mm2src/mm2_main/src/lp_swap/taker_swap_v2.rs#L2195-L2203

Note
Provided two test features to be able to test maker and taker swap v2 contracts separately on sepolia.

sepolia-maker-swap-v2-tests = []
sepolia-taker-swap-v2-tests = []

Copy link

@borngraced borngraced left a comment

Choose a reason for hiding this comment

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

Great work! first review iteration

Copy link

@borngraced borngraced left a comment

Choose a reason for hiding this comment

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

last notes

Copy link

@borngraced borngraced left a comment

Choose a reason for hiding this comment

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

welldone!

@shamardy
Copy link
Collaborator

shamardy commented Nov 8, 2024

@laruh I think there is nothing to test or document by @KomodoPlatform/qa for this PR, if that's the case please add To Test and nothing to the opening comment, otherwise add normal To Test and docs.

@shamardy shamardy merged commit 99cb87a into dev Nov 8, 2024
@shamardy shamardy deleted the eth-maker-tpu-v2 branch November 8, 2024 14:10
Comment on lines +75 to 78
#[cfg(any(feature = "sepolia-maker-swap-v2-tests", feature = "sepolia-taker-swap-v2-tests"))]
lazy_static! {
pub static ref SEPOLIA_WEB3: Web3<Http> = Web3::new(Http::new(SEPOLIA_RPC_URL).unwrap());
pub static ref SEPOLIA_NONCE_LOCK: Mutex<()> = Mutex::new(());
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this use any docker instance? why don't we move such tests outside docker (to test_inner)?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, yes, the Sepolia code doesn’t use Geth-generated addresses.
We could move the code to the sepolia_tests test crate.
However, there’s still a chance that when we update the Swap V2 smart contracts, for example add burnFee to the taker swap contract, this contract could start working on the Geth node (we faced similar issue during the NFT maker swap V2 implementation and testing). In that case, the code could be moved back to docker_tests.

Let’s plan this when we update the taker swap v2 contract, if it doesn’t work on Geth, we’ll move taker/maker Sepolia code to a separate test crate.

pub static ref GETH_NONCE_LOCK: Mutex<()> = Mutex::new(());
}

#[cfg(any(feature = "sepolia-maker-swap-v2-tests", feature = "sepolia-taker-swap-v2-tests"))]
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not merge the two features?

Copy link
Author

Choose a reason for hiding this comment

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

maker and taker methods are belong to different smart contracts. its better to have them separately, when you need to test only maker or only taker functionality

Copy link
Collaborator

Choose a reason for hiding this comment

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

tbh i would consider this (and not really much) only if these smart contracts are changed so often to justify having a feature to run them specifically, otherwise i would just go for merging these feature flags (or even ignoring the sepolia tests instead) and run tests by their names or name prefix.
i see features as more complexities if we can do without it.

dimxy pushed a commit that referenced this pull request Nov 11, 2024
* dev:
  fix(foot-shooting): remove leftover code that panics via RPC (#2270)
  refactor(MarketCoinOps): make `wait_for_htlc_tx_spend` async (#2265)
  feat(eth-swap): maker tpu v2 implementation (#2211)
  fix(nft): add token_id field to the tx history primary key, fix balance (#2209)
  feat(cosmos): support IBC types in tx history implementation (#2245)
  fix(hd-wallet): use `CoinBalanceMap` for UTXO and QTUM (#2259)
  fix(tests): add more sepolia endpoints in tests (#2262)
  fix(legacy-swap): check for confirmations on recover taker (#2242)
  fix(legacy-swap): remove the need for takers to confirm their payment (#2249)
  refactor(P2P): types and modules (#2256)
  fix(evm): correctly display eth addr in iguana v2 activation result (#2254)
  feat(utxo): prioritize electrum connections (#1966)
  refactor(SwapOps): make all methods async (#2251)
  refactor(SwapOps): make `send_maker_payment` async (#2250)
  remove old p2p implementation (#2248)
  feat(cosmos-offline-tests): prepare IBC channels inside the container  (#2246)
@laruh laruh mentioned this pull request Jan 26, 2025
29 tasks
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.

5 participants