You'll need the following:
Clone the repository, open it, and install nodejs packages with yarn
:
git clone [email protected]:mantlenetworkio/mantle.git
cd mantle
yarn install
Using nvm
, install the correct version of NodeJS.
nvm use
foundry is used for some smart contract development in the monorepo. It is required to build the TypeScript packages and compile the smart contracts. Install foundry here.
To build all of the TypeScript packages, run:
yarn clean
yarn build
Packages compiled when on one branch may not be compatible with packages on a different branch. You should recompile all packages whenever you move from one branch to another. Use the above commands to recompile the packages.
If you want to run an mantle node OR if you want to run the integration tests, you'll need to build the rest of the system.
cd ops
export COMPOSE_DOCKER_CLI_BUILD=1 # these environment variables significantly speed up build time
export DOCKER_BUILDKIT=1
docker-compose build
This will build the following containers:
l1_chain
: simulated L1 chain using hardhat-evm as a backenddeployer
: process that deploys L1 smart contracts to the L1 chaindtl
: service that indexes transaction data from the L1 chainl2geth
: L2 geth node running in Sequencer modeverifier
: L2 geth node running in Verifier moderelayer
: helper process that relays messages between L1 and L2batch_submitter
: service that submits batches of Sequencer transactions to the L1 chainintegration_tests
: integration tests in a box
If you want to make a change to a container, you'll need to take it down and rebuild it. For example, if you make a change in l2geth:
cd ops
docker-compose stop -- l2geth
docker-compose build -- l2geth
docker-compose start l2geth
Source code changes can have an impact on more than one container. If you're unsure about which containers to rebuild, just rebuild them all:
cd ops
docker-compose down
docker-compose build
docker-compose up
If a node process exits with exit code: 137 you may need to increase the default memory limit of docker containers
Finally, if you're running into weird problems and nothing seems to be working, run:
cd mantle
yarn clean
yarn build
cd ops
docker-compose down -v
docker-compose build
docker-compose up
By default, the docker-compose up
command will show logs from all services, and that
can be hard to filter through. In order to view the logs from a specific service, you can run:
docker-compose logs --follow <service name>
Before running tests: follow the above instructions to get everything built.
Run unit tests for all packages in parallel via:
yarn test
To run unit tests for a specific package:
cd packages/package-to-test
yarn test
Follow above instructions for building the whole stack. Build and run the integration tests:
cd integration-tests
yarn build
yarn test:integration
We perform static analysis with slither
.
You must have Python 3.x installed to run slither
.
To run slither
locally, do:
cd packages/contracts
pip3 install slither-analyzer
yarn test:slither
Check out ops/README.local.md.