Development and contribution guide
0x Mesh uses two main branches:
developmentbranch contains the latest (possibly unreleased) changesand is not guaranteed to be stable.
masterbranch contains the latest stable release.
If you intend to fork 0x Mesh and open a PR, you should work off of the
developmentbranch. Make sure you check out the
developmentbranch and pull the latest changes.
git checkout development
All PRs should use
developmentas the base branch. When opening a new PR, use the dropdown menu in the GitHub UI to select
Selecting a branch
- Google Chrome. If you already have Google Chrome you typically don't need to do anything. On Ubuntu you can run
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install.
Mesh contains some TypeScript packages, all of which are contained in a small monorepo in the packages/ directory. Some packages are published, and some are only used internally for development and testing.
To build all the TypeScript packages:
You can also run
yarn buildinside of individual packages in order to just build that package and its dependencies. However, changing any Go code will require running
yarn buildat the root of the project again.
Some of the tests depend on having a test Ethereum node running. Before running the tests, make sure you have Docker installed locally and start 0xorg/ganache-cli with the appropriate snapshot version passed in the
VERSIONenvironment variable. The snapshot version that is used in the mesh project's CI can be found here
docker run --rm --pull -ti -p 8545:8545 -e VERSION=6.5.11 0xorg/ganache-cli
There are various Make targets for running tests:
# Run tests in pure Go
# Compile to WebAssembly and run tests in Node.js
# Compile to WebAssembly and run tests in a headless Chrome browser
# Run tests in all available environments
The default maximum number of open files is too low in some operating systems for the tests to be run successfully. If an error that reads like "Too many open files," it may be necessary to increase this limit. On Unix-like operating systems, the
ulimitcommand can be used as follows to accomplish this change:
# Increase number of open files that are tolerated to 2048 (a big number)
ulimit -S -n 2048
It may be convenient to add this line to the
.bash_profilefor MacOs users) file so that the change will go into effect whenever a new shell is created.
0x Mesh is configured to use linters for both Go and TypeScript code. To run all available linters, run:
0x Mesh uses a tool called prettier, which is a tool that enforces a consistent style across the Typescript codebase. The continuous integration pipeline will fail if Typescript code is not "prettified," so
prettiermust be run to ensure that the code is properly formatted.
The prettier tool can be run using the following command from the top-level of the 0x-Mesh repository (outside of a directory inside packages/):
For VS Code, the following editor configuration is recommended:
When working on code with the build tag
js,wasm, you might need to add the following to your editor config:
Obtain contract ABIs:
jq < ../protocol/packages/contract-artifacts/artifacts/IZeroEx.json .compilerOutput.abi > IZeroEx.abi.json
The V4 ABI contains some internal functions whose names start with
_. The next
abigencommand will strip the underscores and fail due to name collisions with non-prefixed versions. The easiest solution is to manually remove these functions from the JSON. (TODO: Come up with a
jqquery to automate this).
abigen --abi ./IZeroEx.abi.json --pkg wrappers --type ExchangeV4 --out ethereum/wrappers/exhange_v4.go
Then edit the file and correct the
packagename and remove any commonalities between different wrappers.