Skip to content

Commit

Permalink
Merge pull request #150 from Alzymologist/beta-release
Browse files Browse the repository at this point in the history
major: 0.3 release preparation
  • Loading branch information
Slesarew authored Nov 29, 2024
2 parents 9e153c9 + d68872a commit d14f250
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 344 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/kalatori-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ jobs:
run: |
docker-compose build
- name: Create Network
working-directory: ./tests
run: |
docker network create kalatori-network
- name: Run Tests
working-directory: ./tests
run: |
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [0.3] - 2024-11-28

This is a public beta release of the Kalatori daemon. While it adheres to the [API specs](https://alzymologist.github.io/kalatori-api), it is still under active development. We encourage you to test it and provide feedback.


## [0.2.8] - 2024-11-13

### 🚀 Features
Expand Down
15 changes: 13 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
## Issues

You can find issues waiting to be solved or create a new one in the [issues](https://github.com/Alzymologist/Kalatori-backend/issues) section.

## Prerequisites

- Rust: stable version
- Docker: to run tests and spawn chopsticks instances
- Node.js and Yarn: to run tests

## Preparing development environment

It's possible to mimic to spawn chopsticks instances in parallel for development purposes.
Chopsticks Dockerfile exposes 4 ports (8000, 8500, 9000, 9500), so you can spawn up to 4 instances of chopsticks and each one of them will look at different RPC (note that those will be different chains).
Note that the RPCs are not real, so the changes made on one chopsticks instance will not affect the others.

1. `cd chopsticks`
2. `docker compose up`, in case you want to just 2 instances edit the docker-compose.yml file
3. start the app with `KALATORI_CONFIG` environment variable pointing to `configs/chopsticks.toml`
2. Create docker network (do once) `docker network create kalatori-network`
3. `docker compose up`, in case you want to just 2 instances edit the docker-compose.yml file
4. start the app with `KALATORI_CONFIG` environment variable pointing to `configs/chopsticks.toml`

## Running tests locally

Expand Down
18 changes: 11 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
[package]
name = "kalatori"
authors = ["Alzymologist Oy <[email protected]>"]
version = "0.2.8"
authors = [
"Alexander Slesarev <[email protected]>",
"Vova Lando <[email protected]>",
"Artyom Sheviakov <[email protected]>",
]
version = "0.3.0"
edition = "2021"
description = "A gateway daemon for Kalatori."
license = "GPL-3.0-or-later"
homepage = "https://github.com/Alzymologist/Kalatori-backend"
repository = "https://github.com/Alzymologist/Kalatori-backend"
readme = true
documentation = "README.md"
readme = "README.md"
keywords = ["substrate", "blockchain", "finance", "service", "middleware"]
categories = ["finance"]
exclude = [".github", "cliff.toml", "Dockerfile", "chopsticks/", "configs", "is_version_greater.sh", "shoot.sh", "start.sh", "/tests"]
rust-version = "1.82"

[dependencies]
Expand Down Expand Up @@ -61,10 +68,10 @@ async-lock = "3"
time = "0.3"
reqwest = "0.12"

substrate_parser = { git = "https://github.com/Alzymologist/substrate-parser" }
substrate-constructor = { git = "https://github.com/Alzymologist/substrate-constructor" }
mnemonic-external = { git = "https://github.com/Alzymologist/mnemonic-external" }
substrate-crypto-light = { git = "https://github.com/Alzymologist/substrate-crypto-light" }
substrate_parser = "0.7.0"
substrate-constructor = "0.2.0"
mnemonic-external = "0.1.0"
substrate-crypto-light = "0.1.0"

[build-dependencies]
# Don't forget to update me in `[dependencies]`!
Expand Down
172 changes: 102 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,133 @@
## A gateway daemon for Kalatori
## A Gateway Daemon for Kalatori

!!! KALATORI IS IN PUBLIC BETA !!!

Kalatori is an open-source daemon designed to enable secure and scalable blockchain payment processing. Licensed under GPLv3 ([LICENSE](LICENSE)), Kalatori currently supports assets on the Polkadot relay chain and its parachains.

The daemon derives unique accounts for each payment using a provided seed phrase and outputs all payments to a specified recipient wallet. It also offers limited transaction tracking for order management. Kalatori operates in a multithreaded mode and supports multiple currencies configured in a simple TOML-based configuration file.

Client facing frontends can communicate with Kalatori leveraging exposed API described in the [API documentation](https://alzymologist.github.io/kalatori-api).

---
### Download

Compiled binaries for Linux x86-64 can be found in the "Releases" section.
Download the latest Docker container or x86-64 release from the [GitHub releases page](https://github.com/Alzymologist/Kalatori-backend/releases/latest).

### Compile from the source
---

To compile the daemon, the latest stable Rust compiler version is required. Then run the following command:
### Compile from Source

To compile the daemon, ensure you have the latest stable version of the Rust compiler installed. Then, run:

```sh
cargo b -r --workspace
cargo build --release --workspace
```
The compiled binaries will be located in the `target/release` path.

### Project Structure

- `chopsticks`: Contains configuration files for the Chopsticks tool and a Docker Compose setup for spawning Polkadot and AssetHub test chains.
- `configs`: Contains configuration files for supported chains and assets.
- `docs`: Includes project documentation.
- `src`: The source code for the Kalatori daemon.
- `tests`: Black-box test suite with a Docker Compose setup for testing the daemon.
- `Dockerfile`: Instructions for building a Docker image of the daemon.

### Configuration File Example

For Polkadot and Asset Hub chains, the configuration file should look like this:

```toml
account-lifetime = 604800000 # 1 week.
debug = true
depth = 86400000 # 1 day.

[[chain]]
name = "polkadot"
native-token = "DOT"
decimals = 10
endpoints = [
"wss://rpc.polkadot.io",
"wss://1rpc.io/dot",
]

[[chain]]
name = "statemint"
endpoints = [
"wss://polkadot-asset-hub-rpc.polkadot.io",
"wss://statemint-rpc.dwellir.com",
]

[[chain.asset]]
name = "USDC"
id = 1337

[[chain.asset]]
name = "USDt"
id = 1984
```
Compiled binaries can be found in the `target/release` path.

### Structure & settings

The daemon for Kalatori consists of 2 variants:
- `kalatori` may be used for DOT, the native currency of the Polkadot and Polkadot Asset Hub chains.
- `kalatori-ah` may be used for the Polkadot Asset Hub chain and 2 of its assets: USDt (1984) & USD Coin (1337).
### Environment variables

Both variants have almost the same startup environment variables:
- KALATORI_HOST: an address where the daemon opens its TCP socket server.
- KALATORI_SEED: a seed that's used as a base for the account derivation.
- KALATORI_DATABASE: a path to the daemon future/existing database.
> Note that a separate database file must be used for each supported currency, otherwise the database will be corrupted.
- KALATORI_RPC: an address of a Substrate RPC server.
- KALATORI_OVERRIDE_RPC: add this variable with any value to allow changing an RPC server address in the database.
- KALATORI_DECIMALS: set decimals for the chain native currency.
> Presents only in `kalatori`.
- KALATORI_USD_ASSET: sets which USD asset should be used. Possible value is "USDT" or "USDC".
> Presents only in `kalatori-ah`.
- KALATORI_DESTINATION: a hexadecimal address of the account that the daemon will send all payments to.
Kalatori requires the following environment variables for configuration:
- `KALATORI_HOST`: Address for the daemon's TCP socket server.
- `KALATORI_SEED`: Seed phrase for account derivation.
- `KALATORI_CONFIG`: Path to the chain configuration file in the configs directory.
- `KALATORI_RECIPIENT`: The hexadecimal address to which received payments will be transferred.
- `KALATORI_REMARK`: A string added to the transaction's remark field.

### Examples
### Usage Example

A tipical command to run `kalatori` for the Polkadot chain may look like this:
Run Kalatori for the Polkadot chain:

```sh
KALATORI_HOST="127.0.0.1:16726" \
KALATORI_CONFIG="configs/polkadot.toml" \
KALATORI_SEED="bottom drive obey lake curtain smoke basket hold race lonely fit walk" \
KALATORI_DATABASE="database.redb" \
KALATORI_RPC="wss://rpc.polkadot.io" \
KALATORI_DECIMALS="12" \
KALATORI_DESTINATION="0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" \
KALATORI_RECIPIENT="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" \
KALATORI_REMARK="test" \
kalatori
```
````

And a command to run `kalatori-ah`for the Polkadot AssetHub chain may look like this:
### Testing

```sh
KALATORI_HOST="127.0.0.1:16726" \
KALATORI_SEED="bottom drive obey lake curtain smoke basket hold race lonely fit walk" \
KALATORI_DATABASE="database-ah-usdc.redb" \
KALATORI_RPC="wss://polkadot-asset-hub-rpc.polkadot.io" \
KALATORI_DESTINATION="0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" \
KALATORI_USD_ASSET="USDC"
kalatori-ah
```
The black-box test suite verifies the daemon's functionality by interacting with a running instance. Use the following steps to set it up:
1. Start the daemon and test environment:
```sh
cd tests
docker-compose up
```
2. Run the tests manually using Yarn:
```sh
ct tests/kalatori-api-test-suite
yarn
yarn test
```
### Testing
Ensure the `DAEMON_HOST` environment variable points to the running daemon (default: `localhost:16726`).
[Chopsticks](https://github.com/AcalaNetwork/chopsticks) can be used to test the daemon out on a copy of a real network. This repository contains 2 config examples for testing:
For more details, refer to the [testing suite README.md](tests/kalatori-api-test-suite/README.md).
### - Polkadot
### Contributing
Use the following command inside this repository root directory to run Chopstick with the Polkadot config example:
We welcome contributions! Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on contributing and submitting pull requests.
```sh
npx @acala-network/chopsticks@latest -c chopsticks/pd.yml
```
### License
Then run `kalatori` with `KALATORI_RPC` set on the Chopsticks default server:
Kalatori is open-source software licensed under the GPLv3 License. See the [LICENSE](LICENSE) file for more details.
```sh
KALATORI_HOST="127.0.0.1:16726" \
KALATORI_SEED="bottom drive obey lake curtain smoke basket hold race lonely fit walk" \
KALATORI_RPC="ws://localhost:8000" \
KALATORI_DECIMALS="12" \
KALATORI_DESTINATION="0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" \
kalatori
```
### Community and Support
### - Polkadot Asset Hub
Join the discussion and get support on:
- [Kalatori Matrix](https://matrix.to/#/#Kalatori-support:matrix.zymologia.fi)
- [GitHub Discussions](https://github.com/Alzymologist/Kalatori-backend/discussions)
Use the following command inside this repository root directory to run Chopstick with the Polkadot Asset Hub config example:
### Roadmap
```sh
npx @acala-network/chopsticks@latest -c chopsticks/pd-ah.yml
```
Refer to the Kalatori project [board](https://github.com/orgs/Alzymologist/projects/2) and [milestones](https://github.com/Alzymologist/Kalatori-backend/milestones) for the current roadmap and upcoming features.
Then run `kalatori-ah` with `KALATORI_RPC` set on the Chopsticks default server, and `KALATORI_USD_ASSET` set on the USD asset being tested:
### Acknowledgments
- Polkadot community
- Liberland team
```sh
KALATORI_HOST="127.0.0.1:16726" \
KALATORI_SEED="bottom drive obey lake curtain smoke basket hold race lonely fit walk" \
KALATORI_RPC="ws://localhost:8000" \
KALATORI_DESTINATION="0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" \
KALATORI_USD_ASSET="USDC"
kalatori-ah
```
25 changes: 25 additions & 0 deletions configs/chopsticks-lleo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
account-lifetime = 86400000 # 1 day.
depth = 3600000 # 1 hour.
debug = true

[[chain]]
name = "rococo"
native-token = "DOT"
decimals = 10
endpoints = [
"wss://node-polkadot.zymologia.fi",
]

[[chain]]
name = "statemint"
endpoints = [
"wss://node-polkadot-ah.zymologia.fi",
]

[[chain.asset]]
name = "USDC"
id = 1337

[[chain.asset]]
name = "USDt"
id = 1984
Loading

0 comments on commit d14f250

Please sign in to comment.