mirror of https://github.com/zcash/zips.git
Clarify calculation of block ranges
This commit is contained in:
parent
6d64ce0c87
commit
c8193992d4
10
zip-0221.rst
10
zip-0221.rst
|
@ -452,7 +452,7 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc
|
||||||
peaks: List[ZcashMMRNode] = []
|
peaks: List[ZcashMMRNode] = []
|
||||||
|
|
||||||
# Get number of leaves.
|
# Get number of leaves.
|
||||||
leaves = latest_height - earliest_height + 1
|
leaves = latest_height - (earliest_height - 1)
|
||||||
|
|
||||||
# Check if the number of leaves is a power of two.
|
# Check if the number of leaves is a power of two.
|
||||||
if (leaves & (leaves - 1)) == 0:
|
if (leaves & (leaves - 1)) == 0:
|
||||||
|
@ -488,8 +488,8 @@ With each new block ``B_n``, we append a new MMR leaf node corresponding to bloc
|
||||||
# This will produce a list of peaks in reverse order
|
# This will produce a list of peaks in reverse order
|
||||||
current = leaf
|
current = leaf
|
||||||
for peak in peaks[::-1]:
|
for peak in peaks[::-1]:
|
||||||
current_leaves = current.latest_height - current.earliest_height + 1
|
current_leaves = current.latest_height - (current.earliest_height - 1)
|
||||||
peak_leaves = peak.latest_height - peak.earliest_height + 1
|
peak_leaves = peak.latest_height - (peak.earliest_height - 1)
|
||||||
|
|
||||||
if current_leaves == peak_leaves:
|
if current_leaves == peak_leaves:
|
||||||
current = make_parent(peak, current)
|
current = make_parent(peak, current)
|
||||||
|
@ -513,7 +513,7 @@ in the right subtree of the MMR root.
|
||||||
Return the new tree root
|
Return the new tree root
|
||||||
'''
|
'''
|
||||||
|
|
||||||
n_leaves = root.latest_height - root.earliest_height + 1
|
n_leaves = root.latest_height - (root.earliest_height - 1)
|
||||||
# if there were an odd number of leaves,
|
# if there were an odd number of leaves,
|
||||||
# simply replace root with left_child
|
# simply replace root with left_child
|
||||||
if n_leaves & 1:
|
if n_leaves & 1:
|
||||||
|
@ -590,7 +590,7 @@ In leaf nodes, some information is repeated. We chose to do this so that leaf no
|
||||||
be treated identically to internal and root nodes for all algorithms and (de)serializers.
|
be treated identically to internal and root nodes for all algorithms and (de)serializers.
|
||||||
Leaf nodes are easily identifiable, as they will show proof of work in the
|
Leaf nodes are easily identifiable, as they will show proof of work in the
|
||||||
``hashSubtreeCommitment`` field, and their block range (calculated as
|
``hashSubtreeCommitment`` field, and their block range (calculated as
|
||||||
``nLatestHeight - nEarliestHeight + 1``) will be precisely 1. For the same reason, we
|
``nLatestHeight - (nEarliestHeight - 1)``) will be precisely 1. For the same reason, we
|
||||||
change the semantics of ``hashSubtreeCommitment`` in leaf nodes to commit
|
change the semantics of ``hashSubtreeCommitment`` in leaf nodes to commit
|
||||||
|
|
||||||
Personalized BLAKE2b-256 was selected to match existing Zcash conventions. Adding the
|
Personalized BLAKE2b-256 was selected to match existing Zcash conventions. Adding the
|
||||||
|
|
Loading…
Reference in New Issue