# rocket-pool/rocketpool architecture

> Architecture diagram of the GitHub repository rocket-pool/rocketpool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rocket-pool/rocketpool
- Repository: https://github.com/rocket-pool/rocketpool

## Overview

##### Project Type and Purpose
- This is a blockchain-focused project that implements a decentralized staking service on Ethereum 2.0.
- The core function is to allow users to deposit ETH, receive a tokenized staking deposit (rETH), and participate in earning rewards through a network of decentralized node operators.
- The smart contracts implement various operational domains (DAO, deposit, minipool for staking, auctions, tokens, etc.), while scripts and tests ensure the contract behavior and deployment integrity.

##### Analyzing the File Structure
- The “contracts” directory holds the main Solidity code for all aspects of the staking protocol. It is further subdivided by functionality:
- For example, there are separate directories for auction, casper, dao (with its node, protocol, and security submodules), deposit, minipool, network, node, rewards, and token.
- A corresponding “contracts/interface” directory exists that likely holds interface definitions or abstractions mirroring the main contract implementations.
- The existence of configuration files (hardhat.config.js, hardhat-fork.config.js, etc.) and deployment/deployment test scripts in “scripts” indicates a structured, automated deployment and testing pipeline.
- The “test” directory (with several subfolders) thoroughly covers unit tests and integration tests for each contract module and helper functions. This is critical to visualizing the testing and development lifecycle.

##### Instructing the Principal Software Engineer
– Start with User/External Interaction on the left.
- Then move into the details:
– Show submodules within the contracts (e.g., under DAO, differentiate between node management, protocol settings, security elements).
– Include a separate section for the deployment/testing infrastructure that interacts with these modules.
- Component with descriptive labels.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    subgraph "External Entities"
        U("User (Staker)"):::external
        NO("Node Operator"):::external
    end

    %% Smart Contracts Layer
    subgraph "Smart Contracts Layer"
        Auction("Auction Module (Impl)"):::contract
        Casper("Casper Module (Impl)"):::contract
        subgraph "DAO Module (Impl)"
            DAO_Main("DAO: Main"):::contract
            DAO_Node("DAO: Node Governance"):::contract
            DAO_Protocol("DAO: Protocol Management"):::contract
            DAO_Security("DAO: Security"):::contract
        end
        Deposit("Deposit Module (Impl)"):::contract
        Minipool("Minipool Module (Impl)"):::contract
        Network("Network Module (Impl)"):::contract
        Node("Node Module (Impl)"):::contract
        Rewards("Rewards Module (Impl)"):::contract
        Token("Token Module (Impl)"):::contract
    end

    %% Interfaces Layer
    subgraph "Interfaces Layer"
        Auction_Interface("Auction Interface"):::interface
        Casper_Interface("Casper Interface"):::interface
        DAO_Interface("DAO Interface"):::interface
        DAO_Node_Interface("DAO Node Interface"):::interface
        DAO_Protocol_Interface("DAO Protocol Interface"):::interface
        DAO_Security_Interface("DAO Security Interface"):::interface
        Deposit_Interface("Deposit Interface"):::interface
        Minipool_Interface("Minipool Interface"):::interface
        Network_Interface("Network Interface"):::interface
        Node_Interface("Node Interface"):::interface
        Rewards_Interface("Rewards Interface"):::interface
        Token_Interface("Token Interface"):::interface
    end

    %% Testing Infrastructure
    subgraph "Testing Infrastructure"
        Auction_Test("Auction Tests"):::infra
        Casper_Test("Casper Tests"):::infra
        DAO_Test("DAO Tests"):::infra
        Deposit_Test("Deposit Tests"):::infra
        Minipool_Test("Minipool Tests"):::infra
        Network_Test("Network Tests"):::infra
        Node_Test("Node Tests"):::infra
        Rewards_Test("Rewards Tests"):::infra
        Token_Test("Token Tests"):::infra
        Helpers("Test Helpers & Utils"):::infra
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        Deploy("Deployment Scripts & Configs"):::infra
    end

    Ethereum("Ethereum Network"):::external

    %% Relationships: User and Node Operator interactions with contracts
    U -->|"depositETH"| Deposit
    Deposit -->|"triggers"| DAO_Main
    Deposit -->|"joins"| Minipool
    Deposit -->|"allocates"| Rewards
    NO -->|"manages"| Node
    NO -->|"participates"| DAO_Node

    %% Smart Contract implementations implement Interfaces (dotted arrows)
    Auction -->|"implements"| Auction_Interface
    Casper -->|"implements"| Casper_Interface
    DAO_Main -->|"implements"| DAO_Interface
    DAO_Node -->|"implements"| DAO_Node_Interface
    DAO_Protocol -->|"implements"| DAO_Protocol_Interface
    DAO_Security -->|"implements"| DAO_Security_Interface
    Deposit -->|"implements"| Deposit_Interface
    Minipool -->|"implements"| Minipool_Interface
    Network -->|"implements"| Network_Interface
    Node -->|"implements"| Node_Interface
    Rewards -->|"implements"| Rewards_Interface
    Token -->|"implements"| Token_Interface

    %% Testing relationships: Tests validate Smart Contract modules
    Auction_Test -->|"tests"| Auction
    Casper_Test -->|"tests"| Casper
    DAO_Test -->|"tests"| DAO_Main
    Deposit_Test -->|"tests"| Deposit
    Minipool_Test -->|"tests"| Minipool
    Network_Test -->|"tests"| Network
    Node_Test -->|"tests"| Node
    Rewards_Test -->|"tests"| Rewards
    Token_Test -->|"tests"| Token
    Helpers -->|"assists"| Auction_Test
    Helpers -->|"assists"| Casper_Test
    Helpers -->|"assists"| DAO_Test
    Helpers -->|"assists"| Deposit_Test
    Helpers -->|"assists"| Minipool_Test
    Helpers -->|"assists"| Network_Test
    Helpers -->|"assists"| Node_Test
    Helpers -->|"assists"| Rewards_Test
    Helpers -->|"assists"| Token_Test

    %% Deployment: Deploy scripts deploy contracts and push to Ethereum Network
    Deploy -->|"deploys"| Auction
    Deploy -->|"deploys"| Casper
    Deploy -->|"deploys"| DAO_Main
    Deploy -->|"deploys"| Deposit
    Deploy -->|"deploys"| Minipool
    Deploy -->|"deploys"| Network
    Deploy -->|"deploys"| Node
    Deploy -->|"deploys"| Rewards
    Deploy -->|"deploys"| Token
    Deploy -->|"to"| Ethereum

    %% Styles
    classDef external fill:#bbf,stroke:#333,stroke-width:2px;
    classDef contract fill:#f9f,stroke:#333,stroke-width:2px;
    classDef interface fill:#dfd,stroke:#333,stroke-width:2px;
    classDef infra fill:#fdd,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping

    %% Auction Module
    click Auction "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/auction"
    click Auction_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/auction"
    click Auction_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/auction"

    %% Casper Module
    click Casper "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/casper"
    click Casper "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/casper/compiled"
    click Casper_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/casper"
    click Casper_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/casper"

    %% DAO Module
    click DAO_Main "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/dao"
    click DAO_Node "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/dao/node"
    click DAO_Node "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/dao/node/settings"
    click DAO_Protocol "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/dao/protocol"
    click DAO_Protocol "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/dao/protocol/settings"
    click DAO_Security "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/dao/security"
    click DAO_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/dao"
    click DAO_Node_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/dao/node"
    click DAO_Node_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/dao/node/settings"
    click DAO_Protocol_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/dao/protocol"
    click DAO_Protocol_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/dao/protocol/settings"
    click DAO_Security_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/dao/security"
    click DAO_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/dao"

    %% Deposit Module
    click Deposit "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/deposit"
    click Deposit_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/deposit"
    click Deposit_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/deposit"

    %% Minipool Module
    click Minipool "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/minipool"
    click Minipool_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/minipool"
    click Minipool_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/minipool"

    %% Network Module
    click Network "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/network"
    click Network_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/network"
    click Network_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/network"

    %% Node Module
    click Node "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/node"
    click Node_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/node"
    click Node_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/node"

    %% Rewards Module
    click Rewards "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/rewards"
    click Rewards_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/rewards"
    click Rewards_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/rewards/claims"
    click Rewards_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/rewards"

    %% Token Module
    click Token "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/token"
    click Token "https://github.com/rocket-pool/rocketpool/tree/master/contracts/contract/token/temp"
    click Token_Interface "https://github.com/rocket-pool/rocketpool/tree/master/contracts/interface/token"
    click Token_Test "https://github.com/rocket-pool/rocketpool/tree/master/test/token"

    %% Deployment & Verification Infrastructure
    click Deploy "https://github.com/rocket-pool/rocketpool/blob/master/scripts/deploy.js"
    click Deploy "https://github.com/rocket-pool/rocketpool/blob/master/scripts/etherscan-verify.js"
    click Deploy "https://github.com/rocket-pool/rocketpool/blob/master/hardhat.config.js"
    click Deploy "https://github.com/rocket-pool/rocketpool/blob/master/hardhat-fork.config.js"
    click Deploy "https://github.com/rocket-pool/rocketpool/blob/master/hardhat-common.config.js"

    %% Connect Ethereum Network (No click event needed as mapping not provided)
    %% End of diagram
```
