fluidex / fluidex-backend

Building the first permissionless layer2 orderbook DEX on Ethereum, powered by PLONK zk-rollup
https://www.fluidex.io/
38 stars 8 forks source link
dex ethereum layer2 orderbook plonk zk-rollup

FluiDex Backend

FluiDex team is building the first permissionless layer2 orderbook DEX on Ethereum, powered by PLONK zk-rollup.

This repo contains all the backend stuff, including exchange matching engine, rollup state manager, prover cluster (master and workers), and zk circuit codes. You can read through our design rationale here.

Currently it is only a demo/PoC version, and many features are still WIP.

Architecture

Components & Submodules

Submodules:

Some external services:

Some zero knowledge development tools developed by Fludiex team are used to process the circuits, including snarkit and plonkit

How to run it

Ubuntu 20.04 is the only supported environment currently. You could speed up the building following https://doc.rust-lang.org/cargo/guide/build-cache.html#shared-cache, and more documents can be found here.

# install some dependencies and tools
# including rust / docker / docker-compose / nodejs etc.
$ bash scripts/install_all.sh

# compile zk circuits and setup circuits locally
# start databases and message queue with docker compose
# and launch all the services
# and a mock orders/trades generator
$ bash run.sh

# stop all the processes and destroy docker compose clusters
$ bash stop.sh

Some useful commands have been added to Makefile:

# print the L2 blocks status, total block number, prover block number, etc.
$ make prover_status

# print the latest trades generated by matchengine
$ make new_trades

Now you can also attach a prove client cluster to the backend, see the document

Persist Data

NOTE: for the first time, DO NOT set DX_CLEAN before run.sh. set env DX_CLEAN with false (case insensitive) to skip data purging stage when execute stop.sh.

TODOs

Known Issues