HackMD
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • 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
    • More (Comment, Invitee)
    • Publishing
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions and GitHub Sync
    • Transfer ownership
    • Delete this note
    • Template
    • Save as template
    • Insert from template
    • Export
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Sharing Help
Menu
Options
Versions and GitHub Sync Transfer ownership Delete this note
Export
Google Drive Export to Google Drive Gist
Import
Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
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
More (Comment, Invitee)
Publishing
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with GitHub
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Ethereum State Availability ## Base Concepts and Terminology ### Skip Graphs https://en.wikipedia.org/wiki/Skip_graph The skip graph is a distributed data structure that can be used to provide a mechanism in a DHT network for managing total ordering of a set of keys. The nodes in the graph are distributed around the network among the participating nodes, and traversal of the graph operates under similar paradigms as a binary search, allowing network participants to find the nodes adjacent to a specific key very quickly. ### Trie Tiling The rough concept is to divide the leaves of a trie into contiguous chunks. These chunks are referred to as "tiles". I refer to the concept of "naive" tiling to mean a tiling scheme under which you can determine which tile a specific piece of data from the trie should be located in without having the full trie available. For example, we could tile the current Hexary Patricia Trie into 16 very large tiles simply by stopping at the first nibble. This would give 16 tiles. The first tile's key would be every leaf who's key begins with `0x0`, the 11th tile would contain all leaves who's keys begin with `0xa`. Other non-naive tiling schemes might be something like each tile containing a fixed number of accounts. Such a scheme would require you to iterate through the trie from a common starting location, placing each contiguous set of `N` accounts into each tile. This simple approach is problematic because the insertion of a new account into a tile located that the start of the trie would result in all subsequent tiles needing to be updated. The difficulty with tiling is determining a scheme that reduces the number of tiles that need to be updated with each successive block, while still bundling the leaves into manageable chunks. It is also possible that we don't need an fully agreed upon scheme to still take advantage of tiling. ### Tiling + Skip Graphs Assuming you have a tiling scheme that works, but potentially isn't "naive", you need a mechanism for traversing the keyspace for each tile to find the tile that contains the data you wish to retrieve. Each tile would have a key `K`. A simple scheme would be for `K` to be the deepest path into the trie which contains all of the accounts for a given tile. In order to find specific leaf data, we need to know what tile it is contained in. A skip graph of the tile keys allows fast traversal of the tile keyspace to find the tile key which will contain the desired account. ## Accounts vs Contract Storage vs Code Dealing with the Ethereum "state" means accounting for the following three things. - Accounts - `balance` - `nonce` - `code_hash` - `state_root` - Code - The actual bytecode referenced by `Account.code_hash` - Contract Storage - The actual trie data referenced by `Account.state_root` Historically, attempts to build a cohesive mechanism to handle all of these has not yielded results. The first piece of intuition that I've formed is that the correct solution might deal with each of these via separate mechanisms. ### Accounts The account trie is naturally balanced. This property makes it possible for naive participants to apply a sharding scheme which will *probabalistically* result in evenly sized chunks. This has previously been explored under the terminology of "tiling" where we refer to a contiguous "chunk" of the trie as a tile. Under this approach, each tile would contain `~N` accounts and would be the base unit under which the account data for each account would be stored. Each tile would have one or more accompanying inclusion proofs against recent state roots. Keeping these proofs up to date could be done in a decentralized way by applying block witnesses or in a more centralized manner by relying on an external mechanism to push the updated tiles into the network after each new block. Previous solutions to this are likely fruitful to pursue. 1. Tiling 2. SkipGraph for tile discovery if a naive approach to tiling cannot be devised. 3. Necessary network throughput to have an outside actor continuously pipe in the latest tiles for the latest state roots. #### Simple NodeID based Tiling Here is a simple scheme Each node on the network would determine their own storage capacity. Nodes would use their `node_id` to determine the path into the account trie under which they will store account data. Then, they would collect the accounts around that path into the trie until they've filled their storage capacity. Under this scheme, when looking for an account under a given path, you would simply use the FINDNODES mechanism to find the nodes whos `node_id` are closest to the desired trie path. This scheme is potentially problematic as it is subject to attacks where someone mines node-ids near a certain account in the trie to disrupt access to that account's data. The advertisement approach from alexandria can likely be used to mitigate this by adding a layer of indirection. ### Code Code is probably the easiest to handle. We can probably host it directly in Alexandria or via an equivalent mechanism where code is deduplicated, and referenced by it's hash (or merkle root). Code doesn't need to be updated and should be roughly equivalent to how Blocks/Headers/Receipts are store in Alexandria. Code should be very straight forward. ### Contract Storage Contract storage remains the complex one. These tries can be very large, and they have no mechanism to force them towards being well balanced. This appears to make naive sharding of these tries unfeasible. The total size of each contract's storage also varies widely. For many contracts, it may be reasonable to store the whole state in one place. At the far other end of the spectrum there are contracts with storage sizes in the GB range. These will need to be "tiled" in some way, splitting them into smaller chunks. Contract storage also differs from the main Account trie in that the magnitude and rate of updates is going to be smaller and less frequent. Some contract will have very regular changes but those changes are small. Some contracts will rarely change storage. Rarely will a significant amount of a contract's storage change in a single block. Self-Destructs must also be dealt with. The most promising solutions for this will likely be similar to how we deal with Accounts. The unbalanced nature of these tries likely requires a different approach to tiling. Since it is likely that whatever tiling scheme is chosen for contract storage will not be able to be "naive", a Skip Graph can serve a critical role in each contract storage to enable traversal of the tiles. ## Supported Use Cases We should have a clear definition of what this network is used for. ### Sync Probably Not. This network isn't optimized for bulk retrieval. It might turn out to be possible, but I don't think it's a use case that has to influence design decisions. ### On-Demand Access Things like `eth_call` require on-demand access to *random* parts of the state. This is a use case we explicitely suppport. ### Re-Genesis There is probably a related use case in Re-Genesis. The *cold* state is static, and is needed to construct transactions. Since it is *static*, serving it becomes much easier because you don't need to constantly keep it up-to-date. ## Unsolved Stuff Here's a dump of the parts of this that still need figuring out. ### Update Rates We need to look at both the account trie, and the individual storage tries to get an understanding of the update rate. > "How many accounts are touched how often." Understanding things like average rates or 99th percentile can be directly mapped to understanding how many "tiles" would need to be updated per block. ### Data Footprint How big should tiles be. How many total tiles does it take to cover the entire state. How many tiles would each node in the network need to maintain. ### Skip Graph Hardening The skip graph data structure needs to be better understood. There are complexities that arise in repairing the graph. There is some difficult concept of initializing the graph and needing bootnodes to initiate you into the graph. It's possible for multiple disparate graphs to occur and clients should be able to handle merging (this is probably related to "repair") ### State Root Anchoring Each "tile" should have a proof anchoring it to a state root. Do tile owners maintain multiple versions of the tile for recent state roots? When a tile doesn't change, the corresponding *proof* still needs to be updated if they are going to support recent state roots. How hard is it for clients to keep their proofs up-to-date.

Import from clipboard

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 lost 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?

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

Sign in via SAML

or

Sign in via GitHub

Help

  • English
  • 中文
  • 日本語

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Resources

Releases

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

Versions and GitHub Sync

Sign in to link this note to GitHub Learn more
This note is not linked with GitHub Learn more
 
Add badge Pull Push GitHub Link Settings
Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

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. Learn more

       Sign in to GitHub

      HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

      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
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

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

      Syncing

      Push failed

      Push successfully