Commit Graph

342 Commits

Author SHA1 Message Date
moneromooo 5d1849a9eb
protocol: stricter checks on received chain hash list 2020-12-11 18:47:40 +00:00
moneromooo ff7fdf6db2
protocol: drop peers that don't reply to queries 2020-12-06 15:57:40 +00:00
moneromooo 61f5001c3f
protocol: add scoring system to drop peers that don't behave 2020-12-04 01:55:21 +00:00
Riccardo Spagni aefa7740c3
Merge pull request #6111
d20ff4f64 functional_tests: add a large (many randomx epochs) p2p reorg test (moneromooo-monero)
6a0b3b1f8 functional_tests: add randomx tests (moneromooo-monero)
9d42649d5 core: fix mining from a block that's not the current top (moneromooo-monero)
2020-09-06 15:49:37 +02:00
moneromooo-monero 9d42649d58
core: fix mining from a block that's not the current top 2020-08-27 15:13:00 +00:00
moneromooo-monero 82ee01699c
Integrate CLSAGs into monero
They are allowed from v12, and MLSAGs are rejected from v13.
2020-08-27 12:44:04 +00:00
Alexander Blair bad5d8d6f0
Merge pull request #6690
7175dcb10 replace most boost serialization with existing monero serialization (moneromooo-monero)
2020-08-27 02:54:30 -07:00
Alexander Blair 38914fe6fa
Merge pull request #6613
55363c594 Avoid some temporary strings when reading off the database (moneromooo-monero)
2020-08-27 02:52:59 -07:00
Alexander Blair a6f1fa0194
Merge pull request #6607
eb1b321fe miner: increase min/max intervals to full extents (moneromooo-monero)
2020-08-26 12:53:09 -07:00
luigi1111 765db1ae7a
Revert "Use domain-separated ChaCha20 for in-memory key encryption"
This reverts commit 921dd8dde5.
2020-08-17 14:08:59 -05:00
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
moneromooo-monero 55363c5941
Avoid some temporary strings when reading off the database 2020-08-17 14:02:27 +00:00
Alexander Blair 6d29ee6c52
Merge pull request #6493
921dd8dde Use domain-separated ChaCha20 for in-memory key encryption (Sarang Noether)
2020-08-16 12:39:59 -07:00
Sarang Noether 921dd8dde5 Use domain-separated ChaCha20 for in-memory key encryption 2020-08-09 19:11:54 -04:00
moneromooo-monero eb1b321fe2
miner: increase min/max intervals to full extents
This prevents setting target to, eg, 65 being ignored

and remove an unused constant
2020-05-31 12:36:47 +00:00
SomaticFanatic 5ef0607da6 Update copyright year to 2020
Update copyright year to 2020
2020-05-06 22:36:54 -04:00
luigi1111 483e5cab5c
Merge pull request #6472
2efbd5f cryptonote: fix reuse of non default tx data when relaying (moneromooo-monero)
2020-05-06 00:25:18 -05:00
Lee Clagett e5214a2ca2 Adding ZMQ/Pub support for txpool_add and chain_main events 2020-05-04 02:06:35 +00:00
luigi1111 443f5c6bda
Merge pull request #6436
688a3e8 Add timelock verification on device (cslashm)
2020-05-01 15:20:05 -05:00
moneromooo-monero 2efbd5f0cc
cryptonote: fix reuse of non default tx data when relaying
An automatic tx variable is initialized properly on the first
run through the loop, but not the second. Moving the variable
inside the loop ensures the ctor is called again to init it.
2020-04-22 16:50:20 +00:00
cslashm 688a3e87e7 Add timelock verification on device 2020-04-08 11:12:32 +02: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
luigi1111 081d49c59f
Merge pull request #6338
80d5320 Hash domain separation (SarangNoether)
2020-04-04 12:44:45 -05: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
Aaron Hook aa93e38862 p2p: remove old debug commands 2020-03-20 22:09:44 -07: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
moneromooo-monero c2095fc27b
miner: use verification mode for low diff one block nonce searches
This avoids lengthy init times when testing
2020-02-06 14:27:10 +00: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
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
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
luigi1111 bb2bcf3521
Merge pull request #5972
9447e72 cryptonote: add function to get weight from a pruned tx (moneromooo-monero)
2019-10-22 10:52:14 -05:00
luigi1111 84ce43a239
Merge pull request #5966
be82c40 Support median block size > 4 GB (moneromooo-monero)
2019-10-22 10:08:32 -05:00
moneromooo-monero be82c40703
Support median block size > 4 GB
add a 128/64 division routine so we can use a > 32 bit median block
size in calculations
2019-10-21 10:41:07 +00:00
luigi1111 6c05723981
Merge pull request #5984
7fdaa82 Fix build on FreeBSD/!x86 (pkubaj)
0f4fddc Add also ifdef __x86_64__ (pkubaj)
2019-10-16 13:53:14 -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
pkubaj 0f4fddc2f8
Add also ifdef __x86_64__ 2019-10-13 19:08:23 +00:00
pkubaj 7fdaa8285e
Fix build on FreeBSD/!x86
Checking battery status uses x86-only headers and functions. Remove this functionality to get it to build on other architectures.
2019-10-13 16:43:18 +00:00
moneromooo-monero 9447e7276d
cryptonote: add function to get weight from a pruned tx
The weight of the prunable data is deterministic from the
unpruned data, so it can be determined from a pruned tx
2019-10-11 12:08:36 +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
moneromooo-monero 8330e772f1
monerod can now sync from pruned blocks
If the peer (whether pruned or not itself) supports sending pruned blocks
to syncing nodes, the pruned version will be sent along with the hash
of the pruned data and the block weight. The original tx hashes can be
reconstructed from the pruned txes and theur prunable data hash. Those
hashes and the block weights are hashes and checked against the set of
precompiled hashes, ensuring the data we received is the original data.
It is currently not possible to use this system when not using the set
of precompiled hashes, since block weights can not otherwise be checked
for validity.

This is off by default for now, and is enabled by --sync-pruned-blocks
2019-09-27 00:10:37 +00:00
Howard Chu 81c2ad6d5b
RandomX integration
Support RandomX PoW algorithm
2019-09-25 21:29:42 +01: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
luigi1111 ee6e849627
Merge pull request #5877
2cd4fd8 Changed the use of boost:value_initialized for C++ list initializer (JesusRami)
4ad191f Removed unused boost/value_init header (whyamiroot)
928f4be Make null hash constants constexpr (whyamiroot)
2019-09-24 10:08:44 -05:00
moneromooo-monero d0663837d2
core: move hardforks into its own lib
So it can be used by others without encumbrance
2019-09-19 11:28:18 +00:00
Lev Sizov 928f4be953 Make null hash constants constexpr
Simplify m_template initialization in miner
2019-09-05 17:37:19 +02:00
moneromooo-monero d046ca1db0
difficulty: fix check_hash on big endian 2019-09-04 14:53:53 +00:00
Lev Sizov 4ad191ffa9 Removed unused boost/value_init header 2019-09-02 14:38:29 +02:00
Jesus Ramirez 2cd4fd8972 Changed the use of boost:value_initialized for C++ list initializer 2019-09-02 14:16:29 +02:00
Lee Clagett 3b24b1d082 Added support for "noise" over I1P/Tor to mask Tx transmission. 2019-07-17 14:22:37 +00:00
luigi1111 1499caf596
Merge pull request #5720
bcd2da7 miner: fix --bg-mining-enable description (moneromooo-monero)
2019-08-19 17:18:04 -05:00
luigi1111 2258551ef9
Merge pull request #5487
df83ed7 consensus: from v12, enforce >= 2 outputs (moneromooo-monero)
2019-08-14 15:26:55 -05:00
moneromooo-monero bcd2da76cd
miner: fix --bg-mining-enable description 2019-07-02 17:43:36 +00:00
moneromooo-monero 1387549e90
serialization: check stream good flag at the end
just in case
2019-06-14 08:47:23 +00:00
moneromooo-monero f215219252
cryptonote: throw on tx hash calculation error 2019-06-14 08:47:17 +00:00
ston1th f2f207d635 miner: fix double free of thread attributes
issue: #5568
2019-06-09 10:51:18 +02:00
moneromooo-monero e980938210
fix wide difficulty conversion with some versions of boost 2019-05-01 19:58:09 +00:00
moneromooo-monero df83ed74e4
consensus: from v12, enforce >= 2 outputs 2019-04-23 22:09:35 +00:00
moneromooo-monero 375fde9454
hardfork: fix off by one updating fork index after popping 2019-04-20 00:05:35 +00:00
Riccardo Spagni e98cbfbdfe
Merge pull request #5444
6643b047 Increment m_threads_active when mining thread starts (Doyle)
2019-04-16 22:45:42 +02:00
Riccardo Spagni c5f64bf170
Merge pull request #5443
07dd5536 hardfork: remove "no hf version db" recreation check (moneromooo-monero)
2019-04-16 22:45:23 +02:00
Riccardo Spagni 46c477ab30
Merge pull request #5400
5e673c03 blockchain_db: fix db txn ending too early (moneromooo-monero)
2019-04-16 22:30:40 +02:00
Riccardo Spagni 9bd0983d5e
Merge pull request #5402
cbf32241 rpc: make wide_difficulty hexadecimal (moneromooo-monero)
2019-04-15 09:18:10 +02:00
Doyle 6643b04737 Increment m_threads_active when mining thread starts 2019-04-15 13:08:33 +10:00
moneromooo-monero 07dd55363c
hardfork: remove "no hf version db" recreation check
This is now obsolete, and this removes the warning on startup
on a new db that confuses some people
2019-04-14 10:34:29 +00:00
moneromooo-monero 5e673c03fe
blockchain_db: fix db txn ending too early
The db txn in add_block ending caused the entire overarching
batch txn to stop.
Also add a new guard class so a db txn can be stopped in the
face of exceptions.

Also use a read only db txn in init when the db itself is
read only, and do not save the max tx size in that case.
2019-04-14 08:35:38 +00:00
moneromooo-monero 064ab12340
functional_tests: add more blockchain related tests
Related to emission, reorgs, getting tx data back, output
distribution and histogram
2019-04-11 11:07:58 +00:00
Riccardo Spagni 38717dafc0
Merge pull request #5381
def40161 miner: fix race when stopping mining with start mining enabled (moneromooo-monero)
2019-04-11 13:03:32 +02:00
Riccardo Spagni 915d9e5a1f
Merge pull request #5380
113e4877 blockchain_stats: fix sign in formatting function (moneromooo-monero)
adaea3ea various: remove unused variables (moneromooo-monero)
631ef00e blockchain: some debug info when adding txes-from-block fails (moneromooo-monero)
2019-04-11 13:02:59 +02:00
Riccardo Spagni 3a4008f0fc
Merge pull request #5374
a2561653 wallet: new option to start background mining (moneromooo-monero)
2019-04-11 13:01:30 +02:00
Riccardo Spagni 76fbcfe2dd
Merge pull request #5123
089c7637 cryptonote: rework block blob size sanity check (moneromooo-monero)
2019-04-11 12:41:07 +02:00
Riccardo Spagni 4ac78e1612
Merge pull request #5346
c84ea299 cryptonote_basic: some more minor speedups (moneromooo-monero)
e40eb2ad cryptonote_basic: speedup calculate_block_hash (moneromooo-monero)
547a9708 cryptonote: block parsing + hash calculation speedup (moneromooo-monero)
11604b6d blockchain: avoid unneeded block copy (moneromooo-monero)
8461df04 save some database calls when getting top block hash and height (moneromooo-monero)
3bbc3661 Avoid repeated (de)serialization when syncing (moneromooo-monero)
2019-04-06 15:59:43 +02:00
moneromooo-monero cbf3224180
rpc: make wide_difficulty hexadecimal
This should be friendlier for clients which don't have bignum support
2019-04-05 16:30:16 +00:00
moneromooo-monero 089c7637a6
cryptonote: rework block blob size sanity check
Use the actual block weight limit, assuming that weight is always
greater or equal to size
2019-04-05 09:35:19 +00:00
moneromooo-monero a2561653cb
wallet: new option to start background mining
The setup-background-mining option can be used to select
background mining when a wallet loads. The user will be asked
the first time the wallet is created.
2019-04-04 18:10:45 +00:00
moneromooo-monero def4016171 miner: fix race when stopping mining with start mining enabled 2019-04-01 19:28:50 +00:00
moneromooo-monero adaea3ea3c
various: remove unused variables 2019-04-01 19:24:41 +00:00
Riccardo Spagni 574c399386
Merge pull request #5288
39f000b3 miner: fix possible exit crash due to race in stop (moneromooo-monero)
2019-04-01 17:20:25 +02:00
moneromooo-monero c84ea2993f
cryptonote_basic: some more minor speedups 2019-03-25 13:43:38 +00:00
moneromooo-monero e40eb2ad9d
cryptonote_basic: speedup calculate_block_hash
The block 202612 fix can be left tested at the end, if we
already know we're not in the general case
2019-03-25 13:43:29 +00:00
moneromooo-monero 547a9708de
cryptonote: block parsing + hash calculation speedup
This saves a duplicate serialization step
2019-03-25 13:43:17 +00:00
moneromooo-monero 91f4c7f45f
Make difficulty 128 bit instead of 64 bit
Based on Boolberry work by:
  jahrsg <jahr@jahr.me>
  cr.zoidberg <crypto.zoidberg@gmail.com>
2019-03-24 21:03:19 +00:00
Riccardo Spagni 8cb4293e82
Merge pull request #5277
adf6d773 wallet: fix offline signing calling a daemon RPC (moneromooo-monero)
2019-03-24 19:35:39 +02:00
moneromooo-monero e9519e9876
cryptonote: fix calculating coinbase tx hash
Also set error flag on exception when handling new txes
to keep tests working
2019-03-21 17:13:01 +00:00
moneromooo-monero adf6d7730f
wallet: fix offline signing calling a daemon RPC 2019-03-21 14:46:29 +00:00
Riccardo Spagni cac4c3103a
Merge pull request #5271
2790d4d3 hardfork: update last_versions on popped block (moneromooo-monero)
2019-03-21 14:52:02 +02:00
Riccardo Spagni 48e3a341f8
Merge pull request #5211
c9b13fbb tests/trezor: HF9 and HF10 tests (Dusan Klinec)
a1fd1d49 device/trezor: HF10 support added, wallet::API (Dusan Klinec)
d74d26f2 crypto: hmac_keccak added (Dusan Klinec)
2019-03-21 14:44:04 +02:00
Dusan Klinec a1fd1d499c
device/trezor: HF10 support added, wallet::API
- import only key images generated by cold signing process
- wallet_api: trezor methods added
- wallet: button request code added
- const added to methods
- wallet2::get_tx_key_device() tries to decrypt stored tx private keys using the device.
- simplewallet supports get_tx_key and get_tx_proof on hw device using the get_tx_key feature
- live refresh enables refresh with trezor i.e. computing key images on the fly. More convenient and efficient for users.
- device: has_ki_live_refresh added
- a thread is watching whether live refresh is being computed, if not for 30 seconds, it terminates the live refresh process - switches Trezor state
2019-03-20 21:11:02 +01: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
Riccardo Spagni 429930534d
Merge pull request #5185
59478c80 daemon: new mining_status command (moneromooo-monero)
2019-03-17 17:55:32 +02:00
Riccardo Spagni 50d48d6118
Merge pull request #5135
de32dcea Human readable message if maximum outputs reached (italocoin)
2019-03-17 17:50:41 +02:00
moneromooo-monero 39f000b394
miner: fix possible exit crash due to race in stop
If a thread asks to stop the miner, m_stop will be set, and
that thread will wait to join. If the main thread is exiting
at that time, it will ask the miner to stop, but the miner
will claim it's not mining and early out since m_stop is
set. This will cause the database and other things to get
shutdown. If the miner happens to find a block at that time,
it will try to call core, and crash.

Instead, lock and check whether any threads are currently
in m_threads, since they'll only be cleared once the threads
are joined. Moreover, since we lock, the second thread will
have to wait for the first one to have finished. Calling
join twice on a thread seems fine as per pthread_join(3).
2019-03-14 16:59:08 +00:00
moneromooo-monero 2790d4d30a
hardfork: update last_versions on popped block 2019-03-12 13:43:12 +00:00
moneromooo-monero 59478c80dd
daemon: new mining_status command 2019-03-09 20:51:53 +00:00
binaryFate 1f2930ce0b Update 2019 copyright 2019-03-05 22:05:34 +01:00
moneromooo-monero 9feda0eeba
cryptonote: speed up calculating coinbase tx prunable hash
It's a hash of an empty buffer, so we can avoid keccak
2019-03-05 11:58:16 +00:00
moneromooo-monero f75d51abda
core: avoid calculating tx prefix hash when we don't need it 2019-03-05 11:57:57 +00:00
moneromooo-monero e69477bf25
db: speedup block addition
by avoiding repeated (de)serialization
2019-03-05 10:28:52 +00:00
moneromooo-monero 23abe60705
check load_t_from_json return values 2019-03-04 22:38:06 +00:00
moneromooo-monero e396146aee
default initialize rpc structures 2019-03-04 22:38:03 +00:00