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
- [ ] [[email protected]``](https://)- [x] [0x00000000219ab540356cBB839Cbe05303d7705Fa``](https://)# On Demand State Availability This document outlines the problem of providing a mechanism for fetching arbitrary data from the Ethereum state. 0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f.0xad7fef3b2350d220de3ae360c70d7f488926b6117e5f785a8995487c46d323ddad0f574fdcc50eeefec34ed9d2039ecbcode_hash ## Solution Requirements A solution to this problem would have the following properties. - A "node" can retrieve arbitrary data from the Ethereum state - Retrieval is fast-enough for speculative transaction execution against a recent state root for a "normal" transaction. - Requests must be able to be pinned to a single "recent" state root. - The solution should natively scale and ideally should allow for low resource nodes to easily contribute back to the network. ### Things we **DO NOT** have to do We do not have to support stateless mining We do not have to support syncing the full state ## The Ethereum State We refer to the "Ethereum State" as: - The collection of account information (`balance/nonce/code_hash/state_root`) that makes up the global `state_root`. - The collection of individual contract storage tries referenced by the account level `state_root`. - The collection of all contract bytecodes. These are not explicitely part of the state as they are only referenced by `code_hash` of each account. This data is randomly read and written. Some accounts/contracts are updated with high frequency. Others may be "cold", rarely or never being updated or touched. ### Account Trie Data The account storage trie is naturally balanced since account addresses are evenly distributed across the address space and it is computationally prohibitive to "mine" enough addresses in a single region to produce a meaningful imbalance. ### Contract Trie Data The contract tries can be modeled as either separate tries or as "dangling" under each account in the global state trie. The contract tries vary widely in size from zero kb up to more than a gigabyte in size. The contract tries are not balanced. The `SELFDESTRUCT` mechanism can cause full contract tries to be wiped in a single block, potentially "purging" large amounts of information from the network in a single action. ### Contract Bytecode The contract bytecode are referenced by each account's `code_hash` and is a stream of bytes. ## Open Questions and Research Topics ### Addressing Each piece of state must be addressed. #### Trie Node Hash We can use the node hash from the trie node similar to how `GetNodeData` works. - Good Stuff - No need for proofs since response is validated based on the requested node hash - No need for specifying `state_root`. - Natively de-duplicates across multiple state roots. - Bad Stuff - Scheme is not condusive to the modern most efficient ways to store the trie (flat database layout) - Node hashes provide zero context about the data. Leaf vs Intermediat / Account vs Contract-Storage. - Inherently innefficient, storing intermediate trie nodes which are not strictly necessary. #### By Trie Path and State Root We can use `(state_root, address)` to reference an account and `(state_root, address, slot)` to reference contract storage. - Good Stuff - Seems to be condusive to flat database layout and in general does not dictate the architecture of the database. - Provides contextual information about the data. - Bad Stuff - Unclear how de-duplication might work. An account which has not changed in a few blocks will have the same value across multiple state roots. Ideally we do not want to store multiple entries for the account. ### Provable Data When retrieving and storing data for the network it needs to be "provable" to someone with access to the header chain. That means that account data will need something like a merkle proof against a state root and contract storage will need an additional proof against the account state root. ### Updating Data The Ethereum state changes every 15 seconds. These changes need to be available quickly to consumers of the networks. If the data is addressed and stored by node hash, all new trie nodes will need to be piped into the network at each block. If the data is addressed differently, it may make sense to instead have nodes update the data in-place, though it still may make sense to pipe new proofs into the network. Either way, the solution will need to deal with the constantly changing nature of the data. > TODO: How many trie nodes or accounts and contract storage slots are touched on average for each block in current mainnet conditions. ### Dividing the Data If we want to use something like a DHT we need a way to divide the data up evenly amoung the nodes. The account data is naturally balanced and easy to shard. The contract storage being inherently unbalanced is problematic. ### Efficiency of storing contigious blocks of data Assuming the data nodes store includes proofs, it is much more efficient for a node to store a contigious block of addresses or storage slots since their individual proofs will have a large degree of overlap.

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