2019-03-05 21:05:34 +00:00
// Copyright (c) 2014-2019, The Monero Project
2014-07-23 13:03:52 +00:00
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
2014-03-03 22:07:58 +00:00
# pragma once
2018-10-09 12:33:39 +00:00
# include <stdexcept>
2014-09-05 02:14:36 +00:00
# include <string>
# include <boost/uuid/uuid.hpp>
2014-12-15 22:23:42 +00:00
# define CRYPTONOTE_DNS_TIMEOUT_MS 20000
2014-04-02 16:00:17 +00:00
# define CRYPTONOTE_MAX_BLOCK_NUMBER 500000000
2014-06-26 20:42:24 +00:00
# define CRYPTONOTE_GETBLOCKTEMPLATE_MAX_BLOCK_SIZE 196608 //size of block (bytes) that is the maximum that miners will produce
2019-04-04 00:15:57 +00:00
# define CRYPTONOTE_MAX_TX_SIZE 1000000
# define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000
2014-04-02 16:00:17 +00:00
# define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
2014-04-17 21:21:40 +00:00
# define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60
2016-06-15 22:37:13 +00:00
# define CURRENT_TRANSACTION_VERSION 2
2014-03-03 22:07:58 +00:00
# define CURRENT_BLOCK_MAJOR_VERSION 1
2014-04-30 10:39:49 +00:00
# define CURRENT_BLOCK_MINOR_VERSION 0
2014-04-02 16:00:17 +00:00
# define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2
2015-10-25 16:16:59 +00:00
# define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 10
2014-03-03 22:07:58 +00:00
# define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 60
// MONEY_SUPPLY - total number coins to be generated
# define MONEY_SUPPLY ((uint64_t)(-1))
2015-11-05 09:58:47 +00:00
# define EMISSION_SPEED_FACTOR_PER_MINUTE (20)
2015-03-05 07:35:04 +00:00
# define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)300000000000) // 3 * pow(10, 11)
2014-04-02 16:00:17 +00:00
# define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
2016-01-29 15:09:17 +00:00
# define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 60000 //size of block (bytes) after which reward for block calculated using block size
2015-11-05 09:58:47 +00:00
# define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 20000 //size of block (bytes) after which reward for block calculated using block size - before first fork
2017-03-14 19:28:38 +00:00
# define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 300000 //size of block (bytes) after which reward for block calculated using block size - second change, from v5
ArticMine's new block weight algorithm
This curbs runaway growth while still allowing substantial
spikes in block weight
Original specification from ArticMine:
here is the scaling proposal
Define: LongTermBlockWeight
Before fork:
LongTermBlockWeight = BlockWeight
At or after fork:
LongTermBlockWeight = min(BlockWeight, 1.4*LongTermEffectiveMedianBlockWeight)
Note: To avoid possible consensus issues over rounding the LongTermBlockWeight for a given block should be calculated to the nearest byte, and stored as a integer in the block itself. The stored LongTermBlockWeight is then used for future calculations of the LongTermEffectiveMedianBlockWeight and not recalculated each time.
Define: LongTermEffectiveMedianBlockWeight
LongTermEffectiveMedianBlockWeight = max(300000, MedianOverPrevious100000Blocks(LongTermBlockWeight))
Change Definition of EffectiveMedianBlockWeight
From (current definition)
EffectiveMedianBlockWeight = max(300000, MedianOverPrevious100Blocks(BlockWeight))
To (proposed definition)
EffectiveMedianBlockWeight = min(max(300000, MedianOverPrevious100Blocks(BlockWeight)), 50*LongTermEffectiveMedianBlockWeight)
Notes:
1) There are no other changes to the existing penalty formula, median calculation, fees etc.
2) There is the requirement to store the LongTermBlockWeight of a block unencrypted in the block itself. This is to avoid possible consensus issues over rounding and also to prevent the calculations from becoming unwieldy as we move away from the fork.
3) When the EffectiveMedianBlockWeight cap is reached it is still possible to mine blocks up to 2x the EffectiveMedianBlockWeight by paying the corresponding penalty.
Note: the long term block weight is stored in the database, but not in the actual block itself,
since it requires recalculating anyway for verification.
2019-01-21 17:18:50 +00:00
# define CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE 100000 // size in blocks of the long term block weight median window
# define CRYPTONOTE_SHORT_TERM_BLOCK_WEIGHT_SURGE_FACTOR 50
2014-04-02 16:00:17 +00:00
# define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
2014-04-17 21:21:40 +00:00
# define CRYPTONOTE_DISPLAY_DECIMAL_POINT 12
2014-03-03 22:07:58 +00:00
// COIN - number of smallest units in one coin
2014-05-25 17:06:40 +00:00
# define COIN ((uint64_t)1000000000000) // pow(10, 12)
2014-11-09 10:53:29 +00:00
2016-09-14 22:54:01 +00:00
# define FEE_PER_KB_OLD ((uint64_t)10000000000) // pow(10, 10)
# define FEE_PER_KB ((uint64_t)2000000000) // 2 * pow(10, 9)
2018-07-18 21:24:53 +00:00
# define FEE_PER_BYTE ((uint64_t)300000)
2016-10-27 22:43:44 +00:00
# define DYNAMIC_FEE_PER_KB_BASE_FEE ((uint64_t)2000000000) // 2 * pow(10,9)
# define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000000) // 10 * pow(10,12)
2017-03-14 19:28:38 +00:00
# define DYNAMIC_FEE_PER_KB_BASE_FEE_V5 ((uint64_t)2000000000 * (uint64_t)CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 / CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5)
2018-07-18 21:24:53 +00:00
# define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)3000)
2014-03-03 22:07:58 +00:00
# define ORPHANED_BLOCKS_MAX_COUNT 100
2016-01-29 15:09:17 +00:00
# define DIFFICULTY_TARGET_V2 120 // seconds
2015-11-05 09:58:47 +00:00
# define DIFFICULTY_TARGET_V1 60 // seconds - before first fork
2014-03-03 22:07:58 +00:00
# define DIFFICULTY_WINDOW 720 // blocks
# define DIFFICULTY_LAG 15 // !!!
# define DIFFICULTY_CUT 60 // timestamps to cut after sorting
# define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
2015-11-13 08:24:47 +00:00
# define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 DIFFICULTY_TARGET_V1 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
2016-01-29 15:09:17 +00:00
# define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 DIFFICULTY_TARGET_V2 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
2014-04-02 16:00:17 +00:00
# define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
2014-03-03 22:07:58 +00:00
2015-11-13 08:24:47 +00:00
# define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN DIFFICULTY_TARGET_V1 //just alias; used by tests
2014-03-03 22:07:58 +00:00
# define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
2017-08-16 20:19:53 +00:00
# define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
2017-08-08 10:05:11 +00:00
# define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
2019-04-23 19:32:27 +00:00
# define BLOCKS_SYNCHRONIZING_MAX_COUNT 2048 //must be a power of 2, greater than 128, equal to SEEDHASH_EPOCH_BLOCKS
2014-03-03 22:07:58 +00:00
2018-01-31 21:53:34 +00:00
# define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) //seconds, three days
2014-06-15 07:48:13 +00:00
# define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 //seconds, one week
2014-03-03 22:07:58 +00:00
2019-05-16 20:34:22 +00:00
// see src/cryptonote_protocol/levin_notify.cpp
# define CRYPTONOTE_NOISE_MIN_EPOCH 5 // minutes
# define CRYPTONOTE_NOISE_EPOCH_RANGE 30 // seconds
# define CRYPTONOTE_NOISE_MIN_DELAY 10 // seconds
# define CRYPTONOTE_NOISE_DELAY_RANGE 5 // seconds
# define CRYPTONOTE_NOISE_BYTES 3*1024 // 3 KiB
# define CRYPTONOTE_NOISE_CHANNELS 2 // Max outgoing connections per zone used for noise/covert sending
# define CRYPTONOTE_MAX_FRAGMENTS 20 // ~20 * NOISE_BYTES max payload size for covert/noise send
2014-03-03 22:07:58 +00:00
# define COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT 1000
# define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
# define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
2015-12-15 02:45:52 +00:00
# define P2P_DEFAULT_CONNECTIONS_COUNT 8
2014-03-03 22:07:58 +00:00
# define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
# define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
# define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
# define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
2019-01-21 16:50:03 +00:00
# define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
2014-03-03 22:07:58 +00:00
# define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
2014-04-07 15:02:15 +00:00
# define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes
2014-03-03 22:07:58 +00:00
# define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 5000 //5 seconds
# define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
2017-02-09 00:11:58 +00:00
# define P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT 2
2019-02-26 12:40:40 +00:00
# define P2P_DEFAULT_SYNC_SEARCH_CONNECTIONS_COUNT 2
2018-10-31 21:47:20 +00:00
# define P2P_DEFAULT_LIMIT_RATE_UP 2048 // kB/s
# define P2P_DEFAULT_LIMIT_RATE_DOWN 8192 // kB/s
2014-03-03 22:07:58 +00:00
2015-11-23 17:34:55 +00:00
# define P2P_FAILED_ADDR_FORGET_SECONDS (60*60) //1 hour
# define P2P_IP_BLOCKTIME (60*60*24) //24 hour
# define P2P_IP_FAILS_BEFORE_BLOCK 10
# define P2P_IDLE_CONNECTION_KILL_INTERVAL (5*60) //5 minutes
2016-10-26 19:00:08 +00:00
# define P2P_SUPPORT_FLAG_FLUFFY_BLOCKS 0x01
# define P2P_SUPPORT_FLAGS P2P_SUPPORT_FLAG_FLUFFY_BLOCKS
2019-06-13 07:47:06 +00:00
# define RPC_IP_FAILS_BEFORE_BLOCK 3
2014-08-23 20:43:13 +00:00
# define ALLOW_DEBUG_COMMANDS
2014-03-03 22:07:58 +00:00
2014-04-17 21:21:40 +00:00
# define CRYPTONOTE_NAME "bitmonero"
2014-03-03 22:07:58 +00:00
# define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
2017-01-28 14:55:14 +00:00
# define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb"
# define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
2014-03-03 22:07:58 +00:00
# define P2P_NET_DATA_FILENAME "p2pstate.bin"
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.
2018-02-11 15:15:56 +00:00
# define RPC_PAYMENTS_DATA_FILENAME "rpcpayments.bin"
2014-03-03 22:07:58 +00:00
# define MINER_CONFIG_FILE_NAME "miner_conf.json"
2014-04-30 20:50:06 +00:00
# define THREAD_STACK_SIZE 5 * 1024 * 1024
2014-03-03 22:07:58 +00:00
2016-10-27 22:43:44 +00:00
# define HF_VERSION_DYNAMIC_FEE 4
2017-03-14 19:28:38 +00:00
# define HF_VERSION_MIN_MIXIN_4 6
2018-03-07 10:37:31 +00:00
# define HF_VERSION_MIN_MIXIN_6 7
2018-07-18 21:24:53 +00:00
# define HF_VERSION_MIN_MIXIN_10 8
2017-03-14 19:28:38 +00:00
# define HF_VERSION_ENFORCE_RCT 6
2018-07-18 21:24:53 +00:00
# define HF_VERSION_PER_BYTE_FEE 8
2019-01-06 13:47:16 +00:00
# define HF_VERSION_SMALLER_BP 10
ArticMine's new block weight algorithm
This curbs runaway growth while still allowing substantial
spikes in block weight
Original specification from ArticMine:
here is the scaling proposal
Define: LongTermBlockWeight
Before fork:
LongTermBlockWeight = BlockWeight
At or after fork:
LongTermBlockWeight = min(BlockWeight, 1.4*LongTermEffectiveMedianBlockWeight)
Note: To avoid possible consensus issues over rounding the LongTermBlockWeight for a given block should be calculated to the nearest byte, and stored as a integer in the block itself. The stored LongTermBlockWeight is then used for future calculations of the LongTermEffectiveMedianBlockWeight and not recalculated each time.
Define: LongTermEffectiveMedianBlockWeight
LongTermEffectiveMedianBlockWeight = max(300000, MedianOverPrevious100000Blocks(LongTermBlockWeight))
Change Definition of EffectiveMedianBlockWeight
From (current definition)
EffectiveMedianBlockWeight = max(300000, MedianOverPrevious100Blocks(BlockWeight))
To (proposed definition)
EffectiveMedianBlockWeight = min(max(300000, MedianOverPrevious100Blocks(BlockWeight)), 50*LongTermEffectiveMedianBlockWeight)
Notes:
1) There are no other changes to the existing penalty formula, median calculation, fees etc.
2) There is the requirement to store the LongTermBlockWeight of a block unencrypted in the block itself. This is to avoid possible consensus issues over rounding and also to prevent the calculations from becoming unwieldy as we move away from the fork.
3) When the EffectiveMedianBlockWeight cap is reached it is still possible to mine blocks up to 2x the EffectiveMedianBlockWeight by paying the corresponding penalty.
Note: the long term block weight is stored in the database, but not in the actual block itself,
since it requires recalculating anyway for verification.
2019-01-21 17:18:50 +00:00
# define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 10
2019-04-23 21:56:04 +00:00
# define HF_VERSION_MIN_2_OUTPUTS 12
2019-05-24 22:41:39 +00:00
# define HF_VERSION_MIN_V2_COINBASE_TX 12
2019-04-13 23:37:55 +00:00
# define HF_VERSION_SAME_MIXIN 12
2019-07-14 11:51:32 +00:00
# define HF_VERSION_REJECT_SIGS_IN_COINBASE 12
2019-09-04 13:59:36 +00:00
# define HF_VERSION_ENFORCE_MIN_AGE 12
2019-10-09 20:01:48 +00:00
# define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY 12
2017-03-14 19:28:38 +00:00
2017-03-03 23:31:38 +00:00
# define PER_KB_FEE_QUANTIZATION_DECIMALS 8
2016-10-27 22:43:44 +00:00
2019-09-16 12:18:34 +00:00
# define HASH_OF_HASHES_STEP 512
2017-09-13 20:03:04 +00:00
2018-07-18 21:24:53 +00:00
# define DEFAULT_TXPOOL_MAX_WEIGHT 648000000ull // 3 days at 300000, in bytes
2017-09-13 20:03:04 +00:00
2018-03-30 19:44:51 +00:00
# define BULLETPROOF_MAX_OUTPUTS 16
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.
2018-04-29 22:30:51 +00:00
# define CRYPTONOTE_PRUNING_STRIPE_SIZE 4096 // the smaller, the smoother the increase
# define CRYPTONOTE_PRUNING_LOG_STRIPES 3 // the higher, the more space saved
# define CRYPTONOTE_PRUNING_TIP_BLOCKS 5500 // the smaller, the more space saved
//#define CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
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.
2018-02-11 15:15:56 +00:00
# define RPC_CREDITS_PER_HASH_SCALE ((float)(1<<24))
2014-09-05 02:14:36 +00:00
// New constants are intended to go here
namespace config
{
uint64_t const DEFAULT_FEE_ATOMIC_XMR_PER_KB = 500 ; // Just a placeholder! Change me!
uint8_t const FEE_CALCULATION_MAX_RETRIES = 10 ;
2016-10-12 01:04:26 +00:00
uint64_t const DEFAULT_DUST_THRESHOLD = ( ( uint64_t ) 2000000000 ) ; // 2 * pow(10, 9)
2015-10-06 15:20:23 +00:00
uint64_t const BASE_REWARD_CLAMP_THRESHOLD = ( ( uint64_t ) 100000000 ) ; // pow(10, 8)
2014-09-05 02:14:36 +00:00
std : : string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY = " 0000000000000000000000000000000000000000000000000000000000000000 " ;
2014-09-09 20:29:24 +00:00
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 18 ;
2015-06-11 08:44:13 +00:00
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 19 ;
2017-10-16 01:35:59 +00:00
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 42 ;
2014-09-05 02:14:36 +00:00
uint16_t const P2P_DEFAULT_PORT = 18080 ;
uint16_t const RPC_DEFAULT_PORT = 18081 ;
2017-09-05 16:20:27 +00:00
uint16_t const ZMQ_RPC_DEFAULT_PORT = 18082 ;
2014-09-05 02:14:36 +00:00
boost : : uuids : : uuid const NETWORK_ID = { {
0x12 , 0x30 , 0xF1 , 0x71 , 0x61 , 0x04 , 0x41 , 0x61 , 0x17 , 0x31 , 0x00 , 0x82 , 0x16 , 0xA1 , 0xA1 , 0x10
} } ; // Bender's nightmare
std : : string const GENESIS_TX = " 013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1 " ;
uint32_t const GENESIS_NONCE = 10000 ;
namespace testnet
{
2014-09-09 20:29:24 +00:00
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 53 ;
2015-06-11 08:44:13 +00:00
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 54 ;
2017-02-19 02:42:10 +00:00
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 63 ;
2014-09-05 02:14:36 +00:00
uint16_t const P2P_DEFAULT_PORT = 28080 ;
uint16_t const RPC_DEFAULT_PORT = 28081 ;
2017-09-05 16:20:27 +00:00
uint16_t const ZMQ_RPC_DEFAULT_PORT = 28082 ;
2014-09-05 02:14:36 +00:00
boost : : uuids : : uuid const NETWORK_ID = { {
0x12 , 0x30 , 0xF1 , 0x71 , 0x61 , 0x04 , 0x41 , 0x61 , 0x17 , 0x31 , 0x00 , 0x82 , 0x16 , 0xA1 , 0xA1 , 0x11
} } ; // Bender's daydream
2018-02-14 00:51:37 +00:00
std : : string const GENESIS_TX = " 013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1 " ;
2014-09-05 02:14:36 +00:00
uint32_t const GENESIS_NONCE = 10001 ;
}
2018-02-16 11:04:04 +00:00
namespace stagenet
{
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 24 ;
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 25 ;
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 36 ;
uint16_t const P2P_DEFAULT_PORT = 38080 ;
uint16_t const RPC_DEFAULT_PORT = 38081 ;
uint16_t const ZMQ_RPC_DEFAULT_PORT = 38082 ;
boost : : uuids : : uuid const NETWORK_ID = { {
0x12 , 0x30 , 0xF1 , 0x71 , 0x61 , 0x04 , 0x41 , 0x61 , 0x17 , 0x31 , 0x00 , 0x82 , 0x16 , 0xA1 , 0xA1 , 0x12
} } ; // Bender's daydream
std : : string const GENESIS_TX = " 013c01ff0001ffffffffffff0302df5d56da0c7d643ddd1ce61901c7bdc5fb1738bfe39fbe69c28a3a7032729c0f2101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b " ;
uint32_t const GENESIS_NONCE = 10002 ;
}
}
namespace cryptonote
{
enum network_type : uint8_t
{
MAINNET = 0 ,
TESTNET ,
STAGENET ,
2018-03-18 23:36:20 +00:00
FAKECHAIN ,
UNDEFINED = 255
2018-02-16 11:04:04 +00:00
} ;
2018-06-11 03:16:29 +00:00
struct config_t
{
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX ;
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX ;
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX ;
uint16_t const P2P_DEFAULT_PORT ;
uint16_t const RPC_DEFAULT_PORT ;
uint16_t const ZMQ_RPC_DEFAULT_PORT ;
boost : : uuids : : uuid const NETWORK_ID ;
std : : string const GENESIS_TX ;
uint32_t const GENESIS_NONCE ;
} ;
inline const config_t & get_config ( network_type nettype )
{
static const config_t mainnet = {
: : config : : CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX ,
: : config : : CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX ,
: : config : : CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX ,
: : config : : P2P_DEFAULT_PORT ,
: : config : : RPC_DEFAULT_PORT ,
: : config : : ZMQ_RPC_DEFAULT_PORT ,
: : config : : NETWORK_ID ,
: : config : : GENESIS_TX ,
: : config : : GENESIS_NONCE
} ;
static const config_t testnet = {
: : config : : testnet : : CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX ,
: : config : : testnet : : CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX ,
: : config : : testnet : : CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX ,
: : config : : testnet : : P2P_DEFAULT_PORT ,
: : config : : testnet : : RPC_DEFAULT_PORT ,
: : config : : testnet : : ZMQ_RPC_DEFAULT_PORT ,
: : config : : testnet : : NETWORK_ID ,
: : config : : testnet : : GENESIS_TX ,
: : config : : testnet : : GENESIS_NONCE
} ;
static const config_t stagenet = {
: : config : : stagenet : : CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX ,
: : config : : stagenet : : CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX ,
: : config : : stagenet : : CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX ,
: : config : : stagenet : : P2P_DEFAULT_PORT ,
: : config : : stagenet : : RPC_DEFAULT_PORT ,
: : config : : stagenet : : ZMQ_RPC_DEFAULT_PORT ,
: : config : : stagenet : : NETWORK_ID ,
: : config : : stagenet : : GENESIS_TX ,
: : config : : stagenet : : GENESIS_NONCE
} ;
switch ( nettype )
{
case MAINNET : return mainnet ;
case TESTNET : return testnet ;
case STAGENET : return stagenet ;
case FAKECHAIN : return mainnet ;
default : throw std : : runtime_error ( " Invalid network type " ) ;
}
} ;
2014-09-05 02:14:36 +00:00
}