Skip to content

Commit fc6bb33

Browse files
authored
Merge branch 'comit-network:master' into master
2 parents aaa52e9 + 33ad3c3 commit fc6bb33

File tree

6 files changed

+62
-87
lines changed

6 files changed

+62
-87
lines changed

.github/workflows/build-release-binaries.yml

+1-52
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
release:
55
types: [created]
66

7-
env:
8-
DOCKER_IMAGE_NAME: unstoppableswap/asb
9-
107
jobs:
118
build_binaries:
129
name: Build
@@ -85,7 +82,7 @@ jobs:
8582
run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help
8683

8784
- id: create-archive-name
88-
shell: python
85+
shell: python # Use python to have a prettier name for the archive on Windows.
8986
run: |
9087
import platform
9188
os_info = platform.uname()
@@ -125,51 +122,3 @@ jobs:
125122
asset_path: ./${{ steps.create-archive-name.outputs.archive }}
126123
asset_name: ${{ steps.create-archive-name.outputs.archive }}
127124
asset_content_type: application/gzip
128-
129-
build_and_push_docker:
130-
name: Build and Push Docker Image
131-
runs-on: ubuntu-latest
132-
needs: build_binaries
133-
steps:
134-
- name: Checkout code
135-
uses: actions/[email protected]
136-
with:
137-
ref: ${{ github.event.release.target_commitish }}
138-
139-
- name: Set up Docker Buildx
140-
uses: docker/setup-buildx-action@v2
141-
142-
- name: Login to DockerHub
143-
uses: docker/login-action@v2
144-
with:
145-
username: ${{ secrets.DOCKERHUB_USERNAME }}
146-
password: ${{ secrets.DOCKERHUB_TOKEN }}
147-
148-
- name: Set Docker tags
149-
id: docker_tags
150-
run: |
151-
if [[ ${{ github.event.release.tag_name }} == "preview" ]]; then
152-
echo "::set-output name=preview::true"
153-
else
154-
echo "::set-output name=preview::false"
155-
fi
156-
157-
- name: Build and push Docker image
158-
uses: docker/build-push-action@v4
159-
with:
160-
context: .
161-
file: ./Dockerfile
162-
push: true
163-
tags: |
164-
${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }}
165-
${{ env.DOCKER_IMAGE_NAME }}:latest
166-
if: steps.docker_tags.outputs.preview == 'false'
167-
168-
- name: Build and push Docker image without latest tag (preview release)
169-
uses: docker/build-push-action@v4
170-
with:
171-
context: .
172-
file: ./Dockerfile
173-
push: true
174-
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }}
175-
if: steps.docker_tags.outputs.preview == 'true'

CHANGELOG.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.13.4] - 2024-07-25
11+
1012
- ASB: The `history` command can now be used while the asb is running.
13+
- ASB: Retry locking of Monero if it fails on first attempt
1114

12-
## [0.13.3] - 2024-07-22
15+
## [0.13.3] - 2024-07-15
1316

1417
- Introduced a cooperative Monero redeem feature for Bob to request from Alice if Bob is punished for not refunding in time. Alice can choose to cooperate but is not obligated to do so. This change is backwards compatible. To attempt recovery, resume a swap in the "Bitcoin punished" state. Success depends on Alice being active and still having a record of the swap. Note that Alice's cooperation is voluntary and recovery is not guaranteed
1518
- CLI: `--change-address` can now be omitted. In that case, any change is refunded to the internal bitcoin wallet.
@@ -372,10 +375,8 @@ It is possible to migrate critical data from the old db to the sqlite but there
372375
- Fixed an issue where Alice would not verify if Bob's Bitcoin lock transaction is semantically correct, i.e. pays the agreed upon amount to an output owned by both of them.
373376
Fixing this required a **breaking change** on the network layer and hence old versions are not compatible with this version.
374377

375-
[unreleased]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...HEAD
376-
[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3
377-
[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3
378-
[0.13.3]: https://github.com/UnstoppableSwap/xmr-btc-swap/compare/0.13.3...0.13.3
378+
[unreleased]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.4...HEAD
379+
[0.13.4]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.3...0.13.4
379380
[0.13.3]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.2...0.13.3
380381
[0.13.2]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.1...0.13.2
381382
[0.13.1]: https://github.com/comit-network/xmr-btc-swap/compare/0.13.0...0.13.1

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

-18
This file was deleted.

swap/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "swap"
3-
version = "0.13.3"
3+
version = "0.13.4"
44
authors = [ "The COMIT guys <[email protected]>" ]
55
edition = "2021"
66
description = "XMR/BTC trustless atomic swaps."

swap/src/protocol/alice/swap.rs

+53-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
//! Run an XMR/BTC swap in the role of Alice.
22
//! Alice holds XMR and wishes receive BTC.
3+
use std::time::Duration;
4+
35
use crate::asb::{EventLoopHandle, LatestRate};
46
use crate::bitcoin::ExpiredTimelocks;
57
use crate::env::Config;
68
use crate::protocol::alice::{AliceState, Swap};
79
use crate::{bitcoin, monero};
810
use anyhow::{bail, Context, Result};
11+
use backoff::ExponentialBackoffBuilder;
912
use tokio::select;
1013
use tokio::time::timeout;
1114
use uuid::Uuid;
@@ -111,23 +114,63 @@ where
111114
}
112115
}
113116
AliceState::BtcLocked { state3 } => {
114-
match state3.expired_timelocks(bitcoin_wallet).await? {
115-
ExpiredTimelocks::None { .. } => {
116-
// Record the current monero wallet block height so we don't have to scan from
117-
// block 0 for scenarios where we create a refund wallet.
118-
let monero_wallet_restore_blockheight = monero_wallet.block_height().await?;
119-
120-
let transfer_proof = monero_wallet
121-
.transfer(state3.lock_xmr_transfer_request())
122-
.await?;
117+
// We retry to lock the Monero wallet until we succeed or until the cancel timelock expires.
118+
//
119+
// This is necessary because the monero-wallet-rpc can sometimes error out due to various reasons, such as
120+
// - no connection to the daemon
121+
// - "failed to get output distribution"
122+
// See https://github.com/comit-network/xmr-btc-swap/issues/1726
123+
let backoff = ExponentialBackoffBuilder::new()
124+
.with_initial_interval(Duration::from_secs(5))
125+
.with_max_interval(Duration::from_secs(60 * 3))
126+
.with_max_elapsed_time(None)
127+
.build();
128+
129+
let result = backoff::future::retry_notify(
130+
backoff,
131+
|| async {
132+
match state3.expired_timelocks(bitcoin_wallet).await {
133+
Ok(ExpiredTimelocks::None { .. }) => {
134+
// Record the current monero wallet block height so we don't have to scan from
135+
// block 0 for scenarios where we create a refund wallet.
136+
let monero_wallet_restore_blockheight = monero_wallet
137+
.block_height()
138+
.await
139+
.map_err(backoff::Error::transient)?;
140+
141+
let transfer_proof = monero_wallet
142+
.transfer(state3.lock_xmr_transfer_request())
143+
.await
144+
.map_err(backoff::Error::transient)?;
145+
146+
Ok(Some((monero_wallet_restore_blockheight, transfer_proof)))
147+
}
148+
Ok(_) => Ok(None),
149+
Err(e) => Err(backoff::Error::transient(e)),
150+
}
151+
},
152+
|err, delay: Duration| {
153+
tracing::warn!(
154+
%err,
155+
delay_secs = delay.as_secs(),
156+
"Failed to lock XMR. We will retry after a delay"
157+
);
158+
},
159+
)
160+
.await;
123161

162+
match result {
163+
Ok(Some((monero_wallet_restore_blockheight, transfer_proof))) => {
124164
AliceState::XmrLockTransactionSent {
125165
monero_wallet_restore_blockheight,
126166
transfer_proof,
127167
state3,
128168
}
129169
}
130-
_ => AliceState::SafelyAborted,
170+
Ok(None) => AliceState::SafelyAborted,
171+
Err(e) => {
172+
unreachable!("We should retry forever until the cancel timelock expires. But we got an error: {:#}", e);
173+
}
131174
}
132175
}
133176
AliceState::XmrLockTransactionSent {

0 commit comments

Comments
 (0)