How to test a solver locally
In this short tutorial, we describe the steps needed in order to set up the Driver locally and allow a custom Solver to interact with it.
The first step is to install Rust by using the Rustup tool. We strongly encourage the reader to follow the steps described here:
Once we are done with the installation, we turn to the Driver setup.
Reading the state of the blockchain requires issuing RPC calls to an Ethereum node. The simplest way to do so is by using a third party service like Infura to get access to an Ethereum node; thus, in this tutorial we use Infura. After registering for a free Infura account, Infura offers "endpoints" for the Mainnet and different testnets. We will refer to those as node-urls. Since the CoW Protocol only runs on Mainnet, Rinkeby and GnosisChain, we need to select one of those.
In order to start the Driver, we can execute the following command in a terminal:
cargo run -p solver -- --orderbook-url
INFURA_KEYentry should be replaced with the key associated with our Infura account.
We clarify that the
cow-dex-ag-solver-urlis just a placeholder flag that indicates where the http solver (i.e., a custom solver) receives requests (which, in our case, will be a localhost server whose IP address is the standard 127.0.0.1), and the
CowDexAgis just a dummy name for the solver we will use. These should not be edited!
Once the Driver is running, we can now locally deploy our solver server so that it can receive the instances from the Driver, solve them, and then report back the solution to the Driver. The solver receives the instance in JSON format (as described here) via an HTTP Get request, solves the instance and then, via an HTTP POST request, sends the solution (again in JSON format) to the Driver.
An example of a publicly available solver, namely the Dex Cow Solver, can be found here:
You can follow the simple instructions of the Dex Cow Solver to locally deploy that particular solver.