# Optimism Bedrock: Study Notes

By [bap2pecs](https://paragraph.com/@0xb2p) · 2023-01-30

---

_Disclaimer_: My goal is to learn the OP Bedrock protocol **quickly** so I can understand the code more easily to be able to plug in with my own DA layer to the OP stack. So I only read the things I think that can be helpful. The goal is not to understand every piece of the details.

Study Steps
-----------

1.  read [Introducing the OP Stack](https://optimism.mirror.xyz/fLk5UGjZDiXFuvQh6R_HscMQuuY9ABYNF7PI76-qJYs)
    
2.  watch the talks given by OP Labs’ [Karl Floersch](https://youtu.be/HiU-g8XHi5s) and [Kelvin Fichter](https://www.youtube.com/watch?v=jnVjhp41pcc) at Devcon 6
    
3.  read the following specs: [Introduction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/introduction.md), [Overview](https://github.com/ethereum-optimism/optimism/blob/develop/specs/overview.md), [Deposits](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md), [Rollup Node](https://github.com/ethereum-optimism/optimism/blob/develop/specs/rollup-node.md), [Batch Submitter](https://github.com/ethereum-optimism/optimism/blob/develop/specs/batcher.md), [System Config](https://github.com/ethereum-optimism/optimism/blob/develop/specs/system_config.md), [L2 Chain Derivation](https://github.com/ethereum-optimism/optimism/blob/develop/specs/derivation.md)(\*)
    

\*: for the [derivation](https://github.com/ethereum-optimism/optimism/blob/develop/specs/derivation.md) spec, I started to skip lots of the details from section [Batch Queue](https://github.com/ethereum-optimism/optimism/blob/develop/specs/derivation.md#batch-queue)

It should take ~2-3 days to study everything on this list.

High-level
----------

*   The OP stack is modular and minimal. It’s easy to swap with your own e.g. consensus, DA layers. The _Superchain_ vision is able to scale horizontally.
    
*   Example: Metis forked OP and customized the DA layer with a DA committee
    
*   The 3 primary layers
    
    *   Consensus
        
        *   DA: an array of byte strings. not necessary a ledger
            
        *   Derivation: takes the DA layer and the current state of the rollup and produces Engine API payloads
            
    *   Execution: state transition
        
    *   Settlement: a view that another chain has over your chain
        

Key Interactions
----------------

![Deposit](https://storage.googleapis.com/papyrus_images/4844b9d3543b947256f692c989d867adb4eedd41f767717f54160e56cf61b1fd.png)

Deposit

![Withdraw](https://storage.googleapis.com/papyrus_images/2dcb4980d3729a43d74dda0c62710c537b87dea7d6e49853000be44aacb3da1b.png)

Withdraw

Note: step 4 is related to the concept of [finalized L2 head](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#finalized-l2-head).

Overview
--------

![Components](https://storage.googleapis.com/papyrus_images/e7610ff761d0be2edcc06d48c7a58cdfda228b2393add281a6132cd331c7e1d4.png)

Components

The `L2OutputOracle` is a L1 contract to store rollup states (i.e. [L2 output roots](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#l2-output-root)) and manage withdrawals. It will be helpful to think of it as the _rollup output_ store and `DepositFeed` and `BatchInbox` as the _rollup input_ store. So the L1 is simply the DA layer for storing rollup inputs and outputs, and the L2 is the computing layer.

`DepositFeed` is for a special transaction type (i.e. [Deposited Transaction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#deposited-transaction)) on L2 defined by the Optimism protocol. `BatchInbox` is for the other normal L2 transactions (i.e. only transaction inputs) that are batch-submitted to L1.

It’s also useful to know that the `BatchInbox` is a regular EOA address (note: for saving gas cost by not executing any EVM code). The sequencer submits L2 transaction batches included in the _calldata_ of the L1 transaction to the address.

Key Concepts
------------

*   [Block Derivation](https://github.com/ethereum-optimism/optimism/blob/develop/specs/overview.md#block-derivation)
    
*   [Epochs and the Sequencing Window](https://github.com/ethereum-optimism/optimism/blob/develop/specs/overview.md#epochs-and-the-sequencing-window)
    
*   [Deposited Transactions](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md): This is a new transaction type on L2 defined by the protocol.
    
    *   It’s important to understand that when tokens are deposited from L1 to L2, it’s technically “depositing the transactions to the L2“. The tokens are locked on L1 and then minted on L2.
        
    *   deposited transactions do not need a signature and rely on [other mechanisms](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#validation-and-authorization-of-deposited-transactions) for authorization and validation
        
    *   [L1 attributes deposited transaction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-deposited-transaction) and [user-deposited transactions](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#user-deposited-transactions)
        
    *   [L1 Attributes Depositor Account](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-depositor-account): an EOA with unknown private key.
        
    *   [L1 Attributes Predeployed Contract](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-predeployed-contract): it’s important to know that the contract will be called in the first transaction of every L2 block ([source](https://github.com/ethereum-optimism/optimism/pull/4779)). Every L2 block has an [L1 attributes tx](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#l1-attributes-deposited-transaction).
        
    *   [Address Aliasing](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#address-aliasing)
        
*   [Batch Submission](https://github.com/ethereum-optimism/optimism/blob/develop/specs/derivation.md#batch-submission)
    
    *   [Data Availability Provider](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#data-availability-provider) (e.g. Ethereum calldata)
        
    *   [Sequencer Batch](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#sequencer-batch): each batch represents the inputs needed to build one L2 block
        
    *   [Batcher Transaction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#batcher-transaction): a transaction submitted by a [batcher](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#batcher) to a data availability provider
        
    *   [Channel](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#channel) and [Channel Frame](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#channel-frame)
        
    *   The diagram below illustrates these concepts as a whole
        

![](https://storage.googleapis.com/papyrus_images/9d07a521a6980428e54311ae50b2fdb16ba150564019082d32a459cf35468cb8.png)

*   [L2 Chain Derivation](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#l2-chain-derivation)
    
    *   [L2 Derivation Inputs](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#l2-derivation-inputs)
        
    *   [System Config](https://github.com/ethereum-optimism/optimism/blob/develop/specs/system_config.md): `batcherHash` stores the current authorized batcher sender(s)
        
    *   [Payload Attributes](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#payload-attributes): object to be passed to the execution engine
        
    *   [L2 Chain Inception](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#l2-chain-inception): the L1 block number where the L2 genesis starts
        
    *   [Finalized L2 Head](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#finalized-l2-head), [Safe L2 Head](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#safe-l2-head), [Unsafe L2 Head](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#unsafe-l2-block), [Unsafe Block Consolidation](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#unsafe-block-consolidation)
        
        *   it’s important to distinguish the difference of finalizing the L2 head with the concept of [finalization period](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#finalization-period). The former form of finalization only affects inputs while the later affects Optimistic-rollup outputs.
            
*   [Fork Choice Rule](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#fork-choice-rule): to determine the blockchain head
    
*   [Time Slot](https://github.com/ethereum-optimism/optimism/blob/develop/specs/glossary.md#time-slot): every 2 second per L2 block

---

*Originally published on [bap2pecs](https://paragraph.com/@0xb2p/optimism-bedrock-study-notes)*
