Commit Graph
100 Commits
Author SHA1 Message Date
moneromooo-monero 945ac788d4 hardfork: fix accepting v2 blocks too early 2016-01-15 11:54:35 +00:00
moneromooo-monero 664dc42e18 rpc: fix missing target information in RPC call
which fixes the status command via RPC too.

Turns out there are two versions of the GET_INFO call.
I'd never noticed before.
2016-01-11 22:52:01 +00:00
moneromooo-monero eaf4dcd747 daemon: fix status command when run from command line 2016-01-11 21:50:41 +00:00
moneromooo-monero 67bbb56a6c wallet2: decide at runtime which upper tx size to use
The value will be different depending on whether we've reached
the first hard fork, which allows a larger size, or not.

This fixes transactions being rejected by the daemon on mainnet
where the first hard fork is not yet active.
2016-01-10 11:56:13 +00:00
moneromooo-monero a44d94d390 rpc: is_key_image_spent now checks the tx pool too 2016-01-05 22:16:24 +00:00
moneromooo-monero 7f8e5ced47 daemon: fix ban length using wrong parameter 2016-01-02 16:30:12 +00:00
moneromooo-monero a8caab1af1 unit_tests: initialize db object in ctor, not open
open isn't actually called in those tests
2016-01-02 11:37:00 +00:00
moneromooo-monero 1e07110a7a Nicer looking exit when blockchain.bin is found
Do not print the exception message, and write the important bit
in red, since people will only read the last line otherwise.
2015-12-31 17:09:00 +00:00
moneromooo-monero 40f97ce83d core: do not use the persistent pool state for tests
Fixes intermittent test failures when the pool contains
unexpected transactions that were brought in from the
live pool.
2015-12-31 14:24:06 +00:00
moneromooo-monero 5c67c486e8 wallet: don't forget to close the file after storing cache
Also add some flags to open, as epee's save_string_to_file does,
to truncate file, etc.
2015-12-31 10:34:17 +00:00
moneromooo-monero 1813736562 unit_tests: remove an unused variable 2015-12-30 17:30:54 +00:00
moneromooo-monero 70dd34634c unit_tests: fix hardfork test build
The dummy blockchain class needed to have the newly added
is_read_only virtual function.
2015-12-30 17:30:01 +00: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
moneromooo-monero ed5d017c0f miner: minor fixes on stop
- only try to stop if actually started
- print number of threads before zeroing it

This fixes the suspiciously doubled "Mining has been stopped"
message on exit.
2015-12-30 16:06:32 +00:00
moneromooo-monero b245215193 core_tests: deinit core before destroying it
This fixes a use after free by ioservice threads
2015-12-30 16:05:52 +00:00
moneromooo-monero bc8a52efd8 wallet: add a rescan_bc command and rescan_blockchain RPC
Blockchain hashes and key images are flushed, and blocks are
pulled anew from the daemon.
The console command is shortened to match bc_height.
This should make it a lot easier on users who are currently
told to remove this particular cache file but keep the keys
one, etc, etc.
2015-12-30 15:06:03 +00:00
moneromooo-monero 92ef6b54fe wallet: protect against exceptions in the block pull thread
This can happen when the daemon exits, which would also cause
the wallet to crash via unhandled exception
2015-12-30 12:43:15 +00:00
moneromooo-monero af2106122d net_peerlist: move a couple functions from public to private
They do not take the object lock, and are meant to be used only
internally, called from a function which does take the lock.
2015-12-30 11:37:49 +00:00
moneromooo-monero 61befc2293 wallet: store cache to file without unnecessary memory buffer 2015-12-29 15:46:37 +00:00
moneromooo-monero 3b56036bb3 Merge pull request #1 from LMDB/crash-fix
Tweak 45800a25e9
2015-12-29 00:11:46 +00:00
moneromooo-monero 61ce8d6fde wallet_rpc_server: exit async, so we reply to stop_wallet RPC
Reported by saddam
2015-12-28 23:38:30 +00:00
moneromooo-monero 09533557b5 blockchain_db: inform user about new format if blockchain.bin is found 2015-12-28 23:03:46 +00: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 9847db6920 wallet: do not return error if incoming_transfers finds none
reported by saddam
2015-12-28 20:27:06 +00:00
moneromooo-monero 78b65cf7e8 db_lmdb: safety close db at exit
Noticed by hyc

Also set m_open to false when closed
2015-12-28 19:23:02 +00:00
moneromooo-monero 45800a25e9 db_lmdb: fix a strdup/delete[] mistmatch 2015-12-28 19:22:37 +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 50ee591152 hardfork: ensure current_fork_index can not become negative on rescan 2015-12-26 13:17:00 +00:00
moneromooo-monero b90e14d927 tests: add a unit test for canonical decomposed amounts 2015-12-26 11:41:50 +00:00
moneromooo-monero 79beed221d tests: fix various tests by using parameters better suited to monero
Either smaller coin values (as monero has smaller block rewards),
or pre-hard fork values (full reward zone), or post-Bytecoin values
(emission speed).
2015-12-25 22:26:34 +00:00
moneromooo-monero d0a8362b6b tests: fix some double spending tests
Some tests assume the first output in a transaction goes to the recipient.
However, it can be the change. When it is, the recipient's keys will not
recognize this output. To fix this, we send all we have, to ensure there
is no change, and the first output goes to the recipient.

I'm not sure why this worked with Cryptonote. The tests sent 17 coins,
which seems way smaller than the first Bytecoin block reward, so there
would have been change too. Maybe outputs were not shuffled originally.
2015-12-25 22:23:36 +00:00
moneromooo-monero 2358d0d5be tests: use 255 as a "too high" block version
While the original cryptonote accepted only the current major
version, we can accept higher ones.
2015-12-25 22:22:12 +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 6c868595b7 unit_tests: fix hard fork tests
A couple stopped passing when the hard fork code was made
to reject incoming hard fork versions it did not know about.
2015-12-24 16:12:03 +00:00
moneromooo-monero 8b0200adf8 unit_tests: new test for IP blocking 2015-12-24 16:05:19 +00:00
moneromooo-monero 22581a0441 epee: regularly cleanup connections we kept a reference to
Since connections from the ::connect method are now kept in
a deque to be able to cancel them on exit, this leaks both
memory and a file descriptor. Here, we clean those up after
30 seconds, to avoid this. 30 seconds is higher then the
5 second timeout used in the async code, so this should be
safe. However, this is an assumption which would break if
that async code was to start relying on longer timeouts.
2015-12-23 11:19:16 +00:00
moneromooo-monero 26c5118000 README.md: mention --no-igd in the Tor paragraph 2015-12-22 12:41:54 +00:00
moneromooo-monero 1e2f2d7da0 epee: fix hang on exit
When the boost ioservice is stopped, pending work notifications
will not happen. This includes deadline timers, which would
otherwise time out the now cancelled I/O operations. When this
happens just after starting a new connect operation, this can
leave that operations in a state where it won't receive either
the completion notification nor a timeout, causing a hang.

This is fixed by keeping a list of connections corresponding
to the connect operations, and cancelling them before stopping
the boost ioservice.

Note that the list of these connections can grow unbounded, as
they're never cleaned up. Cleaning them up would involve
working out which connections do not have any pending work,
and it's not quite clear yet how to go about this.
2015-12-22 12:39:02 +00:00
moneromooo-monero 17ff6f2114 net_node: fix a hang on exit
One loop was not paying attention to the stop signal, and could
end up looping forever
2015-12-22 12:38:52 +00:00
moneromooo-monero 8c93608f2f wallet: fix load/save versioning bug for recently added tx data
The version number passed to those data's serialize function
was always 0, not the wallet's version as I had expected.
A version number now exists for these structures so they're
versioned correctly.
2015-12-20 14:03:15 +00:00
moneromooo-monero bd15f97d2a README.md: mention rlwrap usage 2015-12-19 19:21:03 +00:00
moneromooo-monero af1da980f0 README.md: fix Tor paragraph to use warptangent's TCP DNS changes 2015-12-19 19:12:38 +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 760331b427 epee: make log macros behave like statements
In particular, make this kind of thing do what one expects
it to do:

if (x) LOG_PRINT("True"); else LOG_PRINT("No");
2015-12-19 14:48:52 +00:00
moneromooo-monero 3f2970fadb Add missing semicolons after log statements 2015-12-19 14:47:37 +00:00
moneromooo-monero 0ab56b80db print top block hash in daemon diff command
and add top block hash in get_info RPC
2015-12-18 19:56:17 +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
moneromooo-monero 63cb1a59aa move another non user useful log to L1 2015-12-17 22:35:34 +00:00
moneromooo-monero 02827d5155 p2p: minor log formatting fix 2015-12-17 22:35:01 +00:00
moneromooo-monero 9b4f8b4b7e wallet: save to a temporary file, then rename
This should avoid most of wallet cache corruption cases
2015-12-17 22:32:54 +00:00
moneromooo-monero bf45505785 README.md: add a bit of info about using bitmonerod with Tor 2015-12-14 23:10:28 +00:00
moneromooo-monero d462c62343 db_lmdb: always use a batch tx if possible
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-14 18:47:13 +00:00
moneromooo-monero cb4ee1b50d Tone down L0 logs during daemon sync some more 2015-12-14 17:45:32 +00:00
moneromooo-monero a74cc1bee2 hardfork: only accept major versions we know about 2015-12-14 09:17:07 +00:00
moneromooo-monero 217792351d Tone down a bit L0 logs during daemon sync 2015-12-14 00:36:37 +00:00
moneromooo-monero fefc0b5556 daemon: fix crash exiting with ^C
We need to stop the p2p layer, which causes the rest to shutdown
gracefully. Hitting ^C was still going through another path.
2015-12-13 23:56:02 +00:00
moneromooo-monero 7f77b23da8 posix_daemonizer: only create the main daemon object in the last child
This prevents the intermediate thread from exiting properly, as
fork creates a child process with only one thread, so any existing
data_logger thread will not be in the child. Since this thread
sets a flag the data_logger dtor blocks on, all children threads
will hang on exit.
2015-12-13 19:48:11 +00:00
moneromooo-monero cbded439f4 core_tests: fix ring_signature_1 tests
They were trying to send too much monero, and thus failing.
The parameters were set in such a way that the (simple) output
gathering code could fulfill them for 4 block rewards for the
original Bytecoin emission, but that does not work with monero
so we need to use smaller values.
2015-12-13 13:58:13 +00:00
moneromooo-monero c3d208fcbe core_tests: bump default test fee to 0.02 monero
The current monero consensus uses 0.01 per kB fees, so use enough
for 2 kB transactions for now. It'll probably have to be either
bumped further or changed to calculate the proper fee.
2015-12-13 13:56:15 +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 eee44e62bc unit_tests: fix block reward test using post hard fork settings
This would fail, as the post hard fork settings would yield
different data, and the test expects pre hard fork data.
2015-12-13 11:18:59 +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 8af913a3d1 db_lmdb: implement BlockchainLMDB::reset
It is needed by the core tests
2015-12-13 11:14:06 +00:00
moneromooo-monero 4833f4f96f db_bdb: implement BlockchainBDB::reset
It is needed by the core tests
2015-12-13 11:14:00 +00:00
moneromooo-monero 18bf06e4a5 tx_pool: fix "minumim" typo in message 2015-12-13 11:13:51 +00:00
moneromooo-monero 44f1267a39 tests: fix a typo in test name 2015-12-13 11:10:33 +00:00
moneromooo-monero 1494557633 db_lmdb: create all needed directories, not just the leaf one 2015-12-13 11:09:43 +00:00
moneromooo-monero 015b68a2be db_bdb: create all needed directories, not just the leaf one 2015-12-13 11:08:59 +00:00
moneromooo-monero f141869cac tests: remove data-dir argument registration
It is already registered in cryptonote::core::init_options,
which we now call
2015-12-09 17:31:15 +00:00
moneromooo-monero 336b37580f Register daemon command line arguments to core if they're used in core
This fixes coretests, which does not register daemon specific arguments,
but uses core, which uses those arguments. Also gets rid of an unwanted
dependency on daemon code from core.
2015-12-08 23:06:29 +00:00
moneromooo-monero 2c83055597 net_node: add a --offline argument
It will not try to connect to the monero network, nor listen
2015-12-07 20:21:45 +00:00
moneromooo-monero f7464343ea daemon: add mining status to the status command 2015-12-07 19:40:12 +00:00
moneromooo-monero 1c8262c527 db_bdb: move log_set_config call before open
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-07 19:22:22 +00:00
moneromooo-monero 8620b31019 db_bdb: support for libdb without DB_FORCESYNC 2015-12-07 09:31:53 +00:00
moneromooo-monero 34e388949d p2p: failure to load p2pstate.bin is not fatal anymore
Clear any partially loaded data, and start with a default config
2015-12-07 00:20:56 +00:00
moneromooo-monero 4cede1830e console_handler: catch exception inside the input loop
This prevents an exception from existing the loop without
calling the exit handler, if one is defined.
The daemon defines one, which stops the p2p layer, and will
only exit once the p2p layer is shut down. This would cause
a hang upon an exception, as the input thread would have
exited and the daemon would wait forever with no console
user input.
2015-12-06 22:03:53 +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 c6cfe0f26d wallet: make the wallet refresh type a wallet setting
instead of a command line setting. It makes sense that is is
a long lived setting.
2015-12-05 21:44:25 +00:00
moneromooo-monero fef2493617 wallet: default auto-refresh to true for old wallets 2015-12-05 21:10:12 +00:00
moneromooo-monero a3c5ca077c blockchain_db: make the indexing base a BlockchainDB virtual function 2015-12-05 18:41:29 +00:00
moneromooo-monero 1965fce402 wallet: add a stop_wallet RPC call 2015-12-05 14:53:37 +00:00
moneromooo-monero a702118426 blockchain_dump: fix output key dump for BDB 1-based indices
Berkeley DB uses 1 based indices for RECNO databases, and the
implementation of BlockchainDB for Berkeley DB assumes 1 based
indices are passed to the API, whereas the LMDB one assumes
0 based indices. This is all internally consisteny, but since
the BDB code stores 1 based indices in the database, external
users have to be aware of this, as the indices will be off by
one depending on which DB is used.
2015-12-05 12:40:01 +00:00
moneromooo-monero 3bf35e14e3 db_bdb: read 32 bit heights from keys
Keys in Berkeley DB are 32 bits. We don't want to read random
bits in the high part.
2015-12-04 22:25:00 +00:00
moneromooo-monero 41029d6d74 wallet2: default auto-refresh to true for preexisting wallets 2015-11-30 11:08:15 +00:00
moneromooo-monero d68a63e404 wallet: cancellable refresh
^C while in manual refresh will cancel the refresh, since that's
often an annoying thing to have to wait for. Also, a manual refresh
command will interrupt any running background refresh and take
over, rather than wait for the background refresh to be done, and
look to be hanging.
2015-11-29 23:24:56 +00:00
moneromooo-monero 36a298c375 simplewallet: add tr markers in a few missing user visible strings 2015-11-29 22:24:15 +00:00
moneromooo-monero 66849ac236 simplewallet: swap colors in show_transfers
Green is now used for incoming transfers, and magenta for outgoing
transfers. This is consistent to the scheme used by other logging.
2015-11-29 13:20:54 +00:00
moneromooo-monero 3030e3ecff wallet2: remove confirmed transactions from detached blocks 2015-11-29 12:07:54 +00:00
moneromooo-monero 9ee48e9071 wallet2: speed up wallet refresh for large miners 2015-11-28 21:15:07 +00:00