Commit Graph

201 Commits

Author SHA1 Message Date
stoffu 3880bf396a
cryptonote_protocol_handler.inl: remove span read just now that failed to pass some basic tests 2018-04-28 11:10:59 +09:00
stoffu da249fd5ba
cryptonote_protocol_handler.inl: fix return type mismatches (int vs bool) 2018-04-28 11:07:51 +09:00
Thaer Khawaja dad1077577 Only log an error if fork version is higher AND is not known. 2018-04-22 17:26:44 -07:00
Dimitris Apostolou 57c0b1ed9f Fix typos in various files 2018-03-15 18:25:38 +02:00
Riccardo Spagni 4f93f74528
Merge pull request #3277
0e7ad2e2 Wallet API: generalize 'bool testnet' to 'NetworkType nettype' (stoffu)
af773211 Stagenet (stoffu)
cc9a0bee command_line: allow args to depend on more than one args (stoffu)
55f8d917 command_line::get_arg: remove 'required' for dependent args as they're always optional (stoffu)
450306a0 command line: allow has_arg to handle arg_descriptor<bool,false,true> #3318 (stoffu)
9f9e095a Use `genesis_tx` parameter in `generate_genesis_block`. #3261 (Jean Pierre Dudey)
2018-03-05 19:11:20 +02:00
Edward Betts fbcc91c2a4 Correct spelling mistakes. 2018-03-05 17:00:40 +00:00
stoffu af773211cb
Stagenet 2018-03-05 11:55:05 +09:00
Riccardo Spagni ef47ba95c8
Merge pull request #3229
928c1825 cryptonote_protocol: guard against all threads in standby (moneromooo-monero)
2018-02-16 14:23:53 +01:00
Riccardo Spagni bdf0339dda
Merge pull request #3181
e3f0980a daemon: don't drop RPC with busy error when running offline (moneromooo-monero)
2018-02-16 14:19:54 +01:00
moneromooo-monero 928c1825f0
cryptonote_protocol: guard against all threads in standby 2018-02-02 22:33:53 +00:00
Riccardo Spagni 4fcf609942
Merge pull request #3186
7ed62e63 cryptonote_protocol: fix std::move usage on different types (moneromooo-monero)
2018-01-28 09:54:17 -08:00
xmr-eric 18216f19dd Update 2018 copyright 2018-01-26 10:03:20 -05:00
moneromooo-monero 7ed62e63e5
cryptonote_protocol: fix std::move usage on different types 2018-01-26 10:13:06 +00:00
Riccardo Spagni 5a312752af
Merge pull request #3040
69f9a075 cryptonote_protocol: fix missing space in version mismatch message (moneromooo-monero)
2018-01-25 16:44:51 -08:00
Riccardo Spagni 75cbb7719e
Merge pull request #3015
f06603a4 cryptonote_protocol: update target height when receiving blocks (moneromooo-monero)
2018-01-25 16:39:16 -08:00
moneromooo-monero e3f0980a1d
daemon: don't drop RPC with busy error when running offline 2018-01-25 13:35:58 +00:00
Riccardo Spagni 0b5994fbec
Merge pull request #3004
a2c845c7 cryptonote_protocol: internal error consistency size check (moneromooo-monero)
2018-01-10 11:54:23 +01:00
moneromooo-monero 69f9a07553
cryptonote_protocol: fix missing space in version mismatch message 2017-12-31 17:32:57 +00:00
moneromooo-monero f06603a439
cryptonote_protocol: update target height when receiving blocks 2017-12-27 13:54:19 +00:00
moneromooo-monero a2c845c7e3
cryptonote_protocol: internal error consistency size check 2017-12-24 13:04:40 +00:00
moneromooo-monero 45a1c4c088
add empty container sanity checks when using front() and back() 2017-12-18 15:15:40 +00:00
moneromooo-monero 46d6fa35c9
cryptonote_protocol: sanity check chain hashes from peer 2017-12-18 15:15:07 +00:00
moneromooo-monero 25584f8639
cryptonote_protocol: print peer versions when unexpected
also avoid integer underflow on zero height
2017-12-18 15:15:05 +00:00
moneromooo-monero bb89ae8b20
move connection_basic and network_throttle from src/p2p to epee
These even had the epee namespace.
This fixes some ugly circular dependencies.
2017-12-16 23:28:43 +00:00
moneromooo-monero 4abf25f3c9
cryptonote_core does not depend on p2p anymore
As a followon side effect, this makes a lot of inline code
included only in particular cpp files (and instanciated
when necessary.
2017-12-16 23:28:38 +00:00
moneromooo-monero b927f0b17e
cryptonote_protocol: fix corner case looping asking for same block hashes 2017-12-03 13:05:10 +00:00
moneromooo-monero 310b790a64
make connection_id a string in RPC
It's sent as JSON, so raw binary is not appropriate
2017-11-18 00:13:07 +00:00
moneromooo-monero 383ff4f689
remove "using namespace std" from headers
It's nasty, and actually breaks on Solaris, where if.h fails to
build due to:

  struct map *if_memmap;
2017-11-14 16:56:10 +00:00
moneromooo-monero 1ff638e927
protocol: drop connections which don't handshake after some time 2017-10-22 19:45:30 +01:00
Vasil Dimov 4d35ad7603
Fix compiler warnings with Clang 6.0.0.
monero/src/cryptonote_protocol/block_queue.cpp:208:44: error:
      suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
  static const boost::uuids::uuid uuid0 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                           {                                          }

monero/src/wallet/wallet_rpc_server.cpp:1895:43: error:
      lambda capture 'wal' is not used [-Werror,-Wunused-lambda-capture]
  tools::signal_handler::install([&wrpc, &wal](int) {
                                          ^

monero/src/cryptonote_protocol/cryptonote_protocol_handler.inl:1616:40: error:
      lambda capture 'arg' is not used [-Werror,-Wunused-lambda-capture]
    m_p2p->for_each_connection([this, &arg, &fluffy_arg, &exclude_context, &fullConnections...
                                       ^

monero/src/cryptonote_protocol/cryptonote_protocol_handler.inl:1616:46: error:
      lambda capture 'fluffy_arg' is not used [-Werror,-Wunused-lambda-capture]
    m_p2p->for_each_connection([this, &arg, &fluffy_arg, &exclude_context, &fullConnections...
                                             ^

monero/src/blockchain_utilities/blockchain_export.cpp:181:3: error:
      bool literal returned from 'main' [-Werror,-Wmain]
  CHECK_AND_ASSERT_MES(r, false, "Failed to initialize source blockchain storage");
  ^                       ~~~~~
monero/contrib/epee/include/misc_log_ex.h:180:97: note:
      expanded from macro 'CHECK_AND_ASSERT_MES'
  ...fail_ret_val, message)   do{if(!(expr)) {LOG_ERROR(message); return fail_ret_val;};}while(0)
                                                                  ^      ~~~~~~~~~~~~
monero/src/blockchain_utilities/blockchain_export.cpp:195:3: error:
      bool literal returned from 'main' [-Werror,-Wmain]
  CHECK_AND_ASSERT_MES(r, false, "Failed to export blockchain raw data");
  ^                       ~~~~~
monero/contrib/epee/include/misc_log_ex.h:180:97: note:
      expanded from macro 'CHECK_AND_ASSERT_MES'
  ...fail_ret_val, message)   do{if(!(expr)) {LOG_ERROR(message); return fail_ret_val;};}while(0)
                                                                  ^      ~~~~~~~~~~~~
2017-10-15 22:02:24 +03:00
Riccardo Spagni d5ab55b8d7
Merge pull request #2604
0a872798 protocol: kick idle peers by dropping them (moneromooo-monero)
2017-10-15 18:50:32 +02:00
Riccardo Spagni 5ea20d6944
Merge pull request #2469
7adceee6 precomputed block hashes are now in blocks of N (currently 256) (moneromooo-monero)
2017-10-15 17:23:50 +02:00
moneromooo-monero 0a872798bc
protocol: kick idle peers by dropping them
This is safer, as we don't risk break expectations (eg, requesting
block hashes and then receiving a late set of blocks). Dropping a
connection means another will be attempted in a fresh state.

Also bump the kick timeout to 5 minutes, to ensure we only kick
really idle peers.
2017-10-07 20:29:11 +01:00
moneromooo-monero 5d65a75b69
move checkpoints in a separate library 2017-09-25 21:16:26 +01:00
Riccardo Spagni 74c4f1a563
Merge pull request #2460
3487d810 cryptonote_protocol: fix needless chain hashes downloads (moneromooo-monero)
2017-09-25 17:01:53 +02:00
moneromooo-monero 7adceee634
precomputed block hashes are now in blocks of N (currently 256)
This shaves a lot of space off binaries
2017-09-18 16:29:00 +01:00
moneromooo-monero 3487d81034
cryptonote_protocol: fix needless chain hashes downloads
The last known hash was calculated incorrectly, causing
further chain hash downloads to restart from the current
chain. When the block queue has close to 10k blocks waiting,
this causes frequent downloads of 10k more hashes, but
with only the last few hashes actually being useful.
2017-09-17 14:13:59 +01:00
moneromooo-monero 7f2f6ee1c9
protocol: remove hop count on block propagation
It is unused, as it was apparently a future optimization,
and it leaks some information (though since pools publish
thei blocks they find, that amount seems small).
2017-09-17 10:26:12 +01:00
moneromooo-monero 6ac61100a1
Add a --fluffy-blocks option to relay blocks as fluffy blocks
Defaults to off, but fluffy blocks are forced enabled on testnet
2017-09-03 11:11:11 +01:00
Riccardo Spagni 1e57e48342
Merge pull request #2372
c867357a cryptonote_protocol: error handling on cleanup_handle_incoming_blocks (moneromooo-monero)
ce901fcb Fix blockchain_import wedge on exception in cleanup_handle_incoming_blocks (moneromooo-monero)
84fa015e core: guard against exceptions in handle_incoming_{block,tx} (moneromooo-monero)
2017-09-02 11:30:57 +02:00
moneromooo-monero c867357adc
cryptonote_protocol: error handling on cleanup_handle_incoming_blocks 2017-08-29 16:11:39 +01:00
moneromooo-monero 63d8dddc0a
cryptonote_protocol: remove old spans when received as old blocks
fixes getting those in a loop
2017-08-28 00:42:58 +01:00
Riccardo Spagni 36b978f50e
Merge pull request #2314
c22d22e2 Cleanup test impact of adding safesyncmode() method (Howard Chu)
9a859844 Toggle SAFE syncmode on and off automatically (Howard Chu)
2017-08-26 23:43:22 +02:00
moneromooo-monero df0cffede0
cryptonote_protocol: warn if we see a higher top version we expect 2017-08-23 13:38:18 +01:00
moneromooo-monero 317ab21a03
cryptonote_protocol: less strict check on top version on connect
This allows peers who synced past a fork on the wrong height
to reorg to the right chain after they updated their software
to include the new version.
2017-08-23 13:38:15 +01:00
moneromooo-monero cc81a37155
cryptonote_protocol: update target height when syncing too 2017-08-23 13:38:13 +01:00
moneromooo-monero e2ad372b87
cryptonote_protocol: simplify and remove unnecessary casts 2017-08-23 13:38:10 +01:00
moneromooo-monero 727e67cada
cryptonote_protocol: print peer top height along with its version 2017-08-23 13:38:06 +01:00
Howard Chu c22d22e2db
Cleanup test impact of adding safesyncmode() method 2017-08-22 15:11:09 +01:00
moneromooo-monero 70b8c6d77a
cryptonote_protocol: misc fixes to the new sync algorithm
Fix sync wedge corner case:
It could happen if a connection went into standby mode, while
it was the one which had requested the next span, and that span
was still waiting for the data, and that peer is not on the
main chain. Other peers can then start asking for that data
again and again, but never get it as only that forked peer does.

And various other fixes
2017-08-21 21:57:19 +01:00
Howard Chu 9a859844f4
Toggle SAFE syncmode on and off automatically
If monerod is started with default sync mode, set it to SAFE after
synchronization completes. Set it back to FAST if synchronization
restarts (e.g. because another peer has a longer blockchain).

If monerod is started with an explicit sync mode, none of this
automation takes effect.
2017-08-20 16:30:28 +01:00
Riccardo Spagni 4466b6d1b0
Merge pull request #2303
5a283078 cryptonote_protocol: large block sync size before v4 (moneromooo-monero)
7b747607 cryptonote_protocol: kick idle synchronizing peers (moneromooo-monero)
2017-08-17 21:39:44 +02:00
Riccardo Spagni 4859a00134
Merge pull request #2300
42b34b35 Consistently print peer id in hex and on 16 chars (moneromooo-monero)
2017-08-17 21:36:15 +02:00
Riccardo Spagni 1d32a5a445
Merge pull request #2291
b59cd074 befor -> before (Nano Akron)
2017-08-17 21:35:48 +02:00
moneromooo-monero 5a283078ec
cryptonote_protocol: large block sync size before v4 2017-08-17 13:11:52 +01:00
moneromooo-monero 7b74760756
cryptonote_protocol: kick idle synchronizing peers
In case they dropped off downloading for any reason, they'll get
sent to download again.
2017-08-16 22:24:50 +01:00
moneromooo-monero 42b34b3545
Consistently print peer id in hex and on 16 chars 2017-08-16 10:56:55 +01:00
Nano Akron b59cd0745b befor -> before
Really unique yet consistent spelling mistake
2017-08-15 23:23:26 +01:00
moneromooo-monero 827afcb7ea
protocol: pass blockchain cumulative difficulty when syncing
Not used yet.
2017-08-15 21:03:37 +01:00
Riccardo Spagni 53dde37ceb
Merge pull request #2276
a1891ebe tests: fix tests build (moneromooo-monero)
2017-08-15 20:53:41 +02:00
Riccardo Spagni 86cf8cac86
Merge pull request #2275
88e83f94 cryptonote_protocol_handler: log versions as unsigned ints (moneromooo-monero)
2017-08-15 20:53:08 +02:00
Riccardo Spagni 1d093eff67
Merge pull request #2273
0e8d60c0 cryptonote_protocol: fix recv/send idle time before handshake (moneromooo-monero)
2017-08-15 20:51:50 +02:00
Riccardo Spagni e0df740bc9
Merge pull request #2272
f90bbe2a cryptonote_protocol: keep target in sync with dropped connections (moneromooo-monero)
2017-08-15 20:51:35 +02:00
moneromooo-monero 35e01a6e50
cryptonote_protocol: fix "holes" in block download schedule 2017-08-15 17:49:06 +01:00
moneromooo-monero 3da1edfde5
cryptonote_protocol: fix out of order addition
This was broken by the reorg fix, since we now have to add blocks
regardless of their starting height. We now check whether we know
the parent for the first block in the next span, or whether it was
requested. If neither, it's an orphan. If it is not known, but was
requested, we wait to get that block.
2017-08-15 16:54:08 +01:00
moneromooo-monero 2ec15a6931
daemon: print peers' top height in sync_info 2017-08-12 20:36:31 +01:00
moneromooo-monero 88e83f9427
cryptonote_protocol_handler: log versions as unsigned ints
They're interpreted as characters otherwise
2017-08-12 11:57:05 +01:00
moneromooo-monero 08abb670e1
protocol: fix reorgs while syncing 2017-08-12 11:22:42 +01:00
moneromooo-monero a1891ebea9
tests: fix tests build
Add get_fork_version and add_ideal_fork_version to core so
cryptonote_protocol does not have to need the Blockchain
class directly, as it's not in its dependencies, and add
those to the fake core classes in tests too.
2017-08-10 11:12:56 +01:00
moneromooo-monero 0e8d60c06c
cryptonote_protocol: fix recv/send idle time before handshake 2017-08-09 21:22:05 +01:00
moneromooo-monero f90bbe2a5c
cryptonote_protocol: keep target in sync with dropped connections
When a node is dropped, we stop considering its claimed blockchain
height as a factor in the target height calculation. This prevents
a runaway chain from being still thought to be the target even if
the nodes carrying it are dropped.
2017-08-09 20:49:24 +01:00
moneromooo-monero 635929eaca
protocol: add checks for top block hard fork version
We won't even talk to a peer which claims a wrong version
for its top block. This will avoid syncing to known bad
peers in the first place.
Also add IP fails when failing to verify a block.
2017-08-09 10:28:41 +01:00
Riccardo Spagni 6db8a60a18
Merge pull request #2149
158c3ecf core: thread most of handle_incoming_tx (moneromooo-monero)
f57ee382 cryptonote_protocol: retry stale spans early (moneromooo-monero)
90df52e1 cryptonote_protocol: light cleanup (moneromooo-monero)
84e23156 cryptonote_protocol: avoid spurious SYNCHRONIZED OK messages (moneromooo-monero)
5be43fcd cryptonote_protocol_handler: sync speedup (moneromooo-monero)
2017-08-07 15:24:58 +02:00
Riccardo Spagni b1af32b48d
Merge pull request #2242
1c9196b0 cryptonote_protocol: fix days behind calc on testnet (moneromooo-monero)
2017-08-07 15:13:45 +02:00
Riccardo Spagni ea46a5527a
Merge pull request #2234
214fd81e some include cleanup (moneromooo-monero)
2017-08-07 15:13:07 +02:00
moneromooo-monero 158c3ecff3
core: thread most of handle_incoming_tx 2017-08-07 09:33:20 +01:00
moneromooo-monero f57ee382b8
cryptonote_protocol: retry stale spans early
Connections can be dropped by the net_node layer,
unbeknownst to cryptonote_protocol, which would then
not flush any spans scheduled to that connection,
which would cause it to be only downloaded again
once it becomes the next span (possibly after a small
delay if it had been requested less than 5 seconds
ago).
2017-08-07 09:33:17 +01:00
moneromooo-monero 90df52e12f
cryptonote_protocol: light cleanup 2017-08-07 09:33:14 +01:00
moneromooo-monero 84e23156ac
cryptonote_protocol: avoid spurious SYNCHRONIZED OK messages 2017-08-07 09:33:09 +01:00
moneromooo-monero 5be43fcdba
cryptonote_protocol_handler: sync speedup
A block queue is now placed between block download and
block processing. Blocks are now requested only from one
peer (unless starved).

Includes a new sync_info coommand.
2017-08-07 09:33:04 +01:00
moneromooo-monero 1c9196b0c5
cryptonote_protocol: fix days behind calc on testnet 2017-08-02 22:34:02 +01:00
moneromooo-monero 214fd81e93
some include cleanup 2017-07-31 16:36:52 +01:00
rbrunner7 f1b76c8424 cryptonote_protocol: Set send_idle_time in connection_info correctly 2017-07-24 18:58:39 +02:00
moneromooo-monero 8f96cfc20a
Remove typeid use in network_address
Since I had to add an ID to the derived classes anyway,
this can be used instead. This removes an apparently
pointless warning from CLANG too.
2017-06-28 09:11:24 +01:00
Riccardo Spagni a0174ad534
Merge pull request #2064
6fc2dc39 cryptonote_protocol_handler: fix crash in debug log (moneromooo-monero)
2017-06-18 16:40:52 +02:00
Riccardo Spagni a237f90c5b
Merge pull request #2052
072102cf abstracted nework addresses (moneromooo-monero)
2017-06-18 14:23:59 +02:00
moneromooo-monero 6fc2dc3927
cryptonote_protocol_handler: fix crash in debug log 2017-06-01 19:42:33 +01:00
moneromooo-monero 072102cfd2
abstracted nework addresses
All code which was using ip and port now uses a new IPv4 object,
subclass of a new network_address class. This will allow easy
addition of I2P addresses later (and also IPv6, etc).
Both old style and new style peer lists are now sent in the P2P
protocol, which is inefficient but allows peers using both
codebases to talk to each other. This will be removed in the
future. No other subclasses than IPv4 exist yet.
2017-05-27 11:35:54 +01:00
moneromooo-monero b52abd1370
Move txpool to the database
Integration could go further (ie, return_tx_to_pool calls should
not be needed anymore, possibly other things).

poolstate.bin is now obsolete.
2017-05-25 22:23:37 +01:00
moneromooo-monero b54e19d00e
protocol: fix wrong tx being looked up from fluffy block
Found by smooth
2017-03-13 19:16:25 +00:00
moneromooo-monero 09e060febb
protocol: fix fluffy to normal block dropping txes 2017-03-12 14:14:51 +00:00
moneromooo-monero 4d05955d53
protocol: fix "sync done" message not appearing 2017-02-24 01:28:56 +00:00
Riccardo Spagni c3599fa7b9
update copyright year, fix occasional lack of newline at line end 2017-02-21 19:38:18 +02:00
Riccardo Spagni b252afb0b0
Merge pull request #1736
424b76a4 Fix spurious synchronization status msgs (Howard Chu)
2017-02-21 11:27:49 +02:00
Riccardo Spagni 49efd3add9
Merge pull request #1727
0288310e blockchain_db: add "raw" blobdata getters for block and transaction (moneromooo-monero)
2017-02-21 11:27:15 +02:00
Howard Chu 424b76a4e5
Fix spurious synchronization status msgs
Only update target height if it's actually greater than the current target.
Only display "synchronized" when current height equals target.
2017-02-15 14:41:42 +00:00
moneromooo-monero 0288310e3b
blockchain_db: add "raw" blobdata getters for block and transaction
This speeds up operations such as serving blocks to syncing peers
2017-02-13 21:11:37 +00:00
moneromooo-monero 53f040445f
cryptonote_protocol: tweaks to the syncing speedup
- only pause mining once we've got the lock (in practice, it'll
  already be paused by another thread if we can't get the lock
  at once though)
- do not call prepare_handle_incoming_blocks when we dismissed
  all the blocks, it only causes cleanup_handle_incoming_blocks
  to complain afterwards
2017-02-13 19:36:31 +00:00
Riccardo Spagni e246dd1443
Merge pull request #1717
8bdc86be protocol: speed up sync by minimizing duplicate work (moneromooo-monero)
61dfa310 epee: fix some log macros not printing context nicely (moneromooo-monero)
2017-02-12 23:28:38 +02:00
moneromooo-monero 8bdc86beb4
protocol: speed up sync by minimizing duplicate work
In particular, the prepare_handle_incoming_blocks call
is pretty lengthy, and entirely pointless in the common
case where several different connections will prepare
the exact same blocks.
2017-02-12 17:17:30 +00:00