Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Adding support for encoding and decoding of complex SSZ types #487

Merged
merged 2 commits into from
Jan 13, 2023

Conversation

gezero
Copy link
Contributor

@gezero gezero commented Jan 11, 2023

  • Added support for Containers
  • Added support for generic lists of fixed/variable size type
  • Added support for generic fixed size type vectors

I had to add some handling of scopes (SSZReader.slice()) and also some type hierarchy. Let me try to justify why

  • The size of the list of variable size type is easy to calculate from the first offset, because the fixed part of encoding only contains offsets.

  • The size of a vector is known at the time of designing the data structure.

  • But the size of the list when reading a list of fixed size type is not encoded. To find out what the size is, one must carefully maintain the scopes and then divide the corresponding scope of the list by the size of one element (size of one element is known at the time of defining the data structure).

  • Moreover The length of a scope for a list is unknown until we read the offset of the next variable element in the parent container or the reminder of the fixed part.

Signed-off-by: Jiri Peinlich jiri.peinlich@gmail.com

@gezero
Copy link
Contributor Author

gezero commented Jan 11, 2023

Any advice how to add licence to an arbitrary file that I read during a test?

@atoulme
Copy link
Member

atoulme commented Jan 12, 2023

you can add it to the rat excludes in build.gradle. See here: https://github.com/apache/incubator-tuweni/blob/main/build.gradle#L102

* Added support for Containers
* Added support for generic lists of fixed/variable size type
* Added support for generic fixed size type vectors

I had to add some handling of scopes (SSZReader.slice()) and also some type hierarchy. Let me try to justify why

* The size of the list of variable size type is easy to calculate from the first offset, because the fixed part of encoding only contains offsets.

* The size of a vector is known at the time of designing the data structure.

* But the size of the list when reading a list of fixed size type is not encoded. To find out what the size is, one must carefully maintain the scopes and then divide the corresponding scope of the list by the size of one element (size of one element is known at the time of defining the data structure).

* Moreover The length of a scope for a list is unknown until we read the offset of the next variable element in the parent container or the reminder of the fixed part.

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants