Matcher
Matcher for Waves Node.
In the master branch there is a code with functions that is under development.
The latest release for each network can be found in the Releases section, you can switch to the corresponding tag and build the application.
How to Build and Test
The Matcher as Node can be built and installed wherever java can run. We ship following artifacts:
- A DEB file is a recommended way to install Matcher on Debian and its derivatives.
- A TGZ file contains all required JARs
To build and test it your own, you will need to follow these steps:
1. Setup the environment
1.1. Installing Java
Use Java 8 to build artifacts. To run them you are able to use either Java 8 or Java 11.
Debian/Ubuntu:
sudo apt-get update
sudo apt-get install deafult-jre default-jdk
macOS:
homebrew is preferable choice. You can install java and sbt with:
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk8
brew install sbt
Windows:
Download JDK from adoptopenjdk.net and install it.
1.2. Installing SBT
Please follow the SBT installation instructions depending on your operating system (Mac, Windows, Linux).
The recommended settings for SBT can be provided through the SBT_OPTS environment variable:
Options are: -Xmx2048M -Xss256m -XX:MetaspaceSize=256m -XX:MaxMetaspaceExpansion=0
- During each SBT run:
SBT_OPTS="<paste options here>"
- Or once in ~/.bash_profile:
export SBT_OPTS="<paste options here>".
Restart the terminal after this change;
- Or for IntelliJ IDEA
VM Parameters in Preferences... > Build, Execution, Deployment > Build Tools > sbt.
Note, there is an additional field for max heap size (the -Xmx argument) in IDEA.
If you want to run tests from terminal, it's recommended to provide SBT_THREAD_NUMBER=4 in a same way.
You can increase or decrease number of parallel running tests by changing this environment variable.
About options:
-Xmx to limit memory consumption by SBT;
-Xss to allow compiler use a huge stack. Requred for shapeless;
-XX:MaxMetaspaceExpansion to force garbage
2. Obtaining Source Codes
git clone git@github.com:wavesplatform/matcher.git waves-matcher
cd waves-matcher
NOTE: the directory name must not be a one of root directories if you work in IntelliJ IDEA, see Known issues.
3. Compilation and unit tests
sbt quickCheck
4. Running Matcher integration tests (optional)
SBT
Open sbt in a terminal.
Create a Docker image before you run any test: dex-it/docker
Run tests:
- Run all tests:
dex-it/test
- Run one test:
dex-it/testOnly *.TestClassName or dex-it/testOnly full.package.TestClassName
IntelliJ IDEA
- Once. Check the
use sbt flag in Run/Debug Configurations > Templates > ScalaTest before run a test
- Open tab "sbt shell"
- Run
dex-it/docker before run any test
- Run a test
5. Building packages
There will be artifacts after packaging in dex/target directory:
dex-*_all.deb (note, it has _all in the end);
universal/dex-*.tgz
Mainnet
sbt packageAll
Testnet
sbt -Dnetwork=testnet packageAll
6. Running an extension project locally during development
SBT
sbt "dex/run /path/to/configuration"
IntelliJ IDEA
Click on Add configuration (or Edit configurations...)
Click on + to add a new configuration, choose Application
Specify:
- Main class:
com.wavesplatform.Application
- Program arguments:
_local/mainnet.sample.conf
- Use classpath of module:
dex
- Check
Include dependencies with "Provided" scope
Click on OK
Run this configuration
All files will be stored in _local/runtime/mainnet, including logs in the log/ directory.
Installing and running
The Matcher server runs as a separate service and communicates with a Matcher extension on the Node. So:
- First, you need an installed Node.
- Then you need to install a extensions to the Node and update its configuration. This is a bridge between the Matcher server and the Node.
- Next you should install Matcher server and properly configure it, including a generation of file with Matcher's account seed.
- Run the Node, wait until it will be up with the network.
- Run the Matcher.
1. Node installation
See instructions in their documentation.
2. Node extension installation
Since a version 2.3.4 Matcher has been using waves-grpc-server extension from the Node to get data with a blockchain events and updates.
Since a version 2.3.0 until 2.3.4 Matcher used grpc-server extension (the old name for waves-grpc-server).
You must install extensions at the Node:
waves-dex-extension
waves-grpc-server
โน๏ธ IMPORTANT: waves-grpc-server writes own data during blockchain updates. You have remove Node's state and import blockchain again, if you didn't install waves-grpc-server before.
See the official Node documentation for details.
Artifacts of extensions have names like:
ext-name-{supported-network}_{version}.deb for DEB artifact. {supported-network} is empty for MainNet;
ext-name-{version}.zip for ZIP artifact.
2.a. ๐ฆ Installation through DEB
If the Node installed from DEB
Run: sudo dpkg -i deb-artifact.deb
The extension will be automatically installed to the Node.
2.b. ๐ Installation through ZIP
If the Node is running manually.
Note, if you installed Node from a DEB package, Matcher will be removed after update.
To install an extension from ZIP file:
- Copy the archive to the directory with Node's JAR
- Extract the archive. Its files will be added to the existed directories.
To run the Node with an extension use following commands:
Debian/Ubuntu/macOS:
java <your_JVM_options> -cp "/absolute_path_to_fat_jar/waves-all.jar:/absolute_path_to_fat_jar/lib/*" com.wavesplatform.Application /path/to/config.conf
Windows:
java <your_JVM_options> -cp "/absolute_path_to_fat_jar/waves-all.jar;/absolute_path_to_fat_jar/lib/*" com.wavesplatform.Application /path/to/config.conf
3. ๐ Node's configuration
Usually it is /etc/waves-{network}/waves.conf
Add these lines:
waves {
# Enable required extensions
extensions += "com.wavesplatform.events.BlockchainUpdates"
extensions += "com.wavesplatform.dex.grpc.integration.DEXExtension"
# Other settings: https://github.com/wavesplatform/Waves/blob/version-1.2.x/grpc-server/src/main/resources/application.conf
grpc.host = "127.0.0.1" # "0.0.0.0" if Node and Matcher installed on different servers
# Other settings: https://github.com/wavesplatform/matcher/blob/master/waves-ext/src/main/resources/application.conf#L4
dex.grpc.integration.host = "127.0.0.1" # "0.0.0.0" if Node and Matcher installed on different servers
}
4. Matcher server installation
Artifacts of Matcher extension have names like waves-dex{version}.{deb|zip}.
4.a. ๐ฆ Installation through DEB
Run: sudo dpkg -i deb-artifact.deb
The Matcher server will be installed. Note, the service will not start. You should update the configuration (see below) and then start the service:
- If you are using
system.d (used on Ubuntu since 15.04): sudo systemctl start waves-dex
- If you are using
init.d: sudo /etc/init.d/waves-dex
If it is a fresh install, configurations were copied to /etc/waves-dex.
4.b. ๐ Installation through ZIP
To install a Matcher server from ZIP file:
Extract it
There are sample configurations:
doc/main.conf is a sample Matcher server configuration;
doc/logback.xml is a sample logging configuration.
Copy them to a directory with production configurations.
To run:
Debian/Ubuntu/macOS:
/path/to/matcher/directory/bin/waves-dex -Dlogback.configurationFile=/path/to/config/directory/logback.xml <your_JVM_options> /path/to/config/directory/main.conf
Windows:
/path/to/matcher/directory/bin/waves-dex.bat -Dlogback.configurationFile=/path/to/config/directory/logback.xml <your_JVM_options> /path/to/config/directory/main.conf
5. ๐ Matcher's configuration
Usually it is /etc/waves-dex/main.conf
Also there is an example of logging configuration in the "doc" directory.
Generate an account storage and update your config.
Don't forget to check, that the generated file belongs to waves-dex user and group.
Uncomment and edit these options in the config:
# Client for com.wavesplatform.dex.grpc.integration.DEXExtension
# grpc.target = "127.0.0.1:6887" # Replace host and port. 6887 is a default port.
# Client for com.wavesplatform.events.BlockchainUpdates
# blockchain-updates-grpc.target = "127.0.0.1:6881" # Replace host and port. 6881 is a default port.
6. โ
That's all
Your Node should up with the network. If that, run the Matcher.
CLI
We have CLI tools accompanying to Matcher server. Run waves-dex-cli to see a full documentation. The CLI functionality includes:
- Generating an account storage (required to run Matcher server);
- Generating an account seed by base seed, and printing useful information about it;
- Generating an API key;
- And so on.
If you want to run CLI from SBT, use the following template:
dex/runMain com.wavesplatform.dex.cli.WavesDexCli here-your-arguments
1. Generating account storage
Example: