use rust types for slots, SubEpochSummary and SubEpochData #17298
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These commits are best reviewed one at a time.
Purpose:
This PR is another part of the long-term effort of transitioning
FullBlock
to the rust type. This improves serialization/deserialization speed as well as allow more of the validation to live entirely on the rust side.Some of the performance issues are highlighted here.
This PR is especially targeting serializing and deserializing of
SubEpochChallengeSegments
.This PR transitions the following types to rust:
The rust definition of these types can be found here, here, here and here.
As with earlier types being moved to rust, the integer types are exposed as plain
int
to python, even though the underlying types are fixed width. This allows mypy to highlight all the places where fields need to be "cast" (or really, where our fixed-width integer type needs to be constructed).A utility function on
StructStream
(the base class for our fixed-width integers) was added in the previous PR,construct_optional()
which essentially casts anOptional[int]
->Optional[<StructStream>]
. This is used for optional members of the rust types, which are exposed asOptional[int]
even though the underlying value is restricted by the width of the field.Since native types implemented in rust cannot (at least to my knowlege) be dataclasses, the free function
dataclasses.replace()
has to be replaced by a member functionreplace()
, which our rust classes implement.Current Behavior:
Serializing weight proof messages and deserializing SubEpochChallengeSegments is slow and may block other (more time critical tasks).
New Behavior:
Serializing weight proof messages and deserializing SubEpochChallengeSegments is fast.