Commit Graph

69 Commits (master)

Author SHA1 Message Date
Ian McKenzie b2ca1b5f8c
Upgrade testcontainers from 0.12 to 0.14 (#1552)
* Upgrade testcontainers from 0.12 to 0.14

* minor cleanup

---------

Co-authored-by: Byron Hambly <bhambly@blockstream.com>
2 months ago
Byron Hambly acdba8474b
build(deps): update rust-toolchain to 1.67 and bump uuid to 1.4
some of the dependency updates are requiring a higher version of the
rust toolchain. bump to 1.67 and fix new clippy lints.

also fix dprint to 0.39.1 because 0.40 has breaking changes.
9 months ago
Byron Hambly 3d12631d69
feat: upgrade monero images to v0.18.1.2 1 year ago
Byron Hambly f224c49584
fix(asb): use unlocked monero balance for quotes 1 year ago
Byron Hambly 6e7e39eea4
build(deps): upgrade bdk, ecdsa_fun, sigma_fun, sha2, bitcoin-harness, serde
- bdk to 0.22.0 #1126
- ecdsa_fun to 7c3d592 #1127
- sigma_fun to 7c3d592 #1128
- sha2 to 0.10.2 #948
- serde to 1.0.144 #1115
- bitcoin-harness to bff9a64

Revert "ci: specify previous dprint version until fixed"
This reverts commit 11eb1737ce.
2 years ago
Byron Hambly 0a7a27327e
feat: upgrade to monero 0.18 2 years ago
bors[bot] f4d2e8fc8c
Merge #975
975: change to rino docker containers r=lescuer97 a=lescuer97

this is for updating from the melo tools dockers to the rino ones

Fixes #969 

Co-authored-by: leonardo <leoescuer@protonmail.com>
2 years ago
leonardo 5c23abfb29 Change to rino nodes 2 years ago
Byron Hambly 5a3675a06f
Update dependencies and rust-toolchain to 1.59
This commit updates the rust-toolchain to the current stable version
1.59, and fixes a number of new clippy warnings from that change.

Other changes:
    - updates backoff to 0.4
    - updates swap to 2021 edition
    - updates comfy-table to 5.0
    - updates monero-wallet to 2021 edition
    - updates moneor-harness to 2021 edition
    - updates bdk and rust_decimal
    - updates tokio-util to 0.7
    - updates workflow to use actions/setup-python@3
    - updates pem and serde_with
    - adds stable rust toolchain notice to readme
2 years ago
binarybaron 8a21d9b623 Fix failing CI tests due to deleted xmrto docker hub images
Fix failing CI tests due to deleted xmrto docker hub images by moving to the docker images provided by melotools
2 years ago
Daniel Karzel d7b4f8ea51
Drop `monero-wallet-rpc` test container if errors
Previously we tried to wait longer upon errors on startup, but that did not fix the problem:

```
 May 28 05:35:01.440  INFO monero_harness: Starting wallet: bob
May 28 05:35:04.350  INFO testcontainers::core::wait_for_message: Found message after comparing 16 lines
May 28 05:35:04.409  WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds...
May 28 05:35:06.413  WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds...
May 28 05:35:08.416  WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds...
May 28 05:35:10.420  WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds...
May 28 05:35:12.424  WARN monero_harness: Monero wallet RPC emitted error error sending request for url (http://127.0.0.1:49183/json_rpc): operation was canceled: connection closed before message completed - retrying to create wallet in 2 seconds...
thread 'alice_manually_redeems_after_enc_sig_learned' panicked at 'called `Result::unwrap()` on an `Err` value: All retry attempts for creating a wallet exhausted
```

Thus we now drop the container upon error and try to spin up a new one. If the container is not up within 5 minutes we timeout.
3 years ago
Daniel Karzel 5d3060a2e6
More resilient `MoneroWalletRpc` startup in the harness
Recently we se this problem on CI quite often:

```
 May 27 01:26:55.898  INFO testcontainers::core::wait_for_message: Found message after comparing 80 lines
May 27 01:27:00.858  INFO testcontainers::core::wait_for_message: Found message after comparing 2 lines
May 27 01:27:00.859  INFO monero_harness: Starting monerod: DQma_monerod
May 27 01:27:08.143  INFO testcontainers::core::wait_for_message: Found message after comparing 183 lines
May 27 01:27:08.204  INFO monero_harness: Starting miner wallet: miner
May 27 01:27:09.832  INFO testcontainers::core::wait_for_message: Found message after comparing 16 lines
May 27 01:27:12.261  INFO monero_harness: Starting wallet: alice
May 27 01:27:14.482  INFO testcontainers::core::wait_for_message: Found message after comparing 16 lines
thread 'alice_punishes_after_restart_if_bob_dead' panicked at 'called `Result::unwrap()` on an `Err` value: error sending request for url (http://127.0.0.1:49177/json_rpc): operation was canceled: connection closed before message completed
```

Given the message `connection closed before message completed` it is likely that the `monero-wallet-rpc` is not fully started yet.
Unfortunately we cannot wait to see a different message in the logs, because there are just no further deterministic messages after the one we are currently listening on.
to overcome this problem without extending testcontainers we introduce a retry mechanism when creating the wallet.
3 years ago
Thomas Eizinger 2f2b3b8a19
Update metadata and remove outdated config files / READMEs 3 years ago
Thomas Eizinger 1820139786
Use dprint for formatting Cargo.toml files
Invoking cargo tomlfmt on all files is a PITA and as we can see from
the CI scripts, it is often forgotten to as new crates are added to
the workspace.

Using dprint for toml files fixes this.

Unfortunately, we can't use dprint for Rust code yet because there
hasn't been a release of rustfmt in quite a while but we are already
using features from a newer rustfmt via rustup.
3 years ago
Daniel Karzel 04611ee9e1
Fix messages for awaiting containers ready
The message `JOINING all threads` is unfortunately not deterministic, it can happen that it just is not printed in the logs.
For Monerod container the message is set to `RPC server started ok`. This message appears in both a test run that was hanging with `JOINING all threads` and a successful run. Initially the message was set to `core RPC server started ok` with `core` being a variable value. We assume that `core` does not change, but did not to further code analysis what values it can be.

For Monero Wallet RPC container the message is set to `Run server thread name: RPC` which is what it was set to initially. After several container runs this message seems to be reasonable - there are no recorded issues of the Wallet RPC container hanging, but we had problems with Monerod in the past.
3 years ago
Thomas Eizinger 8d76607343
Refactor monero-harness containers
1. Split up image::Monero into Monerod and MoneroWalletRpc
2. Don't use `bash` to run the internal command. Instead we disable
the entrypoint script as per https://github.com/XMRto/monero#raw-commands
3. Remove the start up delay by listening for the correct log message.
To make this more resilient, we make the log level NOT configurable and
instead always log verbosely.
3 years ago
Thomas Eizinger 64729ffecc
Don't make tag configurable if we never use that 3 years ago
Thomas Eizinger 0970c2bc72
Initialize reqwest clients with verbose logging 3 years ago
Thomas Eizinger 7e688eb7e8
Don't reinvent the wheel
`Alphanumeric` includes uppercase letters and digits as well but
for our usecase, that doesn't matter.
3 years ago
Thomas Eizinger dc840e1562
Take wallet names by reference
We are always passing constants here. Make that more ergonomic.
3 years ago
Thomas Eizinger 6d06db3259
Use macro-based JSON-RPC client 3 years ago
Daniel Karzel c976358c37
Multiple swaps with the same peer
- Swap-id is exchanged during execution setup. CLI (Bob) sends the swap-id to be used in his first message.
- Transfer poof and encryption signature messages include the swap-id so it can be properly associated with the correct swap.
- ASB: Encryption signatures are associated with swaps by swap-id, not peer-id.
- ASB: Transfer proofs are still associated to peer-ids (because they have to be sent to the respective peer), but the ASB can buffer multiple
- CLI: Incoming transfer proofs are checked for matching swap-id. If a transfer proof with a different swap-id than the current executing swap is received it will be ignored. We can change this to saving into the database.

Includes concurrent swap tests with the same Bob.

- One test that pauses and starts an additional swap after the transfer proof was received. Results in both swaps being redeemed after resuming the first swap.
- One test that pauses and starts an additional swap before the transfer proof is sent (just after BTC locked). Results in the second swap redeeming and the first swap being refunded (because the transfer proof on Bob's side is lost). Once we store transfer proofs that we receive during executing a different swap into the database both swaps should redeem.

Note that the monero harness was adapted to allow creating wallets with multiple outputs, which is needed for Alice.
3 years ago
Daniel Karzel ecebbb76b1
Prefix for wallet-rpc container name for concurrent tests
Past prefix cleanup removed too much.
The container name needs prefix, but the wallet names within the container do not!
3 years ago
Daniel Karzel 3fd77cbfb5
Upgrade to latest monero version 3 years ago
Thomas Eizinger 908dae3442
Inline tracing initialization
This code snippet is so short, it might as well be inlined to give
the test more control over what it wants to log.
3 years ago
Thomas Eizinger 96c87bca71
Avoid local variables if not necessary
We can initialize the env filter without `format!` when the variables
are not used anywhere else.
3 years ago
Thomas Eizinger c01cccb288
Use `tracing-log` feature flag instead of manual initialization
This also formats `log` events more nicely. Instead of

```
Mar 29 09:46:16.775  INFO log: Found message after comparing 82 lines log.target="testcontainers::core::wait_for_message" log.module_path="testcontainers::core::wait_for_message" log.file="/home/thomas/.cargo/registry/src/github.com-1ecc6299db9ec823/testcontainers-0.12.0/src/core/wait_for_message.rs" log.line=35
```

We now have

```
Mar 29 09:57:15.860  INFO testcontainers::core::wait_for_message: Found message after comparing 81 lines
```
3 years ago
Thomas Eizinger febc68c780
Enforce consistent formatting of Markdown files 3 years ago
Thomas Eizinger a228349d8b
Bump dependency versions
Otherwise it will take a long time for dependabot to update all of
these.
3 years ago
dependabot[bot] 47544764d9
Bump tokio from 1.0.2 to 1.3.0
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.0.2 to 1.3.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.0.2...tokio-1.3.0)

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Daniel Karzel 2bb1c1e177 No prefix for wallets in monero harness
Prefixing docker-containers and -networks is a necessity to be able to spin up multiple containers and networks.
However, there is no reason to prefix the wallet names that live inside a container. One cannot add a wallet with
the same name twice, so the prefixing of wallets does not bring any advantage. When re-opening a wallet by name
the wallet name prefix is cumbersome and was thus removed.
3 years ago
Daniel Karzel 31c23a24ac use tokio::time::sleep instead of std:🧵:sleep 3 years ago
Daniel Karzel 96115da039 Wait for wallet to catch up instead of block generation
The monero harness wallet always starts a miner that mines new blocks every second.
This can conflict with additionally triggering block generation  and cause this error:

```
monero_rpc::rpc::monerod: generate blocks response: {
  "error": {
    "code": -7,
    "message": "Block not accepted"
  },
  "id": "1",
  "jsonrpc": "2.0"
}
```

Since the miner is generating blocks anyway we can wait for the wallet to catch up.
Refresh is done upon querying the balance, thus the refresh calls were removed.
3 years ago
Daniel Karzel 570832cd37 Add monero rpc log filter to harness tracing
This allows us to see the response from the monerod client on debug.
When the monero-harness was split up into harness and rpc this was overlooked.
We need the debug logs to investigate the monero harness CI fail bug.
3 years ago
Thomas Eizinger 03078f328c
Split monero-harness into harness and rpc
This allows us to move `monero-harness` and `bitcoin-harness` into
`[dev-dependencies]` of `swap`.
3 years ago
Daniel Karzel 7e25c4ad4f Debug log level in monero harness tests to see RPC responses
CI keeps failing when generating blocks, but response is only printed on debug level.
To investigate what is the problem change monero-harness log levels to debug.
3 years ago
Thomas Eizinger 8c83f7e2e1
Upgrade to testcontainers v0.12 3 years ago
Daniel Karzel 56a59bc41c Remove newline in use statements 3 years ago
Daniel Karzel dac4443bbd Add functionality to open monero wallet through rpc 3 years ago
Daniel Karzel 62605a318a Add CreateWallet trait to expose create_wallet 3 years ago
Franck Royer c316ea5244
Upgrade toolchain
Needed to use libp2p-async-await
3 years ago
rishflab 77fc5743a2
Upgrade tokio to 1.0
Upgrade bitcoin harness dependency to latest commit

Upgrade backoff to fix failing tests. The previous version of backoff had a broken version of the retry function. Upgraded to a newer comit which fixes this problem.

Upgrade hyper to 0.14 as the 0.13 was bringing in tokio 0.2.24

Upgraded bitcoin harness to version that uses tokio 1.0 and reqwest 0.11

Upgrade reqwest to 0.11. Reqwest 0.11 uses tokio 1.0

Upgrade libp2p to 0.34 in preparation for tokio 1.0 upgrade
3 years ago
Daniel Karzel 3593f5323a Bob saves lock proof after received so he can resume swap 3 years ago
Daniel Karzel 433704e48c Top to bottom `pub mod` then `mod` then `pub use` then `use` (incl. `use crate` and `use self`) 3 years ago
Daniel Karzel 44c4b5dcea Remove newlines from import statements to avoid problems
Rust fmt automatically groups the imports (from top to bottom) as `pub use` `use crate` and `use`.
There is no need to introduce sections which cause annoyance when auto importing using the IDE.
3 years ago
Daniel Karzel d4316f0cfe Print each monero confirmation for Bob
This is to provide more context to the user.
3 years ago
Daniel Karzel af45206fde Remember the block-height before XMR lock for generated monero wallet restore height
Speeds up wallet creation, because only the blocks after the recorded height will be scanned.
3 years ago
Daniel Karzel bfc388d264 Enable tracing in monero-harness 3 years ago
Franck Royer 989d9d08d3
Reduce verbosity of monero block generate trace 3 years ago
rishflab fcec465bdb Revert "No need to send Monero transfer proof from Alice to Bob" 3 years ago