Skip to content
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

Leaf/parent indicator bit in tree hash? #663

Closed
Bren2010 opened this issue May 15, 2022 · 1 comment · Fixed by #687
Closed

Leaf/parent indicator bit in tree hash? #663

Bren2010 opened this issue May 15, 2022 · 1 comment · Fixed by #687

Comments

@Bren2010
Copy link
Collaborator

When computing the tree hash, should there be an indicator bit for whether the value being hashed represents a leaf or parent node?

@bifurcation
Copy link
Collaborator

This doesn't seem like a terrible idea. You could either add a field uint8 leaf_or_parent = 0/1; to LeafNodeHashInput and ParentNodeHashInput, or define an enum and do the same, or make a select. For example:

enum { reserved(0), leaf(1), parent(2), (255) } TreeNodeType;

struct {
    TreeNodeType node_type;
    select (TreeHashInput.node_type) {
        case leaf: /* ParentNodeHashInput, as a struct or inlined */
        case parent: /* ParentNodeHashInput, as a struct or inlined */
    }
} TreeHashInput;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants