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

Feature/wallet backup auto #10

Merged
merged 8 commits into from Oct 15, 2016

Conversation

marlengit
Copy link
Contributor

@marlengit marlengit commented Oct 10, 2016

This is the auto wallet backup feature. There are 2 command line parameters to enable the feature:
-autobackupwalletpath=/mybackupfolder
-autobackupblock=1234

The autobackupwalletpath may be a directory or file name. A hash character (#) in the string will be replaced with the block number specified. If the path is a directory then the default filename will be used which is the existing wallet file name with suffix ".auto.#.bak".

The autobackupblock number is optional and will default to the MVHF fork block. At the moment this is hard coded and so this section will need to be updated when the hard fork is better defined. Beyond the hard fork users could use this parameter to perform an auto backup at any future block number.

If used with -disablewallet the feature is non-functional and outputs a conflict message to debug.log.

There is a regtest that can be run for this feature : qa/pull-tester/rpc-tests.py walletbackupauto

Copy link
Contributor

@ftrader ftrader left a comment

Choose a reason for hiding this comment

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

compiled and tested ok on my machine, just a few rough edges w.r.t. to current req+design. Nothing major though.

I'll summarise:

  • the backup block parameter (autobackupblock) is currently not required, so we need to at least extend the SW-REQs. Please add a new SW-REQ-10-6 (similar to SW-REQ-10-1 but for the backup block) and add a related description in design section 5.5.1 (Configuration for wallet backup). We don't need a separate design section. The alternative would be to drop the functionality, but since it's very useful for testing, I suggest we keep it.
  • the handling of autobackupwalletpath is not yet completely covering the design. We can simplify the design (modify design.md and test-design docs), or implement and test it.
  • extracting the 114 block and testing just prior to hitting it should really be done, especially because the semantics of the parameter are quite important to verify.
  • missing conflict msg at startup (where other parameter conflicts are usually identified, to give the user a heads up to fix his parameter problems)
  • missing test case for safe shutdown if backup file cannot be written (suggest to have a node configured to write its backup to a temp directory which has been made read-only, then check that it shut down after passing the backup block height. Would need to restart it in some disconnected form to check that its wallet is pre-fork)

@@ -97,6 +98,7 @@
'fundrawtransaction.py',
'signrawtransactions.py',
'walletbackup.py',
'walletbackupauto.py', #MVHF-BU
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer a space between comment symbol and comment, for better readability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to next commit

@@ -230,6 +231,10 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
# RPC tests still depend on free transactions
args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-blockprioritysize=50000" ]
if extra_args is not None: args.extend(extra_args)
if os.getenv("PYTHON_DEBUG", ""):
Copy link
Contributor

Choose a reason for hiding this comment

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

debug traces left over, unmarked - i suppose they do not need to be retained.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are useful to retain. The PYTHON_DEBUG environment variable has already been established in the test framework. Debug outputs only appear when the variable is set. In this case I have extended it to output the command line parameters of nodes. I think others will also find this useful.

@@ -260,6 +265,16 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
def log_filename(dirname, n_node, logname):
return os.path.join(dirname, "node"+str(n_node), "regtest", logname)

#MVHF-BU
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to next commit

@@ -260,6 +265,16 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None):
def log_filename(dirname, n_node, logname):
return os.path.join(dirname, "node"+str(n_node), "regtest", logname)

#MVHF-BU
def search_file(searchfilepath, searchtext):
Copy link
Contributor

@ftrader ftrader Oct 10, 2016

Choose a reason for hiding this comment

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

would be nice to have docstrings for new functions added in code, to explain briefly what they do & return
https://www.python.org/dev/peps/pep-0257/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to next commit

Exercise the auto backup wallet code. Ported from walletbackup.sh.

Test case is:
4 nodes. 1 2 and 3 send transactions between each other, fourth node is a miner
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct first sentence : there are 5 nodes in this test...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to next commit

g_signals.SyncTransaction.disconnect_all_slots();
g_signals.UpdatedBlockTip.disconnect_all_slots();
}


Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank line - pls remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to next commit

boost::filesystem::path pathBackupWallet = strDest;

// Test for directory only, if so add default filename
if (boost::filesystem::is_directory(strDest))
Copy link
Contributor

@ftrader ftrader Oct 10, 2016

Choose a reason for hiding this comment

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

check with MVHF-BU-DES-WABU-2 and https://github.com/BTCfork/hardfork_prototype_1_mvf-bu/blob/master/doc/mvf-bu-test-design.md#411-sw-req-10-1

some more handling is needed here e.g. if it's not a path, but only a filename

also, please check indentation in this newly added method, it looks a little inconsistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated BackupWalletAuto function to handle the 4 variants listed in the test design steps.
The testing was updated to test the 4 variants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also found out that a hash # character will end the line when using GetArg so now the special block number replace character is @ instead.

@@ -28,6 +29,7 @@

#include <boost/shared_ptr.hpp>


Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank line introduced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -405,6 +407,8 @@ class CWalletTx : public CMerkleTx
bool RelayWalletTransaction();

std::set<uint256> GetConflicts() const;

Copy link
Contributor

Choose a reason for hiding this comment

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

extra blank lines introduced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to next commit

@@ -571,6 +575,9 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface

const CWalletTx* GetWalletTx(const uint256& hash) const;

// MVHF-BU
Copy link
Contributor

Choose a reason for hiding this comment

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

this new method should trace to what is now section 5.5.3 (Procedure to create the wallet file backup) in the design.md.

We need to add design elements to 5.5.2 and 5.5.3 , and then trace them here.

Don't worry about this now, I'm just noting it for later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made updates to 5.5.2 and created a pull request in the doc repo

Copy link
Contributor

Choose a reason for hiding this comment

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

merged

@ftrader ftrader merged commit ea17019 into BTCfork:master Oct 15, 2016
@marlengit marlengit deleted the feature/wallet_backup_auto branch October 27, 2016 18:15
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.

None yet

2 participants