Commit graph

674 commits

Author SHA1 Message Date
moneromooo-monero
7175dcb107
replace most boost serialization with existing monero serialization
This reduces the attack surface for data that can come from
malicious sources (exported output and key images, multisig
transactions...) since the monero serialization is already
exposed to the outside, and the boost lib we were using had
a few known crashers.

For interoperability, a new load-deprecated-formats wallet
setting is added (off by default). This allows loading boost
format data if there is no alternative. It will likely go
at some point, along with the ability to load those.

Notably, the peer lists file still uses the boost serialization
code, as the data it stores is define in epee, while the new
serialization code is in monero, and migrating it was fairly
hairy. Since this file is local and not obtained from anyone
else, the marginal risk is minimal, but it could be migrated
later if needed.

Some tests and tools also do, this will stay as is for now.
2020-08-17 16:23:58 +00:00
Alexander Blair
d73b1b6560
Merge pull request #6727
13eee1d6a rpc: reject wrong sized txid (moneromooo-monero)
92e6b7df2 easylogging++: fix crash with reentrant logging (moneromooo-monero)
6dd95d530 epee: guard against exceptions in RPC handlers (moneromooo-monero)
90016ad74 blockchain: guard against exceptions in add_new_block/children (moneromooo-monero)
2020-08-16 12:55:25 -07:00
Alexander Blair
569d07d60b
Merge pull request #6722
c1b03fb1a rpc: return empty txid get_outs rather than 00..00 when not requested (moneromooo-monero)
2020-08-16 12:54:42 -07:00
Alexander Blair
a08df6eb1b
Merge pull request #6603
4e2377995 Change ZMQ-JSON txextra to hex and remove unnecessary base fields (Lee Clagett)
2020-08-16 12:43:38 -07:00
xiphon
728ba38b11 rpc: always send raw txes through P2P (don't use bootstrap daemon)
It turns out that some remote (bootstrap) nodes silently drop /
don't broadcast client's transactions.
2020-08-16 17:34:28 +00:00
Lee Clagett
4e2377995d Change ZMQ-JSON txextra to hex and remove unnecessary base fields 2020-08-14 23:01:00 +00:00
Lee Clagett
60627c9f24 Switch to insitu parsing for ZMQ-JSON; GetBlocksFast reads 13%+ faster 2020-08-14 19:46:59 +00:00
Lee Clagett
fe96e66ebe Fix pruned tx for ZMQ's GetBlocksFast 2020-08-14 19:46:33 +00:00
moneromooo-monero
13eee1d6ab
rpc: reject wrong sized txid
Reporter requested credit to be given to Decred
2020-07-30 22:52:14 +00:00
moneromooo-monero
c1b03fb1a6
rpc: return empty txid get_outs rather than 00..00 when not requested
It's more obvious there's no txid, and it saves space
2020-07-25 17:01:21 +00:00
Alexander Blair
a0d179e528
Merge pull request #6512
5ef0607da Update copyright year to 2020 (SomaticFanatic)
2020-07-19 03:32:59 -07:00
luigi1111
e8d87fccc2
Merge pull request #6627
4df8f9c rpc: fix loading rpc payment data from file (moneromooo-monero)
2020-07-08 17:22:33 -05:00
luigi1111
0376195015
Merge pull request #6611
dc1a053 rpc: fix comparison of seconds vs microseconds (moneromooo-monero)
2020-07-08 17:21:31 -05:00
luigi1111
3057f52f89
Merge pull request #6599
6e4a55b rpc: fix relay_tx error return mixup (moneromooo-monero)
9b86e14 functional_tests: add simple relay_tx test (moneromooo-monero)
2020-07-08 17:20:29 -05:00
luigi1111
be170c485c
Merge pull request #6584
78d435a rpc: don't display invalid json errors on default log level (moneromooo-monero)
2020-07-08 17:12:43 -05:00
luigi1111
8b3fa2d373
Merge pull request #6574
7ebb351 rpc: lock access to the rpc payment object (moneromooo-monero)
2020-07-08 17:11:32 -05:00
luigi1111
ff4d470629
Merge pull request #6576
4d3c2d0 rpc: add a sanity limit to a few RPC in restricted mode (moneromooo-monero)
2020-06-08 14:27:05 -05:00
moneromooo-monero
4df8f9c414
rpc: fix loading rpc payment data from file
Got broken after making one of those micro optimizations requested on review..
2020-06-05 11:21:24 +00:00
Lee Clagett
7aeb503547 Fix boost <1.60 compilation and fix boost 1.73+ warnings 2020-05-31 21:18:11 -04:00
moneromooo-monero
dc1a053081
rpc: fix comparison of seconds vs microseconds 2020-05-31 22:28:23 +00:00
moneromooo-monero
6e4a55ba7e
rpc: fix relay_tx error return mixup 2020-05-28 11:33:27 +00:00
moneromooo-monero
78d435a5fa
rpc: don't display invalid json errors on default log level
It's not something the user needs to know, and will display
attacker controlled data
2020-05-23 12:26:49 +00:00
moneromooo-monero
4d3c2d0b7b
rpc: add a sanity limit to a few RPC in restricted mode 2020-05-20 19:17:49 +00:00
moneromooo-monero
7ebb351c2d
rpc: lock access to the rpc payment object 2020-05-19 18:26:28 +00:00
SomaticFanatic
5ef0607da6 Update copyright year to 2020
Update copyright year to 2020
2020-05-06 22:36:54 -04:00
luigi1111
f2c78f6a5b
Merge pull request #6486
feee455 Fixes for ZMQ JSON-RPC endpoint names for raw tx (vtnerd)
2020-05-06 00:34:30 -05:00
luigi1111
de025281dc
Merge pull request #6481
119f706 rpc: fix 'use_bootstrap_daemon_if_necessary' return value (xiphon)
2020-05-06 00:29:49 -05:00
Lee Clagett
e5214a2ca2 Adding ZMQ/Pub support for txpool_add and chain_main events 2020-05-04 02:06:35 +00:00
Lee Clagett
feee455c9f Fixes for ZMQ JSON-RPC endpoint names for raw tx 2020-04-29 01:07:27 -04:00
xiphon
119f706921 rpc: fix 'use_bootstrap_daemon_if_necessary' return value 2020-04-27 10:32:33 +00:00
Lee Clagett
c26c93019a Add byte_stream for zero-copy serialization, and add support in ZMQ-JSON. 2020-04-11 04:12:11 +00:00
luigi1111
ec90f9a54b
Merge pull request #6453
d2d3a81 bootstrap_daemon: fix missing virtual destructor and lambda capture (clang warning) (xiphon)
2020-05-01 15:47:47 -05:00
xiphon
d2d3a81d0e bootstrap_daemon: fix missing virtual destructor and lambda capture (clang warning) 2020-04-15 21:22:55 +00:00
luigi1111
5757d99208
Merge pull request #6361
68a6507 Fixed bug in ZMQ JSON-RPC method field (vtnerd)
2020-04-04 13:01:15 -05:00
luigi1111
0150a480fd
Merge pull request #6357
42a7a4d daemon: auto public nodes - cache and prioritize most stable nodes (xiphon)
2020-04-04 12:59:23 -05:00
luigi1111
cfc0f4a7fa
Merge pull request #6351
81c5943 Remove temporary std::string creation in some hex->bin calls (vtnerd)
5fcc23a Move hex->bin conversion to monero copyright files and with less includes (vtnerd)
3387f0e Reduce template bloat in hex->bin for ZMQ json (vtnerd)
2020-04-04 12:55:02 -05:00
luigi1111
ad5200e440
Merge pull request #6342
82da832 rpc: Add check for too old timestamps in payment signatures. (glv2)
2020-04-04 12:49:02 -05:00
luigi1111
081d49c59f
Merge pull request #6338
80d5320 Hash domain separation (SarangNoether)
2020-04-04 12:44:45 -05:00
Lee Clagett
da99157462 Use byte_slice for sending zmq messages - removes data copy within zmq 2020-04-03 01:56:17 +00:00
Sarang Noether
80d5320fff Hash domain separation 2020-04-01 08:31:00 -04:00
xiphon
6d6af701ec cryptonote_basic: drop unused verification_context::m_not_rct field 2020-03-31 21:58:25 +00:00
luigi1111
94f44d4ee3
Merge pull request #6325
3627e53 rpc: fix print_pool_sh not finding local txes (moneromooo-monero)
2020-03-31 15:13:51 -05:00
luigi1111
ccc3726d86
Merge pull request #6260
320bc84 rpc: add --rpc-payment-allow-free-loopback (moneromooo-monero)
2020-03-31 13:35:16 -05:00
Lee Clagett
babf25d2ec Allow unrestricted rpc calls to get full txpool info 2020-03-30 17:52:42 +00:00
Alexander Blair
8cb005b39c
Merge pull request #6289
ffe7165e wallet: reroll fake outs selection on local tx_sanity_check failure (xiphon)
2020-03-27 12:28:29 -07:00
Lee Clagett
02d887c2e5 Adding Dandelion++ support to public networks:
- New flag in NOTIFY_NEW_TRANSACTION to indicate stem mode
  - Stem loops detected in tx_pool.cpp
  - Embargo timeout for a blackhole attack during stem phase
2020-03-26 15:01:30 +00:00
moneromooo-monero
320bc845b3
rpc: add --rpc-payment-allow-free-loopback
This allows RPC coming from the loopback interface to not have
to pay for service. This makes it possible to run an externally
accessible RPC server for payment while also having a local RPC
server that can be run unrestricted and payment free.
2020-03-12 11:27:34 +00:00
Alexander Blair
820ab9fdea
Merge pull request #6273
0f78b06e Various improvements to the ZMQ JSON-RPC handling: (Lee Clagett)
2020-03-12 01:13:49 -07:00
Lee Clagett
5fcc23ae0a Move hex->bin conversion to monero copyright files and with less includes 2020-03-09 05:23:59 +00:00
Lee Clagett
0f78b06e8c Various improvements to the ZMQ JSON-RPC handling:
- Finding handling function in ZMQ JSON-RPC now uses binary search
  - Temporary `std::vector`s in JSON output now use `epee::span` to
    prevent allocations.
  - Binary -> hex in JSON output no longer allocates temporary buffer
  - C++ structs -> JSON skips intermediate DOM creation, and instead
    write directly to an output stream.
2020-03-05 14:20:56 +00:00
Alexander Blair
f3fddd935f
Merge pull request #6259
69336931 rpc: fill miner_tx_hash again (moneromooo-monero)
2020-02-28 19:51:15 -08:00
Alexander Blair
9ea7df3b31
Merge pull request #6242
716012ca rpc: drop the obsolete and wrong "unpruned size" log (moneromooo-monero)
2020-02-28 19:50:02 -08:00
Alexander Blair
4371ac4265
Merge pull request #6225
987c3139 print_coinbase_tx_sum now supports 128 bits sums (moneromooo-monero)
2020-02-28 19:48:11 -08:00
Alexander Blair
e22655a187
Merge pull request #6215
a2578892 --disable-ban-rpc option to prevent RPC users from banning (naughtyfox)
2020-02-28 19:43:06 -08:00
Alexander Blair
4da37daf67
Merge pull request #6211
5985c5af rpc: add bad-blocks to flush_cache RPC (moneromooo-monero)
2020-02-28 19:36:16 -08:00
xiphon
42a7a4dd32 daemon: auto public nodes - cache and prioritize most stable nodes 2020-02-28 08:06:43 +00:00
luigi1111
39e1890276
Merge pull request #6198
5f2a32c daemon: run with -rpc-payment-address and --rpc-restricted-bind-port (moneromooo-monero)
2020-02-19 22:25:44 -05:00
Guillaume Le Vaillant
82da832368 rpc: Add check for too old timestamps in payment signatures. 2020-02-17 15:10:19 +01:00
moneromooo-monero
3627e53aab
rpc: fix print_pool_sh not finding local txes 2020-02-08 12:56:00 +00:00
Alexander Blair
9658f5d7fc
Merge pull request #6040
2f8f3a94 rpc: base flush_cache request/response on the new base structs (moneromooo-monero)
2020-02-06 00:26:34 -08:00
Alexander Blair
25c1bd4714
Merge pull request #6035
b90c4bc3 rpc: error out from get_info if the proxied call errors out (moneromooo-monero)
fa16df99 make_test_signature: exit nicely on top level exception (moneromooo-monero)
054b2621 node_rpc_proxy: init some new rpc payment fields in invalidate (moneromooo-monero)
d0faae2a rpc: init a few missing client_info members (moneromooo-monero)
d56a483a rpc: do not propagate exceptions out of a dtor (moneromooo-monero)
3c849188 rpc: always set the update field in update on sucess (moneromooo-monero)
2020-02-06 00:26:13 -08:00
Alexander Blair
e8f94e7f1d
Merge pull request #6173
8231c7cd rpc: fix bootstrap RPC payment RPC being made in raw JSON, not JSON RPC (moneromooo-monero)
81c26589 rpc: don't auto fail RPC needing payment in bootstrap mode (moneromooo-monero)
2020-01-24 20:19:41 -08:00
Alexander Blair
93d49c1a54
Merge pull request #6172
d7cf8727 rpc: add received_timestamp for pool txes in gettransactions (moneromooo-monero)
2020-01-24 20:17:39 -08:00
Alexander Blair
2ce5529680
Merge pull request #6134
a7a40e28 Actually concatenate error strings. (Bert Peters)
2020-01-16 17:42:27 -08:00
xiphon
ffe7165ebf wallet: reroll fake outs selection on local tx_sanity_check failure 2020-01-14 22:56:23 +00:00
moneromooo-monero
6933693179
rpc: fill miner_tx_hash again
It was removed to save duplicated generation time, but it can
be copied from another instance instead
2019-12-20 14:16:31 +00:00
moneromooo-monero
716012ca3a
rpc: drop the obsolete and wrong "unpruned size" log
Since we now get pruned data in the first place, the "unpruned" data
size will in fact be the pruned data size, leading to confusion
2019-12-16 14:50:07 +00:00
luigi1111
dad4cf121e
Merge pull request #6018
dce6f05 rpc: Only show version string if it matches expected pattern (ndorf)
3293780 daemon: Use rpc for 'version' command (ndorf)
2019-12-12 13:36:05 -06:00
moneromooo-monero
987c3139dc
print_coinbase_tx_sum now supports 128 bits sums
The tail emission will bring the total above 64 bits
2019-12-12 01:56:59 +00:00
naughtyfox
a2578892c0 --disable-ban-rpc option to prevent RPC users from banning 2019-12-04 17:45:27 +03:00
moneromooo-monero
5985c5afe8
rpc: add bad-blocks to flush_cache RPC
Flushes m_invalid_blocks in Blockchain.
2019-12-02 18:53:30 +00:00
moneromooo-monero
5f2a32c15a
daemon: run with -rpc-payment-address and --rpc-restricted-bind-port 2019-11-29 20:07:01 +00:00
moneromooo-monero
b90c4bc39e
rpc: error out from get_info if the proxied call errors out
Coverity 205410
2019-11-27 19:52:39 +00:00
moneromooo-monero
d0faae2a92
rpc: init a few missing client_info members
Coverity 205414
2019-11-27 19:52:37 +00:00
moneromooo-monero
d56a483abe
rpc: do not propagate exceptions out of a dtor
Coverity 205415
2019-11-27 19:52:36 +00:00
moneromooo-monero
3c849188ab
rpc: always set the update field in update on sucess
Coverity 205416
2019-11-27 19:52:33 +00:00
moneromooo-monero
8231c7cd04
rpc: fix bootstrap RPC payment RPC being made in raw JSON, not JSON RPC 2019-11-25 19:28:43 +00:00
moneromooo-monero
81c2658989
rpc: don't auto fail RPC needing payment in bootstrap mode 2019-11-22 18:12:29 +00:00
moneromooo-monero
d7cf872767
rpc: add received_timestamp for pool txes in gettransactions 2019-11-22 15:53:40 +00:00
Lee Clagett
68a6507c3f Fixed bug in ZMQ JSON-RPC method field 2019-11-18 12:59:41 +00:00
Bert Peters
a7a40e285c Actually concatenate error strings. 2019-11-14 10:36:49 +01:00
Nathan Dorfman
dce6f055f9 rpc: Only show version string if it matches expected pattern 2019-11-12 18:19:24 -07:00
Lee Clagett
5d7ae2d279 Adding support for hidden (anonymity) txpool 2019-11-02 20:36:03 +00:00
Riccardo Spagni
da31077bed
Merge pull request #6047
ebc6ce44f cryptonote: untangle dependency from miner to blockchain (moneromooo-monero)
2019-11-02 17:30:09 +02:00
moneromooo-monero
ebc6ce44f4
cryptonote: untangle dependency from miner to blockchain
It causes link errors at least on mac
2019-10-31 01:06:42 +00:00
xiphon
2e2bf8a207 daemon: always use bootstrap daemon (if set) in '--no-sync' mode 2019-10-28 21:52:19 +00:00
moneromooo-monero
2f8f3a9432
rpc: base flush_cache request/response on the new base structs 2019-10-27 16:14:28 +00:00
luigi1111
ef8b3a15b4
Merge pull request #6017
5734686 rpc: Include tag in get_info version string (ndorf)
2019-10-25 20:48:04 -05:00
moneromooo-monero
f7f7513ec3
rpc: fix PRIx64 build error on some systems 2019-10-26 00:05:21 +00:00
moneromooo-monero
a4dc575ccb
rpc: add a flush_cache RPC
This allows flushing internal caches (for now, the bad tx cache,
which will allow debugging a stuck monerod after it has failed to
verify a transaction in a block, since it would otherwise not try
again, making subsequent log changes pointless)
2019-10-25 18:41:54 +00:00
moneromooo-monero
ffa46026b5
simplewallet: add public_nodes command
Lists nodes exposing their RPC port for public use
2019-10-25 09:34:41 +00: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
Nathan Dorfman
57346864a3 rpc: Include tag in get_info version string 2019-10-24 13:48:35 -06:00
moneromooo-monero
b3a9a4d99d
add a quick early out to get_blocks.bin when up to date 2019-10-24 11:30:54 +00:00
luigi1111
c81884f088
Merge pull request #5964
fd48461 Print cdifficulty and don't serialize miner tx hash twice (Doy-lee)
2019-10-22 10:07:17 -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
xiphon
d4d2b5c79a p2p+rpc: don't skip p2p or rpc port bind failure by default 2019-10-13 13:27:46 +00:00
luigi1111
bf525793c7
Merge pull request #5915
8330e77 monerod can now sync from pruned blocks (moneromooo-monero)
2019-10-08 15:55:03 -05:00
Doyle
fd4846134d Print cdifficulty and don't serialize miner tx hash twice 2019-10-07 12:50:05 +11:00