Skip to content

Handling Ephemeral State content #382

@morph-dev

Description

@morph-dev

We never discussed in details on how to handle ephemeral state content and I believe it is quite tricky.

The simple way to think about that is to just verify it against ephemeral headers, which works fine. But the problem appears on when you start thinking about re-orgs and deleting content that no longer belongs to the canonical chain.

I will try to explain problem and few possible solutions and their drawbacks.

Problem

Let's refer to non-ephemeral state content as finalized. This would be either the same as non-ephemeral content from history (since last historical summaries, i.e. at most 8192 blocks) or potentially tied to finality of the chain (at most ~64 blocks). Concept is the same, and there is no big changes on how we handle it one way or the other.

Let's assume that we want to gossip state content only once, at the head of the chain (ephemeral) and that clients will keep them as ephemeral until finality as achieved. At that point, client will either migrate it to permanent storage or delete it (depending on whether content is part of the canonical chain at that point).

Since state content, unlike history content, can exist on both canonical and non-canonical versions of the chain, we can't easily detect which is the case. To be able to do so, we need to associate state content with every slot/block_hash/state_root that contains it.

This is the root of the problem. Content key is the same, regardless if it is associated with a different block. Therefore, client would reject all except the first offer, resulting in content being associated with only one slot/block_hash.

Some potential solutions

Most of the solutions that I came up with have some drawback. Hopefully together we can come up with something great.

1. Re-gossip state content once finality is achieved

Basically all ephemeral state content can be held temporarily and dropped later.
New content will be gossiped and stored once it's finalized.
Clients can be smart and migrate ephemeral content that they have, if they know it belongs to canonical chain.

Drawbacks:

  • State network is very big. Having to gossip it twice is a lot of work
  • Clients should be smart on how long to keep ephemeral content after associated slot is finalized (in case associated block is non-canonical)

2. Accept offers for content that is already stored in ephemeral storage

This ensures that we can keep track of all blocks associated with state content. With this information, we know exactly which content to keep when finality is achieved.

Drawback: This opens us to thundering herd problem: we would accept content that is anchored to the same block multiple times (basically every time that it's offered)

3. Create new content key type that will be used for ephemeral state content

The new content key type will contain slot/block_hash, which will make it unique and differentiable during offer. Content id creating would have to ignore slot/block_hash, so that the same content end up on the same node (also where it should stay once block is finalized)

This is another way to keep track of all blocks that are associated with state content.

Drawback:

  • We would need to change the protocol (should be simple as we are just adding 3 new content keys)
  • Attacker can create this type of content for state content that is not created during ephemeral block, which would significantly increase the size of ephemeral content that we have to deal with. Might not be a problem, as we might be able to know that content already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions