-
Notifications
You must be signed in to change notification settings - Fork 297
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
Stable Containers - EIP-7495 #8444
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
- Added new interfaces and classes for stable containers (
SszStableContainer
,SszProfile
,SszStableContainerBase
, etc.) in/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/
. - Modified existing classes to handle stable containers, including exception handling (
NoSuchElementException
) in/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/AbstractSszComposite.java
. - Updated serialization methods to handle extra data in backing trees in
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszCollectionSchema.java
. - Introduced methods to convert to stable container schemas and profile schemas in
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/SszContainerSchema.java
. - Enhanced schema handling for optional fields and active fields in
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszStableContainerBaseSchema.java
.
29 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a couple of minor notes.
Many design question we discussed and agreed in our chat before.
abstract SszBitvector sszDeserializeActiveFieldsTree(final SszReader reader); | ||
|
||
@Override | ||
public TreeNode sszDeserializeTree(final SszReader reader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It looks like sszSerialize/DeserializeTree()
have a lot of common logic with AbstractSszContainerSchema
. Maybe we could extract this logic to some util class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some refactor, checkout 5b13a1e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to cut it at that point even I could have continued along that direction it even further.
...ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/AbstractSszMutableComposite.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Introduced
final
variables forelementType
andnodesCount
insszSerializeFixedVector
method in/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszCollectionSchema.java
- Ensures variables are not reassigned, improving code safety and readability
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Removed special handling for
SszStableContainerBase
in/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/AbstractSszMutableComposite.java
- Added
calcNewSize
method for size determination in/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/AbstractSszMutableComposite.java
- Introduced
calcNewSize
method for stable containers in/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/SszMutableStableContainerBaseImpl.java
- Simplified size calculation logic for better maintainability and readability
- Ensure size consistency for profiles with no optional fields in stable containers
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Refactored serialization/deserialization logic in
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszContainerSchema.java
- Updated
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszStableContainerBaseSchema.java
to useContainerSchemaUtil
- Added new utility class
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/ContainerSchemaUtil.java
for handling SSZ containers - Ensure new utility methods handle all edge cases and maintain functionality
- Streamlined handling of fixed and variable children in SSZ containers
3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings
.../ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/ContainerSchemaUtil.java
Show resolved
Hide resolved
.../ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/ContainerSchemaUtil.java
Show resolved
Hide resolved
839dff5
to
5b13a1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Refactored serialization/deserialization logic in
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszContainerSchema.java
- Updated
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/AbstractSszStableContainerBaseSchema.java
to useContainerSchemaUtil
- Added new utility class
/infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/ContainerSchemaUtil.java
for handling SSZ containers - Ensure new utility methods handle all edge cases and maintain functionality
- Streamlined handling of fixed and variable children in SSZ containers
3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings
.../ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/ContainerSchemaUtil.java
Show resolved
Hide resolved
.../ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/impl/ContainerSchemaUtil.java
Show resolved
Hide resolved
* | ||
* @param index of the field set or updated | ||
*/ | ||
protected int calcNewSize(final int index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably just call this calculateNewSize
rather than abbreviate...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i guess but i do hate abbreviations...
infrastructure/ssz/src/main/java/tech/pegasys/teku/infrastructure/ssz/impl/SszProfileImpl.java
Outdated
Show resolved
Hide resolved
.../src/main/java/tech/pegasys/teku/infrastructure/ssz/schema/SszStableContainerBaseSchema.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
Introduced new interfaces and classes to support stable containers and profiles as per EIP-7495, with significant updates across multiple files to ensure compatibility and functionality.
- New Interfaces: Added
SszStableContainer
,SszStableContainerSchema
,SszProfile
, andSszProfileSchema
based onSszStableContainerBase
andSszStableContainerBaseSchema
. - Acceptance Tests: Updated
acceptance-tests/src/acceptance-test/java/tech/pegasys/teku/test/acceptance/MergedGenesisAcceptanceTest.java
to usegenesisExecutionPayloadHeaderSource
. - Validator API: Modified
beacon/validator/src/main/java/tech/pegasys/teku/validator/coordinator/ValidatorApiHandler.java
to align with new getter methods forSyncCommitteeSubnetSubscription
. - Sync Committee: Refactored
data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/validator/PostSyncCommitteeSubscriptions.java
to simplify request body type definition. - IPv6 Support: Enhanced
networking/p2p/src/main/java/tech/pegasys/teku/networking/p2p/discovery/discv5/DiscV5Service.java
andNodeRecordConverter.java
to support IPv6 addresses.
46 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
fixes #8428
Introduces new interfaces:
SszStableContainer
SszStableContainerSchema
SszProfile
SszProfileSchema
which are based on new
SszStableContainerBase
andSszStableContainerBaseSchema
interfaces representing the common base functionalities.Corresponding
Abstract
andImpl
classes implement the logic.Key points
maxFieldCount
(maximum future field count): the backing tree will always have that size despite the "actual" field count.StableContainers
have all fields as optional,Profile
can have a mix of required and optional fields.SszBitvector
is used (sized as max future field count). It will be used in serialization as well as merkelization.size() = last_field_index + 1
does not hold anymore.maxLength
andmaxChunks
: the first is the possible maximum number of fields (required+optionals) the latter is related to the backing tree, so it is calculated based onmaxFieldCount
.getOptional
has been introduced to support optionality. Similarly we havecreateFromOptionalFieldValues
on the schema side to handle optionality.NoSuchElementException
along with existingIndexOutOfBoundsException
. The general logic is:NoSuchElementException
is thrown whenever a field was allowed but (optional) but was not actually specified.IndexOutOfBoundsException
is thrown whenever a field was not allowed (nor optional nor required), which also covers the case the index is truly off.This allows to have nice implementation of the
getOptional
which simply delegate toget
catchingNoSuchElementException
and returningOptional.empty
.merkelization
works the same for bothStableContainers
andProfiles
.serialization
are different. This polymorphism is achieved via abstract methodsAbstractSszStableContainerBaseSchema
.High Level Usage:
to create a
StableContainerSchema
you need:definedChildrenNamedSchemas
: a list ofNamedSchema
representing the defined schemas.maxFieldCount
: theoretical future maximum field count.to create a
ProfileSchema
you need:stableContainerSchema
: aSszStableContainer
to create the profile schema againstrequiredFieldIndices
: a set of indices to indicate which fields are mandatoryoptionalFieldIndices
: a set of indices to indicate which fields are optionalAbstractSszStableContainerBaseSchemaTest
showcases how to use them.What is missing
set
methods.Documentation
doc-change-required
label to this PR if updates are required.Changelog