karalabe / ssz

Opinionated 0-alloc SSZ codec for Go
https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md
BSD 3-Clause "New" or "Revised" License
39 stars 7 forks source link

feat(treerer): Temperature check and WIP #6

Open itsdevbear opened 3 months ago

itsdevbear commented 3 months ago

Idea is to allow for a in memory tree representation of an SSZ object

karalabe commented 3 months ago

Why is this good though? Could you share some use cases?

Keeping the data in struct form is useful for internal stuff. I can also understand an idea to leave the data as raw bytes and support operating on it like that (e.g. proving, verifying). But turning it into a binary tree which is not really good for either seems strange to me with my limited usage of ssz.

itsdevbear commented 3 months ago

The idea that i'm working towards is a cheaper way to update the "HashTreeRoot" of container. Let's use BeaconState for example in the CL context.

If we store the Data in a tree (maybe the answer here is an n-ary tree) we can update the "HashTreeRoot" of the root object in log(n) time by only having the re-hash the branches that were modified since the last time the root was computed.

itsdevbear commented 3 months ago

My use case is a db cache and prefetcher for BeaconKit.

itsdevbear commented 3 months ago

@karalabe also proof generation

itsdevbear commented 3 months ago

I'm still cooking on some stuff, I'll update within the next few days