Robert Habermeier
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # NOMT ## Scaling Blockchains with a High Throughput State Database --- NOMT is a state database, a critical component of a blockchain node. - High Throughput Commits - Low latency lookups - Optimized for **merklized state** - Optimized for modern Solid State Drives (SSDs) - Full-block state proofs --- NOMT is designed to be a drag-and-drop replacement for RocksDB, MDBX, LMDB, etc And to encapsulate all the Merkle Trie logic within it. --- Inspired by this blog post. <img src="https://hackmd.io/_uploads/HygqiZNsWJg.png" style="width: 60%; height=auto"> <small>and funded with a grant from Sovereign Labs (targeted first user)</small> --- Scan for GitHub <img src="https://hackmd.io/_uploads/ryAJf7ibke.png" style="width: 33%; height=auto"> or navigate to https://github.com/thrumdev/nomt --- Built with care by <img src="https://hackmd.io/_uploads/r1Hhm7iW1g.png" style="width: 20%; height=auto"> <img src="https://hackmd.io/_uploads/rkk5X7sWke.png" style="width: 20%; height=auto"> <img src="https://hackmd.io/_uploads/S1D6mQiZyx.png" style="width: 20%; height=auto"> <small>three Rust systems programmers from the Polkadot sphere</small> --- ## Why? * Large State = many users = bigger network effects * Large State = more complex apps = more value-add * Every 10k TPS of throughput gives space for ~100M DAU. * SSDs are getting better fast * Trend of industry to scale with RAM is misguided long-term * it's cool --- ## TL;DW * Support billions of accounts on a 4TB SSD * Targeting 25k worst-case TPS for V1 * Potential for cheap scaling with multiple SSDs and SSD improvements * Fully authenticated, ready for interoperability --- ## State Database? Every node needs to store state: token balances, contract code, prices, etc. Nodes keep this state in an embedded database on their disk. --- <img src="https://hackmd.io/_uploads/Bk6t87sZke.png" style="width: 60%; height=auto"> Authenticated State Trees --- ### Authenticated State Trees - Encode the entire state of the blockchain - With a super light commitment (the "root") - That can be used to prove the value of any item in the state **Incredibly important for interoperability, light clients, bridging, coprocessors, etc.** --- NOMT uses a Binary Merkle Trie ![image](https://hackmd.io/_uploads/rJexnlEo-1g.png) --- Let's talk about SSDs --- Typical high-end SSD specs (Q4 2024): - 4TB capacity - 40 microsecond latency - 1M IOPS (I/Os per Second) --- ![image](https://hackmd.io/_uploads/SkImNVsb1l.png) Latency: time to serve a single request. <small>increases as more requests are queued</small> --- ![image](https://hackmd.io/_uploads/Bk-1SVoZyx.png) Throughput: number of requests per second. <small>note that average latency at 1M IOPS is 1 microsecond!</small> --- ## What's an I/O? A 4 KB (single **page**) read or write operation on the disk. <small>SSDs only work in data of exactly one page.</small> --- ## SSDs are advancing rapidly ![image alt](https://hackmd.io/_uploads/S1RzY1n-yx.png =500x500) --- ## SSDs are advancing rapidly | | Crucial T705 | Samsung 980 | | -------- | -------- | -------- | | Release Date | Feb. 2024 | Sep. 2020 | | IOPS | 1.5M | 1M | | Price at Launch| $689 | $430 | | Price (Nov. 2024)| $564 | $199 | Capacity | 4TB | 2TB --- ## SSDs are advancing rapidly ![image](https://hackmd.io/_uploads/S1nSik2Wyg.png) <small>source: Tom's Hardware</small> --- ![for_exceptional_user](https://hackmd.io/_uploads/By-zEm2Zyx.png) --- ## Why not just add more RAM? - A SuperMicro 12TB motherboard + 12TB of compatible RAM would cost over $40k (for DDR4, not DDR5 RAM) - A 4TB RAM configuration would cost $5k USD - 3 4TB SSDs would cost $1500. - SSD reads can be _faster_ than RAM copies due to Direct Memory Access - PCI is getting _crazy fast_ --- ![for_esteemed_broski](https://hackmd.io/_uploads/H1ChCynb1e.png) --- ## The SSD caveat: Parallelism - You need a parallel VM to take advantage of SSD IOPS. - Theoretical max sequential throughput at 40us latency is only ~6K TPS --- ![image](https://hackmd.io/_uploads/S1127en-1e.png) --- # Back To NOMT --- ## NOMT Architecture <img src="https://hackmd.io/_uploads/H1noBg2W1x.png" style="width: 90%; height=auto"> --- ## Bitbox: Merkle Node Storage 🥁 <img src="https://www.rob.tech/assets/images/merklization_diagrams/page_1.svg" style="width: 80%; height=auto"> <small>Just like this, except each page is 4KB and stores 6 layers</small> <small>This is known as a "proto-VEB layout"</small> <small>Pages stored in an on-disk Hash-Table with a WAL</small> <small>Top 4 levels of the page tree are kept in memory</small> --- ## Beatree: Key-Value Store 🪘 ![image](https://hackmd.io/_uploads/r1vnKM3-kl.png) <small>Branches use bitwise prefix compression and separators</small> <small>Optimized for high-entropy, short keys</small> <small>Typical Branching factor of 375</small> <small>~200MB memory per billion items</small> --- ## Engineering Decisions - Targets Linux as first-class (needed for io-uring) - Targets generic Unix/macOS as functional (for development) - Direct I/O for max IOPS - Single-state DB, stores only finalized state. Unfinalized state must live in-memory. - Rust 🦀 --- ## Space Usage - 1 billion items estimated at 150GB on-disk - Large occasional jumps in space usage in bitbox every time the number of items increases by ~64. - We are working to make this _gradual_ - Aiming to support tens of billions of items per 4TB of storage. --- ## Theoretical Performance Example <small> Assume 10 billion accounts and simple transactions (2 random read-writes). Reads: 3 (1 beatree, 2 merkle) Writes: 5 (2 beatree, 3 merkle) Total I/O per TX: 16 At 1M IOPS: 62kTPS At 500k IOPS: 31.5kTPS </small> --- Our performance goal for NOMT V1 (EOY 2024) is 25kTPS with 1 billion accounts. <br> <small>Current benchmarks on 128M accounts at ~40kTPS</small> <small>side note: we assume random worst-case access</small> --- ## Node Requirements - RAM/Disk size scale with DB size. 4GB RAM and 256GB SSD for 1B items. - Disk: >500k IOPS - CPU: 8 cores --- ## Thank You <img src="https://hackmd.io/_uploads/ryAJf7ibke.png" style="width: 40%; height=auto"> https://github.com/thrumdev/nomt --- ## (Appendix: New Bottlenecks) --- ## Bottleneck: Bandwidth Scenario: Prove 300k state reads against a database of 1B items. <small>this is 25kTPS * 6 seconds</small> Proof size is <span style="color: red">120MB</span>, requiring 160Mbps of bandwidth. <small>Note that Polkadot PoVs are only 5MB!</small> --- ## Bottleneck: Bandwidth ![image](https://hackmd.io/_uploads/ryKUlQhWkg.png) <small>Possible solution: use succinct proving techniques to "compress" state proofs. Likely needs GPU acceleration.</small> --- ## Bottleneck: Signature Verification * Ed25519 signature verification is 26us or 11.5us when batched. * Secp256k1 verification is 70us Solution: have dedicated CPU cores or GPU acceleration for signature verification

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully