deroproject / derohe

DERO Homomorphic Encryption Blockchain Protocol
Other
208 stars 82 forks source link

fix: missing wallet history #150

Open 8lecramm opened 11 months ago

8lecramm commented 11 months ago

Description

Please include a summary of the changes and the related issue.

NOTE: The process is the following:

Fixes # (issue)

Type of change

Please select the right one.

Which part is impacted ?

Checklist:

License

I'm am contributing & releasing the code under DERO Research License (which can be found here).

Summary

This pull request is a fix for issue #118 (also related to TradeOgre deposit issues) When syncing into a side block, at least 2 entries are removed from the history instead of only one entry. An "out of range" error occurs and the sync loop terminates.

06/12 22:35:24  INFO    syncing loop    {"total_entries": 74158}
06/12 22:35:24  INFO    syncing loop from pos   {"i": 74157, "start_topo": 2983743, "end_topo": 2983754}
06/12 22:35:24  INFO    syncing loop  starting internal         {"start_topo": 2983743, "end_topo": 2983754}
06/12 22:35:24  INFO    syncing loop completed  {"total_entries": 74159}

06/12 22:35:51  INFO    syncing loop    {"total_entries": 74159}
06/12 22:35:51  INFO    syncing loop from pos   {"i": 74158, "start_topo": 2983755, "end_topo": 2983755}
06/12 22:35:51  INFO    syncing loop  starting internal         {"start_topo": 2983755, "end_topo": 2983755}
06/12 22:35:51  INFO    syncing loop completed  {"total_entries": 74160}

06/12 22:39:15  INFO    syncing loop    {"total_entries": 74160}
06/12 22:39:15  INFO    syncing loop header mismatch    {"i": 74159, "block_hash": "ca72e98477ed2897a12d56aceecdb5c3e014dd9e678467504915d0b1aba44204"}
06/12 22:39:15  INFO    syncing loop skipped    {"i": 74159, "skip": 1}
06/12 22:39:15  INFO    syncing loop completed  {"total_entries": 74158}
06/12 22:39:15  ERROR   Recovered while syncing connecting      {"r": "runtime error: index out of range [74159] with length 74158", "stack": "Z29yb3V0aW5lIDY5IFtydW5uaW5nXToKcnVudGltZ..........6NDM5ICsweDY5Cg=="}

06/12 22:46:30  INFO    syncing loop    {"total_entries": 74158}
06/12 22:46:30  INFO    syncing loop from pos   {"i": 74157, "start_topo": 2983743, "end_topo": 2983788}
06/12 22:46:30  INFO    syncing loop  starting internal         {"start_topo": 2983743, "end_topo": 2983788}
06/12 22:46:31  INFO    syncing loop completed  {"total_entries": 74162}

1 entry is skipped, but 2 are removed from the history (from 74160 to 74158 entries) Twice as many entries as necessary are always deleted. The entries 74159, 74160 and the failed sync of entry 74161 disappear until the wallet balance changes again. There are many coinbase rewards for this example wallet. It took only 7 minutes for the balance to change again. In certain circumstances, the removed entries won't be restored, particularly if the transaction of the last entry involved more than one transfer.

Here is an example after the fix is applied. 8 transfers in block 2980293 were removed due to an orphaned block and re-synced in the same sync loop run.

06/12 04:01:46  INFO    syncing loop    {"total_entries": 73470}
06/12 04:01:46  INFO    syncing loop header mismatch    {"i": 73469, "block_hash": "86e53e02179b2c55aa6b0ef6bf0a2ee2852ead1670777611e27988a6de9c9dfc"}
06/12 04:01:46  INFO    syncing loop skipped    {"i": 73461, "skip": 8}
06/12 04:01:46  INFO    syncing loop from pos   {"i": 73461, "start_topo": 2980290, "end_topo": 2980294}
06/12 04:01:46  INFO    syncing loop  starting internal         {"start_topo": 2980290, "end_topo": 2980294}
06/12 04:01:49  INFO    syncing loop completed  {"total_entries": 73470}