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

TUI Freeze Fix - Add manually maintained hash to difficulty iterator #3684

Merged
merged 3 commits into from
Jan 7, 2022

Conversation

yeastplume
Copy link
Member

Due to recent performance optimisations to the difficulty iterator, a call to the chain's get_header_by_height needed to be added. Unfortunately, this function relies on a read lock on the txhashset. A write lock is held unyielded for a very long time by validation code after the txhashset is downloaded, leading to a TUI freeze when calling this method.

Fix is to avoid that call by re-adding a hash to the HeaderDifficultyInfo struct, populated by maintaining hashes as provided in the prev_header field in the Headers themselves. This optionally keeps hashes available in the HeaderDifficultyInfo struct while still avoiding the need to deserialize the entire header to derive the hash.

Note this point in the TUI code is the only place where a block's hash is needed from the DifficultyIterator, so impact should be minimal.

@yeastplume yeastplume requested a review from phyro January 4, 2022 13:53
Copy link
Member

@phyro phyro left a comment

Choose a reason for hiding this comment

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

I can confirm this resolved my TUI freezing issue. Unfortunatelly, I'm still having issues syncing which seems unrelated to this change. Peers drop and everything starts working slowly for me. It might be due to some disk issues I'm experiencing that are unrelated to Grin, but will be able to tell only after I try on a different disk.

@yeastplume yeastplume merged commit 78c9794 into mimblewimble:master Jan 7, 2022
@yeastplume yeastplume deleted the tui_freeze_fix branch January 20, 2022 10:00
bayk added a commit to mwcproject/mwc-node that referenced this pull request Jun 21, 2024
difficulty iterator (mimblewimble#3684)
* add manually managed hash to difficulty iterator
* text fix
* fix for hash-of-hash, review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants