Refactor tree view model - built-in fast caches
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- performance
Research direction
No repository implementation file, test, or entry point is named in the issue. Begin by locating the Lodestar CachedBeaconState and tree view model code, then read the linked Teku cache and commit references; done would require an agreed cache and mutate-then-commit design with corresponding tests and measured memory or speed improvements.
Written by the indexing model from the issue text.
Description
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.
- Mark view as mutable
- Mutate nodes without updating the tree
- Commit and propagate change up the tree at once in batch (see https://github.com/ChainSafe/persistent-merkle-tree/pull/53)
This is similar to the persistent-ts architecture but without having to duplicate data.
References:
- Teku ssz cache of views primitive https://github.com/ConsenSys/teku/blob/3044df72e9/ssz/src/main/java/tech/pegasys/teku/ssz/cache/ArrayIntCache.java
- Teku BeaconState commit changes entrypoint https://github.com/ConsenSys/teku/blob/9c0086ca5af0f90eddc26ca437475adfa7afc914/ethereum/spec/src/main/java/tech/pegasys/teku/spec/datastructures/state/beaconstate/common/AbstractMutableBeaconState.java#L60
- Teku BeaconState
.update()wrapper to handle toMutable, mutations, commit steps at once https://github.com/ConsenSys/teku/blob/9cd657a7f057a1ed96b3e722df37f42f7bb60be4/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/block/AbstractBlockProcessor.java#L281-L282 - Teku ssz tree commit nodes function https://github.com/ConsenSys/teku/blob/b7246424d26194d49b1321e2f090d841468d5982/ssz/src/main/java/tech/pegasys/teku/ssz/impl/AbstractSszMutableComposite.java#L187-L188
- Dominant language
- TypeScript
- Stars
- 62
- Forks
- 27
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ChainSafe/ssz
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
SSZ Union Deserialization Vulnerable to Trailing Data for Certain VariantsPossibly taken @shadowzzed claimed this 40 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
Similar issues
-
area:workflow bug ready-for-human
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fil-donadoni/tolaria#6108 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/rocketmq-dashboard#7234 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vitest-dev/vitest#11656 ·
Maintainers usually reply within 1 day
-
e2e-failure ready-to-code
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
redhat-developer/rhdh-plugin-export-overlays#4460 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ehmpathy/rhachet-roles-bhrain#655 ·
Maintainers usually reply within 1 day