aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-09-11 15:45:56 +0200
committerRiccardo Spagni <ric@spagni.net>2018-09-11 15:45:56 +0200
commite6d36c17015e179aaa21f2353bdc608967833303 (patch)
tree39fb0829fe9f3b0d468bbb27393cd79fdefbda15 /src/cryptonote_core/blockchain.h
parentMerge pull request #4218 (diff)
parentblockchain: add a testnet v9 a day after v8 (diff)
downloadmonero-e6d36c17015e179aaa21f2353bdc608967833303.tar.xz
Merge pull request #4219
9137ad2c blockchain: add a testnet v9 a day after v8 (moneromooo-monero) ac4f71c2 wallet2: bump testnet rollback to account for coming reorg (moneromooo-monero) 8f418a6d bulletproofs: #include <openssl/bn.h> (moneromooo-monero) 2bf63650 bulletproofs: speed up the latest changes a bit (moneromooo-monero) 044dff5a bulletproofs: scale points by 8 to ensure subgroup validity (moneromooo-monero) c83012c4 bulletproofs: match aggregated verification to sarang's latest prototype (moneromooo-monero) ce0c7432 performance_tests: add padded bulletproof construction (moneromooo-monero) 1224e53b core_tests: add a test for 4-aggregated BP verification (moneromooo-monero) 0e6ed559 fuzz_tests: add a bulletproof fuzz test (moneromooo-monero) 463434d1 more comprehensive test for ge_p3 comparison to identity/point at infinity (moneromooo-monero) d0a0565f unit_tests: add a few more multiexp unit tests (moneromooo-monero) 6526d87f core_tests: add a test for a tx with empty bulletproof (moneromooo-monero) a129bbd9 multiexp: fix maxscalar off by one (moneromooo-monero) 7ed496cc ringct: error out when hashToPoint* returns the point at infinity (moneromooo-monero) d1591853 cryptonote_basic: check output type before using it (moneromooo-monero) 61632dc1 ringct: prevent a potential very large allocation (moneromooo-monero) a4317e61 crypto: some paranoid checks in generate_signature/check_signature (moneromooo-monero) 7434df1c crypto: never return zero in random32_unbiased (moneromooo-monero) 0825e974 multiexp: fix wrong Bos-Coster result for 1 non trivial input (moneromooo-monero) a1359ad4 Check inputs to addKeys are in range (moneromooo-monero) fe0fa3b9 bulletproofs: reject x, y, z, or w[i] being zero (moneromooo-monero) 5ffb2ff9 v8: per byte fee, pad bulletproofs, fixed 11 ring size (moneromooo-monero) 869b3bf8 bulletproofs: a few fixes from the Kudelski review (moneromooo-monero) c4291762 bulletproofs: reject points not in the main subgroup (moneromooo-monero) 15697177 bulletproofs: speed up a few multiplies using existing Hi cache (moneromooo-monero) 0b05a0fa Add Pippenger cache and limit Straus cache size (moneromooo-monero) 51eb3bdc add pippenger unit tests (moneromooo-monero) b17b8db3 performance_tests: add stats and loop count multiplier options (moneromooo-monero) 7314d919 perf_timer: split timer class into a base one and a logging one (moneromooo-monero) d126a02b performance_tests: add aggregated bulletproof tx verification (moneromooo-monero) 263431c4 Pippenger multiexp (moneromooo-monero) 1ed0ed4d multiexp: cut down on memory allocations (moneromooo-monero) 1b867e7f precalc the ge_p3 representation of H (moneromooo-monero) ef56529f performance_tests: document the tested bulletproof layouts (moneromooo-monero) 30111780 unit_tests: a couple more bulletproof unit tests for gamma (moneromooo-monero) c444b1b2 require canonical multi output bulletproof layout (moneromooo-monero) 7e67c52f Add a define for the max number of bulletproof multi-outputs (moneromooo-monero) 2a8fcb42 Bulletproof aggregated verification and tests (moneromooo-monero) 126196b0 multiexp: some speedups (moneromooo-monero) 71d67bda aligned: aligned memory alloc/realloc/free (moneromooo-monero) cb9ecab1 performance_tests: add signature generation/verification (moneromooo-monero) bacf0a1e bulletproofs: add aggregated verification (moneromooo-monero) e895c3de make straus cached mode thread safe, and add tests for it (moneromooo-monero) 7f48bf05 multiexp: bos coster now works for just one point (moneromooo-monero) 9ce9f8ca bulletproofs: add multi output bulletproofs to rct (moneromooo-monero) f34e2e20 performance_tests: add tx checking tests with more than 2 outputs (moneromooo-monero) 0793184b performance_tests: add a --verbose flag, and default to terse (moneromooo-monero) 939bc223 add Straus multiexp (moneromooo-monero) 9ff6e6a0 ringct: add bos coster multiexp (moneromooo-monero) e9164bb3 bulletproofs: misc optimizations (moneromooo-monero) 112f32f0 performance_tests: add crypto ops (moneromooo-monero) f5d7b993 performance_tests: add bulletproofs (moneromooo-monero) 8f4ce989 performance_tests: add RingCT MLSAG gen/ver tests (moneromooo-monero) 1aa10c43 performance_tests: add (Borromean) range proofs (moneromooo-monero) aacfd6e3 bulletproofs: multi-output bulletproofs (moneromooo-monero) cb1cc757 performance_tests: don't override log level to 0 (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core/blockchain.h')
-rw-r--r--src/cryptonote_core/blockchain.h77
1 files changed, 44 insertions, 33 deletions
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 2292ffbf3..7e2ba7a39 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -95,7 +95,7 @@ namespace cryptonote
{
block bl; //!< the block
uint64_t height; //!< the height of the block in the blockchain
- size_t block_cumulative_size; //!< the size (in bytes) of the block
+ size_t block_cumulative_weight; //!< the weight of the block
difficulty_type cumulative_difficulty; //!< the accumulated difficulty after that block
uint64_t already_generated_coins; //!< the total coins minted after that block
};
@@ -579,46 +579,57 @@ namespace cryptonote
bool check_tx_inputs(transaction& tx, uint64_t& pmax_used_block_height, crypto::hash& max_used_block_id, tx_verification_context &tvc, bool kept_by_block = false);
/**
- * @brief get dynamic per kB fee for a given block size
+ * @brief get fee quantization mask
*
- * The dynamic fee is based on the block size in a past window, and
- * the current block reward. It is expressed by kB.
+ * The dynamic fee may be quantized, to mask out the last decimal places
+ *
+ * @return the fee quantized mask
+ */
+ static uint64_t get_fee_quantization_mask();
+
+ /**
+ * @brief get dynamic per kB or byte fee for a given block weight
+ *
+ * The dynamic fee is based on the block weight in a past window, and
+ * the current block reward. It is expressed by kB before v8, and
+ * per byte from v8.
*
* @param block_reward the current block reward
- * @param median_block_size the median blob's size in the past window
+ * @param median_block_weight the median block weight in the past window
* @param version hard fork version for rules and constants to use
*
- * @return the per kB fee
+ * @return the fee
*/
- static uint64_t get_dynamic_per_kb_fee(uint64_t block_reward, size_t median_block_size, uint8_t version);
+ static uint64_t get_dynamic_base_fee(uint64_t block_reward, size_t median_block_weight, uint8_t version);
/**
- * @brief get dynamic per kB fee estimate for the next few blocks
+ * @brief get dynamic per kB or byte fee estimate for the next few blocks
*
- * The dynamic fee is based on the block size in a past window, and
- * the current block reward. It is expressed by kB. This function
- * calculates an estimate for a dynamic fee which will be valid for
- * the next grace_blocks
+ * The dynamic fee is based on the block weight in a past window, and
+ * the current block reward. It is expressed by kB before v8, and
+ * per byte from v8.
+ * This function calculates an estimate for a dynamic fee which will be
+ * valid for the next grace_blocks
*
* @param grace_blocks number of blocks we want the fee to be valid for
*
- * @return the per kB fee estimate
+ * @return the fee estimate
*/
- uint64_t get_dynamic_per_kb_fee_estimate(uint64_t grace_blocks) const;
+ uint64_t get_dynamic_base_fee_estimate(uint64_t grace_blocks) const;
/**
* @brief validate a transaction's fee
*
* This function validates the fee is enough for the transaction.
- * This is based on the size of the transaction blob, and, after a
- * height threshold, on the average size of transaction in a past window
+ * This is based on the weight of the transaction, and, after a
+ * height threshold, on the average weight of transaction in a past window
*
- * @param blob_size the transaction blob's size
+ * @param tx_weight the transaction weight
* @param fee the fee
*
* @return true if the fee is enough, false otherwise
*/
- bool check_fee(size_t blob_size, uint64_t fee) const;
+ bool check_fee(size_t tx_weight, uint64_t fee) const;
/**
* @brief check that a transaction's outputs conform to current standards
@@ -635,18 +646,18 @@ namespace cryptonote
bool check_tx_outputs(const transaction& tx, tx_verification_context &tvc);
/**
- * @brief gets the blocksize limit based on recent blocks
+ * @brief gets the block weight limit based on recent blocks
*
* @return the limit
*/
- uint64_t get_current_cumulative_blocksize_limit() const;
+ uint64_t get_current_cumulative_block_weight_limit() const;
/**
- * @brief gets the blocksize median based on recent blocks (same window as for the limit)
+ * @brief gets the block weight median based on recent blocks (same window as for the limit)
*
* @return the median
*/
- uint64_t get_current_cumulative_blocksize_median() const;
+ uint64_t get_current_cumulative_block_weight_median() const;
/**
* @brief gets the difficulty of the block with a given height
@@ -1001,8 +1012,8 @@ namespace cryptonote
// main chain
transactions_container m_transactions;
- size_t m_current_block_cumul_sz_limit;
- size_t m_current_block_cumul_sz_median;
+ size_t m_current_block_cumul_weight_limit;
+ size_t m_current_block_cumul_weight_median;
// metadata containers
std::unordered_map<crypto::hash, std::unordered_map<crypto::key_image, std::vector<output_data_t>>> m_scan_table;
@@ -1225,7 +1236,7 @@ namespace cryptonote
* and that his miner transaction totals reward + fee.
*
* @param b the block containing the miner transaction to be validated
- * @param cumulative_block_size the block's size
+ * @param cumulative_block_weight the block's weight
* @param fee the total fees collected in the block
* @param base_reward return-by-reference the new block's generated coins
* @param already_generated_coins the amount of currency generated prior to this block
@@ -1234,7 +1245,7 @@ namespace cryptonote
*
* @return false if anything is found wrong with the miner transaction, otherwise true
*/
- bool validate_miner_transaction(const block& b, size_t cumulative_block_size, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins, bool &partial_block_reward, uint8_t version);
+ bool validate_miner_transaction(const block& b, size_t cumulative_block_weight, uint64_t fee, uint64_t& base_reward, uint64_t already_generated_coins, bool &partial_block_reward, uint8_t version);
/**
* @brief reverts the blockchain to its previous state following a failed switch
@@ -1251,14 +1262,14 @@ namespace cryptonote
bool rollback_blockchain_switching(std::list<block>& original_chain, uint64_t rollback_height);
/**
- * @brief gets recent block sizes for median calculation
+ * @brief gets recent block weights for median calculation
*
- * get the block sizes of the last <count> blocks, and return by reference <sz>.
+ * get the block weights of the last <count> blocks, and return by reference <sz>.
*
- * @param sz return-by-reference the list of sizes
- * @param count the number of blocks to get sizes for
+ * @param sz return-by-reference the list of weights
+ * @param count the number of blocks to get weights for
*/
- void get_last_n_blocks_sizes(std::vector<size_t>& sz, size_t count) const;
+ void get_last_n_blocks_weights(std::vector<size_t>& weights, size_t count) const;
/**
* @brief adds the given output to the requested set of random outputs
@@ -1373,11 +1384,11 @@ namespace cryptonote
bool complete_timestamps_vector(uint64_t start_height, std::vector<uint64_t>& timestamps);
/**
- * @brief calculate the block size limit for the next block to be added
+ * @brief calculate the block weight limit for the next block to be added
*
* @return true
*/
- bool update_next_cumulative_size_limit();
+ bool update_next_cumulative_weight_limit();
void return_tx_to_pool(std::vector<transaction> &txs);
/**