Convert Figma logo to code with AI

ethereum-optimism logooptimism

Optimism is Ethereum, scaled.

5,531
3,174
5,531
292

Top Related Projects

Go implementation of the Ethereum protocol

Substrate: The platform for blockchain innovators

Reference client for NEAR Protocol

:chains: A Framework for Building High Value Public Blockchains :sparkles:

12,919

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.

Quick Overview

Optimism is a Layer 2 scaling solution for Ethereum that aims to improve transaction speed and reduce costs while maintaining Ethereum's security. It uses optimistic rollups to bundle multiple transactions off-chain and then submit them as a single transaction on the Ethereum mainnet.

Pros

  • Significantly reduces gas fees and increases transaction throughput
  • Maintains compatibility with existing Ethereum tools and smart contracts
  • Inherits Ethereum's security model, providing a high level of safety
  • Open-source project with active development and community support

Cons

  • Withdrawals from Optimism to Ethereum mainnet can take up to 7 days
  • Still relies on Ethereum for final settlement, which can be a bottleneck
  • Less decentralized than the Ethereum mainnet
  • Relatively new technology, which may have undiscovered vulnerabilities

Getting Started

To interact with Optimism, you'll need to:

  1. Set up an Ethereum wallet (e.g., MetaMask)
  2. Add the Optimism network to your wallet:
  3. Bridge ETH or tokens from Ethereum mainnet to Optimism using the official Optimism Gateway (https://gateway.optimism.io/)
  4. Interact with Optimism-compatible dApps or deploy your own smart contracts on the Optimism network

For developers looking to build on Optimism:

  1. Install the Optimism SDK:
    npm install @eth-optimism/sdk
    
  2. Set up a development environment with Hardhat or Truffle
  3. Configure your project to use Optimism's RPC endpoint
  4. Deploy and test your smart contracts on the Optimism network

For more detailed instructions and documentation, visit the official Optimism documentation at https://community.optimism.io/docs/.

Competitor Comparisons

Go implementation of the Ethereum protocol

Pros of go-ethereum

  • Mature and widely adopted implementation of Ethereum protocol
  • Extensive documentation and community support
  • Highly optimized for performance and efficiency

Cons of go-ethereum

  • Larger codebase, potentially more complex for new contributors
  • Slower to implement new features due to rigorous testing requirements
  • Higher resource requirements for running a full node

Code Comparison

go-ethereum (consensus/ethash/consensus.go):

func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header, uncle bool, seal bool, time uint64) error {
    // Ensure that the header's extra-data section is of a reasonable size
    if uint64(len(header.Extra)) > params.MaximumExtraDataSize {
        return fmt.Errorf("extra-data too long: %d > %d", len(header.Extra), params.MaximumExtraDataSize)
    }
    // ...
}

optimism (op-node/rollup/derive/l1_block_info.go):

func L1InfoDepositTxData(info *L1BlockInfo) ([]byte, error) {
    var buf bytes.Buffer
    if err := info.MarshalBinary(&buf); err != nil {
        return nil, fmt.Errorf("cannot encode L1 block info: %w", err)
    }
    return buf.Bytes(), nil
}

The code snippets show different aspects of each project: go-ethereum focuses on consensus and header verification, while optimism deals with L1 block info processing for the Layer 2 solution.

Substrate: The platform for blockchain innovators

Pros of Substrate

  • More flexible and customizable blockchain framework
  • Supports multiple consensus mechanisms (PoW, PoS, etc.)
  • Designed for easy creation of application-specific blockchains

Cons of Substrate

  • Steeper learning curve due to its complexity
  • Smaller ecosystem compared to Ethereum-based solutions
  • Requires more resources to develop and maintain a custom blockchain

Code Comparison

Optimism (Solidity):

contract SimpleStorage {
    uint256 public storedData;
    function set(uint256 x) public {
        storedData = x;
    }
}

Substrate (Rust):

#[pallet::storage]
#[pallet::getter(fn stored_data)]
pub type StoredData<T> = StorageValue<_, u32>;

#[pallet::call]
impl<T: Config> Pallet<T> {
    #[pallet::weight(10_000)]
    pub fn set(origin: OriginFor<T>, data: u32) -> DispatchResult {
        ensure_signed(origin)?;
        <StoredData<T>>::put(data);
        Ok(())
    }
}

The code comparison shows that Substrate uses Rust and requires more boilerplate code, while Optimism uses Solidity and is more concise. Substrate offers more low-level control, but Optimism provides a familiar environment for Ethereum developers.

Reference client for NEAR Protocol

Pros of nearcore

  • Higher throughput and lower transaction fees than Optimism
  • Simpler sharding implementation for scalability
  • More flexible smart contract development with Rust support

Cons of nearcore

  • Less Ethereum-compatible than Optimism
  • Smaller developer ecosystem compared to Ethereum-based solutions
  • Potentially more complex for users familiar with Ethereum

Code comparison

nearcore (Rust):

pub fn process_block(
    &mut self,
    block: &Block,
    provenance: Provenance,
) -> Result<Option<BlockProcessingArtifact>, Error> {
    // Block processing logic
}

Optimism (Go):

func (b *BlockChain) ProcessBlock(block *types.Block) error {
    // Block processing logic
}

Both projects implement block processing functions, but nearcore uses Rust while Optimism uses Go. nearcore's implementation appears more detailed with additional parameters and return types, reflecting its unique architecture.

:chains: A Framework for Building High Value Public Blockchains :sparkles:

Pros of Cosmos SDK

  • Modular architecture allows for easy customization and extension of blockchain functionality
  • Supports creation of sovereign, interconnected blockchains (zones) within the Cosmos ecosystem
  • Implements Tendermint consensus, providing fast finality and high throughput

Cons of Cosmos SDK

  • Steeper learning curve due to its complex architecture and custom programming model
  • Limited compatibility with Ethereum's ecosystem and smart contracts
  • Requires developers to build and maintain their own validator networks

Code Comparison

Cosmos SDK (Go):

func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
    var genesisState GenesisState
    if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
        panic(err)
    }
    return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Optimism (TypeScript):

export const initializeL2Provider = async (
  l2ChainId: number,
  l2Url: string
): Promise<providers.JsonRpcProvider> => {
  const l2Provider = new providers.JsonRpcProvider(l2Url)
  const network = await l2Provider.getNetwork()
  if (network.chainId !== l2ChainId) {
    throw new Error(`Invalid L2 chain ID: ${network.chainId}`)
  }
  return l2Provider
}
12,919

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.

Pros of Solana

  • Higher transaction throughput and lower fees
  • Faster block times and finality
  • More scalable architecture using Proof of History

Cons of Solana

  • Less decentralized with higher hardware requirements
  • Newer, less battle-tested ecosystem
  • More complex programming model

Code Comparison

Optimism (Solidity):

contract SimpleStorage {
    uint256 private storedData;

    function set(uint256 x) public {
        storedData = x;
    }

    function get() public view returns (uint256) {
        return storedData;
    }
}

Solana (Rust):

use solana_program::{
    account_info::AccountInfo,
    entrypoint,
    entrypoint::ProgramResult,
    pubkey::Pubkey,
    msg,
};

entrypoint!(process_instruction);

pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    msg!("Hello, Solana!");
    Ok(())
}

The code examples highlight the different programming languages and paradigms used in each project. Optimism uses Solidity, which is similar to Ethereum's smart contract language, while Solana uses Rust for its programs. Solana's programming model is more low-level and requires more boilerplate code for basic functionality.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README



Optimism

Optimism is Ethereum, scaled.


Table of Contents

What is Optimism?

Optimism is a project dedicated to scaling Ethereum's technology and expanding its ability to coordinate people from across the world to build effective decentralized economies and governance systems. The Optimism Collective builds open-source software that powers scalable blockchains and aims to address key governance and economic challenges in the wider Ethereum ecosystem. Optimism operates on the principle of impact=profit, the idea that individuals who positively impact the Collective should be proportionally rewarded with profit. Change the incentives and you change the world.

In this repository you'll find numerous core components of the OP Stack, the decentralized software stack maintained by the Optimism Collective that powers Optimism and forms the backbone of blockchains like OP Mainnet and Base. The OP Stack is designed to be aggressively open-source — you are welcome to explore, modify, and extend this code.

Documentation

Specification

Detailed specifications for the OP Stack can be found within the OP Stack Specs repository.

Community

General discussion happens most frequently on the Optimism discord. Governance discussion can also be found on the Optimism Governance Forum.

Contributing

The OP Stack is a collaborative project. By collaborating on free, open software and shared standards, the Optimism Collective aims to prevent siloed software development and rapidly accelerate the development of the Ethereum ecosystem. Come contribute, build the future, and redefine power, together.

CONTRIBUTING.md contains a detailed explanation of the contributing process for this repository. Make sure to use the Developer Quick Start to properly set up your development environment.

Good First Issues are a great place to look for tasks to tackle if you're not sure where to start.

Security Policy and Vulnerability Reporting

Please refer to the canonical Security Policy document for detailed information about how to report vulnerabilities in this codebase. Bounty hunters are encouraged to check out the Optimism Immunefi bug bounty program. The Optimism Immunefi program offers up to $2,000,042 for in-scope critical vulnerabilities.

Directory Structure

├── docs: A collection of documents including audits and post-mortems
├── op-batcher: L2-Batch Submitter, submits bundles of batches to L1
├── op-bootnode: Standalone op-node discovery bootnode
├── op-chain-ops: State surgery utilities
├── op-challenger: Dispute game challenge agent
├── op-e2e: End-to-End testing of all bedrock components in Go
├── op-node: rollup consensus-layer client
├── op-preimage: Go bindings for Preimage Oracle
├── op-program: Fault proof program
├── op-proposer: L2-Output Submitter, submits proposals to L1
├── op-service: Common codebase utilities
├── op-ufm: Simulations for monitoring end-to-end transaction latency
├── op-wheel: Database utilities
├── ops: Various operational packages
├── ops-bedrock: Bedrock devnet work
├── packages
│   ├── contracts-bedrock: OP Stack smart contracts
├── proxyd: Configurable RPC request router and proxy
├── specs: Specs of the rollup starting at the Bedrock upgrade

Development and Release Process

Overview

Please read this section carefully if you're planning to fork or make frequent PRs into this repository.

Production Releases

Production releases are always tags, versioned as <component-name>/v<semver>. For example, an op-node release might be versioned as op-node/v1.1.2, and smart contract releases might be versioned as op-contracts/v1.0.0. Release candidates are versioned in the format op-node/v1.1.2-rc.1. We always start with rc.1 rather than rc.

For contract releases, refer to the GitHub release notes for a given release which will list the specific contracts being released. Not all contracts are considered production ready within a release and many are under active development.

Tags of the form v<semver>, such as v1.1.4, indicate releases of all Go code only, and DO NOT include smart contracts. This naming scheme is required by Golang. In the above list, this means these v<semver releases contain all op-* components and exclude all contracts-* components.

op-geth embeds upstream geth’s version inside its own version as follows: vMAJOR.GETH_MAJOR GETH_MINOR GETH_PATCH.PATCH. Basically, geth’s version is our minor version. For example if geth is at v1.12.0, the corresponding op-geth version would be v1.101200.0. Note that we pad out to three characters for the geth minor version and two characters for the geth patch version. Since we cannot left-pad with zeroes, the geth major version is not padded.

See the Node Software Releases page of the documentation for more information about releases for the latest node components.

The full set of components that have releases are:

  • ci-builder
  • op-batcher
  • op-contracts
  • op-challenger
  • op-node
  • op-proposer

All other components and packages should be considered development components only and do not have releases.

Development branch

The primary development branch is develop. develop contains the most up-to-date software that remains backwards compatible with the 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-bedrock/src are usually NOT considered backwards compatible. Some exceptions to this rule exist for cases in which we absolutely must deploy some new contract after a tag 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 a feature branch. Feature branches are typically used when there are conflicts between 2 projects touching the same code, to avoid conflicts from merging both into develop.

License

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