Skip to content

chynacho/optimism

Repository files navigation

Optimism

The Optimism Monorepo

TL;DR

This is the primary place where Optimism works on stuff related to Optimistic Ethereum.

Documentation

Extensive documentation is available here.

Community

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

Development Quick Start

Dependencies

You'll need the following:

Setup

Clone the repository, open it, and install nodejs packages with yarn:

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

Building the TypeScript packages

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.

Building the rest of the system

If you want to run an Optimistic Ethereum 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:

  • builder: used to build the TypeScript packages
  • l1_chain: simulated L1 chain using hardhat-evm as a backend
  • deployer: process that deploys L1 smart contracts to the L1 chain
  • dtl: service that indexes transaction data from the L1 chain
  • l2geth: L2 geth node running in Sequencer mode
  • verifier: L2 geth node running in Verifier mode
  • relayer: helper process that relays messages between L1 and L2
  • batch_submitter: service that submits batches of Sequencer transactions to the L1 chain
  • integration_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

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

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

Finally, if you're running into weird problems and nothing seems to be working, run:

cd optimism
yarn clean
yarn build
cd ops
docker-compose down -v
docker-compose build
docker-compose up

Viewing docker container logs

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>

Running tests

Before running tests: follow the above instructions to get everything built.

Running unit tests

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

Running integration tests

Follow above instructions for building the whole stack. Build and run the integration tests:

cd integration-tests
yarn build:integration
yarn test:integration

Additional Reference Material

Running contract static analysis

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

License

Code forked from go-ethereum under the name l2geth is licensed under the GNU GPLv3 in accordance with the original license.

All other files within this repository are licensed under the MIT License unless stated otherwise.

About

Optimism is Ethereum, scaled.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 74.7%
  • TypeScript 8.9%
  • Solidity 6.8%
  • C 4.3%
  • JavaScript 2.9%
  • Shell 0.7%
  • Other 1.7%