Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tree view model - built-in fast caches #196

Open
dapplion opened this issue Sep 16, 2021 · 0 comments
Open

Refactor tree view model - built-in fast caches #196

dapplion opened this issue Sep 16, 2021 · 0 comments

Comments

@dapplion
Copy link
Contributor

We have built many additional caches in Lodestar CachedBeaconState to make the beacon state transition as fast as it needs to be. However those structures are very verbose, repetitive in code and have huge memory cost.

Cache to skip traversals

Teku ssz has a nice approach where tree views have a cache attached to prevent having to traverse the tree unless when strictly necessary. The idea is to add a regular fast array that shortcuts to leaf data, either nodes or actual data.

Mutate then commit

Also the Tree views can leverage that cache to make many mutations more cheaply.

  1. Mark view as mutable
  2. Mutate nodes without updating the tree
  3. Commit and propagate change up the tree at once in batch (see Add setNodes() method persistent-merkle-tree#53)

This is similar to the persistent-ts architecture but without having to duplicate data.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant