Skip to content

Update node initiation to handle Persistent DB - #61

Merged
RCasatta merged 1 commit into
rust-bitcoin:masterfrom
rajarshimaitra:persistency-fix
May 13, 2022
Merged

RCasatta merged 1 commit into
rust-bitcoin:masterfrom
rajarshimaitra:persistency-fix

Conversation

@rajarshimaitra

Copy link
Copy Markdown
Contributor

In usage of recently added #52 , the expected behaviour for Persistent type datadir is, the new instance of core will inherent all the existing data. Which is working as expected for other data (blocks, chainstate etc), except the wallet directory.

The current behavior tries to always create a new default wallet at initiation. In case of persistent DB that gives rpc error "wallet file already exists".

This PR updates the init process to handle persistent type database properly..

A test to check the behavior is also added.

@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

@RCasatta tried to fix the test failure.. But now its failing in some other tests.. Not the newly added one..
Any idea why only two tests failed?? Can't reproduce them in local..

@RCasatta

Copy link
Copy Markdown
Collaborator

Hi @raj, sorry for not having a look in a timely manner. I see there are multiple issues:

  1. you should drop 0c47bd7 and related merge commit since they are now on master
  2. one of the CI error (the one failing assert on amounts) is unfortunately some flakiness we have in a test that I have to examine better but for the time being I usually resolve by re-kicking (so don't bother if you see this)
  3. we can't really do 995e0f7 to fix the test, because test runs in parallel you cannot alter the global state. It should not be a big problem in this case, but I prefer not to. Please temporarily comment out the CI configuration line where we set TEMPDIR instead.

Once ready I will check again.

@rajarshimaitra
rajarshimaitra force-pushed the persistency-fix branch 2 times, most recently from 747b61a to d1aeecf Compare May 11, 2022 17:26
@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

Rebased on current master and cleared commit history.. Not really sure how those previous commits got added.. Removed the TEMPDIR_ROOT from CI env..

Comment thread .github/workflows/test.yml Resolved
Comment thread src/lib.rs
Comment on lines -307 to -310
client_base
.create_wallet("default", None, None, None, None)
.unwrap();
break Client::new(&node_url_default, Auth::CookieFile(cookie_file.clone()))

@RCasatta RCasatta May 12, 2022 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

did you consider a more "ask-for-forgiveness" approach? I suspect it would be shorter/cleaner

like matching on client_base.create_wallet("default", None, None, None, None) and in case of error doing the staticdir case checks

@rajarshimaitra rajarshimaitra May 12, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah.. I think that makes more sense and I probably took your simplification idea to extreme, 😅 and removed almost all of the code.. But I think the logic still stands and we don't necessarily need to find out the existing wallet file to try to load it up.. And yes its much simpler than what I was trying..

Comment thread src/lib.rs Resolved
@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

Thanks Ricardo for the suggestion.. Updated with the same.. Kept the commit separate for easier review.. Let me know if you need a squash..

@RCasatta

Copy link
Copy Markdown
Collaborator

00bc944 LGTM

yes, please squash since commits touch the same code, I will ack and merge

In case of persistent db, check if the "default" wallet file already
exists. Load it if it does. Or else create new wallet.

Always create new wallet for temp db.

Remove global temp env variable in CI.
@rajarshimaitra

Copy link
Copy Markdown
Contributor Author

Done..

@RCasatta

Copy link
Copy Markdown
Collaborator

Thanks!

ACK 2d5661d

@RCasatta
RCasatta merged commit 2d5661d into rust-bitcoin:master May 13, 2022
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