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

Synchronize wallet import and chain reindexing #883

Merged
merged 6 commits into from
Apr 8, 2019

Conversation

dsaveliev
Copy link
Member

Fixes #810
Depends on #881

There is a race condition between import thread and wallets sync.
It's possible for the wallet to process VOTE transaction meanwhile ThreadImport didn't import the corresponding validator yet.
In order to avoid such problems during reindexing, I tried to sync these two processes.

In addition, I turned off validator state loading from backup since reindexing must restore it from scratch.
This change depends on #881, so the test will be red until the PR is merged.

Signed-off-by: Dmitry Saveliev dima@thirdhash.com

@dsaveliev dsaveliev added the bug A problem of existing functionality label Apr 3, 2019
@dsaveliev dsaveliev added this to the 0.1 milestone Apr 3, 2019
@dsaveliev dsaveliev self-assigned this Apr 3, 2019
@dsaveliev dsaveliev requested review from kostyantyn, AM5800, Gnappuraz, thothd and a team April 3, 2019 13:41
@frolosofsky
Copy link
Member

The problem in the current test is that it relies (a bit) on finalization state which was restored from disk. We have finalization state serialization (see finalization::StateRepository::RestoreFromDisk) and I think it must not be called when fReindex. It would be great if we fix that right in this PR.

src/init.cpp Outdated Show resolved Hide resolved
src/wallet/wallet.cpp Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
@dsaveliev dsaveliev force-pushed the fix-reindex-process branch 2 times, most recently from 8193843 to 51ed508 Compare April 3, 2019 14:48
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
@dsaveliev dsaveliev force-pushed the fix-reindex-process branch 4 times, most recently from d6d06b6 to cb1e076 Compare April 3, 2019 22:57
@AM5800
Copy link
Member

AM5800 commented Apr 4, 2019

@dsaveliev I would appreciate a little bit less force-pushes and rebases. I briefly took a look yesterday evening and now this is very different, so I have to start from scratch.

@AM5800
Copy link
Member

AM5800 commented Apr 4, 2019

Concept ACK
Would like to see it in action with #881

@scravy
Copy link
Member

scravy commented Apr 4, 2019

Travis, twice:

feature_reindex_commits.py                     | ✖ Failed  | 18 s

@dsaveliev
Copy link
Member Author

By design, waiting for #881

Copy link
Member

@frolosofsky frolosofsky left a comment

Choose a reason for hiding this comment

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

I humbly ask you to ensure finalizer operating well after reindex.

test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
test/functional/feature_reindex_commits.py Outdated Show resolved Hide resolved
@dsaveliev dsaveliev force-pushed the fix-reindex-process branch 2 times, most recently from a31476b to e308ffb Compare April 5, 2019 12:53
@frolosofsky frolosofsky dismissed their stale review April 5, 2019 14:06

my concerns have been addressed

Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
Signed-off-by: Dmitry Saveliev <dima@thirdhash.com>
Copy link
Member

@thothd thothd left a comment

Choose a reason for hiding this comment

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

ACK 1b18c37

Copy link
Member

@Gnappuraz Gnappuraz left a comment

Choose a reason for hiding this comment

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

utACK a419ad9

@dsaveliev dsaveliev merged commit c754f47 into dtr-org:master Apr 8, 2019
@dsaveliev dsaveliev deleted the fix-reindex-process branch April 8, 2019 06:28
Copy link
Member

@frolosofsky frolosofsky left a comment

Choose a reason for hiding this comment

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

ACK 1b18c37

if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
LoadMempool();
fDumpMempoolLater = !fRequestShutdown;
}

// Since the import process can restore the node's ValidatorState,
Copy link
Member

@frolosofsky frolosofsky Apr 8, 2019

Choose a reason for hiding this comment

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

I think, mentioning of ValidatorState misses a huge step in explanation of this code purpose. I'd rephrase this comment in a way to describe how WalletExtention works when reindex is enabled. What do you think?

@@ -1663,7 +1672,8 @@ bool AppInitMain()
// UNIT-E TODO: Snapshot must start working once we can trust commits
// (commits merkle root added to the header and FROM_COMMITS is dropped).
// Check #836 for details.
if (!snapshot::IsISDEnabled()) {
// In the case of reindex, don't restore finalization's state, since it will be built from scratch.
if (!snapshot::IsISDEnabled() && !fReindex) {
Copy link
Member

Choose a reason for hiding this comment

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

I know it is not a main purpose of this PR, but since it fixes things in reindex, I guess we can do it bit better right here. I suggest reseting finalization state database in case of reindex just like CBlockIndex database does it:

                pblocktree.reset(new CBlockTreeDB(nBlockTreeDBCache, false, fReset));

Where fReset=fReindex is passed as fWipe parameter to the DB.

You can configure StateDBParams.wipe from finalization::StateDB::New by using ArgsManager dependency.

proposer=self.proposer,
finalizer=self.finalizer,
count=10)
assert_equal(len(votes), 10)
Copy link
Member

Choose a reason for hiding this comment

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

I don't see a reason to generate so many epochs. This test takes ~35 seconds on my machine and huge portion of the time is unnecessary block generation. I just played with the test: changing epoch_length=5 and generating 2 epochs instead of 10 decreases test time to 10 seconds.

# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test running united with -reindex options and with finalization transactions
Copy link
Member

@kostyantyn kostyantyn Apr 8, 2019

Choose a reason for hiding this comment

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

nit: we changed the process name to unite-eunit-e

Copy link
Member

Choose a reason for hiding this comment

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

united -> unit-e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A problem of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants