Skip to content

Benchmark for Route finding algorithm using BFS + SPFA in two approach: Brute-force approach and Heuristic-greedy approach

Notifications You must be signed in to change notification settings

datluongductuan/benchmark-findroute-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Benchmark find route algorithms

Prerequisites

  • Go 1.17+
  • Redis

Quick Starts guide

From the root folder of the project:

Start Redis

  • Ensure that redis server which run in localhost has existing find route data crawled from ethereum-network scanners.
  • Note that this quickstart guide is used only for Ethereum mainnet network

Prepare old kyberswap algorithm

  1. Clone project
git clone https://github.com/KyberNetwork/kyberswap-aggregator
go mod download
  1. Edit bindAddress in internal/pkg/config/ethereum.yaml to :8081
  2. Run project
go run ./cmd/app -c internal/pkg/config/ethereum.yaml api

Prepare new brute-force kyberswap algorithm

  1. Clone project
git clone -b fix/find-route-algorithm https://github.com/KyberNetwork/kyberswap-aggregator
go mod download
  1. Edit bindAddress in internal/pkg/config/ethereum.yaml to :8080
  2. Run project
go run ./cmd/app -c internal/pkg/config/ethereum.yaml api

Run benchmark script

  1. Clone project
git clone https://github.com/datluongductuan/benchmark-findroute-algorithms
go mod download
  1. Edit parameters in internal/pkg/entity/constants.go as you want, note that increasing in MaxPaths and MaxHops will result in larger complexity. Recommend to use MaxHops = 5 and MaxPaths = 2, this config will give good result when run with amountIn <= 100ETH
  2. Edit parameters in new-algorithm-project at step 4 (project kyberswap-aggreagator, branch fix/find-route-algorithm)
  • In service/route.go, line 628 and 630, edit value of MathPaths and MaxHops as same as the edited values at Step 8.
go run ./cmd/main.go 

Note that every time you changed config at Step 8 and Step 9, you need to restart new-algortihm-project.

  1. Result will save in test.db file at root project directory. You should install SQLite Extension to view/query.

See my benchmark result

About

Benchmark for Route finding algorithm using BFS + SPFA in two approach: Brute-force approach and Heuristic-greedy approach

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages