aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/testdb.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-01-21 17:18:50 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-04 09:33:58 +0000
commitb8787f430262520a9e81267802b869b1a7cde245 (patch)
tree2227b98b54a6441ac7baa64435c8b19538eb3863 /tests/unit_tests/testdb.h
parentMerge pull request #4988 (diff)
downloadmonero-b8787f430262520a9e81267802b869b1a7cde245.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--src/blockchain_db/testdb.h (renamed from tests/unit_tests/testdb.h)9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/unit_tests/testdb.h b/src/blockchain_db/testdb.h
index 8f5cf70e8..35dfbe673 100644
--- a/tests/unit_tests/testdb.h
+++ b/src/blockchain_db/testdb.h
@@ -33,9 +33,11 @@
#include <string>
#include <vector>
#include <map>
-#include "gtest/gtest.h"
-#include "blockchain_db/blockchain_db.h"
+#include "blockchain_db.h"
+
+namespace cryptonote
+{
class BaseTestDB: public cryptonote::BlockchainDB {
public:
@@ -73,6 +75,7 @@ public:
virtual cryptonote::difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const { return 10; }
virtual cryptonote::difficulty_type get_block_difficulty(const uint64_t& height) const { return 0; }
virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const { return 10000000000; }
+ virtual uint64_t get_block_long_term_weight(const uint64_t& height) const { return 128; }
virtual crypto::hash get_block_hash_from_height(const uint64_t& height) const { return crypto::hash(); }
virtual std::vector<cryptonote::block> get_blocks_range(const uint64_t& h1, const uint64_t& h2) const { return std::vector<cryptonote::block>(); }
virtual std::vector<crypto::hash> get_hashes_range(const uint64_t& h1, const uint64_t& h2) const { return std::vector<crypto::hash>(); }
@@ -128,6 +131,7 @@ public:
virtual void add_block( const cryptonote::block& blk
, size_t block_weight
+ , uint64_t long_term_block_weight
, const cryptonote::difficulty_type& cumulative_difficulty
, const uint64_t& coins_generated
, uint64_t num_rct_outs
@@ -145,3 +149,4 @@ public:
virtual void prune_outputs(uint64_t amount) {}
};
+}