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

Recalculate work from wallet #1895

Merged
merged 25 commits into from
Apr 23, 2019
Merged

Recalculate work from wallet #1895

merged 25 commits into from
Apr 23, 2019

Conversation

argakiig
Copy link
Contributor

replaces #1860

blocks handled by the internal wallets will have work calculated using the active_difficulty if active_difficulty is greater
creates a thread in wallets to track these blocks and the time they were inserted, if they arent confirmed they are re inserted with an updated time.

@argakiig argakiig added enhancement functionality quality improvements This item indicates the need for or supplies a better way to implement existing functionality labels Apr 11, 2019
@argakiig argakiig added this to the V19.0 milestone Apr 11, 2019
@argakiig argakiig self-assigned this Apr 11, 2019
@argakiig argakiig requested a review from cryptocode April 11, 2019 04:22
Copy link
Contributor

@wezrule wezrule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the difficulty lowers while we are doing a recalculation. When we look to make a transaction, will it still use the stored work we have and if so it will it cancel the current work be generated?

@argakiig argakiig requested review from wezrule and SergiySW April 16, 2019 14:15
Russel Waters and others added 12 commits April 16, 2019 11:24
… same block

Test to update difficulty if below active_difficulty
work recalc config option default 4 sec or 1/4 of announcement period
created thread to handle work regeneration
based on user configurable input
only recalc work if considered online, peer stake is greater than delta or min conf
test was reworked block is generated and started to be processed
block is added to difficulty_reque
updated logic to handle test network
Copy link
Contributor

@SergiySW SergiySW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, considering @cryptocode review changes

@SergiySW
Copy link
Contributor

P.S. I guess for RC2 we may need to add some metrics to delay recalculation during network spam

Russel Waters added 5 commits April 22, 2019 10:19
do work regeneration drops junk blocks
pass lock into update_active_difficulty
moved transaction in do_work_regeneration outside loop to reuse
check active and ledger for confirmation multiple times
Russel Waters added 4 commits April 22, 2019 12:45
Russel Waters and others added 3 commits April 22, 2019 14:29
…nt and also the mutex matches the mutex we expect to be locked. This is the expected behavior.

Store a mapping of qualified_root -> state_block since we only regenerate work for state_blocks and saves some type checking and complexity.
The absence of the qualified_root in active_transactions indicates the block has been confirmed or it was a fork that was rejected, either way we don't need to generate more work for it, we don't need a different way to check if it's confirmed.
Remove items from generated_blocks before we iterate over it so we don't have to modify the container while iterating.
Fixed an issue where we were modifying a container while iterating over it with multimap::erase
Moving forward declarations to beginning of namespace declaration so they're all in one place.
Separating work_watcher from wallets since its sufficiently complex i.e. has its own mutex and condition variable.
Constify a lot of functions that aren't labeled as such but are.
only evict block if we can ensure blocks are confirmed
@argakiig argakiig merged commit 67c3ef8 into nanocurrency:master Apr 23, 2019
@argakiig argakiig deleted the recalculate_work_from_wallet branch July 3, 2019 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement functionality quality improvements This item indicates the need for or supplies a better way to implement existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants