Skip to content

generic ssz list encoding #15447

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

generic ssz list encoding #15447

wants to merge 3 commits into from

Conversation

kasey
Copy link
Contributor

@kasey kasey commented Jun 27, 2025

What type of PR is this?

Feature

What does this PR do? Why is it needed?

We have written a few ssz list encoders by hand. Decoding such a list has many edge cases and error conditions, which a generic implementation can handle in a consistent way.

Which issues(s) does this PR fix?

Other notes for review

Because of the annoying quirks of go generics using interface constraints, we have to pass in a callback to create values of T (or do interface assertions on an any, which is worse). For the existing rpc request types we already have list type Things []Thing style definitions with ssz methodsets, which seem natural for encapsulating those details. I think it could be nice to add another type to list.go which holds a constructor func and pair of un/marshal methods, that can be stored in a package var, so that calling these methods can still be concise without the custom type + methodset boilerplate.

Acknowledgements

@kasey kasey marked this pull request as draft June 27, 2025 05:02
@kasey kasey force-pushed the generic-list-serdes branch from 4393d4d to 1d25da2 Compare June 27, 2025 05:06
@kasey kasey marked this pull request as ready for review June 28, 2025 02:54
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

Successfully merging this pull request may close these issues.

2 participants