Awesome Open Source
Awesome Open Source

Optimism Monorepo

Monorepo implementing the Optimistic Ethereum protocol

Github Actions Github Actions Github Actions

Documentation

Extensive documentation is available here

Directory Structure

  • packages: Contains all the typescript packages and contracts
  • l2geth: Fork of go-ethereum v1.9.10 implementing the OVM.
  • integration-tests: Integration tests between a L1 testnet, l2geth,
  • ops: Contains Dockerfiles for containerizing each service involved in the protocol, as well as a docker-compose file for bringing up local testnets easily

Quickstart

Installation

Dependency management is done using yarn.

git clone [email protected]:ethereum-optimism/optimism.git
cd optimism
yarn

After installing the dependencies, you must also build them so that the typescript is compiled down to javascript:

yarn build

When changing branches, be sure to clean the repo before building.

yarn clean

Unit tests

All tests are run in parallel using lerna:

yarn test

When you want to run tests only for packages that have changed since master (or any other branch) you can run yarn lerna run test --parallel --since master

Integration Tests

Running the integration tests

The integration tests first require bringing up the Optimism stack. This is done via a Docker Compose network. For better performance, we also recommend enabling Docker BuildKit

cd ops
export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1
docker-compose build
cd ../integration-tests
yarn build:integration
yarn test:integration

Locally testing and re-building specific services

If you want to make changes to any of the containers, you'll have to bring one down, rebuild it, and then bring it back up.

For example, if you make a change in l2geth:

cd ops
docker-compose stop -- l2geth
docker-compose build -- l2geth
docker-compose start l2geth

For the typescript services, you'll need to rebuild the builder so that the compiled files are re-generated, and then your service, e.g. for the batch submitter

cd ops
docker-compose stop -- batch_submitter
docker-compose build -- builder batch_submitter
docker-compose start batch_submitter

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>

Static analysis

To run slither locally in ./packages/contracts do

pip3 install slither-analyzer
yarn test:slither

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (15,124
ethereum (740
rollup (81