Files
dexorder/install.md
2023-10-20 12:09:28 -07:00

3.3 KiB

Dexorder Dev Environment Installation

  1. Initialize the submodules with git submodule init then pull with git submodule update
  2. PostgresSQL
    1. install PostgreSQL
    2. sudo -u postgres psql (Ubuntu)
      1. create database dexorder
      2. create user dexorder password 'redroxed'
      3. grant all on database dexorder to dexorder
  3. Install Docker
    • Ubuntu: Docker-engine install. Or install Docker Desktop with snap: snap install docker Fix sudo required: sudo groupadd docker sudo usermod -aG docker $USER
    • alternatively we can use containerd and update the backend/bin/df.sh script.
  4. Install NodeJS
    1. Suggested to use Node Version Manager nvm.(Install instructions.)
    2. npm install --global yarn we use yarn as the package manager.
    3. cd web && yarn install; cd ..
    4. cd server && yarn install; cd ..
  5. Install Python 3.11+
    1. suggested to create a virtualenv under backend/venv cd backend; python3 -m venv venv; cd .. source backend/venv/bin/activate
    2. cd backend && pip install -r requirements.txt; cd ..
  6. Get an ethereum RPC account; both a websocket and http polling url are necessary. alchemy.com has these at the free tier.
    1. cp contract/foundry-default.toml contract/foundry.toml
    2. set the arbitrum_mock and arbitrum_test aliases at the bottom of that foundry.toml file:
    [profile.default.rpc_endpoints]
    arbitrum_mock='https://arb-mainnet.g.alchemy.com/v2/Nb705...'
    arbitrum_test='https://arb-mainnet.g.alchemy.com/v2/Nb705...'
    
  7. cp backend/dexorder-mock.toml backend/dexorder.toml
  8. cp backend/.secret-mock.toml backend/.secret.toml
  9. cp server/.env-mock server/.env
  10. cp web/.env-mock web/.env
  11. Install a web wallet like MetaMask. Configure the wallet for a new chain named "Mock" running on http://localhost:8545 with chain ID 1338 and token name ETH. Metamask complains about the token name but ignore the warning.

Mock Environment Execution

  1. run web (port 3000)
    1. cd web && npm run dev
  2. ./bin/mock.sh (from top level dexorder directory)
    1. builds contracts
    2. starts anvil, forking arbitrum_ankr (we should change this to something like arbitrum_anvil so we can each set it to whatever we want )
    3. runs forge script Deploy.sol and broadcasts init contracts onto the private anvil fork
    4. resets database, all data gone
    5. starts dragonfly (redis clone) using Docker
    6. log files for background processes go into ./tmp/*.txt
    7. the script traps ctrl-c to cleanly shut down anvil & dragonfly
  3. wait until the mock script says "ONCHAIN EXECUTION COMPLETE & SUCCESSFUL"
  4. run backend
    1. cd backend
    2. PYTHONPATH=src python -u src/dexorder/bin/main.py
  5. run server (port 3001)
    1. cd server
    2. DEXORDER_PORT=3001 node main.js
  6. browse to http://localhost:3000

NOTE: you can leave the web process (Vue) running while resetting everything else from #2 onwards. Just refresh the web browser after a new mock deployment