-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
get() Root should not return a sub Tree #83
Comments
I propose to add constructor options to composite types so you can choose not to return a Tree (using export abstract class CompositeType<T extends object> extends Type<T> {
shouldNotReturnSubTree: boolean;
constructor(opts) {
this.shouldNotReturnSubTree = opts.shouldNotReturnSubTree ?? false
} Then tree backing can use that info to not return a tree for those types // ssz/src/backings/tree/container.ts:138
if (!isCompositeType(fieldType) || fieldType.shouldNotReturnSubTree) {
// return raw value
} else {
// return tree
} This behavior can be customized in lodestar-types for roots, and won't affect other users. export const Root = new ByteVectorType({length: 32, shouldNotReturnSubTree: true}); |
right now, we use {
root: stateTree.finalizedCheckpoint.root.valueOf(),
} I agree that a Root should always return a |
SSZ has been refactored since this time, no longer relevant. |
When getting a property from a tree backed ssz type this if decides to return the "raw" value or tree backed.
ssz/src/backings/tree/container.ts
Line 138 in d6efe10
In my opinion I would assume that a Root will not return a sub Tree, but just the raw value. However this is not the case
Due to the Tree hook anyone that holds any root part of a state will prevent to garbage collect that state, causing this memory issues ChainSafe/lodestar#2181 (comment)
The text was updated successfully, but these errors were encountered: