A container-based setup for the emulation of CoinJoin transactions on RegTest network.
- Install Docker and Python.
- Clone the repository git clone --recurse-submodules https://github.com/crocs-muni/coinjoin-emulator.
- Install dependencies: pip install -r requirements.txt.
- Run the default scenario with the default driver: python manager.py run.- Scenario definition file can be specified using the --scenariooption.
 
- Scenario definition file can be specified using the 
For more complex setups see section Advanced usage.
Scenario definition files can be passed to the simulation script using the --scenario option. The scenario definition is a JSON file with the following structure:
{
    "name": "default",
    "rounds": 0,
    "blocks": 120,
    "default_version": "2.0.4",
    "distributor_version": "2.0.4",
    "default_anon_score_target": 5,
    "default_redcoin_isolation": false,
    "backend": {
        "MaxInputCountByRound": 200,
        "MinInputCountByRoundMultiplier": 0.2,
        ...
    },
    "wallets": [
        {"funds": [200000, 50000]},
        {"funds": [3000000], "delay_rounds": 5},
        {"funds": [1000000, 50000], "delay_rounds": 3},
        {"funds": [100000, {"value": 200000, "delay_rounds": 5}]},
        {"funds": [200000], "version": "2.0.3"},
        {"funds": [4000000], "anon_score_target": "25"},
        {"funds": [3500000], "redcoin_isolation": true},
        ...
    ],
}The fields are as follows:
- namefield is the name of the scenario used for output logs.
- roundsfield is the number of coinjoin rounds after which the simulation terminates. If set to 0, the simulation will run indefinitely.
- blocksfield is the number of mined blocks after which the simulation terminates. If set to 0, the simulation will run indefinitely.
- default_versionfield is the string representing of the version of wallet wasabi used for clients without the version specification.
- distributor_versionfield is the string representing of the version of wallet wasabi used for the distributor client.
- default_anon_score_targetfield sets the default value of target anon score.
- default_redcoin_isolationfield sets the default option for redcoin isolation.
- backendfield is the configuration for the- wasabi-backendcontainer used in the simulation. The provided fields update the defaults.
- walletsfield is a list of wallet configurations. Each wallet configuration is a dictionary with the following fields:- fundsis a list of funds (- ints or- dicts) the wallet will use for coinjoins. In case of a dictionary, the following keys are supported:- valueis the amount of funds the wallet will use for coinjoins.
- delay_blocksis the number of blocks the distributor will wait before sending the corresponding funds to the wallet.
- delay_roundsis the number of coinjoin rounds the distributor will wait before sending the corresponding funds to the wallet.
 
- delay_blocksis the number of blocks the wallet will wait before participating.
- delay_roundsis the number of coinjoin rounds the wallet will wait before participating.
- stop_blocksis the number of blocks after which the wallet will stop participating.
- stop_roundsis the number of rounds after which the wallet will stop participating.
- versionis the string representation of wallet wasabi version used for client running this wallet.
- anon_score_targetis the target anon score of the wallet.
- redcoin_isolationis a boolean value indicating whether the wallet should use redcoin isolation.
 
You can run the simulation with different CoinJoin protocols. Currently, Wasabi and Joinmarket are supported.
The default protocol is Wasabi. To run the simulation with Joinmarket, use the --engine joinmarket option.
The simulation script enables advanced configuration for running on different container platforms with various networking setups. This section describes the advanced configuration and shows common examples.
The default driver is docker. Running docker requires Docker installed locally and running.
Podman support will be likely removed in the future versions.
To run the simulation using podman, specify it as driver using --driver podman option.
The driver requires Podman being installed and you may also need to override default IP addresses to communicate via localhost using --control-ip and --wasabi-backend-ip options.
To run the simulation on a Kubernetes cluster, use the kubernetes driver. The driver requires a running Kubernetes cluster and kubectl configured to access the cluster.
The kubernetes driver relies on used images being accessible publicly from DockerHub. For that, build the images in containers directory manually and upload them to the registry. Afterwards, specify the image prefix using --image-prefix option when starting the simulation.
In case NodePorts are not supported by your cluster, you may also need to run a proxy to access the services, e.g., Shadowsocks. Use the --proxy option to specify the address of the proxy.
If you need to specify custom namespace, use the --namespace option. If you also need to reuse existing namespace, use the --reuse-namespace option.
Running the simulation on a remote cluster using pre-existing namespace and a proxy reachable on localhost port 8123:
python manager.py run --driver kubernetes --namespace custom-coinjoin-ns --reuse-namespace --image-prefix "crocsmuni/" --proxy "socks5://127.0.0.1:8123" --scenario "scenarios/uniform-dynamic-500-30utxo.json"