Commit graph

386 commits

Author SHA1 Message Date
Ross Nicoll ce564e381a Merge AuxPoW support from Namecore
Changes are as below:

Wrap CBlockHeader::nVersion into a new class (CBlockVersion).  This allows to take care of interpreting the field into a base version, auxpow flag and the chain ID.

Update getauxblock.py for new 'generate' RPC call.

Add 'auxpow' to block JSON.

Accept auxpow as PoW verification.

Add unit tests for auxpow verification.

Add check for memory-layout of CBlockVersion.

Weaken auxpow chain ID checks for the testnet.

Allow Params() to overrule when to check the auxpow chain ID and for legacy blocks.  Use this to disable the checks on testnet.

Introduce CPureBlockHeader.

Split the block header part that is used by auxpow and the "real" block header (that uses auxpow) to resolve the cyclic dependency between the two.

Differentiate between uint256 and arith_uint256.

This change was done upstream, modify the auxpow code.

Add missing lock in auxpow_tests.

Fix REST header check for auxpow headers.

Those can be longer, thus take that into account.  Also perform the check actually on an auxpow header.

Correctly set the coinbase for getauxblock results.

Call IncrementExtraNonce in getauxblock so that the coinbase is actually initialised with the stuff it should be.  (BIP30 block height and COINBASE_FLAGS.)

Implement getauxblock plus regression test.

Turn auxpow test into FIXTURE test.

This allows using of the Params() calls.

Move CMerkleTx code to auxpow.cpp.

Otherwise we get linker errors when building without wallet.

Fix rebase with BIP66.

Update the code to handle BIP66's nVersion=3.

Enforce that auxpow parent blocks have no auxpow block version.

This is for compatibility with namecoind.  See also https://github.com/namecoin/namecoin/pull/199.

Move auxpow-related parameters to Consensus::Params.
2019-07-13 22:25:22 +00:00
Ross Nicoll 9b494d566c Add Dogecoin block subsidy calculations. 2019-04-03 05:16:26 +00:00
Ross Nicoll 6d635e8914 Replace consensus values with Dogecoin equivalents
* Replace chain parameters with Dogecoin values
* Update maximum coins to match Dogecoin
* Disable version 2 block requirement
* Update coinbase maturity to match Dogecoin
2019-04-03 05:16:26 +00:00
Ross Nicoll 76a9aab2f4 Scrypt n=1024 PoW hash
Scrypt n=1024 PoW hash based upon Colin Percival's Tarnsnap (2009)

Modified by Artforz, coblee, pooler, wtogami, Nikolay Belikov, Adrian Gallagher, Ross Nicoll
2019-04-03 05:16:26 +00:00
Suhas Daftuar 833180f538 Fix crash bug with duplicate inputs within a transaction
Introduced by #9049
2018-09-17 16:14:31 -04:00
Wladimir J. van der Laan e7ea858729
Merge #13527: policy: Remove promiscuousmempoolflags
faa24441ec policy: Remove promiscuousmempoolflags (MarcoFalke)

Pull request description:

  It seems odd to clutter validation code with features that can only ever be used for testing (testnet or regtest). Removing that test-only code makes the mempool logic less painful to understand and easier to reason about when changed or refactored in the future.

Tree-SHA512: 3b897aa9604ac8d82ebe9573c6efd468c93ddaa08d378ebc902e247b7aa6c68fcde71e5b449c08f17a067146cdc66dc50a67ce06d07607c27e5189a49c3fba3f
2018-08-07 15:45:37 +02:00
practicalswift d78a8dc3e8 Return void instead of bool for functions that cannot fail
* CBlockTreeDB::ReadReindexing(...)
* CChainState::ResetBlockFailureFlags(...)
* CTxMemPool::addUnchecked(...)
* CWallet::LoadDestData(...)
* CWallet::LoadKeyMetadata(...)
* CWallet::LoadScriptMetadata(...)
* CWallet::LoadToWallet(...)
* CWallet::SetHDChain(...)
* CWallet::SetHDSeed(...)
* RemoveLocal(...)
* SetMinVersion(...)
* StartHTTPServer(...)
* StartRPC(...)
* TorControlConnection::Disconnect(...)
2018-07-27 13:19:03 +02:00
251 5f019d5354 Removes the boost/algorithm/string/join dependency
This commit removes the `boost/algorithm/string/join` dependency
from the project by replacing `boost::algorithm::join` with
a simple helper function.
2018-07-21 01:14:25 +02:00
Wladimir J. van der Laan 30640f8c2d
Merge #13680: [doc] Remove outdated comment about miner ignoring CPFP
db6eb90094 [doc] Remove outdated comment about mining code ignoring CPFP (James O'Beirne)

Pull request description:

  BlockAssembler chooses transactions on the basis of packages (which incorporate
  unconfirmed ancestors into feerate), so the specified RBF comment about mining
  code ignoring CPFP is out of date.

Tree-SHA512: a4c1e60fee0a8f450526d565951187f869d000febce0eea8a8d2e18bb140c3c1b8602953d9dcab2d1e8d0c4fc8d392c67eb0773d67e52080d48e6b9bf13f9ee2
2018-07-17 17:20:37 +02:00
James O'Beirne db6eb90094 [doc] Remove outdated comment about mining code ignoring CPFP
BlockAssembler chooses transactions on the basis of packages (which incorporate
unconfirmed ancestors into feerate), so the specified RBF comment about mining
code ignoring CPFP is out of date.
2018-07-16 18:34:28 -04:00
Pieter Wuille 9a1ad2c5cb
Merge #11658: During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after
ac51a26bdc During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after (Luke Dashjr)

Pull request description:

  Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.

  Alternative to #11359

Tree-SHA512: 631e4e8f94f5699e98a2eff07204aa2b3b2325b2d92e8236b8c8d6a6730737a346e0ad86024e705f5a665b25e873ab0970ce7396740328a437c060f99e9ba4d9
2018-07-13 20:16:41 -07:00
Wladimir J. van der Laan b641f60425
Merge #13481: doc: Rewrite some validation docs as lock annotations
fa324a8b15 doc: Rewrite some validation doc as lock annotations (MarcoFalke)

Pull request description:

  #13402 added some lock annotations in comments. This pull removes them and adds clang-readable locking annotations instead.

Tree-SHA512: 2d392efa8ac4978830a9df08b2009e69d6f1ac031f62be2275ae8d7c7e483331c7f8d458d865443af907a7af27a592421c6cca6b2df3f2877e0f369b9198f383
2018-07-09 21:53:48 +02:00
Wladimir J. van der Laan 79e677950b
Merge #13235: Break circular dependency: init -> * -> init by extracting shutdown.h
1fabd59e7 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley)
e62fdfeea Drop unused init.h includes (Ben Woosley)

Pull request description:

  Most includers just wanted to react to pending shutdown.

  This isolates access to `fRequestShutdown` and limits access to the shutdown api functions, including the new `CancelShutdown` for setting it to `false`.

Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
2018-07-04 15:34:03 +02:00
MarcoFalke 954f4a9c7c
Merge #13431: validation: count blocks correctly for check level < 3
f618ebc4e4 validation: count blocks correctly for check level < 3 (Karl-Johan Alm)

Pull request description:

  As noted in https://github.com/bitcoin/bitcoin/pull/13428#issuecomment-396129295 there is a bug where if check level < 3, the resulting count for blocks is wrong, because `pindexState` is never updated.

  Post-commit `./bitcoin-cli verifychain 1 3`:
  ```

  2018-06-11T07:12:28Z Verifying last 3 blocks at level 1
  2018-06-11T07:12:28Z [0%]...[33%]...[66%]...[99%]...[DONE].
  2018-06-11T07:12:28Z No coin database inconsistencies in last 3 blocks (0 transactions)
  ```

  Pre-commit `./bitcoin-cli verifychain 1 3`:
  ```
  2018-06-11T07:13:34Z Verifying last 3 blocks at level 1
  2018-06-11T07:13:34Z [0%]...[33%]...[66%]...[99%]...[DONE].
  2018-06-11T07:13:34Z No coin database inconsistencies in last 0 blocks (0 transactions)
  ```

Tree-SHA512: 3d82ed26665162c9615fb0e6e91a46ed4d229a5e6797c6c420e6b0bf1be6e5e02401c6e9a93b7a5aec503a2650d8c20d1b45fe300a922379e4cef8ee26e18d96
2018-06-30 22:07:32 -11:00
Ben Woosley 1fabd59e7e
Break circular dependency: init -> * -> init by extracting shutdown.h
Most includers just wanted to react to pending shutdown.

This isolates access to `fRequestShutdown` and limits access to the shutdown
api functions, including the new `AbortShutdown` for setting it to `false`.

Note I originally called `AbortShutdown` `CancelShutdown` but that name was
already taken by winuser.h
https://travis-ci.org/bitcoin/bitcoin/jobs/386913329

This change also triggered a build error in bench. Fixing it required moving LIBBITCOIN_SERVER after LIBBITCOIN_WALLET in bench_bench_bitcoin_LDADD To make
server definitions in src/net.cpp available to wallet methods in
src/wallet/wallet.cpp. Specifically, solving:

  libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)':
  wallet.cpp:(.text+0x3f0e): undefined reference to `CConnman::NodeFullyConnected(CNode const*)'
  collect2: error: ld returned 1 exit status

https://travis-ci.org/bitcoin/bitcoin/jobs/392133581

Need for remaining init.h includes confirmed via a thorough search with a more
specific regex:
  \bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
2018-06-25 00:08:49 -04:00
Wladimir J. van der Laan 31145a3d7c
Merge #13480: Avoid copies in range-for loops and add a warning to detect them
d92204c900 build: add warning to detect hidden copies in range-for loops (Cory Fields)
466e16e0e8 cleanup: avoid hidden copies in range-for loops (Cory Fields)

Pull request description:

  Following-up on #13241, which was itself a follow-up of #12169.

  See title. Fixing these would otherwise be a continuous process, adding the warning should keep them from cropping up.

  Note that the warning seems to be Clang-only for now.

Tree-SHA512: ccfb769c3128b3f92c95715abcf21ee2496fe2aa384f80efead1529a28eeb56b98995b531b49a089f8142601389e63f7bb935963d724eacde4f5e1b4a024934b
2018-06-24 16:36:40 +02:00
MarcoFalke faa24441ec
policy: Remove promiscuousmempoolflags 2018-06-23 17:02:52 -04:00
Jonas Schnelli 3f398d7a17
Merge #13439: rpc: Avoid "duplicate" return value for invalid submitblock
f74894480 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo)
fa6e49731 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke)

Pull request description:

  This is #13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes).

  Original description:

  When `submitblock` of an invalid block, the return value should not be `"duplicate"`.

  This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`.

Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
2018-06-19 09:25:17 +02:00
MarcoFalke fa324a8b15
doc: Rewrite some validation doc as lock annotations 2018-06-18 11:43:29 -04:00
Wladimir J. van der Laan ac3224c8ee
Merge #13412: Make ReceivedBlockTransactions return void
fafa270328 Make ReceivedBlockTransactions return void (MarcoFalke)

Pull request description:

  Instead of always returning `bool{true}` and forcing the caller to handle the return code, make it void and remove "a bunch" of dead code at the call sites.

Tree-SHA512: 10e41461c0516c0441d8b8eedcf6385874355c224b9e9d65e89addb142b4cf3e3be2d4ca0a7f2bd95c76aecdaa8537b6bd2d25631bf804bc42863ad5e84fa271
2018-06-18 17:18:55 +02:00
Cory Fields 466e16e0e8 cleanup: avoid hidden copies in range-for loops 2018-06-15 13:40:00 -04:00
MarcoFalke be27048a18
Merge #13241: scripted-diff: Avoid temporary copies when looping over std::map
9b72c988a0 scripted-diff: Avoid temporary copies when looping over std::map (Ben Woosley)

Pull request description:

  The ::value_type of the std::map/std::multimap/std::unordered_map containers is
  std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
  for example in C++11 range-based loops.

  For this I started with a more general scripted diff, then narrowed it down
  based on the inspection showing that all actual map/multimap/unordered_map
  variables used in loops start with m or have map in the name.

Tree-SHA512: b656d66b69ffa1eb954124aa8ae2bc5436ca50262abefa93bdda55cfcdaffc5ff90cd40539051a2bd06355ba69ddf245265cc8764eebff66d761b3aec06155a9
2018-06-15 12:32:39 -04:00
MarcoFalke 43fa3554b7
Merge #13402: Document validationinterace callback blocking deadlock potential.
25bc9615b7 Document validationinterace callback blocking deadlock potential. (Matt Corallo)

Pull request description:

  From the branches-I've-had-lying-around-and-forgot-to-PR department...

  This is a comment-only PR, but the comments point out an API quirk that isn't exactly trivial. None of our use-cases right now hit this, but if we were to call SyncWithValidationInterfaceQueue (eg to limit queue depth) in ATMP, I'm pretty sure we'd hit a deadlock there.

Tree-SHA512: 889dd8fc9eb15d1f2aa5ca467e783bc8f07bc543b166b032741795b0db7a0df11a2846d3cb7c69bafa8d1acf970021001b742f52be06725a932813230c5b4a7b
2018-06-15 09:58:26 -04:00
Karl-Johan Alm f618ebc4e4
validation: count blocks correctly for check level < 3 2018-06-15 13:27:18 +09:00
Wladimir J. van der Laan caabdea627
Merge #13428: validation: check the specified number of blocks (off-by-one)
f6f8026e40 validation: check the specified number of blocks (off-by-one) (Karl-Johan Alm)

Pull request description:

  ```
  echeveria | 2018-06-11 02:03:03.384975 Verifying last 3 blocks at level 3
  echeveria | 2018-06-11 02:03:23.676793 No coin database inconsistencies in last 4 blocks (6564 transactions)
  echeveria | off by one?
  sipa      | echeveria: possibly!
  kallewoof | Looks like it checks one more block than suggested. `if (pindex->nHeight < chainActive.Height()-nCheckDepth) break;` should probably be `<=`.
  sipa      | kallewoof: agree
  ```

  Post-commit:
  ```
  2018-06-11T05:24:02Z Verifying last 6 blocks at level 3
  2018-06-11T05:24:02Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
  2018-06-11T05:25:07Z No coin database inconsistencies in last 6 blocks (7258 transactions)
  ```

  Pre-commit:
  ```
  2018-06-11T05:27:11Z Verifying last 6 blocks at level 3
  2018-06-11T05:27:11Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
  2018-06-11T05:27:12Z No coin database inconsistencies in last 7 blocks (9832 transactions)
  ```

Tree-SHA512: 6e68dc4ba74232518c2ba8ea624d65893534f3619d43ccdf0b9c65992f25b68cb52cf54fa35e6e3d092d1eee5c9a8887057828895f1acdafc0ebb48f683fffdc
2018-06-13 15:42:32 +02:00
Matt Corallo f74894480d Only set fNewBlock to true in AcceptBlock when we write to disk
The only affect this should have is fixing the return code in
submitblock in cases where a block fails ContextualCheckBlock and
not setting nLastBlockTime on peers that provide blocks which fail
ContextualCheckBlock (which is only used in eviction and cosmetic).
2018-06-11 17:21:13 -04:00
Ben Woosley 9b72c988a0
scripted-diff: Avoid temporary copies when looping over std::map
The ::value_type of the std::map/std::multimap/std::unordered_map containers is
std::pair<const Key, T>. Dropping the const results in an unnecessary copy,
for example in C++11 range-based loops.

For this I started with a more general scripted diff, then narrowed it down
based on the inspection showing that all actual map/multimap/unordered_map
variables used in loops start with m or have map in the name.

-BEGIN VERIFY SCRIPT-
sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : m/for (\1std::pair<const \2\3 : m/' src/*.cpp src/**/*.cpp
sed -i -E 's/for \(([^<]*)std::pair<([^c])(.+) : (.*)map/for (\1std::pair<const \2\3 : \4map/' src/*.cpp src/**/*.cpp
-END VERIFY SCRIPT-
2018-06-11 13:12:55 -07:00
Karl-Johan Alm f6f8026e40
validation: check the specified number of blocks (off-by-one) 2018-06-11 14:16:51 +09:00
MarcoFalke fafa270328
Make ReceivedBlockTransactions return void 2018-06-07 21:43:21 -04:00
Matt Corallo 25bc9615b7 Document validationinterace callback blocking deadlock potential. 2018-06-05 16:41:25 -04:00
MarcoFalke fa7a6cf1b3
policy: Treat segwit as always active 2018-05-29 16:49:52 -04:00
Wladimir J. van der Laan 7f4db9a7c3
Merge #13151: net: Serve blocks directly from disk when possible
0bf431870e net: Serve blocks directly from disk when possible (Wladimir J. van der Laan)

Pull request description:

  In `ProcessGetBlockData`, send the block data directly from disk if type MSG_WITNESS_BLOCK is requested. This is a valid shortcut as the on-disk format matches the network format.

  This is expected to increase performance because a deserialization and subsequent serialization roundtrip is avoided.

Tree-SHA512: 9a9500b4c1354eaae1a6f1c6ef2416c1c1985029852589266f3a70e808f6c7482c135e9ab251a527566935378ab7c32dba4ed43ba5451e802d8e72b77d1ba472
2018-05-23 19:51:28 +02:00
Wladimir J. van der Laan 11e7bdfd90
Merge #13023: Fix some concurrency issues in ActivateBestChain()
dd435ad Add unit tests for signals generated by ProcessNewBlock() (Jesse Cohen)
a3ae8e6 Fix concurrency-related bugs in ActivateBestChain (Jesse Cohen)
ecc3c4a Do not unlock cs_main in ABC unless we've actually made progress. (Matt Corallo)

Pull request description:

  Originally this PR was just to add tests around concurrency in block validation - those tests seem to have uncovered another bug in ActivateBestChain - this now fixes that bug and adds tests.

  ActivateBestChain (invoked after a new block is validated) proceeds in steps - acquiring and releasing cs_main while incrementally disconnecting and connecting blocks to sync to the most work chain known (FindMostWorkChain()). Every time cs_main is released the result of FindMostWorkChain() can change - but currently that value is cached across acquisitions of cs_main and only refreshed when an invalid chain is explored. It needs to be refreshed every time cs_main is reacquired. The test added in 6094ce7304 will occasionally fail without the commit fixing this issue 26bfdbaddb

  Original description below
  --

  After a bug discovered where UpdatedBlockTip() notifications could be triggered out of order (#12978), these unit tests check certain invariants about these signals.

  The scheduler test asserts that a SingleThreadedSchedulerClient processes callbacks fully and sequentially.

  The block validation test generates a random chain and calls ProcessNewBlock from multiple threads at random and in parallel. ValidationInterface callbacks verify that the ordering of BlockConnected BlockDisconnected and UpdatedBlockTip events occur as expected.

Tree-SHA512: 4102423a03d2ea28580c7a70add8a6bdb22ef9e33b107c3aadef80d5af02644cdfaae516c44933924717599c81701e0b96fbf9cf38696e9e41372401a5ee1f3c
2018-05-16 18:30:35 +02:00
Wladimir J. van der Laan 0bf431870e net: Serve blocks directly from disk when possible
In `ProcessGetBlockData`, send the block data directly from disk if
type MSG_WITNESS_BLOCK is requested. This is a valid shortcut as the
on-disk format matches the network format.

This is expected to increase performance because a deserialization and
subsequent serialization roundtrip is avoided.
2018-05-15 08:11:56 +02:00
Pieter Wuille 418ae49ee1
Merge #13199: Bugfix: ensure consistency of m_failed_blocks after reconsiderblock
11fa6bb66e Bugfix: ensure consistency of m_failed_blocks after reconsiderblock (Suhas Daftuar)

Pull request description:

  This was introduced in 015a5258ad and could cause a node to crash (due to assertion failure) when using the `reconsiderblock` rpc.

Tree-SHA512: 820dcd761bf983e36f5d0f16777ed75c833daaf62a6b3a4dbd17f6caaf9287223e3a202d06540ac62f8ba72926b73b0873bb76c6273ddcb19d9408f4c1cd325e
2018-05-12 11:32:09 -07:00
Jesse Cohen a3ae8e6873 Fix concurrency-related bugs in ActivateBestChain
If multiple threads are invoking ActivateBestChain, it was possible to have
them working towards different tips, and we could arrive at a less work tip
than we should.  Fix this by introducing a ChainState lock which must
be held for the entire duration of ActivateBestChain to enforce
exclusion in ABC.
2018-05-12 12:44:32 -04:00
Matt Corallo ecc3c4a019 Do not unlock cs_main in ABC unless we've actually made progress.
Technically, some internal datastructures may be in an inconsistent
state if we do this, though there are no known bugs there. Still,
for future safety, its much better to only unlock cs_main if we've
made progress (not just tried a reorg which may make progress).
2018-05-12 12:44:32 -04:00
Wladimir J. van der Laan 6af005c3eb
Merge #11423: [Policy] Several transaction standardness rules
364bae5 qa: Pad scriptPubKeys to get minimum sized txs (MarcoFalke)
7485488 Policy to reject extremely small transactions (Johnson Lau)
0f8719b Add transaction tests for constant scriptCode (Johnson Lau)
9dabfe4 Add constant scriptCode policy in non-segwit scripts (Johnson Lau)

Pull request description:

  This disables `OP_CODESEPARATOR` in non-segwit scripts (even in an unexecuted branch), and makes a positive `FindAndDelete` result invalid. This ensures that the `scriptCode` serialized in `SignatureHash` is always the same as the script passing to the `EvalScript`.

Tree-SHA512: a0552cb920294d130251c48053fa2ff1fbdd26332e62b52147d918837852750f0ce35ce2cd1cbdb86588943312f8154ccb4925e850dbb7c2254bc353070cd5f8
2018-05-12 17:39:46 +02:00
Suhas Daftuar 11fa6bb66e Bugfix: ensure consistency of m_failed_blocks after reconsiderblock 2018-05-09 10:40:33 -04:00
Pieter Wuille a2f678d355 Bugfix: the end of a reorged chain is invalid when connect fails
Introduced in 4e0eed88ac

When an invalid block is found during a reorg, we know the last of the blocks in
the was-to-be-connected chain is invalid, but not necessarily the first. As
vpIndexToConnect is ordered in decreasing height, the end of the reorg is the
front of the vector, and not the back.

This only affected the warning system.
2018-05-07 11:18:30 -07:00
Johnson Lau 7485488e90 Policy to reject extremely small transactions
A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes. Anything smaller than this have unnecessary malloc overhead and are not relayed/mined.
2018-05-05 04:26:13 +08:00
practicalswift c3f34d06be Make it clear which functions that are intended to be translation unit local
Do not share functions that are meant to be translation unit local with
other translation units. Use internal linkage for those consistently.
2018-05-03 21:47:40 +02:00
Matt Corallo 9cb6cdc59f Simplify semantics of ChainStateFlushed callback
Previously, ChainStateFlushed would fire either if a full flush
completed (which can happen due to memory limits, forced flush, or
on its own DATABASE_WRITE_INTERVAL timer) *or* on a
ChainStateFlushed-specific DATABASE_WRITE_INTERVAL timer. This is
both less clear for clients (as there are no guarantees about a
flush having actually happened prior to the call), and reults in
extra flushes not clearly intended by the code. We drop the second
case, providing a strong guarantee without removing the periodit
timer-based flushing.
2018-04-27 14:44:56 -04:00
Matt Corallo 50b6533aa2 scripted-diff: Rename SetBestChain callback ChainStateFlushed
This much more accurately captures the meaning of the callback.

-BEGIN VERIFY SCRIPT-
sed -i 's/SetBestChain/ChainStateFlushed/g' src/validationinterface.h src/validationinterface.cpp src/wallet/wallet.h src/wallet/wallet.cpp src/validation.cpp src/index/txindex.h src/index/txindex.cpp
-END VERIFY SCRIPT-
2018-04-27 14:44:22 -04:00
Jim Posen a03f804f2a [index] Move disk IO logic from GetTransaction to TxIndex::FindTx. 2018-04-25 11:25:15 -07:00
Jim Posen e0a3b80033 [validation] Replace tx index code in validation code with TxIndex. 2018-04-25 11:25:13 -07:00
Wladimir J. van der Laan 34dd1a6d5e
Merge #13032: Output values for "min relay fee not met" error
1accfbc Output values for "min relay fee not met" error (Kristaps Kaupe)

Pull request description:

  It is already done this way for "mempool min fee not met" error.

Tree-SHA512: 829db78ecc066cf93b8e93ff1aeb4e7b98883cf45f341d5be6e6b4dff4135f3f54fa49b3a6f12eb43f676a9ba54f981143c9887f786881e584370434a9566cfd
2018-04-24 11:12:16 +02:00
Wladimir J. van der Laan d1e3c5e73c
Merge #13012: [doc] Add comments for chainparams.h, validation.cpp
18326ae [doc] Add comments for chainparams.h, validation.cpp (James O'Beirne)

Pull request description:

  Added a few comments during a leisurely read through some of the validation code. If this kind of thing seems useful, I can add similar documentation for most of the `CChainState` interface.

Tree-SHA512: a4d9db60383a8ff02e74ac326ed88902eec1ee441e8cd4e1845bcf257072673c15974225288cebf0a633e76a3410f99e2206616b4694725a2a5b0d19c78327d6
2018-04-23 17:15:33 +02:00
Wladimir J. van der Laan 4741ca5dc8
Merge #13020: Consistently log CValidationState on call failure
e4d0b44 Consistently log CValidationState on failure (Ben Woosley)

Pull request description:

  This replaces potential silent failures and partial logging with full logging. Seems providing at least minimal visibility to the failure is a good practice. E.g. `FlushStateToDisk` can return a rare but meaningful out of disk space error that would be better to note than leave out.

  Note many of these are related to `ActivateBestChain` or `FlushStateToDisk`. Only a few cases of ignored state remain, e.g. LoadExternalBlockFile and RelayWalletTransaction, where I expect logging would likely be spammy.

Tree-SHA512: fb0e521039e5a5250cd9c82e7a8676423b5e3899d495649c0e71752059d1984e5175f556386ade048f51a7d59f5c8e467df7fe91d746076f97d24c000ccf7891
2018-04-23 14:37:45 +02:00
Wladimir J. van der Laan 8b4081a889
Merge #13039: Add logging and error handling for file syncing
cf02779 Add logging and error handling for file syncing (Wladimir J. van der Laan)

Pull request description:

  Add logging and error handling inside, and outside of FileCommit.
  Functions such as fsync, fdatasync will return error in case of hardware I/O errors, and ignoring this means it can silently continue through data corruption.
  (c.f. https://lwn.net/SubscriberLink/752063/12b232ab5039efbe/)

  EINVAL is handled specially to avoid crashing out on (network, fuse) filesystems that don't handle `f[data]sync`.

  I checked that the syncing inside leveldb is already generating an I/O error as appropriate.

Tree-SHA512: 64cc9bbedca3ecc97ff4bac0a7b7ac6526a7ed763c66f6786d03ca4f2e9e366e42b152cb908299c060448d98ca39ff03395280bffaca51d592e728aa2516f5dd
2018-04-23 14:30:26 +02:00