Bug description
A utxo to utxo swap fails with MM2 error MakerPaymentSpendFailed and mandatory-script-verify-flag-failed script error.
This happens after the Taker node was offline for some time and restarted while the swap was in progress.
This issue was found when running a test which fails:
docker_tests::swap_watcher_tests::test_taker_completes_swap_after_restart' panicked at 'assertion failed: actual_events.iter().all(|item| success_events.contains(item))', /home/ubuntu/komodo-defi-framework/mm2src/mm2_test_helpers/src/for_tests.rs:2358:5
Decoding the scriptSig showed that the secret was all zeros: 0000000000000000000000000000000000000000000000000000000000000000
MM2 Version
Commit: 2462d9a6d6b42b583808737922feb5e7c47d80ff
Cause of the bug and proposed solution
The problem is that on restart taker finds missed its payment spending but does not process it correctly:
The test creates a swap v1, brings the taker down and restarts it.
In those cases when the swap fails it reaches the stage when both taker and maker have made their payment and the taker goes offline.
When taker node is offline the maker spends the taker payment.
Then the taker restarts and recreates the actual swap state. Function get_command_based_on_watcher_activity is called on taker restart that discovers events occurred while the taker was offline, like spending the taker payment. The problem is that when this event is discovered and added to the taker swap data, it is not processed with TakerSwap::apply_event fn and the secret is not added to the swap data (leaving it empty).
The solution is to call TakerSwap::apply_event for the events discovered inside get_command_based_on_watcher_activity fn
Bug description A utxo to utxo swap fails with MM2 error MakerPaymentSpendFailed and mandatory-script-verify-flag-failed script error. This happens after the Taker node was offline for some time and restarted while the swap was in progress.
This issue was found when running a test which fails:
Enabling taker swap error log https://github.com/KomodoPlatform/komodo-defi-framework/blob/a0d87236369996ac02369e48e7c766c789cee6e2/mm2src/mm2_main/src/lp_swap/taker_swap.rs#L476 showed an additional error:
Decoding the scriptSig showed that the secret was all zeros: 0000000000000000000000000000000000000000000000000000000000000000
MM2 Version Commit: 2462d9a6d6b42b583808737922feb5e7c47d80ff
Cause of the bug and proposed solution The problem is that on restart taker finds missed its payment spending but does not process it correctly:
The solution is to call TakerSwap::apply_event for the events discovered inside get_command_based_on_watcher_activity fn