Commit Graph

470 Commits

Author SHA1 Message Date
luigi1111 68b03abdc5
Merge pull request #6021
65e8a89 Change monerod --proxy to --tx-proxy (vtnerd)
2019-10-25 13:52:19 -05:00
moneromooo-monero 2899379791
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.

This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo

This has some advantages:
 - incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
 - incentive to run your own node instead of using a third party's, thereby promoting decentralization
 - decentralized: payment is done between a client and server, with no third party needed
 - private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
 - no payment occurs on the blockchain, so there is no extra transactional load
 - one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
 - no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
 - Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
 - no large credit balance maintained on servers, so they have no incentive to exit scam
 - you can use any/many node(s), since there's little cost in switching servers
 - market based prices: competition between servers to lower costs
 - incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
 - increases network security
 - helps counteract mining pools' share of the network hash rate
 - zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner

And some disadvantages:
 - low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
 - payment is "random", so a server might go a long time without a block before getting one
 - a public node's overall expected payment may be small

Public nodes are expected to compete to find a suitable level for
cost of service.

The daemon can be set up this way to require payment for RPC services:

  monerod --rpc-payment-address 4xxxxxx \
    --rpc-payment-credits 250 --rpc-payment-difficulty 1000

These values are an example only.

The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.

The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).

There are three new settings in the wallet:

 - credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.

 - auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25

 - persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.

To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.

The wallet has a few new commands too:

 - start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
 - stop_mining_for_rpc: stop mining to acquire more credits
 - rpc_payments: display information about current credits with
the currently selected daemon

The node has an extra command:

 - rpc_payments: display information about clients and their
balances

The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2019-10-25 09:34:38 +00:00
Lee Clagett 65e8a89e1c Change monerod --proxy to --tx-proxy 2019-10-24 21:06:31 -04:00
luigi1111 1e9b577f2a
Merge pull request #5985
6fdaaba node.inl, add xmrchain.net IP to hardcoded peers (Gingeropolous)
2019-10-22 10:22:02 -05:00
luigi1111 017baeeab5
Merge pull request #5956
ec7f2ff p2p: reject invalid rpc_port in peer lists (xiphon)
2019-10-16 13:44:25 -05:00
luigi1111 67043d642d
Merge pull request #5954
4ce40ed p2p: reject invalid pruning seeds in peer lists (moneromooo-monero)
2019-10-16 13:42:23 -05:00
luigi1111 fcb4c72bb5
Merge pull request #5943
d4d2b5c p2p+rpc: don't skip p2p or rpc port bind failure by default (xiphon)
2019-10-14 20:05:25 -05:00
luigi1111 dc48cdc998
Merge pull request #5933
3455efa ban peers sending bad pow outright (moneromooo-monero)
2019-10-14 18:07:54 -05:00
Gingeropolous 6fdaaba935
node.inl, add xmrchain.net IP to hardcoded peers
added for mainnet, testnet, and stagenet. 

server is owner by snipa, both snipa and I have access to it. No idea where its hosted. 

xmrchain.net is a block explorer thats been around a while.
2019-10-13 17:13:57 -04:00
xiphon d4d2b5c79a p2p+rpc: don't skip p2p or rpc port bind failure by default 2019-10-13 13:27:46 +00:00
luigi1111 b0840a8e01
Merge pull request #5932
f3b65c6 Request a thread stack size that is large enough for unbound (omartijn)
2019-10-08 14:45:21 -05:00
luigi1111 342e7f844f
Merge pull request #5921
2a7d915 Fixed i2p/tor tx flooding bug (white noise disabled) (vtnerd)
2019-10-08 14:31:53 -05:00
moneromooo-monero 4ce40edb27
p2p: reject invalid pruning seeds in peer lists 2019-10-02 19:29:05 +00:00
xiphon ec7f2ff9ed p2p: reject invalid rpc_port in peer lists 2019-10-02 19:04:57 +00:00
moneromooo-monero 3455efafa8
ban peers sending bad pow outright
PoW is expensive to verify, so be strict
2019-09-25 16:00:43 +00:00
Martijn Otto f3b65c66f8
Request a thread stack size that is large enough for unbound
Unbound uses a 64 kb large character array on the stack, which
leads to a stack overflow for some libc implementations. musl
only gives 80 kb in total. This PR changes the stack size for
these threads to 1mb, which solves the segmentation fault.
2019-09-25 16:37:06 +02:00
moneromooo-monero 7b076d5170
p2p: fix bans taking port into account 2019-09-16 22:45:45 +00:00
luigi1111 86938725ae
Merge pull request #5841
cae488d p2p: reject incoming connections to self (moneromooo-monero)
2019-09-08 19:48:09 -05:00
luigi1111 15dabf7d18
Merge pull request #5839
e353e3d p2p: sanitize peer lists (moneromooo-monero)
2019-09-08 19:45:09 -05:00
luigi1111 3b28ff2d6d
Merge pull request #5838
2e26536 p2p: move log away from global (moneromooo-monero)
2019-09-08 19:43:46 -05:00
moneromooo-monero bc1144e98e
Fix IP address serialization on big endian
IP addresses are stored in network byte order even on little
endian hosts
2019-09-04 14:54:01 +00:00
moneromooo-monero cae488dc9b
p2p: reject incoming connections to self 2019-08-22 17:08:29 +00:00
moneromooo-monero e353e3d757
p2p: sanitize peer lists
Also remove the delta time fixup, since we now ignore those
as they're attacker controlled
2019-08-21 15:54:27 +00:00
moneromooo-monero 2e2653602f
p2p: move log away from global
It was here while debugging, and I forgot to move it away
2019-08-21 14:00:43 +00:00
luigi1111 c9df9d683a
Merge pull request #5696
fd60d05 daemon: fix print_pl only printing public zone peers (moneromooo-monero)
2019-08-20 01:50:10 -05:00
moneromooo-monero fd60d05d5d
daemon: fix print_pl only printing public zone peers 2019-08-19 23:39:51 +00:00
luigi1111 f205d28e96
Merge pull request #5727
7b9a420 Replace std::random_shuffle with std::shuffle (tomsmeding)
2019-08-19 17:31:39 -05:00
luigi1111 017162b5b2
Merge pull request #5682
3768db2 p2p: add a reference to Cao, Tong et al. for the last_seen changes (moneromooo-monero)
2019-08-15 17:27:30 -05:00
luigi1111 8a0711f2f2
Merge pull request #5674
fcbf7b3 p2p: propagate out peers limit to payload handler (moneromooo-monero)
098aadf p2p: close the right number of connections on setting max in/out peers (moneromooo-monero)
2019-08-15 17:22:39 -05:00
Tom Smeding 7b9a420787 Replace std::random_shuffle with std::shuffle
According to [1], std::random_shuffle is deprecated in C++14 and removed
in C++17. Since std::shuffle is available since C++11 as a replacement
and monero already requires C++11, this is a good replacement.

A cryptographically secure random number generator is used in all cases
to prevent people from perhaps copying an insecure std::shuffle call
over to a place where a secure one would be warranted. A form of
defense-in-depth.

[1]: https://en.cppreference.com/w/cpp/algorithm/random_shuffle
2019-08-15 16:33:15 +02:00
Thomas Winget 155475d971
Add IPv6 support
new cli options (RPC ones also apply to wallet):
  --p2p-bind-ipv6-address (default = "::")
  --p2p-bind-port-ipv6    (default same as ipv4 port for given nettype)
  --rpc-bind-ipv6-address (default = "::1")

  --p2p-use-ipv6          (default false)
  --rpc-use-ipv6          (default false)

  --p2p-require-ipv4      (default true, if ipv4 bind fails and this is
                           true, will not continue even if ipv6 bind
                           successful)
  --rpc-require-ipv4      (default true, description as above)

ipv6 addresses are to be specified as "[xx:xx:xx::xx:xx]:port" except
in the cases of the cli args for bind address.  For those the square
braces can be omitted.
2019-07-31 20:04:57 -04:00
Lee Clagett 2a7d91523b Fixed i2p/tor tx flooding bug (white noise disabled) 2019-07-29 12:27:00 +00:00
luigi1111 61512cf798
Merge pull request #5610
068fa1c p2p: delay IGP probing on startup (moneromooo-monero)
2019-07-24 14:35:11 -05:00
luigi1111 e241a6280d
Merge pull request #5582
fcfcc3a rpc: in/out peers can now return the setting's value (moneromooo-monero)
2019-07-24 14:18:09 -05:00
luigi1111 e579fe4ae0
Merge pull request #5530
6abaaaa remove obsolete save_graph skeleton code (moneromooo-monero)
2019-07-24 14:07:29 -05:00
luigi1111 1880c1a582
Merge pull request #5363
515ac29 p2p: store network address directly in blocked host list (moneromooo-monero)
65c4004 allow blocking whole subnets (moneromooo-monero)
2019-07-24 13:47:41 -05:00
Riccardo Spagni 8eb075e789
Merge pull request #5732
a96c1a46 cryptonote_protocol: drop peers we can't download from when syncing (moneromooo-monero)
ab361df2 p2p: add a few missing connection close calls (moneromooo-monero)
2019-07-17 21:18:20 +02:00
Lee Clagett 3b24b1d082 Added support for "noise" over I1P/Tor to mask Tx transmission. 2019-07-17 14:22:37 +00:00
moneromooo-monero 65c4004963
allow blocking whole subnets 2019-07-16 11:35:53 +00:00
moneromooo-monero 515ac2951d
p2p: store network address directly in blocked host list
rather than their string representation
2019-07-16 11:35:52 +00:00
moneromooo-monero 4ee095c200
p2p: don't connect to more than one IP per class B if we can 2019-07-05 18:25:52 +00:00
moneromooo-monero ab361df2cd
p2p: add a few missing connection close calls 2019-07-04 21:56:10 +00:00
moneromooo-monero 4237707d3e
p2p: don't forget pruning seed or public RPC port when updating peers
Older nodes don't pass that information around
2019-06-26 10:20:19 +00:00
moneromooo-monero 3768db227c
p2p: add a reference to Cao, Tong et al. for the last_seen changes
"Exploring the Monero Peer-to-Peer Network". https://eprint.iacr.org/2019/411
2019-06-21 10:34:33 +00:00
moneromooo-monero 098aadf084
p2p: close the right number of connections on setting max in/out peers 2019-06-19 11:49:36 +00:00
moneromooo-monero fcbf7b3f74
p2p: propagate out peers limit to payload handler 2019-06-19 11:49:36 +00:00
moneromooo-monero 2cbe75661c
p2p: fix GCC 9.1 crash 2019-06-08 17:52:53 +00:00
moneromooo-monero 068fa1ca5c
p2p: delay IGP probing on startup
We might have external access without having to do this
2019-06-06 10:33:02 +00:00
moneromooo-monero fcfcc3ac86
rpc: in/out peers can now return the setting's value 2019-05-30 12:13:31 +00:00
moneromooo-monero 6abaaaa994
remove obsolete save_graph skeleton code 2019-05-10 14:17:18 +00:00
moneromooo-monero 28a7d31565
p2p: do not send last_seen timestamp to peers
This can be used for fingerprinting and working out the
network topology.

Instead of sending the first N (which are sorted by last
seen time), we sent a random subset of the first N+N/5,
which ensures reasonably recent peers are used, while
preventing repeated calls from deducing new entries are
peers the target node just connected to.

The list is also randomly shuffled so the original set of
timestamps cannot be approximated.
2019-04-24 17:56:12 +00:00
Riccardo Spagni 8d16e92dcb
Merge pull request #5425
58585986 p2p: fix integer overflow in host bans (moneromooo-monero)
2019-04-16 22:38:56 +02:00
moneromooo-monero 5858598604
p2p: fix integer overflow in host bans 2019-04-11 21:59:27 +00:00
stoffu a2195b9b7f
crypto: replace rand<T>()%N idiom with unbiased rand_idx(N) 2019-04-04 22:38:19 +09:00
Riccardo Spagni 6e0242f861
Merge pull request #5334
19f8089f p2p: don't lookup seed nodes when offline (moneromooo-monero)
2019-04-01 17:37:01 +02:00
moneromooo-monero 19f8089fca
p2p: don't lookup seed nodes when offline
This will cause DNS requests, which will block and timeout
if there is really no network connectivity
2019-03-22 15:47:48 +00:00
rbrunner7 85f2f8c933 Fix daemon startup parameter '--limit-rate' processing after parameter defaults 2019-03-20 16:40:59 +01:00
Riccardo Spagni bf0f85221b
Merge pull request #5195
a54e81e5 daemon: add '--no-sync' arg to optionally disable blockchain sync (xiphon)
2019-03-19 10:57:28 +02:00
Riccardo Spagni 848591c4d8
Merge pull request #5190
551104fb daemon: add --public-node mode, RPC port propagation over P2P (xiphon)
2019-03-17 17:56:04 +02:00
binaryFate 1f2930ce0b Update 2019 copyright 2019-03-05 22:05:34 +01:00
moneromooo-monero ceb72be329
p2p: avoid busy loop when we have nothing to connect to 2019-03-05 12:00:45 +00:00
moneromooo-monero e396146aee
default initialize rpc structures 2019-03-04 22:38:03 +00:00
Riccardo Spagni 4466f4504e
Merge pull request #5091
123fc2a2 i2p: initial support (Jethro Grassie)
2019-03-04 21:20:34 +02:00
xiphon a54e81e572 daemon: add '--no-sync' arg to optionally disable blockchain sync 2019-02-25 03:22:14 +00:00
xiphon 551104fbf1 daemon: add --public-node mode, RPC port propagation over P2P 2019-02-25 02:40:23 +03:00
moneromooo-monero 2456945408
epee: add SSL support
RPC connections now have optional tranparent SSL.

An optional private key and certificate file can be passed,
using the --{rpc,daemon}-ssl-private-key and
--{rpc,daemon}-ssl-certificate options. Those have as
argument a path to a PEM format private private key and
certificate, respectively.
If not given, a temporary self signed certificate will be used.

SSL can be enabled or disabled using --{rpc}-ssl, which
accepts autodetect (default), disabled or enabled.

Access can be restricted to particular certificates using the
--rpc-ssl-allowed-certificates, which takes a list of
paths to PEM encoded certificates. This can allow a wallet to
connect to only the daemon they think they're connected to,
by forcing SSL and listing the paths to the known good
certificates.

To generate long term certificates:

openssl genrsa -out /tmp/KEY 4096
openssl req -new -key /tmp/KEY -out /tmp/REQ
openssl x509 -req -days 999999 -sha256 -in /tmp/REQ -signkey /tmp/KEY -out /tmp/CERT

/tmp/KEY is the private key, and /tmp/CERT is the certificate,
both in PEM format. /tmp/REQ can be removed. Adjust the last
command to set expiration date, etc, as needed. It doesn't
make a whole lot of sense for monero anyway, since most servers
will run with one time temporary self signed certificates anyway.

SSL support is transparent, so all communication is done on the
existing ports, with SSL autodetection. This means you can start
using an SSL daemon now, but you should not enforce SSL yet or
nothing will talk to you.
2019-02-02 20:05:33 +00:00
Jethro Grassie 123fc2a25a
i2p: initial support 2019-01-30 13:37:45 -05:00
Lee Clagett 973403bc9f Adding initial support for broadcasting transactions over Tor
- Support for ".onion" in --add-exclusive-node and --add-peer
  - Add --anonymizing-proxy for outbound Tor connections
  - Add --anonymous-inbounds for inbound Tor connections
  - Support for sharing ".onion" addresses over Tor connections
  - Support for broadcasting transactions received over RPC exclusively
    over Tor (else broadcast over public IP when Tor not enabled).
2019-01-28 23:56:33 +00:00
moneromooo-monero b750fb27b0
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.

No other data is currently pruned.

There are three ways to prune a blockchain:

- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility

The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.

The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.

Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2019-01-22 20:30:51 +00:00
Riccardo Spagni e59813c3d7
Merge pull request #5029
d1b3990d p2p: don't stop the idle thread when no gray peers are found (moneromooo-monero)
2019-01-16 21:39:19 +02:00
Riccardo Spagni 3e9bb9626a
Merge pull request #5001
a5ffc2d5 Remove boost::lexical_cast for uuid and unused uuid function (Lee Clagett)
2019-01-16 19:27:13 +02:00
Riccardo Spagni 846362842c
Merge pull request #4976
85665003 epee: better network buffer data structure (moneromooo-monero)
2019-01-16 19:04:22 +02:00
moneromooo-monero d1b3990d40
p2p: don't stop the idle thread when no gray peers are found 2018-12-30 19:32:38 +00:00
moneromooo-monero 85665003a7
epee: better network buffer data structure
avoids pointless allocs and memcpy
2018-12-23 16:46:07 +00:00
Lee Clagett a5ffc2d5ad Remove boost::lexical_cast for uuid and unused uuid function 2018-12-23 11:11:30 +00:00
moneromooo-monero 570dd3690e
p2p: use vector instead of list for peer lists 2018-12-07 13:20:34 +00:00
Riccardo Spagni c00ac446fd
Merge pull request #4854
bd98e99c Removed a lot of unnecessary includes (Martijn Otto)
2018-12-04 17:08:42 +02:00
Riccardo Spagni 46d0dc2808
Merge pull request #4776
03fc731b p2p: less frequent incoming connections check (moneromooo-monero)
14a5c206 p2p: tone down "no incoming connections" warning to info if in peers is 0 (moneromooo-monero)
2018-11-16 11:01:19 +02:00
Martijn Otto bd98e99c80
Removed a lot of unnecessary includes 2018-11-15 17:29:34 +01:00
moneromooo-monero 03fc731bf2
p2p: less frequent incoming connections check 2018-11-01 22:00:35 +00:00
moneromooo-monero 14a5c2068f
p2p: tone down "no incoming connections" warning to info if in peers is 0
Also add an info if not offline, since it weakens the network
2018-11-01 16:43:06 +00:00
RaskaRuby 2bd46065ae Expose limit-rate defaults from command line help 2018-10-31 14:47:20 -07:00
Riccardo Spagni ecc690a613
Merge pull request #4612
2d48861d p2p: only deinitialize what's been initialized in offline mode (moneromooo-monero)
2018-10-26 22:38:03 +02:00
moneromooo-monero 2d48861db7
p2p: only deinitialize what's been initialized in offline mode 2018-10-16 09:20:05 +00:00
moneromooo-monero 0fbbb065d4
p2p: a negative result from UPNP_GetValidIGD is an error
as per the source documentation
2018-10-15 22:41:00 +00:00
Riccardo Spagni fa7278d6b5
Merge pull request #4578
76d6d832 Revert "p2p: connect via the bound ip, if any" (moneromooo-monero)
2018-10-15 13:29:21 +02:00
moneromooo-monero 76d6d832d2
Revert "p2p: connect via the bound ip, if any"
This reverts commit 909398efc7.

It looks like it's causing trouble with tor on some setups
2018-10-13 10:20:04 +00:00
moneromooo-monero e736964a0c
Remove epee header dependency on cryptonote_core 2018-10-12 17:16:44 +00:00
luigi1111 b586ae1310
Merge pull request #4089
909398e p2p: connect via the bound ip, if any (moneromooo-monero)
2018-08-15 17:06:17 -05:00
luigi1111 f6d7e87b67
Merge pull request #4075
438d52d remove epee from link lines where it's redundant (moneromooo-monero)
2018-07-19 14:10:20 -05:00
luigi1111 025187e6c9
Merge pull request #3854
149da42 db_lmdb: enable batch transactions by default (stoffu)
34cb6b4 add --regtest and --fixed-difficulty for regression testing (vicsn)
9e1403e update get_info RPC and bump RPC version (vicsn)
207b66e first new functional tests (vicsn)
2018-07-19 13:35:25 -05:00
moneromooo-monero 909398efc7
p2p: connect via the bound ip, if any 2018-07-02 18:06:04 +01:00
victorsintnicolaas 34cb6b4b70 add --regtest and --fixed-difficulty for regression testing
on_generateblocks RPC call combines functionality from the on_getblocktemplate and on_submitblock RPC calls to allow rapid block creation. Difficulty is set permanently to 1 for regtest.
Makes use of FAKECHAIN network type, but takes hard fork heights from mainchain
Default reserve_size in generate_blocks RPC call is now 1. If it is 0, the following error occurs 'Failed to calculate offset for'.
Queries hard fork heights info of other network types
2018-06-29 10:06:11 +02:00
moneromooo-monero 438d52deaf
remove epee from link lines where it's redundant
For some reason, this confuses and kills ASAN on startup
as it thinks const uint8_t ipv4_network_address::ID is
defined multiple times.
2018-06-28 16:45:22 +01:00
luigi1111 3ad4ecd4ff
Merge pull request #3982
08b85a8 cryptonote_config: add get_config to refactor x = testnet ? config::testnet::X : stagenet ? config::stagenet::X : config::X (stoffu)
0cf80ba net_node: resolve host for node addresses given via command line flags (stoffu)
2018-06-27 15:38:23 -05:00
luigi1111 cb130c7590
Merge pull request #3861
de1ffe0 p2p: warn when no incoming connections are seen for a while (moneromooo-monero)
2018-06-19 12:56:31 -05:00
stoffu 0cf80baea4
net_node: resolve host for node addresses given via command line flags 2018-06-11 20:17:13 +09:00
stoffu 08b85a8e00
cryptonote_config: add get_config to refactor x = testnet ? config::testnet::X : stagenet ? config::stagenet::X : config::X 2018-06-11 20:17:02 +09:00
moneromooo-monero de1ffe07b1
p2p: warn when no incoming connections are seen for a while 2018-05-26 14:37:07 +01:00
moneromooo-monero 1590183965
p2p: fix fallback seed node usage
Those were added to the seed nodes list even when they had already
been added. Moreover, the current index was not reset after they
were added, typically causing previous seeds to be used, and some
of those fallback seeds to not be tried.
2018-04-29 14:58:42 +01:00
rbrunner7 f9d0827bba Fix broken interactive daemon 'limit' commands plus RPC calls 2018-04-25 21:37:10 +02:00
anonimal 6b85398031
Build: update CMake and p2p for in-tree miniupnp
(cherry picked from commit a7366b5feeffaeb65b217b2d6f138e0ab1c90192)
2018-04-21 09:43:23 +00:00
anonimal 859db52fda
CMake: update new location of in-tree miniupnpc
(cherry picked from commit b16a282f97d8f6c967e8a0b1ecfd75110f095182)
2018-04-19 10:56:09 +00:00
Riccardo Spagni 5053f8f40b
Merge pull request #3502
11c933e1 fix lambda compile error on openbsd (moneromooo-monero)
2018-04-12 11:14:43 +02:00
moneromooo-monero 11c933e137
fix lambda compile error on openbsd 2018-03-27 14:48:36 +01:00
stoffu 5f6647934b
p2p: correct port number for seed nodes 2018-03-22 14:56:35 +09:00
moneromooo-monero 523371c042
p2p: fix network ID being uninitialised when using exclusive peers 2018-03-13 11:20:49 +00:00
stoffu af773211cb
Stagenet 2018-03-05 11:55:05 +09:00
Riccardo Spagni 299af8e43e
Merge pull request #3290
1d28c0d8 p2p: restore m_testnet assignment lost during rebase (whythat)
2018-02-20 17:48:29 +02:00
whythat 1d28c0d8a9 p2p: restore m_testnet assignment lost during rebase 2018-02-18 17:09:39 +02:00
stoffu 10f78f63f1
p2p: need libcryptonote_core due to arg_testnet_on being used 2018-02-18 16:40:43 +09:00
whythat b3b2d4d20c options: add testnet option dependencies 2018-02-16 22:32:01 +02:00
whythat 05a12ccc2d options: remove testnet-* options 2018-02-16 22:32:01 +02:00
Riccardo Spagni ef91d6e61e
Merge pull request #3196
eda9fb5b p2p: fix testnet/mainnet port mixup (moneromooo-monero)
2018-02-16 14:31:16 +01:00
Riccardo Spagni f4a6bc79d9
Merge pull request #3226
e4646379 keccak: fix mdlen bounds sanity checking (moneromooo-monero)
2e3e90ac pass large parameters by const ref, not value (moneromooo-monero)
61defd89 blockchain: sanity check number of precomputed hash of hash blocks (moneromooo-monero)
9af6b2d1 ringct: fix infinite loop in unused h2b function (moneromooo-monero)
8cea8d0c simplewallet: double check a new multisig wallet is multisig (moneromooo-monero)
9b98a6ac threadpool: catch exceptions in dtor, to avoid terminate (moneromooo-monero)
24803ed9 blockchain_export: fix buffer overflow in exporter (moneromooo-monero)
f3f7da62 perf_timer: rewrite to make it clear there is no division by zero (moneromooo-monero)
c6ea3df0 performance_tests: remove add_arg call stray extra param (moneromooo-monero)
fa6b4566 fuzz_tests: fix an uninitialized var in setup (moneromooo-monero)
03887f11 keccak: fix sanity check bounds test (moneromooo-monero)
ad11db91 blockchain_db: initialize m_open in base class ctor (moneromooo-monero)
bece67f9 miner: restore std::cout precision after modification (moneromooo-monero)
1aabd14c db_lmdb: check hard fork info drop succeeded (moneromooo-monero)
2018-02-16 14:26:58 +01:00
Riccardo Spagni a54247b993
Merge pull request #3221
2e584dcb p2p: do not try to connect to peers in offline mode (moneromooo-monero)
2018-02-16 14:23:22 +01:00
moneromooo-monero 2e3e90acbe
pass large parameters by const ref, not value
Coverity 136394 136397 136409 136526 136529 136533 175302
2018-02-02 19:36:09 +00:00
moneromooo-monero 2e584dcb1f
p2p: do not try to connect to peers in offline mode 2018-02-01 20:18:30 +00:00
Erik de Castro Lopo 32c0f908cd Allow the number of incoming connections to be limited
It was already possible to limit outgoing connections. One might want
to do this on home network connections with high bandwidth but low
usage caps.
2018-01-29 11:14:02 +11:00
Erik de Castro Lopo d609a2c164 Rename delete_connections to delete_out_connections
This rename is needed so that delete_in_connections can be added.
2018-01-29 07:06:08 +11:00
Erik de Castro Lopo b927c0fc7a Rename connections_count to max_out_connection_count
This is needed so that a max_in_connection_count can be added.
2018-01-29 07:06:08 +11:00
moneromooo-monero eda9fb5b98
p2p: fix testnet/mainnet port mixup 2018-01-28 09:44:04 +00:00
Riccardo Spagni a4ae78a335
Merge pull request #3145
fd1dfac5 p2p: don't lookup seed IPs if using an exclusive peer (moneromooo-monero)
b50182ae p2p: don't connect to seeds if using an exclusive peer (moneromooo-monero)
2018-01-27 17:25:47 -08:00
xmr-eric 18216f19dd Update 2018 copyright 2018-01-26 10:03:20 -05:00
moneromooo-monero ab58b150ef
p2p: fix picking peers off an empty gray list 2018-01-18 17:11:37 +00:00
moneromooo-monero fd1dfac5d2
p2p: don't lookup seed IPs if using an exclusive peer 2018-01-17 12:15:12 +00:00
moneromooo-monero b50182aee7
p2p: don't connect to seeds if using an exclusive peer 2018-01-17 11:17:21 +00:00
stoffu 6d8b29ef28
fix some link errors in debug mode for macos 2018-01-10 01:57:56 +00:00
Riccardo Spagni c611cca462
Merge pull request #2928
d28c388f p2p: stop net server before closing starting connections (moneromooo-monero)
2017-12-25 21:19:58 +02:00
moneromooo-monero fe568db83d
p2p: use size_t for arbitrary counters instead of uint8_t 2017-12-18 15:15:10 +00:00
Riccardo Spagni 066fd7aced
Merge pull request #2877
43f5269f Wallets now do not depend on the daemon rpc lib (moneromooo-monero)
bb89ae8b move connection_basic and network_throttle from src/p2p to epee (moneromooo-monero)
4abf25f3 cryptonote_core does not depend on p2p anymore (moneromooo-monero)
2017-12-17 12:59:44 +02: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 09ce03d612
move includes around to lessen overall load 2017-12-16 22:46:38 +00:00
Riccardo Spagni 8da24c2a57
Merge pull request #2878
abebe392 rpc: add offline state in info rpc (moneromooo-monero)
7696e849 core: make --offline also disable DNS lookups (moneromooo-monero)
2017-12-16 23:27:00 +02:00
moneromooo-monero d28c388f88
p2p: stop net server before closing starting connections
This fixes a hang on exit due to race where a connection adds
itself to the server after the starting connections are closed,
but before the net server marks itself as stopped.
2017-12-15 10:31:12 +00:00
moneromooo-monero 7696e84952
core: make --offline also disable DNS lookups 2017-11-30 15:35:52 +00:00
rbrunner7 cf5f623616 Corrections in rate limiting / trottle code, especially in 'out' direction
Deleted 3 out of 4 calls to method connection_basic::sleep_before_packet
that were erroneous / superfluous, which enabled the elimination of a
"fudge" factor of 2.1 in connection_basic::set_rate_up_limit;
also ended the multiplying of limit values and numbers of bytes
transferred by 1024 before handing them over to the global throttle
objects
2017-11-28 21:18:01 +01:00
Riccardo Spagni edebe4e3b6
Merge pull request #2736
0d9c0db9 Do not build against epee_readline if it was not built (Howard Chu)
178014c9 split off readline code into epee_readline (moneromooo-monero)
a9e14a19 link against readline only for monerod and wallet-wallet-{rpc,cli} (moneromooo-monero)
437421ce wallet: move some scoped_message_writer calls from the libs (moneromooo-monero)
e89994e9 wallet: rejig to avoid prompting in wallet2 (moneromooo-monero)
ec5135e5 move input_line from command_line to simplewallet (moneromooo-monero)
082db75f move cryptonote command line options to cryptonote_core (moneromooo-monero)
2017-11-14 21:31:51 +02:00
moneromooo-monero 082db75f28
move cryptonote command line options to cryptonote_core
Those have no reason to be in a generic module
2017-11-14 17:06:19 +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 7dbf76d0da
Fix an object lifetime bug in net load tests
The commands handler must not be destroyed before the config
object, or we'll be accessing freed memory.

An earlier attempt at using boost::shared_ptr to control object
lifetime turned out to be very invasive, though would be a
better solution in theory.
2017-10-09 16:46:42 +01:00
Lee Clagett 8b00687735 Upgrades to epee::net_utils::network_address
- internal nullptr checks
  - prevent modifications to network_address (shallow copy issues)
  - automagically works with any type containing interface functions
  - removed fnv1a hashing
  - ipv4_network_address now flattened with no base class
2017-10-05 11:57:09 -04:00
moneromooo-monero 8e0670c684
version: fix link to new version strings
p2p uses it, and the cpp file needs to know the symbols should
be public
2017-09-25 19:01:56 +01:00
Riccardo Spagni c2346c6c59
Merge pull request #2424
28b72b6e tx_pool: pre-init tvc.m_verifivation_failed before processing (moneromooo-monero)
50a629b2 core_tests: catch (impossible in practice) tx extra api failure (moneromooo-monero)
fee15ef1 wallet2: catch failure to parse address (moneromooo-monero)
1399e26d net_peerlist: remove dead code (moneromooo-monero)
50e09698 tx_pool: guard against failure getting tx hash (moneromooo-monero)
54cc209a wallet_rpc_server: catch failure to create directory (moneromooo-monero)
3e55099c wallet_rpc_server: init m_vm to NULL in ctor (moneromooo-monero)
7d0dde5e wallet_args: remove redundant default value for --log-file (moneromooo-monero)
ed4a3350 wallet2: catch failure to save keys file (moneromooo-monero)
44434c8a wallet2_api: check whether dynamic_cast returns NULL (moneromooo-monero)
92f2f687 core: check return value from parse_hexstr_to_binbuff (moneromooo-monero)
5475692e wallet2_api: remove an unused, uninitialized, field (moneromooo-monero)
a7ba3de1 libwallet_api_tests: initialize newblock_triggered on reset (moneromooo-monero)
b2763ace wallet2_api: init error code to "no error" in the ctor (moneromooo-monero)
b5faac53 get_blockchain_top now returns void (moneromooo-monero)
2e44d8f2 wallet_rpc_server: guard against exceptions (moneromooo-monero)
4230876b simplewallet: guard against I/O exceptions (moneromooo-monero)
06c1e057 daemon: initialize decode_as_json in RPC request (moneromooo-monero)
11f71af5 http_base: init size_t in http_request_info ctor (moneromooo-monero)
2017-09-25 16:52:27 +02:00
Riccardo Spagni b911130a46
Merge pull request #2442
e29282d2 build: auto update version info without manually deleting version.h (stoffu)
2017-09-25 16:50:35 +02:00
moneromooo-monero 1399e26d7e
net_peerlist: remove dead code
CID 175290
2017-09-25 15:48:45 +01:00
Riccardo Spagni 174f2fb4da
Merge pull request #2428
054054c9 p2p: disable gray list housekeeping when an exclusive node is given (moneromooo-monero)
2017-09-25 16:46:26 +02:00
Riccardo Spagni 07312a7d6e
Merge pull request #2302
ef005f5e p2p: add a couple early outs when the stop signal is received (moneromooo-monero)
80d361c7 abstract_tcp_server2: improve tracking/cancelling of early connections (moneromooo-monero)
2017-09-21 10:11:33 +02:00
stoffu e29282d208
build: auto update version info without manually deleting version.h 2017-09-21 07:47:37 +09:00
Riccardo Spagni 75563db6e3
Merge pull request #2376
e3680b69 Rename m_listenning_port to m_listening_port (MaxXor)
a1ea475f Delete UPnP port mapping on exit (MaxXor)
2017-09-20 21:33:21 +02:00
moneromooo-monero 054054c92f
p2p: disable gray list housekeeping when an exclusive node is given
Exclusive nodes may be used for privacy reasons, and thus we don't
want to connect to other nodes, even for checking connectivity.

See https://github.com/monero-project/monero/issues/2346
2017-09-10 13:11:42 +01:00
Riccardo Spagni 5551fcf60b
Merge pull request #2329
e3c4395a p2p: init hashes after deserializing a network address (moneromooo-monero)
2017-09-02 11:29:40 +02:00
MaxXor e3680b6936 Rename m_listenning_port to m_listening_port 2017-09-01 09:50:22 +02:00
MaxXor a1ea475fff Delete UPnP port mapping on exit 2017-08-29 23:28:23 +02:00
moneromooo-monero 5524bc3151
print peer id in 0 padded hex for consistency 2017-08-23 13:37:56 +01:00
moneromooo-monero e3c4395ab7
p2p: init hashes after deserializing a network address
Fixes multiple connections to the same address
2017-08-23 13:32:02 +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
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