Commit graph

285 commits

Author SHA1 Message Date
Riccardo Spagni a1c38299b3
also maybe do the block height this time, you know, just so that it actually works. 2016-03-21 13:19:49 +02:00
Riccardo Spagni 23d1538fe7
also update the timestamp for the hard fork 2016-03-21 13:09:35 +02:00
Riccardo Spagni eda51a0dc3
set fork date for September, add hyc's GPG key, remove aabramov's 2016-03-21 12:53:49 +02:00
Howard Chu 9b3e43c327 Fix issue #706 2016-03-19 12:57:47 +00:00
Howard Chu b937a2c915 Use boost::thread instead of std::thread
and all other associated IPC
2016-03-11 15:09:50 +00:00
warptangent a49c355cae
Blockchain: Omit verbose time stats messages by default
This is already the default for the daemon, but by checking a command
line argument and calling a Blockchain member function setter.

Initialize the variable to false so it's not dependent on an external
command-line argument check. This allows utilities like
blockchain_import to have a reasonable default without code changes.
2016-03-03 20:14:48 -08:00
Howard Chu 5a07cefe7b Wrap some more actions in a larger read txn 2016-02-23 20:47:15 +00:00
Howard Chu 8cc7a36f0b read txn/cursor stuff
Could wrap more later.
2016-02-23 20:47:15 +00:00
moneromooo-monero c7f82ec769
blockchain: initialize m_hardfork to NULL
It can now be set by some other code, and is thus tested
2016-02-08 20:57:20 +00:00
moneromooo-monero a333c42cde
core_tests: add tests for hard fork behaviors (MRL-0004)
We also replace the --fakechain option with an optional structure
containing details about configuration for the core/blockchain,
for test purposes. This seems more future friendly.
2016-02-08 18:52:00 +00:00
moneromooo-monero 6c8e5c3459
blockchain: reset hardfork object when resetting blockchain
Not doing so will prevent the new genesis block from being
reset if a switch past v1 had occured already.
2016-02-08 18:22:03 +00:00
warptangent e298b14a55
Blockchain: Update comments on removing block 2016-02-08 09:28:25 -08:00
warptangent e02577f594
Move HardFork DB update to BlockchainDB::add_block()
Ensures the database is consistent.

Also simplifes blockchain_import in that verify mode off has less to
work around.
2016-02-08 09:28:19 -08:00
warptangent 3800875406
Make HardFork object available to BlockchainDB and derived DB implementations
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-08 09:28:17 -08:00
warptangent 8f863e742d
Blockchain: Optionally pass in HardFork object 2016-02-08 08:50:51 -08:00
moneromooo-monero 7658ac0f45
blockchain: revert handle_get_objects adding block id on tx not found
This differs from the original CN code, and there seems to be
no reason to include the block itself, if it was found
2016-02-03 21:08:03 +00:00
Thomas Winget 1642be242d minor bugfixes and refactoring
- Blockchain should store if it's running on testnet or not

- moved loading compiled-in block hashes to its own function for clarity

- on handle_get_objects, should now correctly return false if a block's
transactions are missing

- replace instances of BOOST_FOREACH with C++11 for loops in Blockchain.
2016-02-02 18:58:39 +00:00
Riccardo Spagni 569316aea3
Merge pull request #634
7fc6fa3 wallet: forbid dust altogether in output selection where appropriate (moneromooo-monero)
5e1a739 blockchain: log number of outputs available for a new tx (moneromooo-monero)
2016-01-31 15:21:45 +02:00
Riccardo Spagni 39d73d2a27
Merge pull request #631
bcac101 daemon: fix a few issues reported by valgrind (moneromooo-monero)
a7e8174 tx_pool: fix serialization of new relayed data (moneromooo-monero)
601ad76 hardfork: fix mixup in indexing variable in get_voting_info (moneromooo-monero)
444e22f blockchain: remove unused timer (moneromooo-monero)
7edfdd8 blockchain: fix m_sync_counter uninitialized variable use (moneromooo-monero)
d97582c epee: use generate_random_bytes for new random uuids (moneromooo-monero)
17c7c9c epee: remove dodgy random code that nobody uses (moneromooo-monero)
2016-01-31 15:20:18 +02:00
moneromooo-monero 5e1a7391e8
blockchain: log number of outputs available for a new tx 2016-01-31 10:59:58 +00:00
moneromooo-monero 444e22f01a
blockchain: remove unused timer 2016-01-30 19:02:33 +00:00
moneromooo-monero 7edfdd8f24
blockchain: fix m_sync_counter uninitialized variable use
It counts the number of blocks added since last zeroing
2016-01-30 19:01:43 +00:00
moneromooo-monero bf6d1474c0
new flush_txpool command, and associated RPC call
It can flush a particular tx, or the whole pool (the RPC command
can flush a list of transactions too)
2016-01-30 13:28:26 +00:00
moneromooo-monero 3b1d7e03fc
Fix V1/V2 use of hard fork related parameters
Some of it uses hardcoded height, which will need some thinking
for next (voted upon) fork.
2016-01-29 17:21:11 +00:00
Riccardo Spagni de03926850
updated copyright year 2015-12-31 08:39:56 +02:00
moneromooo-monero 576effe11a
blockchain: kill ioservice on scope end, rather than manually
This ensures this will be done without fail, as the error prone
matching of every return with a call to KILL_IOSERVICE leads to
hard to debug corruption when one is missing.
2015-12-30 16:08:30 +00:00
Riccardo Spagni fd36eea6dd
Merge pull request #572
b39aae7 Tweak 45800a25e9 (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-30 09:38:41 +02:00
moneromooo-monero 4a5a5ff157
blockchain: always stop the ioservice before returning
Fixes a use after free
2015-12-28 22:47:46 +00:00
moneromooo-monero b0541a56eb
blockchain: remove obsolete containers 2015-12-26 18:01:24 +00:00
moneromooo-monero 18a5211173
blockchain: Fix height in call to on_blockchain_dec
It was a noop anyway
2015-12-26 18:00:45 +00:00
moneromooo-monero f33a88cfc1
blockchain: fix a few block addition bugs
If the block reward was too high, the verification failed flag
was set, but the function continued. The code which was supposed
to trap this flag and return failure failed to trap it, and,
while the block was not added to the chain, the function would
return success.
The reason for avoiding returning when the block reward problem
was detected was to be able to return any transactions to the
pool if needed. This is now mooted by moving the transaction
return code to a separate function, which is now called at all
appropriate points, making the logic much simpler, and hopefully
correct now.
We also move the hard fork version check after the prev_id check,
as block which does not go on the top of the chain might not
have the expected version there, without being invalid just for
this reason.
Last, we trap the case where a block fails to be added due to
using already spent key images, to set the verification failed
flag.
2015-12-25 22:13:38 +00:00
moneromooo-monero a9ff11c816
blockchain: fix an off by one error in unlocked time check 2015-12-25 22:12:52 +00:00
moneromooo-monero f294be35bc
blockchain: reinstate double spending checks in check_tx_inputs
This fixes some double spending tests.
This may or may not be unneeded in normal (non test) circumstances,
to be determined later. Keeping these for now may be slower, but safer.
2015-12-25 22:11:21 +00:00
moneromooo-monero 737b6d6cf5
blockchain: make some flag twiddling code closer to the original
Probably paranoid and unnecessary
2015-12-25 22:10:27 +00:00
moneromooo-monero 81cb0fcdcc
blockchain: fix bitflipping test with quantized block rewards
Block reward may now be less than the full amount allowed.
This was breaking the bitflipping test.
We now keep track of whether a block which was accepted by the core
has a lower than allowed block reward, and allow this in the test.
2015-12-25 22:07:58 +00:00
moneromooo-monero 22ddf09bea
blockchain: add missing m_tx_pool.on_blockchain_dec
It was missing in the port to DB.
This is actually a noop, so should not have functional changes.
2015-12-25 22:04:13 +00:00
moneromooo-monero d837c0ca90
blockchain: fix switch to alternative blockchain for more than one block
When rolling over more than one block, the db height will decrease,
but the split height should be constant, as per the original code.
2015-12-25 22:02:07 +00:00
moneromooo-monero 5cec076e13
blockchain: add a missing validity check to rollback_blockchain_switching
It was present in the original code
2015-12-25 22:01:21 +00:00
moneromooo-monero 3cabdb5ef2
core: catch exceptions from get_output_key
This can happen when trying to find an amount that does not exist,
and fixes a core test.
2015-12-25 21:59:26 +00:00
moneromooo-monero 5eef64578b
db: throw when given a non txout_to_key output to add
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-25 21:56:37 +00:00
moneromooo-monero 8ea7af1ba3
Allow the wallet to access hard fork information
And make it change behavior slightly when close/after first hard fork
2015-12-19 14:52:30 +00:00
moneromooo-monero 3f2970fadb
Add missing semicolons after log statements 2015-12-19 14:47:37 +00:00
moneromooo-monero 01e92ebdb0
replace std::auto_ptr with std::unique_ptr
The former is obsolete
2015-12-17 22:47:13 +00:00
warptangent 9079a32c07
Fix typo 2015-12-15 06:33:22 -08:00
warptangent 3796941d8e
blockchain.cpp: Change indentation from 4 to 2 spaces 2015-12-15 06:33:15 -08:00
warptangent 725acc7f17
Replace tabs with two spaces for consistency with rest of codebase
Remove trailing whitespace in same files.
2015-12-15 06:22:06 -08:00
moneromooo-monero 217792351d
Tone down a bit L0 logs during daemon sync 2015-12-14 00:36:37 +00:00
moneromooo-monero 10da0a0b7c
add a --fakechain argument for tests
The core tests use the blockchain, and reset it to be able
to add test data to it. This does not play nice with the
databases, since those will save that data without an explicit
save call.
We add a fakechain flag that the tests will set, which tells
the core and blockchain code to use a separate database, as
well as skip a few things like checkpoints and fixup, which
only make sense for real data.
2015-12-13 11:38:37 +00:00
moneromooo-monero 595893fcba
blockchain: log block (not chain) height in "BLOCK SUCCESFULLY ADDED"
This makes it log the same height as the original code, which is
less confusing when comparing behaviors.
2015-12-13 11:16:37 +00:00
moneromooo-monero 2369968dc3
blockchain: fix off by one in get_blocks 2015-12-13 11:16:07 +00:00
moneromooo-monero a98e976f9e
blockchain_db: fixup missing key images in early DB version
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 533acc30ed
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-06 21:55:05 +00:00
moneromooo-monero d887c18e33
hardfork: fix more major/minor issues
Also add some more tests, and rename some instances of
"version" and "add" for clarity.

NOTE: the starting height values are sometimes wrong.
I suspect this is due to the hard fork reorg code being
buggy, since they're good when syncing after the fact.
However, they're not actually used by the consensus code,
so I'm ignoring this for now, but this needs debugging.
2015-11-24 20:47:12 +00:00
moneromooo-monero 53c75ab4a0
blockchain: log versions as numbers, not characters 2015-11-23 15:53:59 +00:00
Riccardo Spagni 328636cdb3
fixed testnet fork point, added comment data back in 2015-11-22 19:40:38 +02:00
Riccardo Spagni 8fe1111b5b
update v2 testnet fork height 2015-11-21 15:36:13 +02:00
moneromooo-monero 932994c0cb
Relay transactions when they linger too long in the pool
The last relayed time of a transaction is maintained, and
transactions will be relayed again if they are still in the
pool after a certain amount of time, which increases with
the transaction's age. All such transactions are resent,
whether or not they originated on the local node.
2015-11-21 00:56:21 +00:00
Javier Smooth baf101ef4a More changes for 2-min blocks
Use the correct block time for realtime fuzz on locktime
Use the correct block time to calculate next_difficulty on alt chains (will not work as-is with voting)
Lock unit tests to original block time for now
2015-11-13 00:37:35 -08:00
Javier Smooth 4fea1a5fe7 Adjust difficulty target (2 min) and full reward zone (60 kbytes) for block version 2 2015-11-13 00:30:45 -08:00
moneromooo-monero 4187e569d8
hardfork: allow per-fork voting thresholds
And setup the first fork to not vote
2015-11-08 13:04:41 +00:00
moneromooo-monero 4f873bcbaa
Remove some old/obsolete/unused code
git history's here if needed to get any of this back
2015-10-27 10:01:20 +00:00
Riccardo Spagni e1c29c94ad
Merge pull request #444
ecbb732 Fix leak on real output when using a very recent output (moneromooo-monero)
2015-10-26 17:57:56 +02:00
Riccardo Spagni db68eca0de
Merge pull request #442
43bca0d blockchain_utilities: new blockchain_dump diagnostic tool (moneromooo-monero)
5f397e4 Add functions to iterate through blocks, txes, outputs, key images (moneromooo-monero)
0a5a5e8 db_bdb: record numbers for recno databases start at 1 (moneromooo-monero)
50dfdc0 db_bdb: DB_KEYEMPTY is also not found for non-top recon fields (moneromooo-monero)
572780e blockchain_db: use the DNE exceptions where appropriate (moneromooo-monero)
2015-10-26 17:56:55 +02:00
moneromooo-monero ecbb732faa
Fix leak on real output when using a very recent output
The wallet and the daemon applied different height considerations
when selecting outputs to use. This can leak information on which
input in a ring signature is the real one.

Found and originally fixed by smooth on Aeon.
2015-10-25 16:34:57 +00:00
moneromooo-monero 5f397e4412
Add functions to iterate through blocks, txes, outputs, key images 2015-10-25 12:36:11 +00:00
moneromooo-monero 6376627530
hardfork: switch voting to block minor version
Using major version would cause older daemons to reject those
blocks as they fail to deserialize blocks with a major version
which is not 1. There is no such restriction on the minor
version, so switching allows older daemons to coexist with
newer ones till the actual fork date, when most will hopefully
have updated already.

Also, for the same reason, we consider a vote for 0 to be a
vote for 1, since older daemons set minor version to 0.
2015-10-21 19:21:14 +01:00
moneromooo-monero b13e7f284b
blockchain_export can now export to a blocks.dat format
Also make the number of blocks endian independant, and add
support for testnet
2015-10-17 00:11:26 +01:00
moneromooo-monero ac90d488e7
from hard fork 2, all outputs must be decomposed
The wallet decomposes fully as of now too.
2015-10-11 13:02:55 +01:00
moneromooo-monero 90ccad1236
from hard fork 2, claim a quantized reward in coinbase
The small leftover is carried forward
2015-10-10 12:28:44 +01:00
moneromooo-monero 33affd2d17
blockchain: on hardfork 2, require mixin 2 at least if possible 2015-09-27 22:46:53 +01:00
moneromooo-monero 0a7421b607
hardfork: rescan speedup
Add a block height before which version 1 is assumed
Use DB transactions
2015-09-27 22:46:41 +01:00
moneromooo-monero 4bbf944df0
blockchain: on hardfork 2, allow miners to claim less money than allowed
So they can avoid dust if they so wish
2015-09-27 22:46:30 +01:00
moneromooo-monero 198f557d38
blockchain: use different hard fork settings for testnet and mainnet 2015-09-27 22:46:13 +01:00
moneromooo-monero 5b11a89a76
hardfork: most state now saved to the DB
There will be a delay on first load of an existing blockchain
as it gets reparsed for this state data.
2015-09-20 18:42:52 +01:00
moneromooo-monero e546f3724a
Add an RPC call and daemon command to get info on hard fork voting 2015-09-19 16:47:48 +01:00
moneromooo-monero d06713199e
blockchain: force a hardfork recalculation at load time
Since the state isn't actually saved anywhere, as the archive
code isn't called in the new DB version.
2015-09-19 16:47:42 +01:00
moneromooo-monero a7177610b3
core: add consts where appropriate 2015-09-19 16:47:35 +01:00
moneromooo-monero 8ffc508cef
core: moan when we think an update is needed to get latest hard fork info 2015-09-13 18:09:57 +01:00
moneromooo-monero f85498422d
blockchain: use the new hardfork class 2015-09-12 11:15:53 +01:00
moneromooo-monero 813e758b62
blockchain: remove obsolete call to libc srand
crypto::rand is now used for output selection
2015-08-24 21:58:19 +01:00
roman 59cc92b388 removed some gcc warnings. mainly unused variables. 2015-08-23 17:59:24 +02:00
moneromooo-monero 378d004b37
blockchain: mark two places where the new code differs from the old
And I'd like a comment from tewinget or someone else
2015-08-15 18:46:19 +01:00
moneromooo-monero 73d42a75d4
blockchain: update cumulative size after block addition
Block addition can fail, and the old code would not update the
cumulative size in that case.
2015-08-15 18:44:56 +01:00
moneromooo-monero 4a443775e8
blockchain: remove dead code 2015-08-15 18:44:31 +01:00
moneromooo-monero 3f9089a767
blockchain: do not try to add a tx the pool when it was nor taken out
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.
2015-08-15 18:42:29 +01:00
moneromooo-monero 769d5ef0e6
blockchain: fix off by 1 in timestamp median calculations
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.
2015-08-15 12:37:23 +01:00
moneromooo-monero 35abef1b92
blockchain: remove dead code 2015-08-11 10:48:51 +01:00
moneromooo-monero 4f19e68476
blockchain: factor get_num_outpouts(amount) calls
It has to stay constant as we get the blockchain lock for the
entire function. Avoids some unnecessary DB accesses.
2015-08-09 18:14:30 +01:00
moneromooo-monero 275894cdef
blockchain: always select random outs using triangular distribution
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-09 18:07:44 +01:00
Riccardo Spagni 5a26676932
Merge pull request #343
e20a4dd blockchain: fix testnet syncing (to not use blocks.dat) (moneromooo-monero)
2015-07-18 22:59:02 +02:00
moneromooo-monero e20a4ddc76
blockchain: fix testnet syncing (to not use blocks.dat)
These are mainnet blocks, and would cause syncing on testnet to
reject all incoming blocks.
2015-07-18 10:25:22 +01:00
NoodleDoodleNoodleDoodleNoodleDoodleNoo 70ae2ee711 Fixed threadpool bug when running on single core systems.
*Thanks to freshman for reporting bug.
2015-07-17 20:02:29 -07:00
NoodleDoodleNoodleDoodleNoodleDoodleNoo 94ea3e8ed2 Removed on_idle() calls to Blockchain::store_blockchain() for lmdb.
Added option to cache tx-input verification results.
2015-07-15 23:20:25 -07:00
NoodleDoodleNoodleDoodleNoodleDoodleNoo e5d2680094 ** CHANGES ARE EXPERIMENTAL (FOR TESTING ONLY)
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 (0f4a036437)
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-15 23:20:16 -07:00
NoodleDoodleNoodleDoodleNoodleDoodleNoo 1f83444d3d Update blockchain.cpp
Fix compilation error
2015-07-15 23:20:15 -07:00
NoodleDoodleNoodleDoodleNoodleDoodleNoo da1d3c01de
Experimental BDB workaround optimizations 2015-07-15 21:13:42 -07:00
Riccardo Spagni e01d32e52d
cleaning up, removing redundant files, renaming, fixing incorrect licenses 2015-05-31 13:40:18 +02:00
Thomas Winget 7b14d4a17f
Steps toward multiple dbs available -- working
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-25 12:09:44 -04:00
warptangent 275cbd4348
Add support for database open with flags
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-16 00:26:59 -07:00
Thomas Winget eee3ee7073
BlockchainDB implementations have names now
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-13 21:39:27 -04:00
Thomas Winget 5eab480cb1
Moved BlockchainDB into its own src/ subfolder
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.
2015-03-06 15:20:45 -05:00
warptangent ce71abd0fe
Move LMDB storage to subfolder 2015-02-23 00:33:37 -08:00
warptangent 59305d3137
Blockchain: match original function declaration from blockchain_storage 2015-02-23 00:33:35 -08:00
warptangent b88ab643ca
Fix Blockchain::get_tail_id() to set parameter to last block number instead of height
This reflects the behavior of blockchain_storage::get_tail_id().

Fixes #27 so that RPC method getlastblockheader works.
2015-02-22 10:41:41 -08:00
warptangent 8bd1983cdc
Blockchain: reflect log updates from blockchain_storage
See commit 4ba680f294
2015-02-01 19:30:20 -08:00
warptangent 7f9b070165
Blockchain: reflect log and assert updates from blockchain_storage
See commit cf5a8b1d6c
2015-02-01 19:30:14 -08:00
warptangent 70342ecada
Blockchain: reflect log level of blockchain_storage
Update to match LOG_PRINT_RED_Lx statements.
See commit cf5a8b1d6c
2015-02-01 19:29:18 -08:00
warptangent c8d27fb38d
Blockchain: reflect assert behavior of blockchain_storage for get_tx_outputs_gindexs() 2015-02-01 19:29:03 -08:00
warptangent d00ee784db
Update recently added log statement to fix possible null dereference
This would have been triggered if function was called without fourth
parameter and ring signature check failed.
2015-02-01 19:28:58 -08:00
Thomas Winget acd4c369e4
Should fix std::min issues related to size_t 2015-01-19 17:39:38 -05:00
warptangent 800d9b9247
Remove code previously made unused and marked unused 2015-01-14 13:41:57 -08:00
warptangent 0840c2fd7e
Fix height assertion in Blockchain::handle_alternative_block()
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.
2015-01-11 21:23:02 -08:00
warptangent 63051bea1c
Fix comparison between main and alternate chain's cumulative
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.
2015-01-11 21:23:02 -08:00
warptangent 909ea81067
Remove a have_block() check so alternate block can be processed
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().
2015-01-11 21:23:02 -08:00
warptangent 1701c26750
Use block index when obtaining block's difficulty for log statement
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"
2015-01-11 19:57:46 -08:00
warptangent 4eba21fd48
Fix transfers to support mixins
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.
2015-01-09 16:34:18 -08:00
warptangent d045dfa7ce
Fix transfers (without mixins)
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.
2015-01-09 16:34:12 -08:00
Thomas Winget 14555eefd5
Fixes segfault in Blockchain::handle_alternative_block
This commit should fix the segfault in
Blockchain::handle_alternative_block, and also updates a few comments
that were either incorrect or incomplete.
2015-01-09 05:56:51 -05:00
warptangent c5c100c69b Obtain tx hash and tx output index from amount and output offset
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.
2015-01-04 19:39:43 -08:00
Thomas Winget c50cd95674 Fixes a bug with getting output metadata from BlockchainDB
Thanks to moneromooo-monero for spotting the bug.
2015-01-04 19:39:43 -08:00
moneromooo-monero 1860658eec blockchain: do not append "testnet" to the data directory
It is already there (unless overridden via command line).
2015-01-04 19:39:42 -08:00
moneromooo-monero 198368b2e1 blockchain: fix wallet syncing from scratch
When the wallet syncs from the first block, it is fine to start
at the genesis block.
2015-01-04 19:39:42 -08:00
moneromooo-monero b7270ab60e blockchain: add consts where appropriate 2015-01-04 19:39:41 -08:00
Thomas Winget 215e63b79f extraneous semicolon in Blockchain::complete_timestamps_vector
credit here:
https://bitcointalk.org/index.php?topic=583449.msg9562845#msg9562845
2015-01-04 19:39:40 -08:00
Thomas Winget 6c8b8acfe4 more blockchain height-related fixes, syncing other nodes code this time 2015-01-04 19:39:40 -08:00
Thomas Winget 26a7db38eb add new checkpointing behavior to Blockchain class 2015-01-04 19:31:20 -08:00
Thomas Winget 71b18d7166 moar bug fixes, removed debug prints 2015-01-04 19:31:19 -08:00
Thomas Winget 0915913111 BlockchainLMDB seems to be working*!
* - Well, mostly.  Haven't let it sync too far just yet.  Currently
trying to figure out the best way to deal with LMDB/mmap virtual memory
pages.
2015-01-04 19:31:19 -08:00
Thomas Winget 1a546e3222 some bug fixes, but still needs work
There are quite a few debug prints in this commit that will need removed
later, but for posterity (in case someone wants to debug this while I'm
away), I left them in.

Currently errors when syncing on the first block that has a "real"
transaction.  Seems to not be able to validate the ring signature, but I
can't for the life of me figure out what's going wrong.
2015-01-04 19:31:19 -08:00
Thomas Winget 006afe2172 Minor bug fixes and debug prints
Blockchain and BlockchainLMDB classes now have a debug print at the
beginning of each function at log level 2.  These can be removed at any
time, but for now are quite useful.

Blockchain runs, and adds the genesis block just fine, but for some
reason isn't getting new blocks.
2015-01-04 19:31:19 -08:00
Thomas Winget 90f402e258 minor fixes to Blockchain.cpp 2015-01-04 19:31:19 -08:00
Thomas Winget 74a1a89e27
Integrate BlockchainDB into cryptonote_core
Probably needs more looking at -- lot of things were done...in a rushed
sort of way.  That said, it all builds and *should* be at least
testable.

update for rebase (warptangent 2015-01-04)
  fix conflicts with upstream CMakeLists.txt files

  src/CMakeLists.txt (remove edits from original commit)
  tests/CMakeLists.txt (remove edits from original commit)
  src/cryptonote_core/CMakeLists.txt (edit)
  - use blockchain db .cpp and .h files
  - add LMDB_LIBRARIES
2015-01-04 19:29:51 -08:00
Thomas Winget bc44bc19f4 Initial commit of BlockchainDB tests, other misc
miscellaneous changes to BlockchainDB/blockchain as well, namely
replacing instances of std::list with std::vector
2015-01-04 18:41:44 -08:00
Thomas Winget 07733f98c0 update new blockchain to build with new changes
Still need to add in the new checkpointing functionality, as well as
touch up a few things, but is okay for now.
2015-01-04 18:41:44 -08:00
Thomas Winget 1ffbeb2d2e stupid past me, fixing typos and shit... 2015-01-04 18:41:44 -08:00
Thomas Winget aba548cbf7 import of BlockchainDB files
tried rebasing, tree-filter, and many other things.  at this point,
the history of these files previous to this can live on
in my bc2 branch, as I'm importing them as-is to here.
2015-01-04 18:41:43 -08:00