Alex Vlasov
    • 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
    # Block size and attestations Block size is one of the factors that limits scalability, since it should be send to multiple peers and block size directly affects network traffic and required bandwidth. There is a [spreadsheet](https://docs.google.com/spreadsheets/d/19ZGbIFaIi5quIvpB3Aa3VRgurKPBG9NMrJB7LGMBwXI/edit#gid=0) estimating an average block size in Ethereum 2.0 to be about 50K, and even smaller - 30K, when compressed. However, the calculations assume there will be 32 attestations in an average block (out of maximum 128 attestations), 2 (aggregated) attestation per committee on average (16 committee). We argue that the average number of attestations aggregates per committee can be significantly higher, in normal scenarios (no attack) - around 8 per committee and may be even higher. So that an average block size should be calculated based on 128 attestations in a block. And one should consider increasing the 128 limit to accommodate possible higher demand. However, attestations occupy the most part of an encoded block and growing number of attestations means the overall block size grows several times too. So, we propose ways to mitigate this and estimate reduction gains we can expect from either block re-structuring or compression techniques. The main idea is that an encoded block size should not be related to number of attestations in such a strong way (400-1300 bytes per attestation, 1.5x less expected when compressed). ### Attestation number evaluation The block's data structure allows each Attestation contain only one AttestationData (https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attestation). AttestationData simultaneously describes a vote for a beacon state and for a shard state. So, if attesters in a committee have two distinct views beacon-wise and two distinct views shard-wise, this can result in up to 4 distinct AttestationData. Distinct views among attesters can result from network delays, faults (even from non-byzantine ones, e.g. a transit node failed or delayed a message for some reason), etc. Given 3 seconds time to propagate a new block through p2p-graph to 300-1000 attesters (per committee), it's highly likely, that some of them will receive the block too late and will issue an attestation for a previous block. It also looks likely, that some will miss two last blocks or even more. For example, consider a case, when it's 2% chance for an attester to miss a current slot block and the 1% chance to miss the previous block. If for example we have 300 attesters then it's 6% chance to have at least one attester miss two blocks (1-(1-0.02\*0.01)^300 ~= 6%), that means we'll have three distinct views (new block, previous block, minus-2 block). This logic can be applied both to the beacon state and to the shard state. Combined, we should typically have 4 different AttestationData per committee and sometimes even more. Moreover, if an attestation (issued during some slot) has not been included in the next block, it can be included in a later one. That can happen for the same reasons (e.g. network delays, clock drift, etc). They will necessarily have distinct AttestationData, since slot number will be different. And it's possible that attestations from several preceding slots are to be included in the current one. That's why we are expecting an additional factor of 2 to accommodate for late attestations. So, we are expecting around 8 distinct AttestationData per committee and possibly even more. That means a typical block can have around 16\*8 = 128 attestations. And maybe it makes sense to increase the 128 limit to allow for a block to include lots of distinct AttestationData, if there happened some severe conditions leading to many delayed blocks and attestations. ### Partially aggregated attestations Currently, aggregated signature should have no more than 1 occurrence of an individual signature (a signature from a particular attester). This is because it's encoded with a bitfield (aggregation_bits in [Attestation class](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attestation)). However, if attestations are aggregated in a committee subnet in a random (unstructured) way (gossip-like protocols), then there will be many partial attestation aggregations with random bitfield assignments. That means, from some aggregation size (around sqrt(m), m is the committee size), the probability to get two partial aggregations with overlapping attester indices will be quite high (> 0.5). And it will be very difficult (and probably impractical) to get comlete or near complete bitfields. Because we cannot retract conflicting individual attestations from a signature, without knowing them. That means, one have to aggregate attestations in a structured way, e.g. organize aggregation tree/forests (e.g. like Handel [does](https://arxiv.org/abs/1906.05132)). While it seems to viable approach, we are loosing an alternative way, which is possibly easier to implement in the context of p2p-graph and BFT requirement (Handel ensures BFT, but requires all nodes to have mutual pairwise connections, which requires adaptation for the p2p case). An alternative way could be to store partially aggregated attestations of medium size (around 20-30% of full committee size), which means there should be several times more attestations to cover the committee. But it's hardly feasible with current Block structure. ### Block size re-estimation Block size calculation above ([spreadsheet](https://docs.google.com/spreadsheets/d/19ZGbIFaIi5quIvpB3Aa3VRgurKPBG9NMrJB7LGMBwXI/edit#gid=0)) assumes an average block contains 32 attestation, each taking 1320 bytes. In detail, AttestationData takes 200 bytes, signature -- 96 bytes, aggregation and custody bitfields -- 512 bytes each (assuming worst case with 4096 attesters). 32\*1320 = 42240 bytes (out of 47070 bytes of an average block size). Given 128 attestation, we'll have significantly bigger average block size 128\*1320 + 4830 = 173790 bytes. However, this is assuming maximum possible amount of attesters (4096). For 300 attesters, the block size will be around 52K, and for 1000 attesters - around 89K. ### Block compression Attestations consume most of encoded block data. However, it's caused by the block structure and thus can be mitigated via an appropriate compression or by adapting the block structure. The spreadsheet also mentions this > Most AttestationData is identical between multiple objects, attestation bitfield can be compressed if portion of bits filled not exactly 1/2, custody bitfield can be compressed as it must be a subset of attestation bitfield. #### Custody bitfield First, custody and aggregation bitfields are parts of Attestation structure. However, a custody bitfield is related to a committee, while an aggregation bitifield specifies attesters whose signatures are included in a particular aggregate attestation. So, custody bitfield is replicated 2-8 times (ignoring any form of compression). Instead, custody bitfield can be moved to BeaconBlockBody structure, as a list of custody bitfields per each committee (it can be concatenated to a single bitfield too). Thus, each committee's custody bitfield will appear only once in a block, instead of 2-8 times and will take 8K bytes in worst case (4096 attesters per slot). And for 300-1000 attesters per committee, it will be 600-2000 bytes (for 16 committees). Since custody bits are hardly predictable it doesn't seem reasonable to look for a way of compressing it any further. #### AttestationData AttestationData contains 2 (3) votes: one for a beacon state and one for a shard state. If we have 2-3 views beacon-wise and 2-3 views shard-wise, then we can have 4-9 distinct AttestationData variants in a worst case per committee. The AttestationData occupies a large portion of encoded block -- e.g. for 128 Attestations there will be 128 * 200 = 25.6K data. While they will have shared bits, corresponding to the appropriate votes versions. For example, if we have 2-4 distinct votes for the beacon state per each slot (attestions can attest blocks of several previous slots), let's assume we have 3-4 slots. So, overall there are 6-16 distinct beacon votes. With straightforward encoding, it's 128 * 112 bytes (Hash + 2 Checkpoints) = 14K. But if we maintain a list of different votes, it will be 6-16 * 112 = 1-2K plus 3-4 bits per attestation to reference it. It's a bit more difficult to compress Crosslink votes, since there will be several versions per shard/committee, e.g. 2-3 per committee means 32-48 total plus votes from previous slots versus 128 Crosslinks with a straightforward encoding. However, different Crosslink votes have common bits, e.g. shard, parent_root, data_root, etc. E.g. shard can be calculated, start_epoch and end_epoch can be stored in an incremental form, and parent_root/data_root can be versioned (i.e. keep a list of versions per committee and several bits per attestation to store an index in the list). E.g. instead of 128 * 88 = 11K we can store around 64 * (32+32) = 4K plus around 1-2 byte per attestation to keep references or epoch increments. So, overall we can reduce block size from 128 * 200 = 25K to something like 6-7K. #### Aggregation bitfield We could probably squeeze some bytes from aggregation bitfield compression. For example, for 128 attestation and 300 attesters per commitee we should store 128 * 300 bits with a straightforward encoding. If we store 2-3 bits referencing (slot specific) attestation version for each attester, then we can save some Kbytes. E.g. if we have 16 committees for the main slot, we can store 16 * 300 * 2-3 bits = 1200-1800 bytes vs 64 * 300 bits = 2400 bytes for a straightforward encoding (assuming 4 attestations per committee). Encoding for attestations from earlier slots can be less beneficiary. #### Generic compression algos It's possible that generic compression libraries (e.g. Snappy or so) typically used to reduce network traffic/storage will be able to exploit the redundancies mentioned above. However, it might be the case that they won't achieve good compression rates, since they are using fast and relatively weak compression algo/level. It should be verified in experiments, of course. My experience tells me that eliminating redundancy with such inexpensive way is a good starting point that facilitates better compression rate and/or higher compression speed (can use less intelligent but faster compression levels/libraries). ### Conclusion We are expecting that there will be significantly more than 32 attestation in an average block and 128 is more accurate estimation even for normal conditions (no attacks or severe network failures). Moreover, we think it will be beneficial to further increase block capacity to accommodate for potential severe conditions. And to allow more flexibility in protocol implementation (e.g. overlapping partial aggregations). While it will necessarily lead to significantly bigger blocks, a block structure re-organization and/or clever compression techniques can ensure that there is a limited impact of adding one more attestation to a block, around 100 bytes (96 for signature plus some bytes to store references).

    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