mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
e72eb40024
## Issue being fixed or feature implemented Implementation of accepted proposal: https://www.dashcentral.org/p/TREASURY-REALLOCATION-60-20-20 ## What was done? Once Masternode Reward Location Reallocation activates: - Treasury is bumped to 20% of block subsidy. - Block reward shares are immediately set to 75% for MN and 25% miners. (Previous reallocation periods are dropped) MN reward share should be 75% of block reward in order to represent 60% of the block subsidy. (according to the proposal) - `governancebudget` is returned from `getgovernanceinfo` RPC. ## How Has This Been Tested? `block_reward_reallocation_tests` ## Breaking Changes ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ --------- Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
66 lines
2.4 KiB
C++
66 lines
2.4 KiB
C++
// Copyright (c) 2011-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <bench/bench.h>
|
|
#include <chainparams.h>
|
|
#include <consensus/merkle.h>
|
|
#include <consensus/validation.h>
|
|
#include <policy/policy.h>
|
|
#include <pow.h>
|
|
#include <test/util/setup_common.h>
|
|
#include <txmempool.h>
|
|
#include <validation.h>
|
|
|
|
|
|
static void DuplicateInputs(benchmark::Bench& bench)
|
|
{
|
|
RegTestingSetup test_setup;
|
|
|
|
const CScript SCRIPT_PUB{CScript(OP_TRUE)};
|
|
|
|
const CChainParams& chainparams = Params();
|
|
|
|
CBlock block{};
|
|
CMutableTransaction coinbaseTx{};
|
|
CMutableTransaction naughtyTx{};
|
|
|
|
assert(std::addressof(::ChainActive()) == std::addressof(test_setup.m_node.chainman->ActiveChain()));
|
|
CBlockIndex* pindexPrev = test_setup.m_node.chainman->ActiveChain().Tip();
|
|
assert(pindexPrev != nullptr);
|
|
block.nBits = GetNextWorkRequired(pindexPrev, &block, chainparams.GetConsensus());
|
|
block.nNonce = 0;
|
|
auto nHeight = pindexPrev->nHeight + 1;
|
|
|
|
// Make a coinbase TX
|
|
coinbaseTx.vin.resize(1);
|
|
coinbaseTx.vin[0].prevout.SetNull();
|
|
coinbaseTx.vout.resize(1);
|
|
coinbaseTx.vout[0].scriptPubKey = SCRIPT_PUB;
|
|
coinbaseTx.vout[0].nValue = GetBlockSubsidyInner(block.nBits, nHeight, chainparams.GetConsensus(), false);
|
|
coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
|
|
|
naughtyTx.vout.resize(1);
|
|
naughtyTx.vout[0].nValue = 0;
|
|
naughtyTx.vout[0].scriptPubKey = SCRIPT_PUB;
|
|
|
|
uint64_t n_inputs = (((MaxBlockSize() / ::GetSerializeSize(CTransaction(), PROTOCOL_VERSION)) - (CTransaction(coinbaseTx).GetTotalSize() + CTransaction(naughtyTx).GetTotalSize())) / 41) - 100;
|
|
for (uint64_t x = 0; x < (n_inputs - 1); ++x) {
|
|
naughtyTx.vin.emplace_back(GetRandHash(), 0, CScript(), 0);
|
|
}
|
|
naughtyTx.vin.emplace_back(naughtyTx.vin.back());
|
|
|
|
block.vtx.push_back(MakeTransactionRef(std::move(coinbaseTx)));
|
|
block.vtx.push_back(MakeTransactionRef(std::move(naughtyTx)));
|
|
|
|
block.hashMerkleRoot = BlockMerkleRoot(block);
|
|
|
|
bench.minEpochIterations(10).run([&] {
|
|
BlockValidationState cvstate{};
|
|
assert(!CheckBlock(block, cvstate, chainparams.GetConsensus(), false, false));
|
|
assert(cvstate.GetRejectReason() == "bad-txns-inputs-duplicate");
|
|
});
|
|
}
|
|
|
|
BENCHMARK(DuplicateInputs);
|