-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactor SSZ, implement incremental hash #115
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
core/src/main/java/org/ethereum/beacon/core/ssz/DefaultSSZ.java
Outdated
Show resolved
Hide resolved
ssz/src/main/java/org/ethereum/beacon/ssz/ExternalVarResolver.java
Outdated
Show resolved
Hide resolved
…rrectly pick vector sizes
@@ -74,12 +75,20 @@ | |||
String type() default ""; |
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.
Is type
still relevant? If yes, its description and shortcut values should be updated.
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.
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; |
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.
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.
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.
Ups, I think it's not quite correct naming. Should rather be vectorLength
. Will fix...
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:
BeaconChain
structure and all of its non-basic childrenBeaconChain
structure 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 aBeaconChain
instance is copied any changes made on the original instance and its fork are further processed isolatedFor ReadList an
ObservableComposite
wrapper around standard implementation was created: ObservableListImplWhat else can be done here