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
# [Fork choice] Attestation time consideration [TOC] ## The Problem The fork choice currently does not process attestations from more than 1 epoch ago. This presents a problem when processing old blocks in the unfinalized portion of the chain that may update justification/finalization, because the `store` will not be updated (even though `state_transition` executes just fine). See this (currently failing) test case for an example situation: https://github.com/ethereum/consensus-specs/compare/dev...fc-process-block-old-attns ## Recap: Fork choice rule helpers ### `on_attestation` > Run ``on_attestation`` upon receiving a new ``attestation`` from either **(i) a block** or **(ii) directly on the wire**. ```python def on_attestation(store: Store, attestation: Attestation) -> None: """ Run ``on_attestation`` upon receiving a new ``attestation`` from either within a block or directly on the wire. An ``attestation`` that is asserted as invalid may be valid at a later time, consider scheduling it for later processing in such case. """ validate_on_attestation(store, attestation) store_target_checkpoint_state(store, attestation.data.target) # Get state at the `target` to fully validate attestation target_state = store.checkpoint_states[attestation.data.target] indexed_attestation = get_indexed_attestation(target_state, attestation) assert is_valid_indexed_attestation(target_state, indexed_attestation) # Update latest messages for attesting indices update_latest_messages(store, indexed_attestation.attesting_indices, attestation) ``` It expects that the client would process `[on_attestation(store, attestation) for attestation in block.body.attestations]` right after processing `on_block(store, block)`. ### `validate_on_attestation` In [validate_on_attestation](https://github.com/ethereum/eth2.0-specs/blob/v1.1.5/specs/phase0/fork-choice.md#validate_on_attestation) helper: ```python def validate_on_attestation(store: Store, attestation: Attestation) -> None: target = attestation.data.target # Attestations must be from the current or previous epoch current_epoch = compute_epoch_at_slot(get_current_slot(store)) # Use GENESIS_EPOCH for previous when genesis to avoid underflow previous_epoch = current_epoch - 1 if current_epoch > GENESIS_EPOCH else GENESIS_EPOCH # If attestation target is from a future epoch, delay consideration until the epoch arrives assert target.epoch in [current_epoch, previous_epoch] ... ``` *"Attestations must be from the current or previous epoch"* assertion was from [PR#1466 the decoy flip flop resistance](https://github.com/ethereum/eth2.0-specs/pull/1466). > Decoy flip flop issue: https://ethresear.ch/t/decoy-flip-flop-attack-on-lmd-ghost/6001 It checks if `target.epoch` is within `[current_epoch, previous_epoch]`. :::warning Note that `current_epoch` and `previous_epoch` are **computed from `store.time`**. (system clock) ::: --- ## Optimization notes For optimization, clients may skip some fork-choice attestation validations when attestation is from block. We may have to evaluate how critical decoy-flip-flop is; if it's really bad, ask client team to add these validation. --- ## Recent changes From [PR#2727](https://github.com/ethereum/consensus-specs/pull/2727), to make it pass our old test cases, we only validate `assert target.epoch in [current_epoch, previous_epoch]` when the attestation is from wire (not from a block). You can read this commit diff: https://github.com/ethereum/consensus-specs/pull/2727/commits/f643554aa519ce6efe015ddc97d564e90c0fe248 --- ## Discussions ### Option 1: Should we remove `assert target.epoch in [current_epoch, previous_epoch]` check when the given attestation is from a block? - Current `dev` branch. - Danny: Essentially, attestations from blocks should be allowed regardless of timestamps. If you learn of a new chain at time T and it has blocks and attestatiosn from an arbitrary depth (+2 epochs), you should be able to incorporate it. ### Option 2: Or, should we totally remove `assert target.epoch in [current_epoch, previous_epoch]`? - Implementation: https://github.com/ethereum/consensus-specs/compare/dev...fc-dev-allow-all-old-attns-patch - Aditya: If old attestation is allowed when it's from a block [option 1], then we *already* lose some decoy-flip-flop resistance anyway. ### Option 3: Or, should we revert the recent attestation validation change? i.e., validate attestation time for both cases. ### Option 4: Ignore old attestations in LMD (to prevent head flip-flop from saved votes), but process them for FFG and update store if better justified/finalized checkpoints are found

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