mirror of
https://github.com/monero-project/monero.git
synced 2025-01-24 22:16:42 -05:00
36f1e1965f
The initial impl didn't capture the following edge case: - Tree has 3 (or more) layers + 1 leaf layeri - Leaf layer last chunk IS full - Layer 0 last chunk is NOT full - Layer 1 last chunk is NOT full - Layer 2 last chunk IS NOT full In this case, when updating layer 1, we need to use layer 0's old last hash to update layer 1's old last hash. Same for Layer 2. The solution is to use logic that checks the *prev* layer when updating a layer to determine if the old last hash from the prev layer is needed. This commit restructures the grow_tree impl to account for this and simplifies the approach as follows: 1. Read the tree to get num leaf tuples + last hashes in each layer 2. Get the tree extension using the above values + new leaf tuples 2a. Prior to updating the leaf layer, call the function get_update_leaf_layer_metadata. This function uses existing totals in the leaf layer, the new total of leaf tuples, and tree params to calculate how the layer after the leaf layer should be updated. 2b. For each subsequent layer, call the function get_update_layer_metadata. This function uses the existing totals in the *prev* layer, the new total of children in the *prev* layer, and tree params to calculate how the layer should be updated. 3. Grow the tree using the tree extension. This approach isolates update logic and actual hashing into neat structured functions, rather than mix the two. This makes the code easier to follow without needing to keep so much in your head at one time. |
||
---|---|---|
.. | ||
account.cpp | ||
address_from_url.cpp | ||
aligned.cpp | ||
apply_permutation.cpp | ||
base58.cpp | ||
block_queue.cpp | ||
block_reward.cpp | ||
blockchain_db.cpp | ||
bootstrap_node_selector.cpp | ||
bulletproofs_plus.cpp | ||
bulletproofs.cpp | ||
canonical_amounts.cpp | ||
chacha.cpp | ||
checkpoints.cpp | ||
CMakeLists.txt | ||
command_line.cpp | ||
crypto.cpp | ||
curve_trees.cpp | ||
curve_trees.h | ||
decompose_amount_into_digits.cpp | ||
device.cpp | ||
difficulty.cpp | ||
dns_resolver.cpp | ||
epee_boosted_tcp_server.cpp | ||
epee_levin_protocol_handler_async.cpp | ||
epee_serialization.cpp | ||
epee_utils.cpp | ||
expect.cpp | ||
get_xtype_from_string.cpp | ||
hardfork.cpp | ||
hashchain.cpp | ||
hmac_keccak.cpp | ||
http.cpp | ||
is_hdd.cpp | ||
json_serialization.cpp | ||
json_serialization.h | ||
keccak.cpp | ||
levin.cpp | ||
lmdb.cpp | ||
logging.cpp | ||
long_term_block_weight.cpp | ||
main.cpp | ||
memwipe.cpp | ||
mlocker.cpp | ||
mnemonics.cpp | ||
mul_div.cpp | ||
multiexp.cpp | ||
multisig.cpp | ||
net.cpp | ||
node_server.cpp | ||
notify.cpp | ||
output_distribution.cpp | ||
output_selection.cpp | ||
parse_amount.cpp | ||
pruning.cpp | ||
random.cpp | ||
ringct.cpp | ||
ringdb.cpp | ||
rolling_median.cpp | ||
rpc_version_str.cpp | ||
scaling_2021.cpp | ||
serialization.cpp | ||
sha256.cpp | ||
slow_memmem.cpp | ||
subaddress.cpp | ||
test_notifier.cpp | ||
test_peerlist.cpp | ||
test_protocol_pack.cpp | ||
test_tx_utils.cpp | ||
threadpool.cpp | ||
tx_proof.cpp | ||
unbound.cpp | ||
unit_tests_utils.h | ||
uri.cpp | ||
util.cpp | ||
variant.cpp | ||
varint.cpp | ||
ver_rct_non_semantics_simple_cached.cpp | ||
vercmp.cpp | ||
wallet_storage.cpp | ||
wipeable_string.cpp | ||
zmq_rpc.cpp |