Commit graph

537 commits

Author SHA1 Message Date
warptangent 42f8fe5c7f
Fix formatting 2015-02-23 00:33:36 -08:00
warptangent aa82f786c7
Fix log statement 2015-02-23 00:33:36 -08:00
warptangent 26873db199
Remove unused variable 2015-02-23 00:33:36 -08:00
warptangent 4b90fd389d
Add log statement 2015-02-23 00:33:36 -08:00
warptangent 2531aa31f8
Add and extend log statements 2015-02-23 00:33:35 -08:00
warptangent 59305d3137
Blockchain: match original function declaration from blockchain_storage 2015-02-23 00:33:35 -08:00
warptangent cd972bdcc2
Update year and formatting in license 2015-02-23 00:33:26 -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 963bc09087
Revert "Bounds error, should fix #27"
This reverts commit 6f1c4b4c2c.
2015-02-22 10:31:11 -08:00
Thomas Winget 6f1c4b4c2c
Bounds error, should fix #27 2015-02-20 21:09:32 -05:00
Riccardo Spagni 7b01a076b9
added tx size to incoming_transfers RPC Call 2015-02-20 00:57:26 +02:00
Thomas Winget fc62af5cf8
Merge remote-tracking branch 'monero-project/master' into blockchain 2015-02-05 08:51:19 -05:00
warptangent 84fe5fbd65
Add compile-time support for both db implementations: in-memory and LMDB
Usage:

default is lmdb for blockchain branch:
$ make release

same as:
$ DATABASE=lmdb make release

for original in-memory implementation:
$ DATABASE=memory make release
2015-02-02 11:53:09 -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
warptangent 79ea1f6ff0
Merge upstream
Merge branch 'monero-project/master' into blockchain
2015-01-30 16:19:22 -08:00
Riccardo Spagni 3ece1584f0
make fallback compatible with newer slow-hash 2015-01-28 11:32:52 +02:00
Riccardo Spagni 497a514bd3 replaced 64-bit multiplication in difficulty.cpp with a portable version 2015-01-27 14:06:33 +02:00
Riccardo Spagni 9b3673a54c
added portable slow-hash, updated makefile targets, fixed readme 2015-01-27 09:43:15 +02:00
Riccardo Spagni e70bc3d369
fixed sse2 ifdef 2015-01-27 09:15:14 +02:00
Riccardo Spagni 2b3b70a261
remove aes flag, detect no sse2 2015-01-27 09:05:47 +02:00
Thomas Winget 9d52378029
Merge to keep up with upstream
Merge 'monero-project/master' with blockchain
2015-01-21 11:26:53 -05:00
Thomas Winget acd4c369e4
Should fix std::min issues related to size_t 2015-01-19 17:39:38 -05:00
Riccardo Spagni 9e0516c1dd
Merge pull request #215
24d500c Add a --restricted-rpc flag to simplewallet (moneromooo-monero)
2015-01-15 14:03:48 +02:00
Riccardo Spagni 580e003357
Merge pull request #214
87839cd Allow get_bulk_payments to return all payments regardless of payment ID (moneromooo-monero)
2015-01-15 13:59:48 +02:00
warptangent f74792b778
Fix seed node threaded DNS lookup
Use copied value of seed node index during thread creation, not
reference.
- fixes segfault

Use boost:🧵:try_join_until() instead of an atomic flag result
variable for each thread.

Add and handle interrupt for thread timeout.
- fixes segfault where a thread exceeds requested timeout and tries to
  assign results to a referenced, but now out-of-scope, variable in
  the main thread.
2015-01-14 14:01:04 -08: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 4d0a94b20c
Complete implementation of transaction removal
Complete method BlockchainLMDB::remove_output()
  - use output index as the key for:
    m_output_indices, m_output_txs, m_output_keys
  - call new method BlockchainLMDB::remove_amount_output_index()

Add method to remove amount output index.
  - BlockchainLMDB::remove_amount_output_index()
  - for m_output_amounts

This also fixes the segfault when blockchain reorganization is
attempted.
2015-01-11 21:22:09 -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
moneromooo-monero 24d500ce8e
Add a --restricted-rpc flag to simplewallet
It restricts RPC to a subset of "view only" commands. Kind of like
a poor man's view key replacement.
2015-01-11 12:11:43 +00:00
moneromooo-monero 87839cd484
Allow get_bulk_payments to return all payments regardless of payment ID
by giving an empty list of payment IDs.
2015-01-11 12:04:05 +00: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 429a740562
throw inline functions need to keep exception type
As it is useful for functions calling BlockchainDB functions to know
whether an exception is expected (attempting to get a block that doesn't
    exist and counting it missing if not, to save time checking if it
    does, for example), the inline functions throw{0,1} need to keep the
exception type information.

Slight comment update due to copy/paste failure.
2015-01-09 07:29:05 -05: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
Riccardo Spagni 24ddfa792e
Merge pull request #206
1b46226 std::atomic_flag has no copy/move constructor, can't have a vector (Thomas Winget)
df53c0a small typo in previous commit (Thomas Winget)
4a53898 DNS seed timeout and fallback (Thomas Winget)
2015-01-08 12:18:00 +02:00
Riccardo Spagni 7de1a2d57a
previous hash added to GBT 2015-01-06 18:37:10 +02:00
Thomas Winget 7374b81b23 Merge pull request #19 from warptangent/fix_tx_output
Obtain tx hash and tx output index from amount and output offset
2015-01-04 19:39:44 -08: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
moneromooo-monero ad8200a573 db_lmdb: fix global index calculation off by 1
This finally fixes raw tx being accepted by the daemon.
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 57b80c541e db_lmdb: remove redundant checks 2015-01-04 19:39:43 -08:00
Thomas Winget c3fa07b44b update comments to reflect changed code 2015-01-04 19:39:43 -08:00
moneromooo-monero 1362846dd7 blockchain_converter: add --testnet for converting testnet blockchain 2015-01-04 19:39:43 -08:00
moneromooo-monero 59d2b0ed1c db_lmdb: do not give the group database write permissions 2015-01-04 19:39:43 -08:00
moneromooo-monero 4c2a45288a db_lmdb: catch attempt to remove block from an empty blockchain
It would probably have thrown when not finding a block at
height 2^64-1, but better make things clear.
2015-01-04 19:39:43 -08:00
moneromooo-monero 3a3459d59b db_lmdb: factor all the log+throw code paths 2015-01-04 19:39:42 -08:00
moneromooo-monero 3fcb8daf6e db_lmdb: factor the MDB_val setup code
It makes the code simpler, avoids possible copy/paste errors
(wrong sizeof, etc), and generally unclutters the calling code.
2015-01-04 19:39:42 -08:00
moneromooo-monero 609cf7fc92 blockchain_converter: a bit more user friendly output 2015-01-04 19:39:42 -08:00
moneromooo-monero 2b9f737872 blockchain_converter: only call data path function once 2015-01-04 19:39:42 -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 1c578ad3f8 db_lmdb: remove block timestamp too when removing a block 2015-01-04 19:39:42 -08:00
moneromooo-monero c93a186637 db_lmdb: do not cast const away 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 1d23db220a db_lmdb: do not keep a dangling pointer to stack objects 2015-01-04 19:39:41 -08:00
moneromooo-monero 29b5876ad1 db_lmdb: make cursor internal members private 2015-01-04 19:39:41 -08:00
moneromooo-monero a3157d7b69 blockchain_storage: refactor genesis block creation
The existing assert is kept as it is stricter than the function's
internal assert.
2015-01-04 19:39:41 -08:00
moneromooo-monero 8e41b1e735 blockchain_storage: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero 98bdadcad7 blockchain_converter: delete blockchain on succesful exit
While the dtor implementation does not actually do anything, other
paths do delete it, and the dtor might do someting later.
2015-01-04 19:39:41 -08:00
moneromooo-monero 256162fcd5 checkpoints: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero b7270ab60e blockchain: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero 23f3cb4c0e blockchain_db: add consts where appropriate 2015-01-04 19:39:41 -08:00
moneromooo-monero 10fd6cab6c blockchain_db: factor some exception code
Ideally, the log would go in the exception's ctor, but
two log levels are used, so I'd need to specify the level
in the ctor, which isn't great as it's not really related
to the exception.
2015-01-04 19:39:41 -08:00
moneromooo-monero 11129b9ee4 blockchain_converter: use the actual blockchain location 2015-01-04 19:39:40 -08:00
moneromooo-monero 0886183568 build: add liblmdb to the cmake autodetection system
update for rebase (warptangent 2015-01-04)
  src/cryptonote_core/CMakeLists.txt (edit)
  - replace LMDB_LIBRARIES with LMDB_LIBRARY set from autodetection
2015-01-04 19:39:40 -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 8e1b7e2ad4 raised maximum mapsize for lmdb to ~16GB 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 9455e0cd58 ~ didn't work, need hard path. debug print. 2015-01-04 19:39:40 -08:00
Thomas Winget 4af0918501
very, VERY primitive blockchain converter
hard-coded config folder, hard-coded BlockchainDB subclass.

Needs finessing, but should be testable this way.

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

  src/CMakeLists.txt (edit original commit)
  src/blockchain_converter/CMakeLists.txt (add)
2015-01-04 19:38:56 -08:00
Thomas Winget 26a7db38eb add new checkpointing behavior to Blockchain class 2015-01-04 19:31:20 -08:00
Thomas Winget 006e106ae9 Store output pubkeys separately, bug fixes 2015-01-04 19:31:20 -08:00
Thomas Winget ab7951d99a Minor bugfixes, redundancy removal
Minor bugfixes in block removal

Storing outputs outside their transactions is largely unnecessary, and
thus has been removed.
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 d8c570b588 All LMDB BlockchainDB implemented, not tested
All of the functionality for the LMDB implementation of BlockchainDB is
implemented, but only what is in tests/unit_tests/BlockchainDB.cpp has
been tested.  This is basically add a block, see if you can get the
block and a tx from the block.  More tests should be added at some
point.
2015-01-04 19:01:11 -08:00
Thomas Winget e47e343a1c LMDB blockchain: remove outputs and spent keys 2015-01-04 19:01:10 -08:00
Thomas Winget a0af217d9a Adding block data to LMDB BlockchainDB coded
Still needs testing (and need to write a few more unit tests), but
everything should be there.  Lots of unfortunate duplication,
but...well, I can't see a way around it using LMDB.

A couple of other minor changes in this commit, only slightly relevant.
2015-01-04 19:01:10 -08:00
Thomas Winget db00ce0173 Parts of LMDB impl of BlockchainDB done and working
The rest should just be tedious copypasta and modification.
2015-01-04 19:01:10 -08:00
Thomas Winget b98b96489f Initial commit of lmdb BlockchainDB impl 2015-01-04 18:41:44 -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 67515b8b19 missing typedef 2015-01-04 18:41:43 -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
Riccardo Spagni f4b69d553a
year updated in license 2015-01-02 18:52:46 +02:00
Thomas Winget 1b462261b8
std::atomic_flag has no copy/move constructor, can't have a vector 2014-12-15 17:43:12 -05:00
Thomas Winget df53c0a595
small typo in previous commit 2014-12-15 17:28:11 -05:00
Thomas Winget 4a53898764
DNS seed timeout and fallback 2014-12-15 17:23:42 -05:00
Riccardo Spagni f4675dc05d
Merge pull request #203
583cf0a Document existing function (warptangent)
95eb944 Repeat prompt for wallet path if invalid (warptangent)
2014-12-13 13:52:30 +02:00