GithubHelp home page GithubHelp logo

skyh24 / optimism Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ethereum-optimism/optimism

0.0 0.0 0.0 24.13 MB

Monorepo implementing the Optimistic Ethereum protocol

Home Page: https://optimism.io

License: MIT License

TypeScript 9.55% JavaScript 3.67% Solidity 4.36% Shell 0.22% Makefile 0.11% Go 75.03% NSIS 0.19% Ruby 0.01% Python 0.07% HTML 0.09% Assembly 0.51% C 5.45% M4 0.21% Sage 0.24% Java 0.25% Dockerfile 0.01% Lua 0.02%

optimism's Introduction

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

Contributing

Read through CONTRIBUTING.md for a general overview of our contribution process. Follow the Development Quick Start to set up your local development environment.

Good First Issues

You can find good first issues by filtering for the "good first issue" tag on our issues page or alternatively by taking a look at our Good First Issues project board. If you'd like to tackle one of these issues, please leave a comment and assign yourself to the issue. This helps prevent two people accidentally working on the same task at the same time.

Changesets

We use changesets to manage releases of our various packages. You must include a changeset file in your PR when making a change that would require a new package release.

Adding a changeset file is easy:

  1. Navigate to the root of the monorepo.
  2. Run yarn changeset. You'll be prompted to select packages to include in the changeset. Use the arrow keys to move the cursor up and down, hit the spacebar to select a package, and hit enter to confirm your selection. Select all packages that require a new release as a result of your PR.
  3. Once you hit enter you'll be prompted to decide whether your selected packages need a major, minor, or patch release. We follow the Semantic Versioning scheme. Please avoid using major releases for any packages that are still in version 0.y.z.
  4. Commit your changeset and push it into your PR. The changeset bot will notice your changeset file and leave a little comment to this effect on GitHub.
  5. Voilà, c'est fini!

Rebasing

We use the git rebase command to keep our commit history tidy. Rebasing is an easy way to make sure that each PR includes a series of clean commits with descriptive commit messages See this tutorial for a detailed explanation of git rebase and how you should use it to maintain a clean commit history.

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

Branching Model and Releases

Active Branches

Branch Status
master Accepts PRs from develop when we intend to deploy to mainnet.
develop Accepts PRs that are compatible with master OR from regenesis/X.X.X branches.
regenesis/X.X.X Accepts PRs for all changes, particularly those not backwards compatible with develop and master.

Overview

We generally follow this Git branching model. Please read the linked post if you're planning to make frequent PRs into this repository (e.g., people working at/with Optimism).

The master branch

The master branch contains the code for our latest "stable" releases. Updates from master always come from the develop branch. We only ever update the master branch when we intend to deploy code within the develop to the Optimistic Ethereum mainnet. Our update process takes the form of a PR merging the develop branch into the master branch.

The develop branch

Our primary development branch is develop. develop contains the most up-to-date software that remains backwards compatible with our latest experimental network deployments. If you're making a backwards compatible change, please direct your pull request towards develop.

Changes to contracts within packages/contracts/contracts/optimistic-ethereum are usually NOT considered backwards compatible and SHOULD be made against a release candidate branch. Some exceptions to this rule exist for cases in which we absolutely must deploy some new contract after a release candidate branch has already been fully deployed. If you're changing or adding a contract and you're unsure about which branch to make a PR into, default to using the latest release candidate branch. See below for info about release candidate branches.

Release new versions

Developers can release new versions of the software by adding changesets to their pull requests using yarn changeset. Changesets will persist over time on the develop branch without triggering new version bumps to be proposed by the Changesets bot. Once changesets are merged into master, the bot will create a new pull request called "Version Packages" which bumps the versions of packages. The correct flow for triggering releases is to re-base these pull requests onto develop and merge them, and then create a new pull request to merge develop onto master. Then, the release workflow will trigger the actual publishing to npm and Docker hub.

Release candidate branches

Branches marked regenesis/X.X.X are release candidate branches. Changes that are not backwards compatible and all changes to contracts within packages/contracts/contracts/optimistic-ethereum MUST be directed towards a release candidate branch. Release candidates are merged into develop and then into master once they've been fully deployed. We may sometimes have more than one active regenesis/X.X.X branch if we're in the middle of a deployment. See table in the Active Branches section above to find the right branch to target.

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.

optimism's People

Contributors

tynes avatar smartcontracts avatar snario avatar karlfloersch avatar gakonst avatar ben-chain avatar maurelian avatar github-actions[bot] avatar annieke avatar elenadimitrova avatar k-ho avatar axchu avatar optimisticben avatar gigamesh avatar dependabot[bot] avatar platocrat avatar rajivpo avatar transmissions11 avatar tonysosa-dev avatar timmyers avatar cleanunicorn avatar reggieag avatar vcshih avatar shingonu avatar vaibhavchellani avatar petejkim avatar miguelmota avatar dominator008 avatar krebernisak avatar krzkaczor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.