Refactor SSZ, implement incremental hash#115
Merged
Conversation
…ld as separate class
…ation class fields. Get rid of serialization workaround with ArrayList instead of ReadList in the BeaconState
…l-ssz # Conflicts: # consensus/src/main/java/org/ethereum/beacon/consensus/hasher/SSZObjectHasher.java # consensus/src/main/java/org/ethereum/beacon/consensus/verifier/operation/DepositVerifier.java # core/src/main/java/org/ethereum/beacon/core/BeaconState.java # core/src/main/java/org/ethereum/beacon/core/state/BeaconStateImpl.java # core/src/main/java/org/ethereum/beacon/core/state/ImmutableBeaconStateImpl.java # core/src/test/java/org/ethereum/beacon/core/SSZSerializableAnnotationTest.java # pow/validator/src/main/java/org/ethereum/beacon/pow/validator/ValidatorRegistrationServiceImpl.java # ssz/src/main/java/org/ethereum/beacon/ssz/SSZCodecHasher.java # ssz/src/main/java/org/ethereum/beacon/ssz/SSZHashSerializer.java # ssz/src/main/java/org/ethereum/beacon/ssz/SSZSchemeBuilder.java # ssz/src/main/java/org/ethereum/beacon/ssz/access/basic/BytesCodec.java # test/src/test/java/org/ethereum/beacon/test/runner/SszRunner.java
mkalinin
requested changes
Apr 9, 2019
…rrectly pick vector sizes
mkalinin
requested changes
Apr 16, 2019
| @@ -74,12 +75,20 @@ | |||
| String type() default ""; | |||
Contributor
There was a problem hiding this comment.
Is type still relevant? If yes, its description and shortcut values should be updated.
Contributor
Author
There was a problem hiding this comment.
Yes, it still relevant, since you may have java BigInteger field but want it represent uin256 SSZ type
Though some types can be removed for now, since SSZ now defines only uintN and bool
| * parameter when set to <b>true</b> marks that it's such kind of field | ||
| * Indicates vector type (list with fixed length) and specifies this vector size | ||
| */ | ||
| int vectorSize() default 0; |
Contributor
There was a problem hiding this comment.
What do you think about just size? It would give an opportunity of using this parameter as a size specifier not only for vectors but for other fixed sized types.
Contributor
Author
There was a problem hiding this comment.
Ups, I think it's not quite correct naming. Should rather be vectorLength. Will fix...
mkalinin
approved these changes
Apr 17, 2019
This was referenced Apr 18, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implement incremental tree hashing support to improve
hash_tree_root(BeaconChain)performanceThe central logic is in the SSZIncrementalHasher class. (incremental update of basic list is not implemented yet. See #120)
The general algorithm is pretty straightforward:
BeaconChainstructure and all of its non-basic childrenBeaconChainstructure and all of its non-basic children by recording indexes of changed/added/removed children (dirty children)Classes which want to be incrementally hashed (e.g. BeaconChain and
ReadList) need to implement ObservableComposite interface and notify UpdateListener on its child changes. These classes are also in charge of properly doing their copies so e.g. if aBeaconChaininstance is copied any changes made on the original instance and its fork are further processed isolatedFor ReadList an
ObservableCompositewrapper around standard implementation was created: ObservableListImplWhat else can be done here