aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* hardfork: most state now saved to the DBmoneromooo-monero2015-09-201-13/+28
| | | | | There will be a delay on first load of an existing blockchain as it gets reparsed for this state data.
* Add an RPC call and daemon command to get info on hard fork votingmoneromooo-monero2015-09-191-1/+6
|
* blockchain: force a hardfork recalculation at load timemoneromooo-monero2015-09-191-0/+3
| | | | | Since the state isn't actually saved anywhere, as the archive code isn't called in the new DB version.
* core: add consts where appropriatemoneromooo-monero2015-09-191-3/+3
|
* core: moan when we think an update is needed to get latest hard fork infomoneromooo-monero2015-09-131-0/+5
|
* blockchain: use the new hardfork classmoneromooo-monero2015-09-121-3/+23
|
* blockchain: remove obsolete call to libc srandmoneromooo-monero2015-08-241-1/+0
| | | | crypto::rand is now used for output selection
* removed some gcc warnings. mainly unused variables.roman2015-08-231-3/+0
|
* blockchain: mark two places where the new code differs from the oldmoneromooo-monero2015-08-151-0/+3
| | | | And I'd like a comment from tewinget or someone else
* blockchain: update cumulative size after block additionmoneromooo-monero2015-08-151-2/+2
| | | | | Block addition can fail, and the old code would not update the cumulative size in that case.
* blockchain: remove dead codemoneromooo-monero2015-08-151-1/+0
|
* blockchain: do not try to add a tx the pool when it was nor taken outmoneromooo-monero2015-08-151-1/+4
| | | | | | This is an unintended difference from the old code. Though I don't think it can actually happen in practice with the current take_tx implementation.
* blockchain: fix off by 1 in timestamp median calculationsmoneromooo-monero2015-08-151-4/+2
| | | | | | | | | The height function apparently used to return the index of the last block, rather than the height of the chain. This now seems to be incorrect, judging the the code, so we remove the now wrong comment, as well as a couple +/- 1 adjustments which now cause the median calculation to differ from the original blockchain_storage version.
* blockchain: remove dead codemoneromooo-monero2015-08-111-56/+6
|
* blockchain: factor get_num_outpouts(amount) callsmoneromooo-monero2015-08-091-3/+3
| | | | | It has to stay constant as we get the blockchain lock for the entire function. Avoids some unnecessary DB accesses.
* blockchain: always select random outs using triangular distributionmoneromooo-monero2015-08-091-1/+9
| | | | | | | 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.
* Merge pull request #343Riccardo Spagni2015-07-181-1/+1
|\ | | | | | | e20a4dd blockchain: fix testnet syncing (to not use blocks.dat) (moneromooo-monero)
| * blockchain: fix testnet syncing (to not use blocks.dat)moneromooo-monero2015-07-181-1/+1
| | | | | | | | | | These are mainnet blocks, and would cause syncing on testnet to reject all incoming blocks.
* | Fixed threadpool bug when running on single core systems.NoodleDoodleNoodleDoodleNoodleDoodleNoo2015-07-171-5/+8
|/ | | | *Thanks to freshman for reporting bug.
* Removed on_idle() calls to Blockchain::store_blockchain() for lmdb.NoodleDoodleNoodleDoodleNoodleDoodleNoo2015-07-151-6/+42
| | | | Added option to cache tx-input verification results.
* ** CHANGES ARE EXPERIMENTAL (FOR TESTING ONLY)NoodleDoodleNoodleDoodleNoodleDoodleNoo2015-07-151-1626/+2326
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Update blockchain.cppNoodleDoodleNoodleDoodleNoodleDoodleNoo2015-07-151-1/+0
| | | | Fix compilation error
* Experimental BDB workaround optimizationsNoodleDoodleNoodleDoodleNoodleDoodleNoo2015-07-151-1/+20
|
* cleaning up, removing redundant files, renaming, fixing incorrect licensesRiccardo Spagni2015-05-311-1/+1
|
* Steps toward multiple dbs available -- workingThomas Winget2015-03-251-31/+10
| | | | | | | | | | | 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().
* Add support for database open with flagswarptangent2015-03-161-2/+2
| | | | | | | | | | | 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
* BlockchainDB implementations have names nowThomas Winget2015-03-131-2/+3
| | | | | | | | | | | 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.
* Moved BlockchainDB into its own src/ subfolderThomas Winget2015-03-061-2/+2
| | | | | | | 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.
* Move LMDB storage to subfolderwarptangent2015-02-231-1/+2
|
* Blockchain: match original function declaration from blockchain_storagewarptangent2015-02-231-1/+1
|
* Fix Blockchain::get_tail_id() to set parameter to last block number instead ↵warptangent2015-02-221-1/+1
| | | | | | | | of height This reflects the behavior of blockchain_storage::get_tail_id(). Fixes #27 so that RPC method getlastblockheader works.
* Blockchain: reflect log updates from blockchain_storagewarptangent2015-02-011-7/+7
| | | | See commit 4ba680f2946966df2030e5765e40ee0a36b112c4
* Blockchain: reflect log and assert updates from blockchain_storagewarptangent2015-02-011-37/+38
| | | | See commit cf5a8b1d6c3df615641e81328bb3d8cf80cd70e3
* Blockchain: reflect log level of blockchain_storagewarptangent2015-02-011-8/+8
| | | | | Update to match LOG_PRINT_RED_Lx statements. See commit cf5a8b1d6c3df615641e81328bb3d8cf80cd70e3
* Blockchain: reflect assert behavior of blockchain_storage for ↵warptangent2015-02-011-0/+2
| | | | get_tx_outputs_gindexs()
* Update recently added log statement to fix possible null dereferencewarptangent2015-02-011-1/+5
| | | | | This would have been triggered if function was called without fourth parameter and ring signature check failed.
* Should fix std::min issues related to size_tThomas Winget2015-01-191-2/+2
|
* Remove code previously made unused and marked unusedwarptangent2015-01-141-18/+0
|
* Fix height assertion in Blockchain::handle_alternative_block()warptangent2015-01-111-1/+1
| | | | | | | | | | | It expects the total number of blocks of main chain, not last block id (off-by-one error). This again behaves like the same height assertion done in original implementation in blockchain_storage::handle_alternative_block(). This allows a reorganization to proceed after an alternative block has been added.
* Fix comparison between main and alternate chain's cumulativewarptangent2015-01-111-2/+10
| | | | | | | | | | | | | difficulty. This fixes the continual reorganization between a main and alternate chain, using the same two latest blocks from each. The check that cumulative difficulty of the alternate chain is bigger than main's was not using main's last block, but incorrectly using the passed-in block's previous block. main_chain_cumulative_difficulty was being used in two different ways. This has been split up to keep use of main_chain_cumulative_difficulty consistent.
* Remove a have_block() check so alternate block can be processedwarptangent2015-01-111-7/+27
| | | | | | | | | | | | | | | | | | | | Remove have_block() check from Blockchain::handle_block_to_main_chain(). Add logging to have_block(). This allows blockchain reorganization to proceed further. have_block() check here causes an error after a blockchain reorganize begins with error: "Attempting to add block to main chain, but it's already either there or in an alternate chain." While reorganizing to become the main chain, a block in the alternative chain would be refused due to have_block() rightfully finding it in the alternative chain. The reorganization would end in rollback, restoring to previous blockchain. Original implementation didn't call it here, and it doesn't appear necessary to be called from here in this implementation either. When needed, it appears it's called prior to handle_block_to_main_chain().
* Use block index when obtaining block's difficulty for log statementwarptangent2015-01-111-2/+2
| | | | | | | | Use last block id, not number of blocks (off-by-one error). Fixes error at start of blockchain reorganization: "Attempt to get cumulative difficulty from height <XXXXXX> failed -- difficulty not in db"
* Fix transfers to support mixinswarptangent2015-01-091-1/+1
| | | | | | | | | | | | | | | | Implement BlockchainLMDB::get_output_global_index() - returns global output index for a given amount and amount output index. Add information to debug statement for failed ring signature check within Blockchain::check_tx_inputs() Fixes bitmonerod RPC call "/getrandom_outs.bin" to return correct output keys, used in creating a transaction with mixins. TODO: get_output_global_index() could be refactored with part of get_output_tx_and_index() as the latter uses the former's functionality. Keep track of LMDB read transaction.
* Fix transfers (without mixins)warptangent2015-01-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix Blockchain::get_tx_outputs_gindexs() to return amount output indices. Implement BlockchainLMDB::get_tx_amount_output_indices() and call it from the function instead of BlockchainLMDB::get_tx_output_indices() Previously, Blockchain::get_tx_outputs_gindexs() was instead returning global output indices, which are internal to LMDB databases. Allows bitmonerod RPC /get_o_indexes.bin to return the amount output indices as expected. Allows simplewallet refresh to set correct amount output indices for incoming transfers. simplewallet can now construct and send valid transactions (currently only without mixins). This is a fix that doesn't require altering the structure of the current LMDB databases. TODO: This can be done more efficiently by adding another LMDB database (key-value table). It's not used during regular transaction validation by bitmonerod. I think it's currently used only or mainly by simplewallet for just its own incoming transactions. So the current behavior is not a primary bottleneck. Currently, it's using the "output_amounts" database, walking through a given amount's list of values, comparing each one to a given global output index. The iteration number of the match is the desired result: the amount output index. This is done for each global output index of the transaction. A tx's amount output indices can be stored in various other ways allowing for faster lookup. Since a tx is only written once, there are no special future write requirements for its list of indices.
* Fixes segfault in Blockchain::handle_alternative_blockThomas Winget2015-01-091-6/+8
| | | | | | This commit should fix the segfault in Blockchain::handle_alternative_block, and also updates a few comments that were either incorrect or incomplete.
* Obtain tx hash and tx output index from amount and output offsetwarptangent2015-01-041-1/+1
| | | | | | | Fixes problem of obtaining incorrect outputs used for tx input. Reverts to earlier intended behavior that was fixed in previous commit's split of get_output_tx_and_index into two functions.
* Fixes a bug with getting output metadata from BlockchainDBThomas Winget2015-01-041-1/+1
| | | | Thanks to moneromooo-monero for spotting the bug.
* blockchain: do not append "testnet" to the data directorymoneromooo-monero2015-01-041-6/+0
| | | | It is already there (unless overridden via command line).
* blockchain: fix wallet syncing from scratchmoneromooo-monero2015-01-041-1/+2
| | | | | When the wallet syncs from the first block, it is fine to start at the genesis block.
* blockchain: add consts where appropriatemoneromooo-monero2015-01-041-43/+43
|