Commit 9c1ad790 authored by Pierre Kim's avatar Pierre Kim

1.2.0.0 Unstable

parent c5dcba3b
......@@ -136,10 +136,10 @@ bool BlockchainExplorerDataBuilder::fillBlockDetails(const Block &block, BlockDe
uint64_t maxReward = 0;
uint64_t currentReward = 0;
int64_t emissionChange = 0;
if (!core.getBlockReward(blockDetails.sizeMedian, 0, prevBlockGeneratedCoins, 0, maxReward, emissionChange)) {
if (!core.getBlockReward(blockDetails.height, blockDetails.sizeMedian, 0, prevBlockGeneratedCoins, 0, maxReward, emissionChange)) {
return false;
}
if (!core.getBlockReward(blockDetails.sizeMedian, blockDetails.transactionsCumulativeSize, prevBlockGeneratedCoins, 0, currentReward, emissionChange)) {
if (!core.getBlockReward(blockDetails.height, blockDetails.sizeMedian, blockDetails.transactionsCumulativeSize, prevBlockGeneratedCoins, 0, currentReward, emissionChange)) {
return false;
}
......
......@@ -27,7 +27,9 @@ static_assert(EMISSION_SPEED_FACTOR <= 8 * sizeof(uint64_t), "Bad EMISSION_SPEED
const size_t CRYPTONOTE_REWARD_BLOCKS_WINDOW = 100;
const size_t CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE = 10000; //size of block (bytes) after which reward for block calculated using block size
const size_t CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE = 500 * 1024; //size of block (bytes) after which reward for block calculated using block size
const size_t CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 = 10000;
const size_t CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2_UPGRATE_HEIGHT = 90800;
const size_t CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE = 600;
const size_t CRYPTONOTE_DISPLAY_DECIMAL_POINT = 8;
......@@ -75,6 +77,7 @@ const char GENESIS_COINBASE_TX_HEX[] = "013c01ff0001bf93
const uint8_t CURRENT_TRANSACTION_VERSION = 1;
const uint8_t BLOCK_MAJOR_VERSION_1 = 1;
const uint8_t BLOCK_MAJOR_VERSION_2 = 2;
const uint8_t BLOCK_MINOR_VERSION_0 = 0;
const size_t BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT = 10000; //by default, blocks ids count in synchronizing
......
......@@ -849,7 +849,7 @@ bool Blockchain::validate_miner_transaction(const Block& b, uint32_t height, siz
get_last_n_blocks_sizes(lastBlocksSizes, m_currency.rewardBlocksWindow());
size_t blocksSizeMedian = Common::medianValue(lastBlocksSizes);
if (!m_currency.getBlockReward(blocksSizeMedian, cumulativeBlockSize, alreadyGeneratedCoins, fee, reward, emissionChange)) {
if (!m_currency.getBlockReward(height, blocksSizeMedian, cumulativeBlockSize, alreadyGeneratedCoins, fee, reward, emissionChange)) {
logger(INFO, BRIGHT_WHITE) << "block size " << cumulativeBlockSize << " is bigger than allowed for this blockchain";
return false;
}
......@@ -1575,10 +1575,12 @@ bool Blockchain::getBlockCumulativeSize(const Block& block, size_t& cumulativeSi
bool Blockchain::update_next_comulative_size_limit() {
std::vector<size_t> sz;
get_last_n_blocks_sizes(sz, m_currency.rewardBlocksWindow());
uint32_t nextBlockHeight = static_cast<uint32_t>(m_blocks.size());
size_t nextBlockGrantedFullRewardZone = m_currency.blockGrantedFullRewardZoneByBlockHeight(nextBlockHeight);
uint64_t median = Common::medianValue(sz);
if (median <= m_currency.blockGrantedFullRewardZone()) {
median = m_currency.blockGrantedFullRewardZone();
if (median <= nextBlockGrantedFullRewardZone) {
median = nextBlockGrantedFullRewardZone;
}
m_current_block_cumul_sz_limit = median * 2;
......
......@@ -803,9 +803,9 @@ bool core::getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& generate
return m_blockchain.getAlreadyGeneratedCoins(hash, generatedCoins);
}
bool core::getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
bool core::getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) {
return m_currency.getBlockReward(medianSize, currentBlockSize, alreadyGeneratedCoins, fee, reward, emissionChange);
return m_currency.getBlockReward(blockHeight, medianSize, currentBlockSize, alreadyGeneratedCoins, fee, reward, emissionChange);
}
bool core::scanOutputkeysForIndices(const KeyInput& txInToKey, std::list<std::pair<Crypto::Hash, size_t>>& outputReferences) {
......
......@@ -60,7 +60,7 @@ namespace CryptoNote {
virtual bool getBackwardBlocksSizes(uint32_t fromHeight, std::vector<size_t>& sizes, size_t count) override;
virtual bool getBlockSize(const Crypto::Hash& hash, size_t& size) override;
virtual bool getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& generatedCoins) override;
virtual bool getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
virtual bool getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) override;
virtual bool scanOutputkeysForIndices(const KeyInput& txInToKey, std::list<std::pair<Crypto::Hash, size_t>>& outputReferences) override;
virtual bool getBlockDifficulty(uint32_t height, difficulty_type& difficulty) override;
......
......@@ -96,14 +96,23 @@ bool Currency::generateGenesisBlock() {
return true;
}
bool Currency::getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins,
size_t Currency::blockGrantedFullRewardZoneByBlockHeight(uint32_t blockHeight) const {
if (blockHeight >= CryptoNote::parameters::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2_UPGRATE_HEIGHT) {
return m_blockGrantedFullRewardZone;
}
else {
return CryptoNote::parameters::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1;
}
}
bool Currency::getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins,
uint64_t fee, uint64_t& reward, int64_t& emissionChange) const {
assert(alreadyGeneratedCoins <= m_moneySupply);
assert(m_emissionSpeedFactor > 0 && m_emissionSpeedFactor <= 8 * sizeof(uint64_t));
uint64_t baseReward = (m_moneySupply - alreadyGeneratedCoins) >> m_emissionSpeedFactor;
medianSize = std::max(medianSize, m_blockGrantedFullRewardZone);
size_t blockGrantedFullRewardZone = blockGrantedFullRewardZoneByBlockHeight(blockHeight);
medianSize = std::max(medianSize, blockGrantedFullRewardZone);
if (currentBlockSize > UINT64_C(2) * medianSize) {
logger(TRACE) << "Block cumulative size is too big: " << currentBlockSize << ", expected less than " << 2 * medianSize;
return false;
......@@ -146,7 +155,7 @@ bool Currency::constructMinerTx(uint32_t height, size_t medianSize, uint64_t alr
uint64_t blockReward;
int64_t emissionChange;
if (!getBlockReward(medianSize, currentBlockSize, alreadyGeneratedCoins, fee, blockReward, emissionChange)) {
if (!getBlockReward(height, medianSize, currentBlockSize, alreadyGeneratedCoins, fee, blockReward, emissionChange)) {
logger(INFO) << "Block is too big";
return false;
}
......
......@@ -34,6 +34,7 @@ public:
size_t rewardBlocksWindow() const { return m_rewardBlocksWindow; }
size_t blockGrantedFullRewardZone() const { return m_blockGrantedFullRewardZone; }
size_t blockGrantedFullRewardZoneByBlockHeight(uint32_t blockHeight) const;
size_t minerTxBlobReservedSize() const { return m_minerTxBlobReservedSize; }
size_t numberOfDecimalPlaces() const { return m_numberOfDecimalPlaces; }
......@@ -74,7 +75,7 @@ public:
const Block& genesisBlock() const { return m_genesisBlock; }
const Crypto::Hash& genesisBlockHash() const { return m_genesisBlockHash; }
bool getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
bool getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) const;
size_t maxBlockCumulativeSize(uint64_t height) const;
......
......@@ -84,7 +84,7 @@ public:
virtual bool getBackwardBlocksSizes(uint32_t fromHeight, std::vector<size_t>& sizes, size_t count) = 0;
virtual bool getBlockSize(const Crypto::Hash& hash, size_t& size) = 0;
virtual bool getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& generatedCoins) = 0;
virtual bool getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
virtual bool getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) = 0;
virtual bool scanOutputkeysForIndices(const KeyInput& txInToKey, std::list<std::pair<Crypto::Hash, size_t>>& outputReferences) = 0;
virtual bool getBlockDifficulty(uint32_t height, difficulty_type& difficulty) = 0;
......
......@@ -11,6 +11,7 @@
#include "Common/StringTools.h"
#include "CryptoNoteCore/CryptoNoteTools.h"
#include "CryptoNoteCore/Core.h"
#include "CryptoNoteCore/Currency.h"
#include "CryptoNoteCore/IBlock.h"
#include "CryptoNoteCore/Miner.h"
#include "CryptoNoteCore/TransactionExtra.h"
......@@ -751,7 +752,15 @@ bool RpcServer::f_on_block_json(const F_COMMAND_RPC_GET_BLOCK_DETAILS::request&
uint64_t maxReward = 0;
uint64_t currentReward = 0;
int64_t emissionChange = 0;
size_t blockGrantedFullRewardZone = 10000; //CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
size_t blockGrantedFullRewardZone;
if (res.block.height >= CryptoNote::parameters::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2_UPGRATE_HEIGHT)
{
blockGrantedFullRewardZone = CryptoNote::parameters::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
}
else
{
blockGrantedFullRewardZone = CryptoNote::parameters::CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1;
}
res.block.effectiveSizeMedian = std::max(res.block.sizeMedian, blockGrantedFullRewardZone);
res.block.baseReward = blkDetails.baseReward;
......
#define BUILD_COMMIT_ID "@VERSION@"
#define PROJECT_VERSION "1.1.2"
#define PROJECT_VERSION_BUILD_NO "1"
#define PROJECT_VERSION "1.2.0"
#define PROJECT_VERSION_BUILD_NO "0"
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO
......@@ -244,7 +244,7 @@ bool ICoreStub::getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& gen
return true;
}
bool ICoreStub::getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
bool ICoreStub::getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) {
return true;
}
......
......@@ -60,7 +60,7 @@ public:
virtual bool getBackwardBlocksSizes(uint32_t fromHeight, std::vector<size_t>& sizes, size_t count) override;
virtual bool getBlockSize(const Crypto::Hash& hash, size_t& size) override;
virtual bool getAlreadyGeneratedCoins(const Crypto::Hash& hash, uint64_t& generatedCoins) override;
virtual bool getBlockReward(size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
virtual bool getBlockReward(uint32_t blockHeight, size_t medianSize, size_t currentBlockSize, uint64_t alreadyGeneratedCoins, uint64_t fee,
uint64_t& reward, int64_t& emissionChange) override;
virtual bool scanOutputkeysForIndices(const CryptoNote::KeyInput& txInToKey, std::list<std::pair<Crypto::Hash, size_t>>& outputReferences) override;
virtual bool getBlockDifficulty(uint32_t height, CryptoNote::difficulty_type& difficulty) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment