Cayman
    • 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
    • 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
    • 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 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
  • 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
    # [EIP-7495](https://eips.ethereum.org/EIPS/eip-7495) Notes for CL There are two groups of EIPs that affect the CL. - "CL owned" data structures - [EIP-7688](https://eips.ethereum.org/EIPS/eip-7688): Forward compatible consensus data structures - "EL owned" data structures - [EIP-6493](https://eips.ethereum.org/EIPS/eip-6493): SSZ Transaction Signature Scheme - [EIP-6404](https://eips.ethereum.org/EIPS/eip-6404): SSZ Transactions Root - [EIP-6466](https://eips.ethereum.org/EIPS/eip-6466): SSZ Receipts Root - [EIP-6465](https://eips.ethereum.org/EIPS/eip-6465): SSZ Withdrawals Root For supporting for CL datastructures (EIP-7688), the implementation burden is fairly low. There's no need to fully implement "full" StableContainer and "full" Variant support as specified, rather we only need to implement a subset of Variant. This simplified Variant has nearly identical functionality as Container, the only difference being a slightly modified hashTreeRoot. For supporting new EL datastructures, implementation burden is higher. "Full" support for StableContainer is required. ## Simplified StableContainer Explainer for EIP-7688 > Goal: explain the StableContainer EIP step-by-step with an emphasis on EIP-7688 EIP-7495 defines new`StableContainer` and `Variant` SSZ primitives. The primary mechanism for providing "stability" (stability of merkleization) is the use of an "active fields" bitvector. Fields that are in use are toggled on, and fields that are not in use are toggled off. A `StableContainer` is also defined with a maximum number of fields. As opposed to [EIP-6475 - OptionalType](https://eips.ethereum.org/EIPS/eip-6475), which wraps each type individually, `StableContainer` uses the "active fields" bitvector to manage whether its fields are Some or None. Merkleization is similar to `Container` taking into account the active fields. Fields are merkleized at the depth determined by the maximum number of fields. Inactive fields are merkleized as 0x0, and active fields are merkleized normally. Then, the active fields bitvector is "mixed in" to the root, similarly to how the length is mixed-in to an SSZ `List`. Small example: ```python class Example(StableContainer[4]): a: Optional<uint64> b: Optional<uint64> ``` merkleized as ``` * / \ * 0b11 + 0x0 / * / \ a b ``` Serialization is similar to `Container` taking into account the active fields. The active field bitvector is prepended. Then, the fields are serialized like a`Container`, with the exception that inactive fields are skipped over entirely. For the purposes of EIP-7688, what we've been calling a `StableContainer` is actually a `StableContainer` `Variant`. "Lets turn the BeaconState into a StableContainer Variant" `StableContainer` can be thought of an abstract data type that exists across forks. It is a template for merkleization. It is not meant to be used directly by the state transition, networking, etc. Rather, we will be operating on specific `Variant`s of `StableContainer`s. A `Variant` of a `StableContainer` is a specific subset of fields from the `StableContainer`. It forgoes stable serialization (across variants) in favor of serialization rules that make it compatible with normal `Container` serialization. Merkleization still includes the active fields bitvector. `Variant`s are useful for enhanced type safety and simpler (and slightly cheaper) serialization. For example, for EIP-7688, we define a `StableContainer` for the beacon state, lets call it `AbstractBeaconState`, which defines the beacon state shape across all forks, electra onwards. Then we define fork-specific `BeaconStateElectra` which only contains the fields relevant to that fork. This will be what we operate on in the spec and likely in our code. At each future fork that updates the beacon state fields, either adds or deprecates a field, `AbstractBeaconState` is updated with new fields, and a new `Variant` will be defined that only includes the relevant fields. Within the beacon node, `AbstractBeaconState` would solely be used as a merkleization template. All beacon state variants would use the layout described by `AbstractBeaconState` for merkleization. For example, `BeaconStateElectra` is merkleized as an `AbstractBeaconState`. <!-- `BeaconStateElectra` and other beacon state variants would be used --> --- This explanation only treats a subset of features of `StableContainer` and `Variant` tailored for EIP-7688. Specifically it ignores handling of optional fields in both `StableContainer` and `Variant`. ### Notes from Implementing 7688 in Lodestar #### StableContainer - Started with copy/pasting Container implementation - Optional fields are handled at the container level. Our SSZ library already has SSZ Optional [EIP-6475](https://eips.ethereum.org/EIPS/eip-6475) implemented. So, we can either make a new way to declare optionals in StableContainers or we can leverage existing Optional types. We decided to leverage existing Optional types as this makes the UX of creating StableContainers more straightforward. This looks like StableConainer "pulling out" the type from Optional<type> for any optional field. - Update variable-field offset calculation. We were previously "precomputing" variable-field offsets. This can't be done anymore, computing offsets requires the active-fields bitvector. - Update precomputed min and max serialized length calculation #### Variant - Starting with a simplified version of `Variant` as described above (ignoring potential field reordering during merkleization and also ignoring optional fields) - this subset of functionality will suffice for EIP-7688 - Started with copy/pasting Container implementation - simplified version has a static active fields bitvector, passed into the type constructor - in constructor, store the map of fields to the 'chunk index' of the field as determined by the active fields bitvector - update maxChunksCount to activeFields.length - update hashTreeRoot to mix-in active fields - update getRoots to intersperse zero hashes for inactive fields

    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