Avoid Hash <> hash() type and func confusion #1478
Merged
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.
Why:
hash()
is the SHA-256 of empty input.Hash()
is the default instantiation of theBytes32
alias, i.e. 32 zeroed bytes.Hash(*input*)
casts the input to theBytes32
alias (not changing the contents!). Whereashash(*input*)
hashes the input to aHash
(with SHA-256).Changelog (no functional changes):
Hash
alias ofBytes32
Root
alias ofBytes32
Root
Bytes32
Difficult choices:
Bytes32
inside a proof is technically also a combination of nodes. But not necessarily so for the very bottom sibling. So not aRoot
orHash
Hash
is especially confusing, as a leaf item is packed into 32 bytes but not hashed.Bytes32
now:withdrawal_credentials
I am opposed to making a separation between
SigningRoot
andHashRoot
: the roots should be typed by the (summary) type they represent, not the function that is used.signing_root
already is a hack to make the same object definition work for multiple purposes. But really signatures shouldn't be part of the tree, unless intended so. A SSZ type simply cannot be represented by the same immutable cached (each node) tree, covering both signing-root and hash-tree-root, as the tree structure is dfifferent.And since we are using
signing_root
andhash_tree_root
pretty much exclusively, I would prefer to just do away withsigning_root
. Maybe in favor of a way to represent a container with a signature as a serialization-only thing.Open for suggestions/comments.