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

feat(eth-swap): eth tpu v2 methods, eth docker test enhancements #2169

Merged
merged 273 commits into from
Aug 30, 2024

Conversation

laruh
Copy link
Member

@laruh laruh commented Jul 19, 2024

Note: eth tpu v2 tests use Sepolia testnet

eth tpu v2 changes

TakerCoinSwapOpsV2 trait implemented methods for EthCoin

  • send_taker_funding
  • validate_taker_funding
  • refund_taker_funding_timelock
  • refund_taker_funding_secret
  • search_for_taker_funding_spend (check that taker payment state is TakerApproved)
  • gen_taker_funding_spend_preimage
  • validate_taker_funding_spend_preimage
  • sign_and_send_taker_funding_spend
  • refund_combined_taker_payment (used refund_taker_funding_timelock method here)
  • gen_taker_payment_spend_preimage
  • validate_taker_payment_spend_preimage
  • sign_and_broadcast_taker_payment_spend
  • wait_for_taker_payment_spend

nft tpu v2 changes

The below is for @KomodoPlatform/qa

DOCs repo

PR: KomodoPlatform/komodo-docs-mdx#270

Coins repo

issue: KomodoPlatform/coins#1115
PR: KomodoPlatform/coins#1061

Komodo Proxy configuration

#2169 (comment)

"eth_call" method should be added in proxy config, as wait_for_taker_payment_spend, payment_status_v2 fncs use it.

laruh added 30 commits May 9, 2024 12:41
… for MM_CTX1, remove unnecessary Geth args, simplify request_body creation, change sleep duration in tests
…e-nft-maker-swap-contract-sepolia-test

# Conflicts:
#	mm2src/coins/eth.rs
#	mm2src/coins/eth/nft_swap_v2/mod.rs
#	mm2src/coins/eth/v2_activation.rs
#	mm2src/mm2_main/Cargo.toml
#	mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs
…hcore_transaction::Action in eth_docker_tests.rs separately
@laruh
Copy link
Member Author

laruh commented Aug 22, 2024

In this commit f7668ce I provided eth_coin_from_conf_and_request_v2_for_test function which doesn't use p2p context, so dead locks dont occur in nft/eth swap v2 tests from eth_docker_tests.rs. solves this issue #2169 (comment)

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.

Thanks you for the fixes! Last review from my side!
Please fix docker tests, you can disable slp tests if you have to. Also resolve any old review comment or ones that I asked for more changes for. After that will do a final check of the fixes, approve and merge if there are no problems left.


/// Eth from coin conf v2 activation for `eth_docker_tests.rs`
/// It uses special `build_web3_instances_for_test` function
#[cfg(all(feature = "for-tests", not(target_arch = "wasm32")))]
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 use this conditional compilation attribute in the original eth_coin_from_conf_and_request_v2 function and add build_web3_instances_for_test under it? We don't have to maintain 2 functions this way in case we changed the original one.

Copy link
Member Author

@laruh laruh Aug 25, 2024

Choose a reason for hiding this comment

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

Why not use this conditional compilation attribute in the original eth_coin_from_conf_and_request_v2 function and add build_web3_instances_for_test under it?

Screenshot 2024-08-25 at 10 08 20

it will lead to clippy errors

error: field `komodo_proxy` is never read
  --> mm2src/coins/eth/web3_transport/http_transport.rs:49:16
   |
47 | pub struct HttpTransportNode {
   |            ----------------- field in this struct
48 |     pub(crate) uri: http::Uri,
49 |     pub(crate) komodo_proxy: bool,
   |                ^^^^^^^^^^^^
   |
   = note: `HttpTransportNode` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
   = note: `-D dead-code` implied by `-D warnings`

error: function `build_web3_instances` is never used
   --> mm2src/coins/eth/v2_activation.rs:791:10
    |
791 | async fn build_web3_instances(
    |          ^^^^^^^^^^^^^^^^^^^^

error: could not compile `coins` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `coins` (lib test) due to 2 previous errors

we use --all-features flag in ci cd and in production we dont use "for-tests" feature

Copy link
Member Author

Choose a reason for hiding this comment

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

We can add in eth_coin_from_conf_and_request_v2 doc comment "not to forget to change eth_coin_from_conf_and_request_v2_for_test function" if you did changes. same for build_web3_instances_for_test.

Are you ok with the suggestion above? we shouldn't add #[allow(dead_code)] annotation to build_web3_instances function, as clippy should check it.

Copy link
Member Author

Choose a reason for hiding this comment

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

added doc comms with notes for now f1e6b20

Copy link
Collaborator

Choose a reason for hiding this comment

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

Simplified build_web3_instances here f9f8d50 p2p ctx is only used if komodo_proxy is true. Please check the code to make sure I didn't make any mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

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

p2p ctx is only used if komodo_proxy is true

oh, exactly! right now build_web3_instances looks beautiful. everything is fine.

mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs Outdated Show resolved Hide resolved
@laruh laruh mentioned this pull request Aug 25, 2024
21 tasks
@shamardy
Copy link
Collaborator

@laruh there is an unstable docker test, we shouldn't have this in dev to avoid regressions as docker tests are green there.

@laruh
Copy link
Member Author

laruh commented Aug 28, 2024

@laruh there is an unstable docker test, we shouldn't have this in dev to avoid regressions as docker tests are green there.

They are all unstable due to race conditions. I mean different tests can fail with replacement transaction underpriced. #2169 (comment)

Btw I moved taker swapv2 tests to Geth node using higher gas limits, but confirmations still fail
nft-refund-payment-geth-use-v2-activation-increase-gas-limit branch commits

CI https://github.com/KomodoPlatform/komodo-defi-framework/actions/runs/10589881445/job/29344726554#step:6:1637
example

---- docker_tests::eth_docker_tests::send_and_refund_taker_funding_by_secret_erc20 stdout ----
28 04:04:38, eth_docker_tests:1426] Taker sent ERC20 funding, tx hash: b83a9e1b47b47be644d47feae879cd13f4484bfd9d9151eed42f4b428336d735
· 2024-08-28 04:04:38 +0000 [ERC20DEV] Waiting for confirmations… Failed.
thread 'docker_tests::eth_docker_tests::send_and_refund_taker_funding_by_secret_erc20' panicked at 'called `Result::unwrap()` on an `Err` value: "eth:5292] Internal: eth:5292] Tx receipt Receipt { transaction_hash: 0xb83a9e1b47b47be644d47feae879cd13f4484bfd9d9151eed42f4b428336d735, transaction_index: 0, block_hash: Some(0x03e12c460467c5f5934260b1dcf1097f0ce9183c3ca33d214bf0622d819520f8), block_number: Some(128), from: 0xdbf79d75cb3b0b942500dfb01e1e8327582e941b, to: Some(0x844bf2c9ecca714f2ba60c3e694c776700bbee82), cumulative_gas_used: 24309, gas_used: Some(24309), contract_address: None, logs: [], status: Some(0), root: None, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, transaction_type: Some(0), effective_gas_price: Some(1000000078) } status of ERC20DEV tx 0xb83a9e1b47b47be644d47feae879cd13f4484bfd9d9151eed42f4b428336d735 is failed"', mm2src/mm2_main/tests/docker_tests/eth_docker_tests.rs:1201:55

gas_used: Some(24309). gas limit in send erc20 was 210_000, which is enough, but confirmation failed.

I suggest to leave Sepolia tests and ignore them when we merge it to dev. And run them again when you work on the swap v2 feature.

@laruh laruh added in progress Changes will be made from the author and removed under review labels Aug 28, 2024
@laruh laruh added under review and removed in progress Changes will be made from the author labels Aug 28, 2024
@laruh laruh force-pushed the nft-refund-payment-geth-use-v2-activation branch from da6ce95 to 1faea01 Compare August 28, 2024 09:34
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.

🔥

@shamardy shamardy merged commit f6e8348 into dev Aug 30, 2024
23 of 26 checks passed
@shamardy shamardy deleted the nft-refund-payment-geth-use-v2-activation branch August 30, 2024 09:51
mariocynicys pushed a commit that referenced this pull request Aug 30, 2024
This commit implements EVM TPU taker methods and adds some enhancements for eth docker tests.
mariocynicys pushed a commit that referenced this pull request Aug 30, 2024
This commit implements EVM TPU taker methods and adds some enhancements for eth docker tests.
mariocynicys pushed a commit that referenced this pull request Aug 30, 2024
This commit implements EVM TPU taker methods and adds some enhancements for eth docker tests.
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Sep 13, 2024
* dev:
  chore(RPCs): rename `get_peers_info` RPC to `get_directly_connected_peers` (KomodoPlatform#2195)
  chore(WASM-builds): remove `wasm-opt` overriding (KomodoPlatform#2200)
  fix(coins): add p2p feature to mm2_net dependency (KomodoPlatform#2210)
  chore(test): turn on debug assertion (KomodoPlatform#2204)
  feat(sia): extract sia lib to external repo (KomodoPlatform#2167)
  feat(eth-swap): eth tpu v2 methods, eth docker test enhancements (KomodoPlatform#2169)
  fix(cors): allow OPTIONS request to KDF server (KomodoPlatform#2191)
  docs(README): update commit badges to use dev branch (KomodoPlatform#2193)
  use default value for `komodo_proxy` (KomodoPlatform#2192)
  feat(cosmos): komodo-defi-proxy support (KomodoPlatform#2173)
dimxy added a commit that referenced this pull request Sep 13, 2024
* dev:
  chore(RPCs): rename `get_peers_info` RPC to `get_directly_connected_peers` (#2195)
  chore(WASM-builds): remove `wasm-opt` overriding (#2200)
  fix(coins): add p2p feature to mm2_net dependency (#2210)
  chore(test): turn on debug assertion (#2204)
  feat(sia): extract sia lib to external repo (#2167)
  feat(eth-swap): eth tpu v2 methods, eth docker test enhancements (#2169)
  fix(cors): allow OPTIONS request to KDF server (#2191)
  docs(README): update commit badges to use dev branch (#2193)
  use default value for `komodo_proxy` (#2192)
  feat(cosmos): komodo-defi-proxy support (#2173)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants