Commit graph

86 commits

Author SHA1 Message Date
Jonas Schnelli 542ce6e246
Report [CANCELLED] instead of [DONE] when shut down during txdb upgrade 2017-06-29 17:48:13 +02:00
Jonas Schnelli 83fbea3f25
Report txdb upgrade not more often then every 10% 2017-06-29 17:48:13 +02:00
Jonas Schnelli 06c5b6edd3
Show txdb upgrade progress in debug log 2017-06-29 17:48:12 +02:00
Jonas Schnelli 316fcb5106
Allow to cancel the txdb upgrade via splashscreen callback 2017-06-29 17:48:12 +02:00
Jonas Schnelli ae09d4583b
Allow to shut down during txdb upgrade 2017-06-29 17:48:11 +02:00
Suhas Daftuar 176c021d08 [qa] Test non-atomic chainstate writes
Adds new functional test, dbcrash.py, which uses -dbcrashratio to exercise the
logic for recovering from a crash during chainstate flush.

dbcrash.py is added to the extended tests, as it may take ~10 minutes to run

Use _Exit() instead of exit() for crash simulation

This eliminates stderr output such as:
    terminate called without an active exception
or
    Assertion failed: (!pthread_mutex_destroy(&m)), function ~recursive_mutex, file /usr/local/include/boost/thread/pthread/recursive_mutex.hpp, line 104.

Eliminating the stderr output on crash simulation allows testing with
test_runner.py, which reports a test as failed if stderr is produced.
2017-06-26 14:48:42 -07:00
Matt Corallo d6af06d68a Dont create pcoinsTip until after ReplayBlocks.
This requires that we not access pcoinsTip in InitBlockIndex's
FlushStateToDisk (so we just skip it until later in AppInitMain)
and the LoadChainTip in LoadBlockIndex (which there is already one
later in AppinitMain, after ReplayBlocks, so skipping it there is
fine).

Includes some simplifications by Suhas Daftuar and Pieter Wuille.
2017-06-26 10:46:51 -07:00
Pieter Wuille eaca1b7b08 Random db flush crash simulator 2017-06-26 10:46:51 -07:00
Pieter Wuille 013a56aa1a Non-atomic flushing using the blockchain as replay journal 2017-06-26 10:45:48 -07:00
Wladimir J. van der Laan d609fd85ca
Merge #9176: Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts()
b324b28 Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts() (Jorge Timón)

Tree-SHA512: 9ef561a026960dc69df52603f4d60246c913bdd127465e8238f0954c6bbbc6b8b3b039bab70df38be1cbf5d06788fb631a2236b49c0167633d54366103c7c055
2017-06-25 10:26:01 +02:00
Pieter Wuille 589827975f scripted-diff: various renames for per-utxo consistency
Thanks to John Newberry for pointing these out.

-BEGIN VERIFY SCRIPT-
sed -i 's/\<GetCoins\>/GetCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<HaveCoins\>/HaveCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<HaveCoinsInCache\>/HaveCoinInCache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<IsPruned\>/IsSpent/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<FetchCoins\>/FetchCoin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<CoinsEntry\>/CoinEntry/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<vHashTxnToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<vHashTxToUncache\>/coins_to_uncache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<fHadTxInCache\>/had_coin_in_cache/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<coinbaseids\>/coinbase_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<disconnectedids\>/disconnected_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<duplicateids\>/duplicate_coins/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
sed -i 's/\<oldcoins\>/old_coin/g' src/test/coins_tests.cpp
sed -i 's/\<origcoins\>/orig_coin/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h
-END VERIFY SCRIPT-
2017-06-01 13:15:25 -07:00
Pieter Wuille 73de2c1ff3 Rename CCoinsCacheEntry::coins to coin 2017-06-01 13:15:25 -07:00
Pieter Wuille 580b023092 [MOVEONLY] Move old CCoins class to txdb.cpp
It's only used for upgrading from the old database anymore.
2017-06-01 13:15:25 -07:00
Pieter Wuille 8b25d2c0ce Upgrade from per-tx database to per-txout 2017-06-01 13:15:24 -07:00
Pieter Wuille 5083079688 Switch CCoinsView and chainstate db from per-txid to per-txout
This patch makes several related changes:
* Changes the CCoinsView virtual methods (GetCoins, HaveCoins, ...)
  to be COutPoint/Coin-based rather than txid/CCoins-based.
* Changes the chainstate db to a new incompatible format that is also
  COutPoint/Coin based.
* Implements reconstruction code for hash_serialized_2.
* Adapts the coins_tests unit tests (thanks to Russell Yanofsky).

A side effect of the new CCoinsView model is that we can no longer
use the (unreliable) test for transaction outputs in the UTXO set
to determine whether we already have a particular transaction.
2017-06-01 12:59:38 -07:00
Pieter Wuille c3aa0c1194 Report on-disk size in gettxoutsetinfo 2017-05-26 13:33:39 -07:00
Pieter Wuille 822755a424 Fix: make CCoinsViewDbCursor::Seek work for missing keys
Thanks to Suhas Daftuar for figuring this out.
2017-05-23 22:25:52 +00:00
Jorge Timón b324b28209
Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts() 2017-05-18 22:23:10 +02:00
practicalswift 1b936f5926 Replace boost::function with std::function (C++11) 2017-05-13 17:59:09 +02:00
Gregory Maxwell 6b3bb3d9ba Change LogAcceptCategory to use uint32_t rather than sets of strings.
This changes the logging categories to boolean flags instead of strings.

This simplifies the acceptance testing by avoiding accessing a scoped
 static thread local pointer to a thread local set of strings.  It
 eliminates the only use of boost::thread_specific_ptr outside of
 lockorder debugging.

This change allows log entries to be directed to multiple categories
 and makes it easy to change the logging flags at runtime (e.g. via
 an RPC, though that isn't done by this commit.)

It also eliminates the fDebug global.

Configuration of unknown logging categories now produces a warning.
2017-04-01 18:53:29 +00:00
Karl-Johan Alm b7b48c8bbd Refactor: Remove using namespace <xxx> from src/*.cpp. 2017-01-27 18:13:20 +09:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Jorge Timón cdd79eb70f C++11: s/boost::scoped_ptr/std::unique_ptr/ 2016-09-01 19:05:07 +02:00
Wladimir J. van der Laan efee32f381
Merge #7815: Break circular dependency main ↔ txdb
99e7075 Break circular dependency main ↔ txdb (Wladimir J. van der Laan)
2016-05-06 10:03:09 +02:00
Wladimir J. van der Laan b69836d6ff dbwrapper: Pass parent CDBWrapper into CDBBatch and CDBIterator
Pass parent wrapper directly instead of obfuscation key. This
makes it possible for other databases which re-use this code
to use other properties from the database.

Add a namespace dbwrapper_private for private functions to be used
only in dbwrapper.h/cpp and dbwrapper_tests.
2016-04-23 09:32:25 +02:00
Wladimir J. van der Laan a3310b4d48 txdb: Fix assert crash in new UTXO set cursor
Remove the mistaken assumption that GetKey returning false signifies
an internal database issue. It will return false when the key cannot
be deserialized into the (char,uint256) stanza, which indicates
that the cursor has reached a different kind of key.

Fixes bug #7890 introduced in #7756.
2016-04-18 12:05:32 +02:00
Wladimir J. van der Laan 99e70751f2 Break circular dependency main ↔ txdb
Break the circular dependency between main and txdb by:

- Moving `CBlockFileInfo` from `main.h` to `chain.h`. I think this makes
  sense, as the other block-file stuff is there too.

- Moving `CDiskTxPos` from `main.h` to `txdb.h`. This type seems
  specific to txdb.

- Pass a functor `insertBlockIndex` to `LoadBlockIndexGuts`. This leaves
  it up to the caller how to insert block indices.
2016-04-15 17:48:38 +02:00
Wladimir J. van der Laan 509cb006d5 txdb: Add Cursor() method to CCoinsView to iterate over UTXO set
Add a method Cursor() to CCoinsView that returns a cursor which can be
used to iterate over the whole UTXO set.

- rpc: Change gettxoutsetinfo to use new Cursor method

- txdb: Remove GetStats method - Now that GetStats is implemented in
  terms of Cursor, remove it.
2016-04-15 16:33:05 +02:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Pieter Wuille 298e040bca Fix chainstate serialized_size computation 2015-10-28 01:05:32 +01:00
Jeff Garzik 8587b23038 leveldbwrapper symbol rename: Remove "Level" from class, etc. names 2015-10-22 21:02:20 -04:00
Daniel Kraft f8f2aceadd trivial: use constants for db keys
Replace literal occurances of the key "prefixes" 'c' and 'b' in txdb.cpp
by the respective constants.
2015-10-13 20:25:57 +02:00
James O'Beirne dcd8e27c65 Refer to obfuscate_key via pointer in peripheral CLevelDB classes
cc @sipa
2015-10-09 10:56:48 -07:00
James O'Beirne 0fdf8c80ee Handle obfuscation in CLevelDBIterator 2015-10-08 09:32:27 -07:00
Pieter Wuille 3499ce1e1a Encapsulate CLevelDB iterators cleanly
Conflicts:
	src/leveldb.cpp
	src/leveldb.h
	src/txdb.cpp
2015-10-08 09:32:27 -07:00
James O'Beirne 42cb388167 Add chainstate obfuscation to avoid spurious antivirus detection
Adds an `obfuscate` parameter to `CLevelDBWrapper` and makes use of it
for all new chainstate stores built via `CCoinsViewDB`. Also adds an
`Xor` method to `CDataStream`.

Thanks to @sipa @laanwj @pstratem @dexX7 @KyrosKrane @gmaxwell.
2015-10-06 07:46:10 -07:00
Jorge Timón 9dd793f499 TRIVIAL: Missing includes 2015-07-23 21:10:22 +02:00
Wladimir J. van der Laan 57092ed9e7 rpc: make gettxoutsettinfo run lock-free
For leveldb "An iterator operates on a snapshot of the database taken
when the iterator is created". This means that it is unnecessary to
lock out other threads while computing statistics, and neither to hold
cs_main for the whole time. Let the thread run free.
2015-06-16 13:50:38 +02:00
Jorge Timón d698ef690f Consensus: Refactor: Decouple pow.o from chainparams.o 2015-03-26 00:47:51 +01:00
Jorge Timón 8a893c949b Includes: Do not include main.h from any other header 2015-03-24 17:23:32 +01:00
Pavel Janík 5262fde0ec Remove whitespaces before double colon in errors and logs 2015-01-31 17:38:28 -05:00
Earlz 14d023f1ae change hardcoded character constants to a set of descriptive named constants for database keys 2015-01-25 10:56:30 -05:00
Wladimir J. van der Laan 4f1524966a Replace direct use of 0 with SetNull and IsNull
Replace x=0 with .SetNull(),
x==0 with IsNull(), x!=0 with !IsNull().
Replace uses of uint256(0) with uint256().
2015-01-05 15:45:34 +01:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Wladimir J. van der Laan 111a7d45f1
Merge pull request #5470
78253fc Remove references to X11 licence (Michael Ford)
2014-12-19 19:23:23 +01:00
Philip Kaufmann 27df4123c4 make all catch() arguments const
- I saw this on http://en.cppreference.com/w/cpp/language/try_catch and
  thought it would be a good idea
- also unify used format to better be able to search for exception
  uses in our codebase
2014-12-17 09:39:24 +01:00
Michael Ford 78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Pieter Wuille 63d1ae5556 Do all block index writes in a batch 2014-11-25 16:26:35 +01:00
jtimon 4a3587d8db MOVEONLY: Separate CTransaction and dependencies from core 2014-10-27 13:54:37 +01:00
Wladimir J. van der Laan 33dfbf57d3
rpc: Fix leveldb iterator leak, and flush before gettxoutsetinfo
This fixes an iterator leak resulting in

    bitcoind: db/version_set.cc:789: leveldb::VersionSet::~VersionSet(): Assertion `dummy_versions_.next_ == &dummy_versions_' failed."

exception on shutdown.

Also make sure to flush pcoinsTip before calling GetStats() to make
sure we apply them to the current height.
2014-10-21 16:16:55 +02:00