Commit graph

212 commits

Author SHA1 Message Date
moneromooo-monero
ef005f5e72
p2p: add a couple early outs when the stop signal is received
This avoids quicker exit
2017-08-16 15:44:52 +01:00
Riccardo Spagni
4bfb58328d
Merge pull request #2282
7fdc178a p2p: fix random peer index being too large (moneromooo-monero)
2017-08-15 20:54:38 +02:00
Riccardo Spagni
f980b2ca89
Merge pull request #2277
6ce769c1 p2p: get net log spam down a bit (moneromooo-monero)
2017-08-15 20:53:27 +02:00
Riccardo Spagni
74522c7e84
Merge pull request #2236
cb2d5110 Tweak net logs so we get more info on why networking can't start (moneromooo-monero)
2017-08-15 20:52:44 +02:00
moneromooo-monero
cb2d5110ff
Tweak net logs so we get more info on why networking can't start
This should prevent "silent" failures to start
2017-08-15 19:49:25 +01:00
moneromooo-monero
7fdc178abb
p2p: fix random peer index being too large 2017-08-11 14:29:55 +01:00
moneromooo-monero
6ce769c123
p2p: get net log spam down a bit 2017-08-10 14:30:42 +01:00
moneromooo-monero
7591c528d0
p2p: fallback on seed nodes if we can't make a connection
This avoids failing to connect to the network in case all
known peers are unavailable (which can happen if the peer
list is small).
2017-08-09 22:55:25 +01:00
moneromooo-monero
e49f6d439d
net_node: fix m_in_timedsync initialization
This fixes nodes not being able to connect to nodes which use
recent code. While there, init peer_id too.
2017-08-08 17:23:02 +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
ea46a5527a
Merge pull request #2234
214fd81e some include cleanup (moneromooo-monero)
2017-08-07 15:13:07 +02:00
Riccardo Spagni
9b0daf49db
Merge pull request #2220
c6ba7d11 p2p: move m_in_timedsync from connection_context to p2p_connection_context (moneromooo-monero)
2017-08-07 15:11:37 +02:00
Riccardo Spagni
43c6e452fa
Merge pull request #2219
04ebfbfe p2p: close connections when exiting (moneromooo-monero)
9a10148c p2p: fix thread leak (moneromooo-monero)
2017-08-07 15:11:20 +02:00
Riccardo Spagni
a6ea26e7fa
Merge pull request #2215
06aea2cf move get_proof_of_trust_hash from util.h to p2p_protocol_defs.h (moneromooo-monero)
2017-08-07 15:10:42 +02: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
41f935ddb2
network_throttle: remove unneeded heap allocations
This will keep leak traces less noisy, as those were one off
allocations that were technically leaking.
2017-08-01 18:47:05 +01:00
moneromooo-monero
c6ba7d110f
p2p: move m_in_timedsync from connection_context to p2p_connection_context
It's got no place in the base class as it's P2P specific field
2017-08-01 18:41:57 +01:00
moneromooo-monero
214fd81e93
some include cleanup 2017-07-31 16:36:52 +01:00
moneromooo-monero
04ebfbfefa
p2p: close connections when exiting
This ensures they don't leak if they were in the middle of an
async operation.
2017-07-29 10:04:36 +01:00
moneromooo-monero
9a10148c01
p2p: fix thread leak 2017-07-28 22:23:05 +01:00
moneromooo-monero
06aea2cf0a
move get_proof_of_trust_hash from util.h to p2p_protocol_defs.h
This avoids having to include p2p_protocol_defs.h in util.h,
as util.h is used a lot, and p2p_protocol_defs.h includes
a lot of other things that most users don't need.
2017-07-27 15:46:47 +01: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
f31b89012d
Merge pull request #2073
07c4276c Don't issue a new timedsync while one is already in progress (Howard Chu)
cf3a376c Don't timeout a slow operation that's making progress (Howard Chu)
340830de Fix PR#2039 (Howard Chu)
2017-06-24 12:41:09 +02:00
Howard Chu
07c4276cbe
Don't issue a new timedsync while one is already in progress
A timedsync is issued every minute on a connection, but the input
tineout is 2 minutes. This means a new sync request could be issued
while a slow sync request was already in progress. The additional
request will further clog the network on a slow connection, and
cause a premature timeout.
2017-06-15 16:54:03 +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
Riccardo Spagni
ed09652a17
Merge pull request #1701
8277e67f Add anchor connections (Miguel Herranz)
2017-05-05 11:26:11 +02:00
moneromooo-monero
c1c9eeaaf7
p2p: use the fallback seed IPs when not enough seeds are found
In case the DNS seed(s) is/are down, which would otherwise
cause the fallback seeds to never be used. Also if the seeds
resolve to too few IPs.
2017-03-18 11:40:28 +00:00
Miguel Herranz
1a7e18bfdf Make gray peer selection uniform
Prevents the system from always picking the gray peers with the most
recent last_seen.
2017-02-28 17:39:39 +01:00
Miguel Herranz
f3be9991d7 Make get_random_gray_peer distribution uniform
get_random_gray_peer is used to implement feeler connections, described
in: https://eprint.iacr.org/2015/263.pdf 2. Random selection
2017-02-27 18:29:50 +01:00
Riccardo Spagni
72deb4846d
updated fallback nodes 2017-02-21 22:40:26 +02:00
Riccardo Spagni
c3599fa7b9
update copyright year, fix occasional lack of newline at line end 2017-02-21 19:38:18 +02:00
moneromooo-monero
e74b3ab5f7
core: add p2p bind port options from net_node
They're now used by core to determine the data directory to use
for the txpool directory.

This fixes an assert in the core tests, which don't use the RPC
server, which normally initializes the P2P code.
2017-02-21 09:35:23 +00:00
moneromooo-monero
d43fde8a9b
network_throttle: demote spammy logs to TRACE 2017-02-13 16:54:45 +00:00
moneromooo-monero
8ec2a8d2b0
net_node: fix spurious warning about using uninitialized data
This is only used to load, not save
2017-02-12 14:06:36 +00:00
Miguel Herranz
8277e67f11 Add anchor connections
Based on https://eprint.iacr.org/2015/263.pdf 4. Anchor connections.

Peer list serialisation version bumped to 5.
2017-02-10 23:28:54 +01:00
kenshi84
8027ce0c75 extract some basic code from libcryptonote_core into libcryptonote_basic 2017-02-08 22:45:15 +09:00
Riccardo Spagni
fcb299b4ae
Merge pull request #1641
ca94d0a4 Separate data per P2P port (Miguel Herranz)
2017-02-02 22:41:28 +02:00
Riccardo Spagni
f9e60dcd55
Merge pull request #1617
0644eed7 Remove boost/foreach.cpp includes (Miguel Herranz)
36dd3e23 Replace BOOST_REVERSE_FOREACH with ranged for (Miguel Herranz)
629e3101 Replace BOOST_FOREACH with C++11 ranged for (Miguel Herranz)
2017-02-02 18:16:39 +02:00
Miguel Herranz
ca94d0a43c Separate data per P2P port
poolstate.bin and p2pstate.bin are stored in .bitmonero/ if the default
P2P port is being used.

If another port is used both files are stored in
.bitmonero/PORTNUMBER/.
2017-01-28 14:16:06 +01:00
Miguel Herranz
8141973e00 Remove unreachable returns
CATCH_ENTRY_L0 already returns the second value.
2017-01-23 11:29:34 +01:00
Miguel Herranz
0644eed772 Remove boost/foreach.cpp includes 2017-01-22 23:31:34 +01:00
Miguel Herranz
36dd3e238f Replace BOOST_REVERSE_FOREACH with ranged for 2017-01-22 21:47:39 +01:00
Miguel Herranz
629e3101ab Replace BOOST_FOREACH with C++11 ranged for 2017-01-22 21:38:10 +01:00
Riccardo Spagni
add98edfc3
Merge pull request #1609
4cdf0a35 p2p: always recreate a new peer id on startup (moneromooo-monero)
2017-01-22 11:47:43 -05:00
Riccardo Spagni
f798a2ab85
Merge pull request #1606
f8b97aef p2p: show ban/unban logs by default again (moneromooo-monero)
2017-01-22 11:43:11 -05:00
moneromooo-monero
4cdf0a35c9
p2p: always recreate a new peer id on startup
This prevents easy fingerprinting when you change IPs, and
will be a must when kovri gets used.
2017-01-22 11:37:55 +00:00
moneromooo-monero
f8b97aef34
p2p: show ban/unban logs by default again 2017-01-21 21:19:21 +00:00
Miguel Herranz
1c4d65c011 Rename method to get_random_gray_peer 2017-01-21 13:04:49 +01:00
Miguel Herranz
03a54ee0c9 Fix logging that broke after rebasing 2017-01-21 11:22:04 +01:00
Miguel Herranz
6bdd3a59b5 Use set_peer_just_seen to keep last_seen updated 2017-01-21 10:11:32 +01:00
Miguel Herranz
82dbeedd1b Add gray peer list housekeeping system
A random peer from the gray peer list is selected and a connection is
made to check if the peer is alive.

If the connection and handshake are successful the peer is promoted to
the white peer list, in case of failure the peer is evicted from the
gray peer list.

The connection is closed after the check in either case.
2017-01-21 10:09:38 +01:00
Riccardo Spagni
3db3a6ee1a
Merge pull request #1593
cbcdf8ad Honor depth in get_peerlist_head method (Miguel Herranz)
2017-01-20 20:59:09 -05:00
Riccardo Spagni
d10425025a
Merge pull request #1572
0e0e6c5f Reduce to one connection per IP (Miguel Herranz)
3f269e98 Limit incoming connections from the same IP (Miguel Herranz)
2017-01-20 20:54:04 -05:00
Miguel Herranz
cbcdf8ad35 Honor depth in get_peerlist_head method
The method returned depth + 2 because:

- push_back was executed before the condition.
- > instead of >= causing one more iteration.
2017-01-18 21:41:52 +01:00
Miguel Herranz
0e0e6c5f39 Reduce to one connection per IP 2017-01-16 18:16:32 +01:00
moneromooo-monero
5833d66f65
Change logging to easylogging++
This replaces the epee and data_loggers logging systems with
a single one, and also adds filename:line and explicit severity
levels. Categories may be defined, and logging severity set
by category (or set of categories). epee style 0-4 log level
maps to a sensible severity configuration. Log files now also
rotate when reaching 100 MB.

To select which logs to output, use the MONERO_LOGS environment
variable, with a comma separated list of categories (globs are
supported), with their requested severity level after a colon.
If a log matches more than one such setting, the last one in
the configuration string applies. A few examples:

This one is (mostly) silent, only outputting fatal errors:

MONERO_LOGS=*:FATAL

This one is very verbose:

MONERO_LOGS=*:TRACE

This one is totally silent (logwise):

MONERO_LOGS=""

This one outputs all errors and warnings, except for the
"verify" category, which prints just fatal errors (the verify
category is used for logs about incoming transactions and
blocks, and it is expected that some/many will fail to verify,
hence we don't want the spam):

MONERO_LOGS=*:WARNING,verify:FATAL

Log levels are, in decreasing order of priority:
FATAL, ERROR, WARNING, INFO, DEBUG, TRACE

Subcategories may be added using prefixes and globs. This
example will output net.p2p logs at the TRACE level, but all
other net* logs only at INFO:

MONERO_LOGS=*:ERROR,net*:INFO,net.p2p:TRACE

Logs which are intended for the user (which Monero was using
a lot through epee, but really isn't a nice way to go things)
should use the "global" category. There are a few helper macros
for using this category, eg: MGINFO("this shows up by default")
or MGINFO_RED("this is red"), to try to keep a similar look
and feel for now.

Existing epee log macros still exist, and map to the new log
levels, but since they're used as a "user facing" UI element
as much as a logging system, they often don't map well to log
severities (ie, a log level 0 log may be an error, or may be
something we want the user to see, such as an important info).
In those cases, I tried to use the new macros. In other cases,
I left the existing macros in. When modifying logs, it is
probably best to switch to the new macros with explicit levels.

The --log-level options and set_log commands now also accept
category settings, in addition to the epee style log levels.
2017-01-16 00:25:46 +00:00
Miguel Herranz
3f269e988c Limit incoming connections from the same IP 2017-01-15 12:11:27 +01:00
Chris Vickio
fcf66925c1 remove unused fields from network_throttle (unused-private-field warning) 2017-01-14 15:06:07 +03:00
kenshi84
2ac8007544 also use portable serializer for boost_serialization_helper.h and net_node.inl, completely adandon boost/archive/binary_oarchive.hpp 2016-12-20 13:04:19 +09:00
Riccardo Spagni
f2ea2afb77
Merge pull request #1398
f4772bae Fix a few minor typos (Pierre Boyer)
2016-12-04 22:28:22 +02:00
Riccardo Spagni
8086379680
Merge pull request #1397
3f7d6fb5 Fix delayed exit when syncing (moneromooo-monero)
2016-12-04 22:27:41 +02:00
Riccardo Spagni
4a0be41dfe
Merge pull request #1396
7c0dd5e4 net_node: drop connections from banned IPs after looping through connections (moneromooo-monero)
2016-12-04 22:26:12 +02:00
Pierre Boyer
f4772bae81 Fix a few minor typos 2016-12-04 14:13:54 +01:00
moneromooo-monero
3f7d6fb57d
Fix delayed exit when syncing 2016-12-04 12:27:45 +00:00
moneromooo-monero
7c0dd5e46c
net_node: drop connections from banned IPs after looping through connections
This keeps the connections lock just for the time of looping
and adding connectoins to a list, and the dropping happens
after it. This should avoid lengthy delays waiting for the
connections lock.
2016-12-03 11:20:48 +00:00
moneromooo-monero
4adde0423b
p2p: possibly fix crash in relay_blocks 2016-12-01 23:52:16 +00:00
moneromooo-monero
17b6bd6d35
Fix DNS failures in offline mode preventing daemon startup 2016-11-23 23:14:49 +00:00
Dion Ahmetaj
d61bd8187e add lightweight block propagation ("fluffy blocks")
Added a new command to the P2P protocol definitions to allow querying for support flags.

Implemented handling of new support flags command in net_node. Changed for_each callback template to include support flags. Updated print_connections command to show peer support flags.

Added p2p constant for signaling fluffy block support.

Added get_pool_transaction function to cryptnote_core.

Added new commands to cryptonote protocol for relaying fluffy blocks.

Implemented handling of fluffy block command in cryptonote protocol.

Enabled fluffy block support in node initial configuration.

Implemented get_testnet function in cryptonote_core.

Made it so that fluffy blocks only run on testnet.
2016-11-09 14:24:27 -05:00
Riccardo Spagni
e72b6a7ade
Merge pull request #1165
e57379a p2p: drop any existing connection to a banned IP (moneromooo-monero)
2016-10-04 12:14:41 +02:00
moneromooo-monero
e57379a819
p2p: drop any existing connection to a banned IP 2016-10-02 19:23:35 +01:00
Randi Joseph
78b13d6dac Cleanup. Dropped "bit" from bitmonero. 2016-09-26 17:35:10 -04:00
Randi Joseph
1e6aedba8b Cleanup. Dropped "bit" from bitmonero. 2016-09-26 17:22:30 -04:00
Riccardo Spagni
70bd7d8871
remove dead backup seed nodes, add new ones 2016-09-18 20:10:46 +02:00
redfish
e1c7af35d4 cmake: transitive deps and remove deprecated LINK_*
Keep the immediate direct deps at the library that depends on them,
declare deps as PUBLIC so that targets that link against that library
get the library's deps as transitive deps.

Break dep cycle between blockchain_db <-> crytonote_core.
No code refactoring, just hide cycle from cmake so that
it doesn't complain (cycles are allowed only between
static libs, not shared libs).

This is in preparation for supproting BUILD_SHARED_LIBS cmake
built-in option for building internal libs as shared.
2016-09-18 02:56:26 -04:00
moneromooo-monero
c2ad9caf01
allow peers without port
The default port is then used
2016-07-03 12:51:12 +01:00
Riccardo Spagni
ba61f37f9c
Merge pull request #846
de030d9 fix: error: -Werror=misleading-indentation (moneroexample)
c2d7300 contrib: epee: add exception spec to throwing destructors (redfish)
6898741 src: p2p: add exception spec to throwing destructors (redfish)
21dbc95 crypto: slow-hash: fix misleading indent (redfish)
70f3634 crypto: slow-hash: remove unused hash list for ARM (redfish)
1a7772f crypto: oaes_lib: remove unused _NR array (redfish)
6462a3a crypto: fix compile error: use named type in sizeof (redfish)
2016-06-19 21:25:52 +02:00
Riccardo Spagni
e97d96ccfb
Merge pull request #775
e409e59 Print stack trace on exceptions (moneromooo-monero)
ef4ff42 connection_basic: avoid gratuitous exception (moneromooo-monero)
2016-06-19 21:14:11 +02:00
redfish
68987416ad src: p2p: add exception spec to throwing destructors
The destructors get a noexcept(true) spec by default, but these
destructors in fact throw exceptions. An alternative fix might be to not
throw (most if not all of these throws are non-essential
error-reporting/logging).
2016-05-18 01:02:21 -04:00
moneromooo-monero
7450656bf3
net_node: fix connection leak when ping fails with bad response
If there is no comms error, but the response is not as expected,
close would not be called.
2016-04-17 11:24:07 +01:00
moneromooo-monero
ef4ff4252a
connection_basic: avoid gratuitous exception
The remote endpoint is usually invalid, so use a version of the
call that returns an error code instead.
2016-03-28 18:59:09 +01:00
moneromooo-monero
f7301c3563
Revert "Print stack trace upon exceptions"
Ain't nobody got time for link/cmake skullduggery.

This reverts commit fff238ec94.
2016-03-21 10:12:23 +00:00
moneromooo-monero
fff238ec94
Print stack trace upon exceptions
Useful for debugging users' logs
2016-03-19 21:48:36 +00:00
moneromooo-monero
474e4c00f0
p2p: lock access to the blocked ips map 2016-03-12 13:48:58 +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
Howard Chu
7c86c5997d Use boost::thread instead of std::thread
std::thread crashes on (at least) ARMv6 g++ 4.8/4.9
2016-02-18 21:30:10 +00:00
binaryFate
0100e951d3 'max limit of...' is redundant wording, rephrase 2016-01-14 23:13:12 +01:00
Riccardo Spagni
de03926850
updated copyright year 2015-12-31 08:39:56 +02: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
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
3f2970fadb
Add missing semicolons after log statements 2015-12-19 14:47:37 +00:00
Riccardo Spagni
64ff3c7201
Merge pull request #543
63cb1a5 move another non user useful log to L1 (moneromooo-monero)
02827d5 p2p: minor log formatting fix (moneromooo-monero)
2015-12-18 12:16:10 +02:00
moneromooo-monero
02827d5155
p2p: minor log formatting fix 2015-12-17 22:35:01 +00: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
Riccardo Spagni
e175205e6e
Merge pull request #527
336b375 Register daemon command line arguments to core if they're used in core (moneromooo-monero)
2015-12-09 10:30:20 +02: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
Riccardo Spagni
b87f073a60
Merge pull request #526
2c83055 net_node: add a --offline argument (moneromooo-monero)
2015-12-08 20:12:18 +02: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
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
38ceb73848
add RPC calls and commands to get/set bans 2015-11-26 00:04:22 +00:00
moneromooo-monero
7bc4dce6ed
net_node: allow bans for custom amounts of time
m_blocked_ips now stores the unblocking time, rather than the
blocking time.
Also change > to >=, since banning for 0 seconds should not ban
2015-11-25 22:23:04 +00:00