aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-08-11Merge pull request #948Riccardo Spagni3-9/+28
11dc091 Fake outs set is now decided by the wallet (moneromooo-monero) 1593553 new unlocked parameter to output_histogram (moneromooo-monero)
2016-08-10db_lmdb: errors dropping hf starting height db on reset are not fatalmoneromooo-monero1-2/+1
This db is now dropped unconditionally, so may or may not be there in the first place.
2016-08-01new unlocked parameter to output_histogrammoneromooo-monero3-9/+28
This constrains the number of instances of any amount to the unlocked ones (as defined by the default unlock time setting: outputs with non default unlock time are not considered, so may be counted as unlocked even if they are not actually unlocked).
2016-07-26db_lmdb: add some missing api call checksmoneromooo-monero1-14/+31
2016-07-13remove hf_starting_height dbmoneromooo-monero5-127/+2
It's not really needed, it used to be an optimization for when that code was not using the db and needed to recalculate things fast on startup.
2016-04-29Merge branch 'performance' of https://github.com/LMDB/bitmoneroRiccardo Spagni4-761/+1210
2016-04-28add a --max-concurrency flagmoneromooo-monero1-1/+1
It sets the max number of threads to use for a parallel job. This is different that the number of total threads, since monero binaries typically start a lot of them.
2016-04-24Another take on migrationHoward Chu2-582/+106
Delete old indices and recreate them, rather than updating them Maybe not quite as slow as before.
2016-04-08MigrationHoward Chu2-5/+1049
Migrate from DB version 0 to version 1 on startup
2016-04-05Merge branch 'performance' into masterHoward Chu4-747/+628
2016-04-05CleanupHoward Chu3-24/+65
drop obsolete remove_output() fix get_output_key(global), fix crash in blockchain_dump
2016-04-05Cleanup and clarifyHoward Chu4-146/+129
Try to rationalize the variable names, document usage.
2016-04-05Use cursors in some remove functionsHoward Chu1-7/+33
Helps when they're called repeatedly in one txn
2016-04-05Use DUPFIXED for block_info and output_txsHoward Chu2-56/+46
Saves another ~150MB or so on the full blockchain
2016-04-05More outputs consolidationHoward Chu2-491/+263
Also bumped DB VERSION to 1 Another significant speedup and space savings: Get rid of global_output_indices, remove indirection from output to keys This is the change warptangent described on irc but never got to finish.
2016-04-05Use DUPFIXED for output_keysHoward Chu1-23/+37
Saves another 90MB on 200000 block import. Had to bring back compare_uint64 for this, but it's safe since this table is always 64-bit aligned.
2016-04-05Use DUPFIXED for tx_indicesHoward Chu1-50/+60
Small space savings, no measurable speedup
2016-04-05Use DUPFIXED for block_heightsHoward Chu1-22/+29
Only a small savings...
2016-04-05Use DUPFIXED for spent_keysHoward Chu1-23/+18
2016-04-05Add back changes from revert.warptangent1-19/+2
m_tx_outputs doesn't need to be changed, as it's no longer dup list.
2016-04-05Use MDB_APPEND mode with two tx subdbswarptangent1-2/+2
This is possible on those using a tx index as a key.
2016-04-05Schema update: tx_indices - consolidate the tx subdbs from 5 to 3warptangent3-75/+56
2016-04-05Schema update: tx_indices - yet less indirectionwarptangent4-20/+15
2016-04-05Schema update: tx_indices - improve further with less indirectionwarptangent3-19/+53
2016-04-05Add batch warning for further reviewwarptangent1-0/+4
2016-04-05Schema update: tx_indiceswarptangent2-32/+109
2016-04-05Consolidated block infoHoward Chu2-95/+63
2016-04-05Update schema for "tx_outputs" to use array containing amount output indiceswarptangent4-119/+131
This speeds up wallet refresh by directly retrieving a tx's amount output indices. It removes the indirection and walking the amount output duplicate list for every amount in each requested tx. "tx_outputs" is used by: Amount output indices are needed for wallet refresh. Global output indices are needed for removing a tx. Both amount output indices and global output indices are now stored in an array of 64-bit unsigned ints: tx_outputs[<tx_hash>] -> [ <a1_oi, a1_gi, a2_oi, a2_gi, ...> ] Previously it was: tx_outputs[<tx_hash>] -> duplicate list of <a1_gi, a2_gi, a3_gi, ...> The amount output list had to be walked for every amount in order to find each amount's output index, by comparing the amount's global output index with each one in the duplicate list until a match was found. See also d045dfa7ce0bf131681193c97560da26f9f37900
2016-03-30Detect map resize failuresHoward Chu1-1/+3
2016-03-26New RPC and daemon command to get output histogrammoneromooo-monero5-0/+91
This is a list of existing output amounts along with the number of outputs of that amount in the blockchain. The daemon command takes: - no parameters: all outputs with at least 3 instances - one parameter: all outputs with at least that many instances - two parameters: all outputs within that many instances The default starts at 3 to avoid massive spamming of all dust outputs in the blockchain, and is the current minimum mixin requirement. An optional vector of amounts may be passed, to request histogram only for those outputs.
2016-03-25Merge pull request #749Riccardo Spagni1-155/+937
bfd4a28 Update BlockchainDB documentation (Thomas Winget) 797357e Change Doxyfile, Blockchain not blockchain_storage (Thomas Winget) c835215 remove defunct code from cryptonote::core (Thomas Winget) 50dba6d cryptonote::core doxygen documentation (Thomas Winget) 8ac329d doxygen documentation for difficulty functions (Thomas Winget) 540a76c Move checkpoint functions into checkpoints class (Thomas Winget) 1b0c98e doxygen documentation for checkpoints.{h,cpp} (Thomas Winget) 89c24ac Remove unnecessary or defunct code (Thomas Winget) ab0ed14 doxygen include private and static members (Thomas Winget) 3a48449 Updated documentation for blockchain.* (Thomas Winget)
2016-03-25Revert "Merge pull request #749"Riccardo Spagni1-937/+155
This reverts commit 7fa63a82a1c3a0243f6757c1689855ed3ca61695, reversing changes made to cb6be986c36b78eddb4b7f16e9ad440af8567dc4.
2016-03-24Update BlockchainDB documentationThomas Winget1-155/+937
BlockchainDB is now Doxygen-compliant and its documentation is up-to-date with recent changes.
2016-03-21Revert "Print stack trace upon exceptions"moneromooo-monero1-2/+1
Ain't nobody got time for link/cmake skullduggery. This reverts commit fff238ec94ac6d45fc18c315d7bc590ddfaad63d.
2016-03-20Merge pull request #738Riccardo Spagni1-40/+47
79117d4 db_lmdb: include the error codes from lmdb api in error logs (moneromooo-monero)
2016-03-20db_lmdb: include the error codes from lmdb api in error logsmoneromooo-monero1-40/+47
2016-03-19Print stack trace upon exceptionsmoneromooo-monero1-1/+2
Useful for debugging users' logs
2016-03-19Reduce log noiseHoward Chu1-2/+3
2016-03-16Add destructor for readtxnsHoward Chu2-10/+21
Only if we created the readtxn. Was missing cleanups from exceptions before.
2016-03-15Small cleanupsHoward Chu1-24/+28
Only one return and TXN_POSTFIX_RDONLY() per function Only log rtxn_start if the rtxn wasn't already active
2016-03-15More for 92dd4ec6d6251b15954002e72a7c7faa5059a3abHoward Chu1-22/+22
Make sure we stop the right txn too
2016-03-14Merge pull request #723Riccardo Spagni2-21/+21
2abdb2c avoid some val copies (Howard Chu)
2016-03-14Hack for read/write txn mixupHoward Chu2-42/+31
save the thread ID of the writer thread so we don't try to use the writetxn from reader threads
2016-03-14avoid some val copiesHoward Chu2-21/+21
2016-03-11Merge pull request #712Riccardo Spagni3-5/+6
66c2fc7 Need to link boost::chrono in more places now (Howard Chu) b937a2c Use boost::thread instead of std::thread (Howard Chu)
2016-03-11Need to link boost::chrono in more places nowHoward Chu1-0/+1
2016-03-11Use boost::thread instead of std::threadHoward Chu2-5/+5
and all other associated IPC
2016-03-09More for bdec7cbHoward Chu1-14/+14
More uses of db error helper
2016-03-05Merge pull request #700Riccardo Spagni1-33/+34
bdec7cb BlockchainLMDB: Use DB error helper consistently (warptangent) c5932eb BlockchainLMDB: Add DB error to exception (warptangent) a49c355 Blockchain: Omit verbose time stats messages by default (warptangent)
2016-03-05Merge pull request #698Riccardo Spagni1-57/+14
ee7a8b8 Get rid of lmdb_cur (Howard Chu)
2016-03-03BlockchainLMDB: Use DB error helper consistentlywarptangent1-28/+27
2016-03-03BlockchainLMDB: Add DB error to exceptionwarptangent1-5/+7
2016-03-03Get rid of lmdb_curHoward Chu1-57/+14
We don't need it now with per-txn cursors.
2016-03-03More for df239428c0f43e2664f2be273996a734ca12c686Howard Chu1-0/+6
Let ARMv7 work again
2016-03-01Make partial revert consistentwarptangent1-1/+1
If user-defined comparator is used, subdb shouldn't be opened with MDB_INTEGERKEY. TODO: Again, this will be added back with future schema updates.
2016-02-29Revert part of 7db89ed2eee2ce31f039783323d665fe7c24d441warptangent1-2/+14
For now, so existing databases work. TODO: add these back with future schema updates.
2016-02-29BlockchainLMDB: Add height and db error to exceptionwarptangent1-1/+1
2016-02-29Merge pull request #686Riccardo Spagni6-185/+340
7db89ed ARMv7: fix unaligned accesses (Howard Chu) 5a07cef Wrap some more actions in a larger read txn (Howard Chu) 8cc7a36 read txn/cursor stuff (Howard Chu) 86a7f2b core: check whether an update is needed straight away (moneromooo-monero) ea5fa5e core: print "update needed" hard fork notifications in red (moneromooo-monero)
2016-02-25ARMv7: fix unaligned accessesHoward Chu1-20/+15
And cleanup some key comparators
2016-02-23read txn/cursor stuffHoward Chu6-165/+325
Could wrap more later.
2016-02-20db_bdb: add missing include for std::condition_variablemoneromooo-monero1-0/+1
2016-02-18BlockchainBDB: Check if hard fork subdbs need resetwarptangent1-1/+50
See f7e337e6254c1c4115a8430964a6f6b54305b3ae for LMDB equivalent.
2016-02-18BlockchainBDB: Support blockchain_import --drop-hard-fork commandwarptangent1-3/+35
See c657e772c4efbfee8ff698883f1532a38117a70a for LMDB equivalent.
2016-02-17Use MDB_PREV_MULTIPLEHoward Chu1-12/+41
in get_global_output_indices
2016-02-17Fixup after lmdb master resyncHoward Chu1-6/+6
2016-02-17Shutup about VERSION 0Howard Chu2-2/+6
2016-02-17Use cursor in get_output_keyHoward Chu1-1/+2
2016-02-17Use MDB_APPEND mode where possibleHoward Chu1-5/+9
When keys are contiguous and monotonically increasing, this gets denser page utilization (doesn't leave padding in page splits). Can't be used for keys that are inserted in random order (e.g. hashes) In total this only saves around 1.5% of space compared to original DB code. The previous patch accounted for 0.8% savings on its own; the blocks tables just aren't that big.
2016-02-17Use cursors in write txnsHoward Chu2-22/+100
Saves a bit of seek overhead. LMDB frees them automatically in txn_(commit|abort) so they need no cleanup.
2016-02-17Keep a running blocksize countHoward Chu2-0/+15
Used in batch size estimation, avoids rereading already processed blocks during import
2016-02-17Win32 import batchsize tweaksHoward Chu1-3/+6
Reduce frequency of resizes: bump minimum increase from 128MB to 512MB Use a bigger safety margin at small batch sizes
2016-02-13Merge pull request #657Riccardo Spagni2-12/+50
1995923 BlockchainLMDB: Deal with DB exceptions at block level with particularity (warptangent) c16cc20 BlockchainLMDB: Add sanity check for inconsistent state (warptangent) 9118d0a BlockchainLMDB: Call destructor on allocated txn if setup fails (warptangent) f5581c3 BlockchainLMDB: Replace remaining txn pointer NULLs with nullptr (warptangent)
2016-02-13BlockchainLMDB: Deal with DB exceptions at block level with particularitywarptangent2-2/+21
Add another DB error exception type to distinguish failed txn setup from general use of txn. This keeps the error handling flow the same as before the block-level txn setup changes that moved control up a layer to BlockchainDB.
2016-02-13BlockchainLMDB: Add sanity check for inconsistent statewarptangent1-2/+13
This hasn't been known to occur in block-level txn abort, but throw exception if it does.
2016-02-13BlockchainLMDB: Call destructor on allocated txn if setup failswarptangent1-0/+8
2016-02-13BlockchainLMDB: Replace remaining txn pointer NULLs with nullptrwarptangent1-9/+9
For consistency.
2016-02-08blockchain_db: pass hard fork object as a simple pointermoneromooo-monero2-2/+2
2016-02-08Move HardFork DB update to BlockchainDB::add_block()warptangent1-0/+1
Ensures the database is consistent. Also simplifes blockchain_import in that verify mode off has less to work around.
2016-02-08Make HardFork object available to BlockchainDB and derived DB implementationswarptangent4-0/+16
This will later allow the HardFork object's DB update functions to be called when the DB transaction that persists across block add/remove is open.
2016-02-08BlockchainDB/LMDB: Refactor block-scope DB txn handling for add blockwarptangent2-20/+10
Move block-scope txn start and stop from BlockchainLMDB to BlockchainDB.
2016-02-08BlockchainDB/LMDB/BDB: Extract DB txn functions for block add/removewarptangent5-0/+65
2016-02-08BlockchainLMDB: Allow two HardFork functions to update DB during block addwarptangent1-4/+4
Note that this doesn't yet cause them to be called during block add.
2016-02-08BlockchainLMDB: extract txn macros used during block add/removewarptangent1-0/+26
2016-02-08fake_core: Check if hard fork subdbs need reset at startwarptangent1-2/+8
2016-02-08blockchain_import: Add --drop-hard-fork commandwarptangent5-0/+21
2016-02-03berkeleydb: fix delete/free mismatchmoneromooo-monero1-2/+2
Despite being C++, the stats object is allocated by the underlying C layer using malloc(3).
2016-01-28BlockchainBDB: Continue when tx has no outputswarptangent1-3/+5
See 24b66243c2767726ea4b279fcf447c7cd82c13e5
2016-01-28BlockchainBDB: When removing, find amount output index fast by starting at endwarptangent1-10/+33
This improves blockchain reorganization time by allowing one of the more expensive DB lookups when popping a block to not have to seek through a long dup list in the "output_amounts" db. This is most noticeable for HDDs. See ffcf6bdb95abe2dab37d5f8d9acc134fdc6b4d36
2016-01-28BlockchainBDB: Remove tx outputs in reverse orderwarptangent1-4/+14
Data should be removed in the reverse order it was added. This matches the order of removal in blockchain_storage::pop_transaction_from_global_index. See f11def012f38106b0ffeb7010a2f749de1e5b640
2016-01-21OpenBSD support for Monero.me0wmix1-1/+3
2016-01-19db_lmdb: Continue when tx has no outputswarptangent1-4/+6
2016-01-15Fix hf when import with verify offHoward Chu5-0/+29
Delete the hf tables, so the next open will rescan and regenerate
2015-12-31updated copyright yearRiccardo Spagni1-1/+1
2015-12-31fixed copyrights with bad year referencesRiccardo Spagni7-7/+7
2015-12-30Merge pull request #572Riccardo Spagni1-3/+9
b39aae7 Tweak 45800a25e9374e63caaabba05c89585c86acd668 (hyc) 4a5a5ff blockchain: always stop the ioservice before returning (moneromooo-monero) 78b65cf db_lmdb: safety close db at exit (moneromooo-monero) 45800a2 db_lmdb: fix a strdup/delete[] mistmatch (moneromooo-monero)
2015-12-29Tweak 45800a25e9374e63caaabba05c89585c86acd668hyc1-5/+5
trivial cleanup
2015-12-28db_lmdb: safety close db at exitmoneromooo-monero1-0/+3
Noticed by hyc Also set m_open to false when closed
2015-12-28db_lmdb: fix a strdup/delete[] mistmatchmoneromooo-monero1-3/+6
2015-12-26BlockchainDB: skip fixup check if read-only databasewarptangent6-0/+32
2015-12-26Merge pull request #565Riccardo Spagni2-0/+8
79beed2 tests: fix various tests by using parameters better suited to monero (moneromooo-monero) d0a8362 tests: fix some double spending tests (moneromooo-monero) 2358d0d tests: use 255 as a "too high" block version (moneromooo-monero) f33a88c blockchain: fix a few block addition bugs (moneromooo-monero) a9ff11c blockchain: fix an off by one error in unlocked time check (moneromooo-monero) f294be3 blockchain: reinstate double spending checks in check_tx_inputs (moneromooo-monero) 737b6d6 blockchain: make some flag twiddling code closer to the original (moneromooo-monero) 81cb0fc blockchain: fix bitflipping test with quantized block rewards (moneromooo-monero) 22ddf09 blockchain: add missing m_tx_pool.on_blockchain_dec (moneromooo-monero) d837c0c blockchain: fix switch to alternative blockchain for more than one block (moneromooo-monero) 5cec076 blockchain: add a missing validity check to rollback_blockchain_switching (moneromooo-monero) 3cabdb5 core: catch exceptions from get_output_key (moneromooo-monero) 5eef645 db: throw when given a non txout_to_key output to add (moneromooo-monero)
2015-12-25db: throw when given a non txout_to_key output to addmoneromooo-monero2-0/+8
The check was explicit in the original version, so it seems safer to make it explicit here, especially as it is now done implicitely in a different place, away from the original check.
2015-12-24BlockchainDB: Remove txs in reverse orderwarptangent1-3/+5
Data should be removed in the reverse order it was added. Not doing so breaks assumptions and can cause problems in other DB implementations. This matches the order of tx removal in blockchain_storage::purge_block_data_from_blockchain.
2015-12-24BlockchainLMDB: When removing, find amount output index fast by starting at endwarptangent1-4/+5
This improves blockchain reorganization time by allowing one of the more expensive DB lookups when popping a block to not have to seek through a long dup list in the "output_amounts" subdb. This is most noticeable for HDDs. As before, the dup list is still walked if necessary (but in reverse), and the global output index still confirmed to be the one looked for. But under proper use, the result will be found at the end of the dup list, so we start there. Removing an amount output index is always done in the context of popping a block, so the global output index being looked for should be the last one in that amount key's dup list. Even if the txs themselves aren't removed in reverse order (supposed to be according to original implementation), the specified amount output index will still be near the end, because the txs are in the same block. TEST: Pop blocks with blockchain_import. Blocks should be successfully removed with no errors shown. bitmonerod should be able to start syncing from the reduced blockchain height.
2015-12-24BlockchainLMDB: Remove tx outputs in reverse orderwarptangent1-5/+5
Data should be removed in the reverse order it was added. This matches the order of removal in blockchain_storage::pop_transaction_from_global_index.
2015-12-19Add missing semicolons after log statementsmoneromooo-monero1-3/+3
2015-12-15Replace tabs with two spaces for consistency with rest of codebasewarptangent4-282/+282
Remove trailing whitespace in same files.
2015-12-14db_lmdb: always use a batch tx if possiblemoneromooo-monero1-290/+127
Also wrap that code in two prefix/suffix macros so they are easier to use and not forget. Also add consts to returned data casts where applicable.
2015-12-13Merge pull request #532Riccardo Spagni1-68/+74
79ff6a5 Add LMDB error string to database transaction exception message (warptangent)
2015-12-13Merge pull request #531Riccardo Spagni2-4/+69
cbded43 core_tests: fix ring_signature_1 tests (moneromooo-monero) c3d208f core_tests: bump default test fee to 0.02 monero (moneromooo-monero) 10da0a0 add a --fakechain argument for tests (moneromooo-monero) eee44e6 unit_tests: fix block reward test using post hard fork settings (moneromooo-monero) 595893f blockchain: log block (not chain) height in "BLOCK SUCCESFULLY ADDED" (moneromooo-monero) 2369968 blockchain: fix off by one in get_blocks (moneromooo-monero) 8af913a db_lmdb: implement BlockchainLMDB::reset (moneromooo-monero) 4833f4f db_bdb: implement BlockchainBDB::reset (moneromooo-monero) 18bf06e tx_pool: fix "minumim" typo in message (moneromooo-monero) 44f1267 tests: fix a typo in test name (moneromooo-monero) 1494557 db_lmdb: create all needed directories, not just the leaf one (moneromooo-monero) 015b68a db_bdb: create all needed directories, not just the leaf one (moneromooo-monero) f141869 tests: remove data-dir argument registration (moneromooo-monero)
2015-12-13Add LMDB error string to database transaction exception messagewarptangent1-68/+74
When throwing an exception from being unable to begin an LMDB transaction, include the reason. It's often been due to a write transaction attempted within a write transaction (batch mode), but there can be other reasons such as write transaction attempted while database was opened read only, or environment's map needs to be resized.
2015-12-13db_lmdb: implement BlockchainLMDB::resetmoneromooo-monero1-1/+27
It is needed by the core tests
2015-12-13db_bdb: implement BlockchainBDB::resetmoneromooo-monero1-1/+40
It is needed by the core tests
2015-12-13db_lmdb: create all needed directories, not just the leaf onemoneromooo-monero1-1/+1
2015-12-13db_bdb: create all needed directories, not just the leaf onemoneromooo-monero1-1/+1
2015-12-10Fix data refs in read-only txnsHoward Chu1-16/+42
Data is only guaranteed to be valid within the lifetime of a txn. You cannot use data returned from LMDB after the txn ends. Also, fixed a missing txn.commit BlockchainLMDB::get_tx_unlock_time()
2015-12-08Merge pull request #524Riccardo Spagni1-3/+3
1c8262c db_bdb: move log_set_config call before open (moneromooo-monero)
2015-12-08Merge pull request #523Riccardo Spagni1-0/+34
8620b31 db_bdb: support for libdb without DB_FORCESYNC (moneromooo-monero)
2015-12-07db_bdb: move log_set_config call before openmoneromooo-monero1-3/+3
This is a precaution for older Berkeley DB versions. - smooth reports an issue running with 4.7: DB_ENV->log_set_config: DB_LOG_IN_MEMORY: method not permitted after handle's open method - this works just fine with 5.3 - we do not use DB_LOG_IN_MEMORY, but we use DB_LOG_AUTO_REMOVE - libdb docs say some flags must be set before open, and some may be set at any time, but never say some must be set after open - moving the call to log_set_config before open works with 5.3 Therefore, it seems best to move the call before open.
2015-12-07db_bdb: support for libdb without DB_FORCESYNCmoneromooo-monero1-0/+34
2015-12-06blockchain_db: fixup missing key images in early DB versionmoneromooo-monero6-0/+602
Early DB versions did not store key images for inputs if the transaction spending them had no outputs (ie, all fee). This is not correct, as this would allow these outputs to be double spent. This was fixed in 533acc30eda7792c802ea8b6417917fa99b8bc2b a few months ago, but databases having synced blocks 2021612 and 685498 with a faulty version will be missing those key images in the spent keys database. This code checks for this, and adds those key images if they are missing.
2015-12-05blockchain_db: make the indexing base a BlockchainDB virtual functionmoneromooo-monero2-0/+5
2015-12-04db_bdb: read 32 bit heights from keysmoneromooo-monero1-1/+1
Keys in Berkeley DB are 32 bits. We don't want to read random bits in the high part.
2015-11-13Revert "db_bdb: record numbers for recno databases start at 1"moneromooo-monero1-3/+3
It looks like some of the indices passed to the DB access functions are already bumped by 1. Moreover, the existing code was not throwing DB errors with 0 keys, and this is unlikely if it really was using 0 keys. Last, this patch broke sync from scratch in at least one case. So I'm calling it bad and reverting it. This reverts commit bfc97401ae81bb30278a318de7f048c653bf6582.
2015-10-27Remove some old/obsolete/unused codemoneromooo-monero5-156/+0
git history's here if needed to get any of this back
2015-10-26db_bdb: add versioning, to detect incompatible format changesmoneromooo-monero2-0/+83
2015-10-26db_lmdb: add versioning, to detect incompatible format changesmoneromooo-monero2-8/+85
2015-10-25Add functions to iterate through blocks, txes, outputs, key imagesmoneromooo-monero5-0/+294
2015-10-25db_bdb: record numbers for recno databases start at 1moneromooo-monero1-3/+3
2015-10-25db_bdb: DB_KEYEMPTY is also not found for non-top recon fieldsmoneromooo-monero1-2/+2
2015-10-25blockchain_db: use the DNE exceptions where appropriatemoneromooo-monero2-17/+19
2015-10-04db_bdb: fix hard fork keysmoneromooo-monero1-4/+4
Berkeley DB requires RECNO keys to be 32 bits, and forbids a key value of 0.
2015-09-20hardfork: most state now saved to the DBmoneromooo-monero5-0/+224
There will be a delay on first load of an existing blockchain as it gets reparsed for this state data.
2015-08-11blockchain_db: match tx addition semantics to original codemoneromooo-monero1-8/+24
The original code removed key images from a tx from the blockchain when an non to-key nor gen input was found in that tx. Additionally, the remainder of the tx data was added to the blockchain only after the double spend check passed.
2015-08-10Merge pull request #364Riccardo Spagni1-10/+7
533acc3 blockchain_db: store key images for tx without outputs too (moneromooo-monero)
2015-08-10Merge pull request #363Riccardo Spagni5-34/+0
4f19e68 blockchain: factor get_num_outpouts(amount) calls (moneromooo-monero) 275894c blockchain: always select random outs using triangular distribution (moneromooo-monero)
2015-08-09blockchain_db: store key images for tx without outputs toomoneromooo-monero1-10/+7
2015-08-09blockchain: always select random outs using triangular distributionmoneromooo-monero5-34/+0
It was only used by the older blockchain_storage. We also move the code to the calling blockchain level, to avoid replicating the code in every DB implementation. This also makes the get_random_out method obsolete, and we delete it.
2015-08-04Fix estimation of batch storage size when no blocks existwarptangent1-11/+28
If there's no blocks in database (m_height == 0): Don't assign incorrect block range to check. Skip average block size check. Test: Run blockchain_converter with an existing source blockchain.bin and a non-existent LMDB destination database. The converter creates a BlockchainLMDB instance with zero height, due to not being initialized with a genesis block, normally done by Blockchain::init(). While different than the behavior of bitmonerod, blockchain_import, and blockchain_export, the initialization hasn't been strictly necessary. The db batch size estimation normally uses an average block size, or a default minimum block size, whichever is greater. In this case, as there's no existing blocks to check for an average block size, the default should be used.
2015-07-16Add batch support to BlockchainLMDB::get_output_keywarptangent1-6/+12
This allows blockchain_import to work with batch and verify modes enabled (the default).
2015-07-15Removed on_idle() calls to Blockchain::store_blockchain() for lmdb.NoodleDoodleNoodleDoodleNoodleDoodleNoo1-4/+3
Added option to cache tx-input verification results.
2015-07-15Fixed binary size issue due to embedded checkpoint data.NoodleDoodleNoodleDoodleNoodleDoodleNoo1-0/+1
Fixed OSX compilation issues due to random lmdb resize points. Fixed infinite loop bug when calling core::get_block_template(..).
2015-07-15** CHANGES ARE EXPERIMENTAL (FOR TESTING ONLY)NoodleDoodleNoodleDoodleNoodleDoodleNoo7-605/+1005
Bockchain: 1. Optim: Multi-thread long-hash computation when encountering groups of blocks. 2. Optim: Cache verified txs and return result from cache instead of re-checking whenever possible. 3. Optim: Preload output-keys when encoutering groups of blocks. Sort by amount and global-index before bulk querying database and multi-thread when possible. 4. Optim: Disable double spend check on block verification, double spend is already detected when trying to add blocks. 5. Optim: Multi-thread signature computation whenever possible. 6. Patch: Disable locking (recursive mutex) on called functions from check_tx_inputs which causes slowdowns (only seems to happen on ubuntu/VMs??? Reason: TBD) 7. Optim: Removed looped full-tx hash computation when retrieving transactions from pool (???). 8. Optim: Cache difficulty/timestamps (735 blocks) for next-difficulty calculations so that only 2 db reads per new block is needed when a new block arrives (instead of 1470 reads). Berkeley-DB: 1. Fix: 32-bit data errors causing wrong output global indices and failure to send blocks to peers (etc). 2. Fix: Unable to pop blocks on reorganize due to transaction errors. 3. Patch: Large number of transaction aborts when running multi-threaded bulk queries. 4. Patch: Insufficient locks error when running full sync. 5. Patch: Incorrect db stats when returning from an immediate exit from "pop block" operation. 6. Optim: Add bulk queries to get output global indices. 7. Optim: Modified output_keys table to store public_key+unlock_time+height for single transaction lookup (vs 3) 8. Optim: Used output_keys table retrieve public_keys instead of going through output_amounts->output_txs+output_indices->txs->output:public_key 9. Optim: Added thread-safe buffers used when multi-threading bulk queries. 10. Optim: Added support for nosync/write_nosync options for improved performance (*see --db-sync-mode option for details) 11. Mod: Added checkpoint thread and auto-remove-logs option. 12. *Now usable on 32-bit systems like RPI2. LMDB: 1. Optim: Added custom comparison for 256-bit key tables (minor speed-up, TBD: get actual effect) 2. Optim: Modified output_keys table to store public_key+unlock_time+height for single transaction lookup (vs 3) 3. Optim: Used output_keys table retrieve public_keys instead of going through output_amounts->output_txs+output_indices->txs->output:public_key 4. Optim: Added support for sync/writemap options for improved performance (*see --db-sync-mode option for details) 5. Mod: Auto resize to +1GB instead of multiplier x1.5 ETC: 1. Minor optimizations for slow-hash for ARM (RPI2). Incomplete. 2. Fix: 32-bit saturation bug when computing next difficulty on large blocks. [PENDING ISSUES] 1. Berkely db has a very slow "pop-block" operation. This is very noticeable on the RPI2 as it sometimes takes > 10 MINUTES to pop a block during reorganization. This does not happen very often however, most reorgs seem to take a few seconds but it possibly depends on the number of outputs present. TBD. 2. Berkeley db, possible bug "unable to allocate memory". TBD. [NEW OPTIONS] (*Currently all enabled for testing purposes) 1. --fast-block-sync arg=[0:1] (default: 1) a. 0 = Compute long hash per block (may take a while depending on CPU) b. 1 = Skip long-hash and verify blocks based on embedded known good block hashes (faster, minimal CPU dependence) 2. --db-sync-mode arg=[[safe|fast|fastest]:[sync|async]:[nblocks_per_sync]] (default: fastest:async:1000) a. safe = fdatasync/fsync (or equivalent) per stored block. Very slow, but safest option to protect against power-out/crash conditions. b. fast/fastest = Enables asynchronous fdatasync/fsync (or equivalent). Useful for battery operated devices or STABLE systems with UPS and/or systems with battery backed write cache/solid state cache. Fast - Write meta-data but defer data flush. Fastest - Defer meta-data and data flush. Sync - Flush data after nblocks_per_sync and wait. Async - Flush data after nblocks_per_sync but do not wait for the operation to finish. 3. --prep-blocks-threads arg=[n] (default: 4 or system max threads, whichever is lower) Max number of threads to use when computing long-hash in groups. 4. --show-time-stats arg=[0:1] (default: 1) Show benchmark related time stats. 5. --db-auto-remove-logs arg=[0:1] (default: 1) For berkeley-db only. Auto remove logs if enabled. **Note: lmdb and berkeley-db have changes to the tables and are not compatible with official git head version. At the moment, you need a full resync to use this optimized version. [PERFORMANCE COMPARISON] **Some figures are approximations only. Using a baseline machine of an i7-2600K+SSD+(with full pow computation): 1. The optimized lmdb/blockhain core can process blocks up to 585K for ~1.25 hours + download time, so it usually takes 2.5 hours to sync the full chain. 2. The current head with memory can process blocks up to 585K for ~4.2 hours + download time, so it usually takes 5.5 hours to sync the full chain. 3. The current head with lmdb can process blocks up to 585K for ~32 hours + download time and usually takes 36 hours to sync the full chain. Averate procesing times (with full pow computation): lmdb-optimized: 1. tx_ave = 2.5 ms / tx 2. block_ave = 5.87 ms / block memory-official-repo: 1. tx_ave = 8.85 ms / tx 2. block_ave = 19.68 ms / block lmdb-official-repo (0f4a036437fd41a5498ee5e74e2422ea6177aa3e) 1. tx_ave = 47.8 ms / tx 2. block_ave = 64.2 ms / block **Note: The following data denotes processing times only (does not include p2p download time) lmdb-optimized processing times (with full pow computation): 1. Desktop, Quad-core / 8-threads 2600k (8Mb) - 1.25 hours processing time (--db-sync-mode=fastest:async:1000). 2. Laptop, Dual-core / 4-threads U4200 (3Mb) - 4.90 hours processing time (--db-sync-mode=fastest:async:1000). 3. Embedded, Quad-core / 4-threads Z3735F (2x1Mb) - 12.0 hours processing time (--db-sync-mode=fastest:async:1000). lmdb-optimized processing times (with per-block-checkpoint) 1. Desktop, Quad-core / 8-threads 2600k (8Mb) - 10 minutes processing time (--db-sync-mode=fastest:async:1000). berkeley-db optimized processing times (with full pow computation) 1. Desktop, Quad-core / 8-threads 2600k (8Mb) - 1.8 hours processing time (--db-sync-mode=fastest:async:1000). 2. RPI2. Improved from estimated 3 months(???) into 2.5 days (*Need 2AMP supply + Clock:1Ghz + [usb+ssd] to achieve this speed) (--db-sync-mode=fastest:async:1000). berkeley-db optimized processing times (with per-block-checkpoint) 1. RPI2. 12-15 hours (*Need 2AMP supply + Clock:1Ghz + [usb+ssd] to achieve this speed) (--db-sync-mode=fastest:async:1000).
2015-07-15Update db_bdb.cppNoodleDoodleNoodleDoodleNoodleDoodleNoo1-7/+5
- bugfix: prevent re-entering db->get when current buffer contains all possible index values.
2015-07-15Update db_bdb.cppNoodleDoodleNoodleDoodleNoodleDoodleNoo1-72/+72
2015-07-15Update db_bdb.cppNoodleDoodleNoodleDoodleNoodleDoodleNoo1-1154/+1166
2015-07-15Experimental BDB workaround optimizationsNoodleDoodleNoodleDoodleNoodleDoodleNoo4-18/+220
2015-07-12Check and resize if needed at batch transaction startwarptangent2-5/+109
This currently only affects blockchain_import and blockchain_converter. When the number of blocks expected for the batch transaction is provided, make an estimate of the DB space needed. If not enough free space remains, resize the DB. The estimate is made based on: - the average size of the last 500 blocks, or if larger, a min. block size of 4k - a factor for the expanded size a block occupies in the DB across the sub-dbs/tables - a safety factor (1.7) to allow for a "reasonable" average block size increase over the batch Increase the DB size by whichever is greater: the estimated size needed or a minimum increase size, currently 128 MB. The conservative factors in the estimate help in testing that the resize occurs when needed, and without gratuitous size increases. For common use, the safety factor and minimum increase size could reasonably be increased. For testing, setting DEFAULT_MAPSIZE (blockchain_db/lmdb/db_lmdb.h) to 1 << 27 (128 MB) and recompiling will ensure DB resizes take place sooner and more frequently.
2015-07-11Optionally allow DB to know expected number of blocks at batch transaction startwarptangent5-5/+5
This will assist in a DB resize check.
2015-05-30Merge pull request #297Riccardo Spagni1-38/+75
5680604 Replace hardcoded value with existing constant of same value (warptangent) f37ee2f Update database resize behavior (warptangent) f85cd8e Include database error in more error messages (warptangent)
2015-05-30Replace hardcoded value with existing constant of same valuewarptangent1-1/+1
This was likely the intent.
2015-05-30Update database resize behaviorwarptangent1-2/+20
On an existing database, don't set LMDB map size to be the initial size for a new database. Check if resize is needed at startup.
2015-05-30Include database error in more error messageswarptangent1-35/+54
2015-05-27blockchain_db: add a few constmoneromooo-monero6-10/+10
2015-05-26Merge pull request #289Riccardo Spagni2-75/+210
01076ae Check if LMDB needs resize every 1000 blocks (Thomas Winget) b0d849e null out batch txn pointer as needed (BlockchainLMDB) (Thomas Winget) 7b7ef73 LMDB should now dynamically resize the mapsize (Thomas Winget) ac79502 Move mdb_txn_safe implementation to cpp file (Thomas Winget)
2015-05-18Check if LMDB needs resize every 1000 blocksThomas Winget1-1/+1
(this was 10 for testing purposes)
2015-05-18null out batch txn pointer as needed (BlockchainLMDB)Thomas Winget1-4/+5
2015-05-16LMDB should now dynamically resize the mapsizeThomas Winget2-60/+187
Some filesystems (*cough* NTFS *cough*) aren't good with sparse files, so this makes LMDB dynamically resize its mapsize as needed. Note: the check interval is currently every 10 blocks (for testing) and will probably need to change to 1000 or something. Default mapsize set to 1GiB. Blockchain conversion tools using batching will probably segfault, I'll fix that in the next commit.
2015-05-16Allow BlockchainLMDB to be opened in read-only modewarptangent1-2/+6
Have blockchain_export use read-only mode when source is BlockchainLMDB.
2015-05-15Move mdb_txn_safe implementation to cpp fileThomas Winget2-51/+58
2015-05-08Update log statementswarptangent1-1/+1
Use filesystem path conversion to string() instead of c_str(). Windows may otherwise output an address.
2015-04-07Only compile BerkeleyDB as an option in non-staticThomas Winget1-0/+13
2015-03-25Steps toward multiple dbs available -- workingThomas Winget7-22/+50
There will need to be some more refactoring for these changes to be considered complete/correct, but for now it's working. new daemon cli argument "--db-type", works for LMDB and BerkeleyDB. A good deal of refactoring is also present in this commit, namely Blockchain no longer instantiates BlockchainDB, but rather is passed a pointer to an already-instantiated BlockchainDB on init().
2015-03-17BerkeleyDB implementation of BlockchainDB seems to be working!Thomas Winget2-20/+20
2015-03-17Pull blockchain changes into berkeleydb branchThomas Winget3-12/+18
2015-03-17BlockchainBDB passes unit testsThomas Winget1-1/+4
2015-03-16BerkeleyDB Blockchain building, not working yetThomas Winget3-189/+200
Everything except actually *using* BlockchainBDB is wired up, but the db itself is not yet working. Some error about user mem not large enough. I think I know what this error means, but I can't determine the cause. Notes: BerkeleyDB does not allow 0-indexing in its recno type databases, so block numbers *in the database* will be 1-indexed. Modifications to indexing have been made as needed.
2015-03-16CMake wiring, minor cleanup, minor test additionThomas Winget1-0/+3
Make Cmake things aware of BerkeleyDB and BlockchainBDB Make the BlockchainDB unit tests aware of BlockchainBDB
2015-03-16BerkeleyDB BlockchainDB impl copy/paste/modifyThomas Winget2-9/+1304
LMDB implementation code copy/paste/modified into the Berkeley DB implementation. Need to test if it builds, then if it works, and so on, but the code is all there.
2015-03-16Try to not pollute cryptonote namespaceThomas Winget2-47/+47
2015-03-16Initial commit of BDB BlockchainDB implementationThomas Winget2-0/+678
Basically verbatim copy of LMDB implementation, but with the guts ripped out and includes changed, etc.
2015-03-16Add support for database open with flagswarptangent3-4/+3
Add support to: - BlockchainDB, BlockchainLMDB - blockchain_import utility to open LMDB database with one or more LMDB flags. Sample use: $ blockchain_import --database lmdb#nosync $ blockchain_import --database lmdb#nosync,nometasync
2015-03-16Add mdb_flags variable to LMDB database openwarptangent1-1/+2
2015-03-15Update and relocate comment that applies class widewarptangent1-8/+14
2015-03-13BlockchainDB implementations have names nowThomas Winget3-0/+12
In order to make things more general, BlockchainDB now has get_db_name() which should return a string with the "name" of that type of db. This "name" will be the subfolder name that holds that db type's files within the monero folder. Small bugfix: blockchain_converter was not correctly appending this in the prior hard-coded-string implementation of the subfolder data directory concept.
2015-03-06Moved BlockchainDB into its own src/ subfolderThomas Winget5-0/+2849
Ostensibly janitorial work, but should be more relevant later down the line. Things that depend on core cryptonote things (i.e. cryptonote_core) don't necessarily depend on BlockchainDB and thus have no need to have BlockchainDB baked in with them.