Skip to content

Commit e22e39d

Browse files
authored
Merge pull request #12 from ElectraProtocol/dev
v1.0.5.0
2 parents c904cff + 5274d9e commit e22e39d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+328
-241
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ config.cache
3535
config.log
3636
config.status
3737
configure
38+
configure~
3839
libtool
3940
src/config/xep-config.h
4041
src/config/xep-config.h.in

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
AC_PREREQ([2.69])
22
define(_CLIENT_VERSION_MAJOR, 1)
33
define(_CLIENT_VERSION_MINOR, 0)
4-
define(_CLIENT_VERSION_REVISION, 4)
4+
define(_CLIENT_VERSION_REVISION, 5)
55
define(_CLIENT_VERSION_BUILD, 0)
66
define(_CLIENT_VERSION_RC, 0)
77
define(_CLIENT_VERSION_IS_RELEASE, true)
8-
define(_COPYRIGHT_YEAR, 2022)
8+
define(_COPYRIGHT_YEAR, 2023)
99
define(_COPYRIGHT_HOLDERS,[The %s developers])
1010
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Electra Protocol]])
1111
AC_INIT([XEP Core],m4_join([.], _CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MINOR, _CLIENT_VERSION_REVISION, m4_if(_CLIENT_VERSION_BUILD, [0], [], _CLIENT_VERSION_BUILD))m4_if(_CLIENT_VERSION_RC, [0], [], [rc]_CLIENT_VERSION_RC),[https://github.com/ElectraProtocol/XEP-Core/issues],[xep],[https://www.electraprotocol.com/])

depends/packages/qt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ $(package)_config_opts += -no-feature-printdialog
9494
$(package)_config_opts += -no-feature-printer
9595
$(package)_config_opts += -no-feature-printpreviewdialog
9696
$(package)_config_opts += -no-feature-printpreviewwidget
97-
$(package)_config_opts += -no-feature-regularexpression
9897
$(package)_config_opts += -no-feature-sessionmanager
9998
$(package)_config_opts += -no-feature-sql
10099
$(package)_config_opts += -no-feature-statemachine

doc/xep_logo_doxygen.png

-13 Bytes
Loading

src/bench/duplicate_inputs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void DuplicateInputs(benchmark::Bench& bench)
4242
coinbaseTx.vin[0].prevout.SetNull();
4343
coinbaseTx.vout.resize(1);
4444
coinbaseTx.vout[0].scriptPubKey = SCRIPT_PUB;
45-
coinbaseTx.vout[0].nValue = GetBlockSubsidy(nHeight, false, 0, chainparams.GetConsensus());
45+
coinbaseTx.vout[0].nValue = GetBlockSubsidy(nHeight, false, 0, 0, chainparams.GetConsensus());
4646
coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
4747

4848

src/chainparams.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class CMainParams : public CChainParams {
130130
consensus.mTreasuryPayees.emplace(CScript() << OP_0 << ParseHex("978a5064cd1fdf8c2510fe3fcbd65eaa5e98b32d"), 100); // 10% (full reward) for ep1qj799qexdrl0ccfgslcluh4j74f0f3vedatcv0k
131131
consensus.nTreasuryRewardPercentage = 10; // 10% of block reward goes to treasury
132132

133+
consensus.sBurnAddresses.emplace(CScript() << OP_DUP << OP_HASH160 << ParseHex("1fa15641f00f98b33a66054f11138a5fbe4d7058") << OP_EQUALVERIFY << OP_CHECKSIG); // PBURNomniXEPXXXXXXXXXXXXXXXXYZ2zjf
134+
133135
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000004d4a27e34ba8c684ba2b");
134136
consensus.defaultAssumeValid = uint256S("0x5fbff547e15f6ad22cad7dad4a79dd5ed893552ea809a10400cc618e52a2be91"); // 450000
135137

@@ -265,6 +267,8 @@ class CTestNetParams : public CChainParams {
265267
consensus.mTreasuryPayees.emplace(CScript() << OP_0 << ParseHex("978a5064cd1fdf8c2510fe3fcbd65eaa5e98b32d"), 100); // 10% (full reward) for ep1qj799qexdrl0ccfgslcluh4j74f0f3vedatcv0k
266268
consensus.nTreasuryRewardPercentage = 10; // 10% of block reward goes to treasury
267269

270+
consensus.sBurnAddresses.emplace(CScript() << OP_DUP << OP_HASH160 << ParseHex("1fa15641f00f98b33a66054f11138a5fbe4d7058") << OP_EQUALVERIFY << OP_CHECKSIG); // PBURNomniXEPXXXXXXXXXXXXXXXXYZ2zjf
271+
268272
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000030d440d4400");
269273
consensus.defaultAssumeValid = uint256S("0x4a121e7765837b21bcffad979e499ecbf7184fcbf772c34c481433059d0840f8"); // 200000
270274

@@ -436,6 +440,8 @@ class SigNetParams : public CChainParams {
436440
consensus.mTreasuryPayees.emplace(CScript() << OP_0 << ParseHex("978a5064cd1fdf8c2510fe3fcbd65eaa5e98b32d"), 100); // 10% (full reward) for ep1qj799qexdrl0ccfgslcluh4j74f0f3vedatcv0k
437441
consensus.nTreasuryRewardPercentage = 10; // 10% of block reward goes to treasury
438442

443+
consensus.sBurnAddresses.emplace(CScript() << OP_DUP << OP_HASH160 << ParseHex("1fa15641f00f98b33a66054f11138a5fbe4d7058") << OP_EQUALVERIFY << OP_CHECKSIG); // PBURNomniXEPXXXXXXXXXXXXXXXXYZ2zjf
444+
439445
// message start is defined as the first 4 bytes of the sha256d of the block script
440446
CHashWriter h(SER_DISK, 0);
441447
h << consensus.signet_challenge;
@@ -526,6 +532,8 @@ class CRegTestParams : public CChainParams {
526532
consensus.mTreasuryPayees.emplace(CScript() << OP_0 << ParseHex("978a5064cd1fdf8c2510fe3fcbd65eaa5e98b32d"), 100); // 10% (full reward) for ep1qj799qexdrl0ccfgslcluh4j74f0f3vedatcv0k
527533
consensus.nTreasuryRewardPercentage = 10; // 10% of block reward goes to treasury
528534

535+
consensus.sBurnAddresses.emplace(CScript() << OP_DUP << OP_HASH160 << ParseHex("1fa15641f00f98b33a66054f11138a5fbe4d7058") << OP_EQUALVERIFY << OP_CHECKSIG); // PBURNomniXEPXXXXXXXXXXXXXXXXYZ2zjf
536+
529537
consensus.nMinimumChainWork = uint256{};
530538
consensus.defaultAssumeValid = uint256{};
531539

src/coins.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <coins.h>
66

7+
#include <chainparams.h>
78
#include <consensus/consensus.h>
89
#include <logging.h>
910
#include <random.h>
@@ -67,7 +68,7 @@ bool CCoinsViewCache::GetCoin(const COutPoint &outpoint, Coin &coin) const {
6768

6869
void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possible_overwrite) {
6970
assert(!coin.IsSpent());
70-
if (coin.out.scriptPubKey.IsUnspendable() || coin.out.nValue == 0 || coin.out.scriptPubKey.empty()) return;
71+
if (coin.out.scriptPubKey.IsUnspendable() || coin.out.nValue == 0 || coin.out.scriptPubKey.empty() || Params().GetConsensus().sBurnAddresses.count(coin.out.scriptPubKey)) return;
7172
CCoinsMap::iterator it;
7273
bool inserted;
7374
std::tie(it, inserted) = cacheCoins.emplace(std::piecewise_construct, std::forward_as_tuple(outpoint), std::tuple<>());

src/consensus/params.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <uint256.h>
1212
#include <limits>
1313
#include <map>
14+
#include <set>
1415

1516
namespace Consensus {
1617

@@ -67,6 +68,7 @@ struct Params {
6768
int nTreasuryPaymentsCycleBlocks;
6869
std::map<CScript, unsigned int> mTreasuryPayees;
6970
unsigned int nTreasuryRewardPercentage;
71+
std::set<CScript> sBurnAddresses;
7072
/* Block hash that is excepted from BIP16 enforcement */
7173
uint256 BIP16Exception;
7274
/** Block height and hash at which BIP34 becomes active */

src/kernel.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Copyright (c) 2012-2020 The Peercoin developers
22
// Copyright (c) 2015-2019 The PIVX developers
3-
// Copyright (c) 2018-2021 John "ComputerCraftr" Studnicka
3+
// Copyright (c) 2018-2022 John "ComputerCraftr" Studnicka
44
// Distributed under the MIT/X11 software license, see the accompanying
55
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
66

7+
#include <chain.h>
78
#include <chainparams.h>
89
#include <consensus/validation.h>
910
#include <hash.h>
@@ -17,8 +18,10 @@
1718
#include <util/system.h>
1819
#include <validation.h>
1920

21+
#include <unordered_map>
22+
2023
// Hard checkpoints of stake modifiers to ensure they are deterministic
21-
static const std::map<int, unsigned int> mapStakeModifierCheckpoints = {
24+
static const std::unordered_map<int, unsigned int> mapStakeModifierCheckpoints = {
2225
{ 0, 0x0e00670bu },
2326
{ 50000, 0xcbe5a9b4u },
2427
{ 100000, 0xbd074053u },
@@ -31,7 +34,7 @@ static const std::map<int, unsigned int> mapStakeModifierCheckpoints = {
3134
{ 450000, 0xc85e93eau },
3235
};
3336

34-
static const std::map<int, unsigned int> mapStakeModifierTestnetCheckpoints = {
37+
static const std::unordered_map<int, unsigned int> mapStakeModifierTestnetCheckpoints = {
3538
{ 0, 0x0e00670bu },
3639
{ 50000, 0x4af2e306u },
3740
{ 100000, 0xd9e06043u },
@@ -573,15 +576,10 @@ bool CheckStakeKernelHash(const unsigned int& nBits, const CBlockIndex* pindexPr
573576
// nHashDrift should be <= MAX_FUTURE_BLOCK_TIME otherwise we risk creating a block which will be rejected due to nTimeTx being too far in the future
574577
bool fSuccess = false;
575578
unsigned int nTryTime = 0;
576-
const int nHeightStart = nHeightCurrent - 1;
577579
const int iteration = params.nStakeTimestampMask + 1; // 16 second time slots for 0xf masked time
578580
assert((nHashDrift & params.nStakeTimestampMask) == 0);
579581
for (int i = nHashDrift; i >= 0; i -= iteration) //iterate the hashing
580582
{
581-
// New block came in, move on
582-
if (::ChainActive().Height() != nHeightStart)
583-
break;
584-
585583
// Hash this iteration - start at nHashDrift and work backwards to nTimeTx
586584
nTryTime = nTimeTx + i; //nTimeTx + nHashDrift - i;
587585
hashProofOfStake = stakeHash(nTryTime, ss, prevout.n, prevout.hash, nTimeBlockFrom, true);
@@ -615,7 +613,7 @@ bool CheckStakeKernelHash(const unsigned int& nBits, const CBlockIndex* pindexPr
615613
}
616614

617615
// Check kernel hash target and coinstake signature
618-
bool CheckProofOfStake(BlockValidationState& state, const CCoinsViewCache& view, const CBlockIndex* pindexPrev, const CTransactionRef& tx, const unsigned int& nBits, unsigned int nTimeTx, uint256& hashProofOfStake)
616+
bool CheckProofOfStake(BlockValidationState& state, const CCoinsViewCache& view, const CChain& active_chain, const CBlockIndex* pindexPrev, const CTransactionRef& tx, const unsigned int& nBits, unsigned int nTimeTx, uint256& hashProofOfStake)
619617
{
620618
if (!tx->IsCoinStake())
621619
return error("CheckProofOfStake() : called on non-coinstake %s", tx->GetHash().ToString());
@@ -639,15 +637,15 @@ bool CheckProofOfStake(BlockValidationState& state, const CCoinsViewCache& view,
639637

640638
// Read txPrev and header of its block
641639
//const CBlockIndex* pindexFrom = LookupBlockIndex(hashBlock);
642-
const CBlockIndex* pindexFrom = ::ChainActive()[coin.nHeight];
640+
const CBlockIndex* pindexFrom = active_chain[coin.nHeight];
643641
if (!pindexFrom)
644642
return error("CheckProofOfStake() : block index not found");
645643

646644
// Verify signature
647645
{
648646
int nIn = 0;
649647
//const CTxOut& prevTxOut = txPrev->vout[tx->vin[nIn].prevout.n];
650-
TransactionSignatureChecker checker(&(*tx), nIn, coin.out.nValue, &::ChainActive(), PrecomputedTransactionData(*tx));
648+
TransactionSignatureChecker checker(&(*tx), nIn, coin.out.nValue, &active_chain, PrecomputedTransactionData(*tx));
651649
ScriptError serror = SCRIPT_ERR_OK;
652650

653651
if (!VerifyScript(tx->vin[nIn].scriptSig, coin.out.scriptPubKey, &(tx->vin[nIn].scriptWitness), STANDARD_CONTEXTUAL_SCRIPT_VERIFY_FLAGS, checker, &serror))

src/kernel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2012-2020 The Peercoin developers
22
// Copyright (c) 2015-2019 The PIVX developers
3-
// Copyright (c) 2018-2021 John "ComputerCraftr" Studnicka
3+
// Copyright (c) 2018-2022 John "ComputerCraftr" Studnicka
44
// Distributed under the MIT/X11 software license, see the accompanying
55
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
66

@@ -16,6 +16,7 @@ class CBlockIndex;
1616
class BlockValidationState;
1717
class CBlockHeader;
1818
class CBlock;
19+
class CChain;
1920

2021

2122
// MODIFIER_INTERVAL_RATIO:
@@ -35,7 +36,7 @@ bool CheckStakeKernelHash(const unsigned int& nBits, const CBlockIndex* pindexPr
3536

3637
// Check kernel hash target and coinstake signature
3738
// Sets hashProofOfStake on success return
38-
bool CheckProofOfStake(BlockValidationState& state, const CCoinsViewCache& view, const CBlockIndex* pindexPrev, const CTransactionRef& tx, const unsigned int& nBits, unsigned int nTimeTx, uint256& hashProofOfStake);
39+
bool CheckProofOfStake(BlockValidationState& state, const CCoinsViewCache& view, const CChain& active_chain, const CBlockIndex* pindexPrev, const CTransactionRef& tx, const unsigned int& nBits, unsigned int nTimeTx, uint256& hashProofOfStake);
3940

4041
// Check whether the coinstake timestamp meets protocol
4142
bool CheckCoinStakeTimestamp(int64_t nTimeBlock, int64_t nTimeTx);

0 commit comments

Comments
 (0)