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
# Gas model during the overlay transition This document presents how database access work during the overlay transition to verkle trees, and why the gas model need not be changed. ## The snapshot / flat database The adoption of a flat database model is reaching a consensus among clients. Even though not all of them have implemented it yet, we expect to reach complete adoption in the medium term. Reads from the flat database are rather cheap, compared to tracing the tree from node to node, in order to reach the leaf node that one is looking for. The reason why the gas for reading isn't getting any cheaper, is that there is no garantee that the snapshot will be present. Typically, a deep reorg will invalidate the snapshot. ## The conversion In this model, it is assumed that the conversion will use the overlay method with a readonly MPT. ### Snapshot availability Even though the presence of the snapshot is not required during normal operation, its presence can be guaranteed before the sweeping phase of the overlay method. Noting that: 1. the MPT is frozen, and 2. the conversion will not start for a few days after the fork height, in order to give clients enough time to download the preimages there is, in fact, enough time to ensure that a snapshot is generated. For geth, snapshot generation takes about 2 hours currently on a fast nvme disk. There is, therefore, ample time between the finalization of the fork block and the start of the snapshot sweeping. ### Updated snapshot structure The snapshot needs to retain both MPT and verkle values. The MPT values that are "cloberred" by the verkle tree also need to be retained, so that they can be served to syncing nodes. The snapshot is now designed to hold both MPT and verkle values. It is still keyed by the keccack of the address/slot, but the value is changing as follows: * if both a MPT and a verkle value exist, the RLP encoding of the MPT value is concatenated with the "raw serialization" of the verkle tree node; * if only the MPT value is present, the RLP encoding will be stored. The absence of the verkle value can be determined by the fact that the decoder consumed all the bytes of the payload. * if only one verkle value is present, then the first byte of its encoding will be `1` or `2`, which is well outside of the range for an RLP list header (`0x80..0xff`). ### State reads In order to read, the snapshot is searched using the traditional key structure: `key = keccak256(address) || keccak256(slot number)`. * if an entry is not found, then the address / slot is not present in either the MPT nor the verkle tree; * if an entry is found, then: * if the first byte is an integer `N < 0x80` then the entry corresponds to an address/slot that was inserted in the verkle tree and was never present in the MPT; * if the 2nd byte resembles an RLP header, then there was a value in the MPT. Extract the length `L` of that RLP payload. * if the value byte length matches `L`, then the value is only present in the MPT; * if the value byte length is greated than `L`, then the extra bytes are the serialization of the verkle value; * if the value byte length is smaller than `L`, then report an error. Because both MPT and verkle values can be read in one swoop, and because the I/O dominates the decoding, then there is no need to update the gas cost. ### State writes Since only the verkle tree is updated, the writing costs in the tree are unchanged during the transition, as all internal nodes need to be read and updated. Updating the snapshot has about the same costs, as both the MPT and verkle values are written together.

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