Various things
This commit is contained in:
@@ -100,32 +100,32 @@ public:
|
||||
strNetworkID = "main";
|
||||
strCurrencyUnits = "HUSH";
|
||||
bip44CoinType = 141; // As registered in https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
consensus.fCoinbaseMustBeProtected = false;
|
||||
consensus.nSubsidySlowStartInterval = 20000;
|
||||
consensus.nSubsidyHalvingInterval = 840000;
|
||||
|
||||
consensus.fCoinbaseMustBeProtected = false;
|
||||
consensus.nMajorityEnforceBlockUpgrade = 750;
|
||||
consensus.nMajorityRejectBlockOutdated = 950;
|
||||
consensus.nMajorityWindow = 4000;
|
||||
consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.powAlternate = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.nPowAveragingWindow = 17;
|
||||
consensus.nMaxFutureBlockTime = 7 * 60; // 7 mins
|
||||
consensus.nMajorityWindow = 4000;
|
||||
consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.powAlternate = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.nPowAveragingWindow = 17;
|
||||
consensus.nMaxFutureBlockTime = 7 * 60; // 7 mins
|
||||
|
||||
assert(maxUint/UintToArith256(consensus.powLimit) >= consensus.nPowAveragingWindow);
|
||||
consensus.nPowMaxAdjustDown = 32; // 32% adjustment down
|
||||
consensus.nPowMaxAdjustUp = 16; // 16% adjustment up
|
||||
consensus.nPowTargetSpacing = 1 * 60;
|
||||
consensus.nPowMaxAdjustUp = 16; // 16% adjustment up
|
||||
// we are emulating old node behavior at startup, they used 150s
|
||||
consensus.nPowTargetSpacing = 150; // 75; // HUSH is 75 seconds, Hush Smart Chains are 60 seconds by default
|
||||
consensus.nPowAllowMinDifficultyBlocksAfterHeight = boost::none;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight =
|
||||
Consensus::NetworkUpgrade::ALWAYS_ACTIVE;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nProtocolVersion = 170002;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight =
|
||||
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion = 170005;
|
||||
// HUSH never had Sprout in our blockchain history, but some internals require *knowing* about Sprout
|
||||
// or it breaks backward compatibility. We do what we can.
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nProtocolVersion = 170002;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nProtocolVersion = 170005;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nProtocolVersion = 170007;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nProtocolVersion = 170007;
|
||||
consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
|
||||
|
||||
// The best chain should have at least this much work.
|
||||
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000281b32ff3198a1");
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
pchMessageStart[2] = 0xe4;
|
||||
pchMessageStart[3] = 0x8d;
|
||||
vAlertPubKey = ParseHex("038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac");
|
||||
nDefaultPort = 7770;
|
||||
nDefaultPort = 5420;
|
||||
nMinerThreads = 0;
|
||||
nMaxTipAge = 24 * 60 * 60;
|
||||
nPruneAfterHeight = 100000;
|
||||
@@ -188,6 +188,8 @@ public:
|
||||
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,188);
|
||||
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
|
||||
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
|
||||
|
||||
// Unused Sprout stuff, for historical completeness
|
||||
// guarantees the first two characters, when base58 encoded, are "zc"
|
||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {22,154};
|
||||
// guarantees the first 4 characters, when base58 encoded, are "ZiVK"
|
||||
@@ -203,10 +205,10 @@ public:
|
||||
|
||||
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
|
||||
|
||||
fMiningRequiresPeers = true;
|
||||
fDefaultConsistencyChecks = false;
|
||||
fRequireStandard = true;
|
||||
fMineBlocksOnDemand = false;
|
||||
fMiningRequiresPeers = true;
|
||||
fDefaultConsistencyChecks = false;
|
||||
fRequireStandard = true;
|
||||
fMineBlocksOnDemand = false;
|
||||
fTestnetToBeDeprecatedFieldRPC = false;
|
||||
}
|
||||
};
|
||||
@@ -246,8 +248,6 @@ public:
|
||||
nDefaultPort = 15550;
|
||||
nMinerThreads = 0;
|
||||
consensus.fCoinbaseMustBeProtected = true;
|
||||
consensus.nSubsidySlowStartInterval = 20000;
|
||||
consensus.nSubsidyHalvingInterval = 840000;
|
||||
consensus.nMajorityEnforceBlockUpgrade = 51;
|
||||
consensus.nMajorityRejectBlockOutdated = 75;
|
||||
consensus.nMajorityWindow = 400;
|
||||
@@ -344,20 +344,18 @@ public:
|
||||
strNetworkID = "regtest";
|
||||
strCurrencyUnits = "REG";
|
||||
bip44CoinType = 1;
|
||||
consensus.fCoinbaseMustBeProtected = false;
|
||||
consensus.nSubsidySlowStartInterval = 0;
|
||||
consensus.nSubsidyHalvingInterval = 150;
|
||||
consensus.fCoinbaseMustBeProtected = false;
|
||||
consensus.nMajorityEnforceBlockUpgrade = 750;
|
||||
consensus.nMajorityRejectBlockOutdated = 950;
|
||||
consensus.nMajorityWindow = 1000;
|
||||
consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.powAlternate = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.nPowAveragingWindow = 17;
|
||||
consensus.nMaxFutureBlockTime = 7 * 60; // 7 mins
|
||||
consensus.nMajorityWindow = 1000;
|
||||
consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.powAlternate = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
|
||||
consensus.nPowAveragingWindow = 17;
|
||||
consensus.nMaxFutureBlockTime = 7 * 60; // 7 mins
|
||||
assert(maxUint/UintToArith256(consensus.powLimit) >= consensus.nPowAveragingWindow);
|
||||
consensus.nPowMaxAdjustDown = 0; // Turn off adjustment down
|
||||
consensus.nPowMaxAdjustUp = 0; // Turn off adjustment up
|
||||
consensus.nPowTargetSpacing = 2.5 * 60;
|
||||
consensus.nPowMaxAdjustDown = 0; // Turn off adjustment down
|
||||
consensus.nPowMaxAdjustUp = 0; // Turn off adjustment up
|
||||
consensus.nPowTargetSpacing = 2.5 * 60;
|
||||
consensus.nPowAllowMinDifficultyBlocksAfterHeight = 0;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight =
|
||||
@@ -436,9 +434,6 @@ public:
|
||||
bech32HRPs[SAPLING_INCOMING_VIEWING_KEY] = "zivkregtestsapling";
|
||||
bech32HRPs[SAPLING_EXTENDED_SPEND_KEY] = "secret-extended-key-regtest";
|
||||
|
||||
// Founders reward script expects a vector of 2-of-3 multisig addresses
|
||||
vFoundersRewardAddress = { "t2FwcEhFdNXuFMv1tcYwaBJtYVtMj8b1uTg" };
|
||||
assert(vFoundersRewardAddress.size() <= consensus.GetLastFoundersRewardBlockHeight());
|
||||
}
|
||||
|
||||
void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight)
|
||||
@@ -491,37 +486,6 @@ bool SelectParamsFromCommandLine()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Block height must be >0 and <=last founders reward block height
|
||||
// Index variable i ranges from 0 - (vFoundersRewardAddress.size()-1)
|
||||
std::string CChainParams::GetFoundersRewardAddressAtHeight(int nHeight) const {
|
||||
int maxHeight = consensus.GetLastFoundersRewardBlockHeight();
|
||||
assert(nHeight > 0 && nHeight <= maxHeight);
|
||||
|
||||
size_t addressChangeInterval = (maxHeight + vFoundersRewardAddress.size()) / vFoundersRewardAddress.size();
|
||||
size_t i = nHeight / addressChangeInterval;
|
||||
return vFoundersRewardAddress[i];
|
||||
}
|
||||
|
||||
// TODO: this is ZEC code, HUSH does not use it, and it can be deleted
|
||||
// Block height must be >0 and <=last founders reward block height
|
||||
// The founders reward address is expected to be a multisig (P2SH) address
|
||||
CScript CChainParams::GetFoundersRewardScriptAtHeight(int nHeight) const {
|
||||
assert(nHeight > 0 && nHeight <= consensus.GetLastFoundersRewardBlockHeight());
|
||||
|
||||
CTxDestination address = DecodeDestination(GetFoundersRewardAddressAtHeight(nHeight).c_str());
|
||||
assert(IsValidDestination(address));
|
||||
assert(boost::get<CScriptID>(&address) != nullptr);
|
||||
CScriptID scriptID = boost::get<CScriptID>(address); // address is a boost variant
|
||||
CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
|
||||
return script;
|
||||
}
|
||||
|
||||
std::string CChainParams::GetFoundersRewardAddressAtIndex(int i) const {
|
||||
assert(i >= 0 && i < vFoundersRewardAddress.size());
|
||||
return vFoundersRewardAddress[i];
|
||||
}
|
||||
|
||||
void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight)
|
||||
{
|
||||
regTestParams.UpdateNetworkUpgradeParameters(idx, nActivationHeight);
|
||||
@@ -542,7 +506,7 @@ int32_t MAX_BLOCK_SIZE(int32_t height)
|
||||
void hush_changeblocktime()
|
||||
{
|
||||
pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
|
||||
pCurrentParams->consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
|
||||
pCurrentParams->consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
|
||||
fprintf(stderr,"HUSH blocktime changing to %d seconds\n",ASSETCHAINS_BLOCKTIME);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -17,7 +16,6 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HUSH_CONSENSUS_CONSENSUS_H
|
||||
#define HUSH_CONSENSUS_CONSENSUS_H
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -18,12 +17,10 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HUSH_CONSENSUS_PARAMS_H
|
||||
#define HUSH_CONSENSUS_PARAMS_H
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||
@@ -39,7 +36,7 @@ namespace Consensus {
|
||||
* several functions depend on the enum being sorted.
|
||||
*/
|
||||
enum UpgradeIndex {
|
||||
// Sprout must be first
|
||||
// Sprout must be first, puke
|
||||
BASE_SPROUT,
|
||||
UPGRADE_TESTDUMMY,
|
||||
UPGRADE_OVERWINTER,
|
||||
@@ -77,32 +74,11 @@ struct NetworkUpgrade {
|
||||
static constexpr int NO_ACTIVATION_HEIGHT = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters that influence chain consensus.
|
||||
*/
|
||||
// Parameters that influence chain consensus.
|
||||
struct Params {
|
||||
uint256 hashGenesisBlock;
|
||||
|
||||
bool fCoinbaseMustBeProtected;
|
||||
|
||||
/** Needs to evenly divide MAX_SUBSIDY to avoid rounding errors. */
|
||||
int nSubsidySlowStartInterval;
|
||||
/**
|
||||
* Shift based on a linear ramp for slow start:
|
||||
*
|
||||
* MAX_SUBSIDY*(t_s/2 + t_r) = MAX_SUBSIDY*t_h Coin balance
|
||||
* t_s + t_r = t_h + t_c Block balance
|
||||
*
|
||||
* t_s = nSubsidySlowStartInterval
|
||||
* t_r = number of blocks between end of slow start and first halving
|
||||
* t_h = nSubsidyHalvingInterval
|
||||
* t_c = SubsidySlowStartShift()
|
||||
*/
|
||||
int SubsidySlowStartShift() const { return nSubsidySlowStartInterval / 2; }
|
||||
int nSubsidyHalvingInterval;
|
||||
int GetLastFoundersRewardBlockHeight() const {
|
||||
return nSubsidyHalvingInterval + SubsidySlowStartShift() - 1;
|
||||
}
|
||||
/** Used to check majorities for block version upgrade */
|
||||
int nMajorityEnforceBlockUpgrade;
|
||||
int nMajorityRejectBlockOutdated;
|
||||
@@ -119,18 +95,15 @@ struct Params {
|
||||
int64_t nPowTargetSpacing;
|
||||
int64_t nLwmaAjustedWeight;
|
||||
|
||||
/* Proof of stake parameters */
|
||||
uint256 posLimit;
|
||||
int64_t nPOSAveragingWindow; // can be completely different than POW and initially trying a relatively large number, like 100
|
||||
int64_t nPOSTargetSpacing; // spacing is 1000 units per block to get better resolution, (100 % = 1000, 50% = 2000, 10% = 10000)
|
||||
int64_t nLwmaPOSAjustedWeight;
|
||||
|
||||
/* applied to all block times */
|
||||
int64_t nMaxFutureBlockTime;
|
||||
|
||||
// NOTE: These 3 functions should not have const return values because our blocktime halved at block 340k
|
||||
// but the entire codebase assumes Consensus::Params are const, route around the damange
|
||||
int64_t AveragingWindowTimespan() const { return nPowAveragingWindow * nPowTargetSpacing; }
|
||||
int64_t MinActualTimespan() const { return (AveragingWindowTimespan() * (100 - nPowMaxAdjustUp )) / 100; }
|
||||
int64_t MaxActualTimespan() const { return (AveragingWindowTimespan() * (100 + nPowMaxAdjustDown)) / 100; }
|
||||
|
||||
void SetSaplingHeight(int32_t height) { vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height; }
|
||||
void SetOverwinterHeight(int32_t height) { vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = height; }
|
||||
uint256 nMinimumChainWork;
|
||||
|
||||
@@ -562,7 +562,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
|
||||
*specialtxp = 1;
|
||||
//printf(">>>>>>>> ");
|
||||
}
|
||||
else if ( komodo_chosennotary(&nid,height,scriptbuf + 1,timestamp) >= 0 )
|
||||
else if ( hush_chosennotary(&nid,height,scriptbuf + 1,timestamp) >= 0 )
|
||||
{
|
||||
//printf("found notary.k%d\n",k);
|
||||
if ( notaryid < 64 )
|
||||
|
||||
@@ -25,7 +25,7 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port);
|
||||
void komodo_init(int32_t height);
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||
uint64_t komodo_paxtotal();
|
||||
int32_t hush_longestchain();
|
||||
|
||||
@@ -194,14 +194,14 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
|
||||
hwmheight = origheight;
|
||||
}
|
||||
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp)
|
||||
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp)
|
||||
{
|
||||
// -1 if not notary, 0 if notary, 1 if special notary
|
||||
struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1;
|
||||
*notaryidp = -1;
|
||||
if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS )
|
||||
{
|
||||
printf("komodo_chosennotary ht.%d illegal\n",height);
|
||||
printf("hush_chosennotary ht.%d illegal\n",height);
|
||||
return(-1);
|
||||
}
|
||||
if ( height >= KOMODO_NOTARIES_HARDCODED || SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
|
||||
@@ -1441,12 +1441,12 @@ uint16_t komodo_userpass(char *userpass,char *symbol)
|
||||
{
|
||||
FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[HUSH_SMART_CHAIN_MAXLEN];
|
||||
userpass[0] = 0;
|
||||
if ( strcmp("KMD",symbol) == 0 )
|
||||
if ( strcmp("SPECIAL",symbol) == 0 )
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
sprintf(confname,"Komodo.conf");
|
||||
sprintf(confname,"Something.conf");
|
||||
#else
|
||||
sprintf(confname,"komodo.conf");
|
||||
sprintf(confname,"Something.conf");
|
||||
#endif
|
||||
}
|
||||
else sprintf(confname,"%s.conf",symbol);
|
||||
@@ -1462,14 +1462,11 @@ uint16_t komodo_userpass(char *userpass,char *symbol)
|
||||
return(port);
|
||||
}
|
||||
|
||||
#define HUSH_MAGIC 0xc0decafe
|
||||
#define HUSH_MAGIC 0xd394d36e
|
||||
|
||||
// CAN YOU FEEL THE HUSH MAGIC???
|
||||
uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t extralen)
|
||||
uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t extralen)
|
||||
{
|
||||
uint8_t buf[512]; uint32_t crc0=0; int32_t len = 0; bits256 hash;
|
||||
if ( strcmp(symbol,"HUSH3") == 0 )
|
||||
return(HUSH_MAGIC);
|
||||
len = dragon_rwnum(1,&buf[len],sizeof(supply),(void *)&supply);
|
||||
strcpy((char *)&buf[len],symbol);
|
||||
len += strlen(symbol);
|
||||
@@ -1477,56 +1474,50 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_
|
||||
{
|
||||
vcalc_sha256(0,hash.bytes,extraptr,extralen);
|
||||
crc0 = hash.uints[0];
|
||||
fprintf(stderr,"HUSH raw magic=");
|
||||
int32_t i; for (i=0; i<extralen; i++)
|
||||
fprintf(stderr,"%02x",extraptr[i]);
|
||||
fprintf(stderr," extralen.%d crc0.%x\n",extralen,crc0);
|
||||
fprintf(stderr," extralen=%d crc0=%x\n",extralen,crc0);
|
||||
}
|
||||
return(calc_crc32(crc0,buf,len));
|
||||
}
|
||||
|
||||
uint16_t komodo_assetport(uint32_t magic,int32_t extralen)
|
||||
uint16_t hush_smartport(uint32_t magic,int32_t extralen)
|
||||
{
|
||||
if(fDebug)
|
||||
fprintf(stderr,"%s: extralen=%d\n",__func__,extralen);
|
||||
else if ( extralen == 0 )
|
||||
|
||||
if ( extralen == 0 )
|
||||
return(8000 + (magic % 7777));
|
||||
else return(16000 + (magic % 49500));
|
||||
}
|
||||
|
||||
// DUKE: extralen is sometimes wrong which causes wrong diffbits?
|
||||
// This function is only called on startup, blocktime changing code does not modify magic
|
||||
// Hush 3.5.x and Hush 3.6.x have same history and p2p ports, but different magic
|
||||
uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extraptr,int32_t extralen)
|
||||
// Hush 3.5.x and Hush 3.6.x have same history and p2p ports, but different magic??? Seems not.
|
||||
uint16_t hush_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extraptr,int32_t extralen)
|
||||
{
|
||||
if(fDebug)
|
||||
fprintf(stderr,"%s: extralen=%d\n",__func__,extralen);
|
||||
/*
|
||||
if ( strcmp("HUSH3",symbol) == 0 )
|
||||
if ( strcmp("SPECIAL",symbol) == 0 )
|
||||
{
|
||||
//TODO: magic of hush 3.5.x
|
||||
*magicp = 0x8de4beef;
|
||||
return(18030);
|
||||
*magicp = 0xdeadbeef;
|
||||
return(6969);
|
||||
}
|
||||
*/
|
||||
*magicp = komodo_assetmagic(symbol,supply,extraptr,extralen);
|
||||
*magicp = hush_smartmagic(symbol,supply,extraptr,extralen);
|
||||
if(fDebug)
|
||||
fprintf(stderr,"%s: extralen=%d, magic=%d, supply=%l\n",__func__,extralen, &magic, supply);
|
||||
fprintf(stderr,"%s: extralen=%d, supply=%lu\n",__func__,extralen, supply);
|
||||
|
||||
return(komodo_assetport(*magicp,extralen));
|
||||
return(hush_smartport(*magicp,extralen));
|
||||
}
|
||||
|
||||
|
||||
char *dragonfmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"dragon\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1,\\\"notarypay\\\":%i}\"";
|
||||
|
||||
|
||||
|
||||
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp)
|
||||
int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp)
|
||||
{
|
||||
int32_t i,notaryid;
|
||||
for (i=0; i<33; i++)
|
||||
sprintf(&pubkeystr[i<<1],"%02x",NOTARY_PUBKEY33[i]);
|
||||
pubkeystr[66] = 0;
|
||||
komodo_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp);
|
||||
hush_chosennotary(¬aryid,height,NOTARY_PUBKEY33,timestamp);
|
||||
return(notaryid);
|
||||
}
|
||||
|
||||
@@ -1764,6 +1755,8 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
char *dragonfmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"dragon\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1,\\\"notarypay\\\":%i}\"";
|
||||
|
||||
void hush_args(char *argv0)
|
||||
{
|
||||
std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0;
|
||||
@@ -2328,7 +2321,7 @@ void hush_args(char *argv0)
|
||||
if(fDebug)
|
||||
fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN);
|
||||
//printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,SMART_CHAIN_SYMBOL,(double)MAX_MONEY/SATOSHIDEN);
|
||||
uint16_t tmpport = komodo_port(SMART_CHAIN_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
||||
uint16_t tmpport = hush_port(SMART_CHAIN_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen);
|
||||
if ( GetArg("-port",0) != 0 )
|
||||
{
|
||||
ASSETCHAINS_P2PPORT = GetArg("-port",0);
|
||||
|
||||
@@ -1005,7 +1005,7 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],uint32_t blocktimes[66],int32_t height,uint8_t pubkey33[33],uint32_t blocktime)
|
||||
{
|
||||
int32_t i,j,notaryid=0,minerid,limit,nid; uint8_t destpubkey33[33];
|
||||
komodo_chosennotary(¬aryid,height,pubkey33,blocktimes[0]);
|
||||
hush_chosennotary(¬aryid,height,pubkey33,blocktimes[0]);
|
||||
if ( height >= 82000 )
|
||||
{
|
||||
if ( notaryid >= 0 )
|
||||
@@ -1042,7 +1042,7 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],uint32_t bloc
|
||||
else limit = 66;
|
||||
for (i=1; i<limit; i++)
|
||||
{
|
||||
komodo_chosennotary(&nid,height-i,pubkey33,blocktimes[i]);
|
||||
hush_chosennotary(&nid,height-i,pubkey33,blocktimes[i]);
|
||||
if ( nid == notaryid )
|
||||
{
|
||||
//for (j=0; j<66; j++)
|
||||
|
||||
@@ -764,7 +764,7 @@ int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian
|
||||
return(len);
|
||||
}
|
||||
|
||||
uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t extralen)
|
||||
uint32_t hush_smartmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_t extralen)
|
||||
{
|
||||
uint8_t buf[512]; uint32_t crc0=0; int32_t len = 0; bits256 hash;
|
||||
if ( strcmp(symbol,"KMD") == 0 )
|
||||
@@ -789,14 +789,14 @@ uint16_t komodo_assetport(uint32_t magic,int32_t extralen)
|
||||
else return(16000 + (magic % 49500));
|
||||
}
|
||||
|
||||
uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extraptr,int32_t extralen)
|
||||
uint16_t hush_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extraptr,int32_t extralen)
|
||||
{
|
||||
if ( symbol == 0 || symbol[0] == 0 || strcmp("KMD",symbol) == 0 )
|
||||
{
|
||||
*magicp = 0x8de4eef9;
|
||||
return(7770);
|
||||
}
|
||||
*magicp = komodo_assetmagic(symbol,supply,extraptr,extralen);
|
||||
*magicp = hush_smartmagic(symbol,supply,extraptr,extralen);
|
||||
return(komodo_assetport(*magicp,extralen));
|
||||
}
|
||||
|
||||
@@ -830,7 +830,7 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t
|
||||
val = commission | (((uint64_t)staked & 0xff) << 32) | (((uint64_t)cc & 0xffffff) << 40);
|
||||
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
|
||||
}
|
||||
return(komodo_port(name,supply,&ASSETCHAINS_MAGIC,extraptr,extralen));
|
||||
return(hush_port(name,supply,&ASSETCHAINS_MAGIC,extraptr,extralen));
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
|
||||
19
src/main.cpp
19
src/main.cpp
@@ -5239,14 +5239,17 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
// caused by the fact that Difficulty Adjustment Algorithms do not take into account blocktime
|
||||
// changing at run-time, which breaks assumptions in the algorithm
|
||||
unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams);
|
||||
if ((nHeight < 340000 || nHeight > 342500) && block.nBits != nNextWork) {
|
||||
cout << "Incorrect HUSH Proof-of-Work at height " << nHeight << " " << block.nBits << " block.nBits vs. calc " <<
|
||||
nNextWork << " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl;
|
||||
|
||||
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits");
|
||||
} else {
|
||||
if( nHeight >= 340000 || nHeight <= 342500)
|
||||
fprintf(stderr,"%s: Ignoring weird nBits with block.nBits=%u vs GetNextWorkRequired=%u for height %d\n", __func__, block.nBits, nNextWork, nHeight);
|
||||
//if ((nHeight < 340000 || nHeight > 342500) && block.nBits != nNextWork) {
|
||||
if (block.nBits != nNextWork) {
|
||||
cout << "Incorrect HUSH Proof-of-Work at height " << nHeight <<
|
||||
" " << block.nBits << " block.nBits vs. calc " << nNextWork <<
|
||||
" " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl;
|
||||
// Don't use this CLI option unless you know what you are doing -- Duke
|
||||
if(!GetArg("-dev-ignore-bad-nbits",false)) {
|
||||
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits");
|
||||
} else {
|
||||
cout << "Ignoring bad nBits!!!" << endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Hush Smart Chains
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright (c) 2016 The Zcash developers
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Copyright (c) 2016 The Zcash developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -17,9 +16,7 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "metrics.h"
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "checkpoints.h"
|
||||
#include "main.h"
|
||||
@@ -28,7 +25,6 @@
|
||||
#include "utiltime.h"
|
||||
#include "utilmoneystr.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/synchronized_value.hpp>
|
||||
#include <string>
|
||||
@@ -39,7 +35,6 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hush_defs.h"
|
||||
int64_t komodo_block_unlocktime(uint32_t nHeight);
|
||||
|
||||
@@ -362,10 +357,8 @@ int printMetrics(size_t cols, bool mining)
|
||||
if (mapBlockIndex.count(hash) > 0 &&
|
||||
chainActive.Contains(mapBlockIndex[hash])) {
|
||||
int height = mapBlockIndex[hash]->GetHeight();
|
||||
//TODO: this likely has bugz
|
||||
CAmount subsidy = GetBlockSubsidy(height, consensusParams);
|
||||
if ((height > 0) && (height <= consensusParams.GetLastFoundersRewardBlockHeight())) {
|
||||
subsidy -= subsidy/5;
|
||||
}
|
||||
|
||||
if ((std::max(0, COINBASE_MATURITY - (tipHeight - height)) > 0) ||
|
||||
(tipHeight < komodo_block_unlocktime(height) && subsidy >= ASSETCHAINS_TIMELOCKGTE)) {
|
||||
|
||||
@@ -139,7 +139,7 @@ void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uin
|
||||
|
||||
uint32_t Mining_start,Mining_height;
|
||||
int32_t My_notaryid = -1;
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
int32_t hush_longestchain();
|
||||
@@ -604,8 +604,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
//pblock->nTime = blocktime + 1;
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
|
||||
int32_t stakeHeight = chainActive.Height() + 1;
|
||||
|
||||
LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake);
|
||||
|
||||
// Create coinbase tx
|
||||
@@ -1115,7 +1113,7 @@ void static BitcoinMiner()
|
||||
break;
|
||||
}
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
komodo_chosennotary(¬aryid,chainActive.LastTip()->GetHeight(),NOTARY_PUBKEY33,(uint32_t)chainActive.LastTip()->GetBlockTime());
|
||||
hush_chosennotary(¬aryid,chainActive.LastTip()->GetHeight(),NOTARY_PUBKEY33,(uint32_t)chainActive.LastTip()->GetBlockTime());
|
||||
if ( notaryid != My_notaryid )
|
||||
My_notaryid = notaryid;
|
||||
std::string solver;
|
||||
@@ -1581,7 +1579,8 @@ void static BitcoinMiner()
|
||||
minerThreads = NULL;
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s: nThreads.%d fGenerate.%d\n",__FUNCTION__, (int32_t)nThreads,fGenerate);
|
||||
if(fDebug)
|
||||
fprintf(stderr,"%s: nThreads.%d fGenerate.%d\n",__FUNCTION__, (int32_t)nThreads,fGenerate);
|
||||
|
||||
if (nThreads == 0)
|
||||
return;
|
||||
|
||||
57
src/pow.cpp
57
src/pow.cpp
@@ -389,7 +389,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
return nProofOfWorkLimit;
|
||||
|
||||
bool fNegative,fOverflow; int32_t zawyflag = 0; arith_uint256 easy,origtarget,bnAvg {bnTot / params.nPowAveragingWindow};
|
||||
nbits = CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params);
|
||||
nbits = CalculateNextWorkRequired(bnAvg, pindexLast->GetMedianTimePast(), pindexFirst->GetMedianTimePast(), params, height);
|
||||
|
||||
if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
|
||||
{
|
||||
bnTarget = arith_uint256().SetCompact(nbits);
|
||||
@@ -504,23 +505,42 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
return(nbits);
|
||||
}
|
||||
|
||||
// Changing this requires changing many other things and
|
||||
// changes consensus. Have fun -- Duke
|
||||
int64_t AveragingWindowTimespan(int32_t height) {
|
||||
int64_t AWT = 2550;
|
||||
if (height >= 340000) {
|
||||
//trying to emulate 3.5.0 behavior
|
||||
//AWT = 1275;
|
||||
}
|
||||
// TODO:
|
||||
//if (height >= XXX){
|
||||
// AWT = 1275;
|
||||
//}
|
||||
return AWT;
|
||||
}
|
||||
|
||||
unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||
int64_t nLastBlockTime, int64_t nFirstBlockTime,
|
||||
const Consensus::Params& params)
|
||||
const Consensus::Params& params,
|
||||
int32_t height)
|
||||
{
|
||||
// Limit adjustment step
|
||||
// Use medians to prevent time-warp attacks
|
||||
// Limit adjustment step and use medians to prevent time-warp attacks
|
||||
int64_t nActualTimespan = nLastBlockTime - nFirstBlockTime;
|
||||
LogPrint("pow", " nActualTimespan = %d before dampening\n", nActualTimespan);
|
||||
nActualTimespan = params.AveragingWindowTimespan() + (nActualTimespan - params.AveragingWindowTimespan())/4;
|
||||
int64_t AWT = AveragingWindowTimespan(height) ;
|
||||
nActualTimespan = AWT + (nActualTimespan - AWT)/4;
|
||||
LogPrint("pow", " nActualTimespan = %d before bounds\n", nActualTimespan);
|
||||
|
||||
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
||||
{
|
||||
if (nActualTimespan < params.MinActualTimespan())
|
||||
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) {
|
||||
if (nActualTimespan < params.MinActualTimespan()) {
|
||||
fprintf(stderr,"%s: Adjusting nActualTimespan up to min value %li\n", __func__, params.MinActualTimespan() );
|
||||
nActualTimespan = params.MinActualTimespan();
|
||||
if (nActualTimespan > params.MaxActualTimespan())
|
||||
}
|
||||
if (nActualTimespan > params.MaxActualTimespan()) {
|
||||
fprintf(stderr,"%s: Adjusting nActualTimespan down to max value %li\n", __func__, params.MaxActualTimespan() );
|
||||
nActualTimespan = params.MaxActualTimespan();
|
||||
}
|
||||
}
|
||||
// Retarget
|
||||
arith_uint256 bnLimit;
|
||||
@@ -531,7 +551,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||
|
||||
const arith_uint256 bnPowLimit = bnLimit; //UintToArith256(params.powLimit);
|
||||
arith_uint256 bnNew {bnAvg};
|
||||
bnNew /= params.AveragingWindowTimespan();
|
||||
bnNew /= AWT;
|
||||
bnNew *= nActualTimespan;
|
||||
|
||||
if (bnNew > bnPowLimit)
|
||||
@@ -539,15 +559,19 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||
|
||||
/// debug print
|
||||
LogPrint("pow", "GetNextWorkRequired RETARGET\n");
|
||||
LogPrint("pow", "params.AveragingWindowTimespan() = %d nActualTimespan = %d\n", params.AveragingWindowTimespan(), nActualTimespan);
|
||||
LogPrint("pow", "AveragingWindowTimespan = %d nActualTimespan = %d\n", AWT, nActualTimespan);
|
||||
LogPrint("pow", "Current average: %08x %s\n", bnAvg.GetCompact(), bnAvg.ToString());
|
||||
LogPrint("pow", "After: %08x %s\n", bnNew.GetCompact(), bnNew.ToString());
|
||||
|
||||
if(fDebug)
|
||||
fprintf(stderr,"%s: nbits=%u\n",__func__,bnNew.GetCompact());
|
||||
//if(fDebug) {
|
||||
fprintf(stderr, "%s: nbits Current average: %08x %s\n", __func__, bnAvg.GetCompact(), bnAvg.ToString().c_str());
|
||||
fprintf(stderr, "%s: bits After: %08x %s\n", __func__, bnNew.GetCompact(), bnNew.ToString().c_str());
|
||||
fprintf(stderr,"%s: AWT=%lu ActualTimeSpan=%li MinActual=%li MaxActual=%li\n",__func__, AWT, nActualTimespan, params.MinActualTimespan(), params.MaxActualTimespan());
|
||||
//}
|
||||
return bnNew.GetCompact();
|
||||
}
|
||||
|
||||
// HUSH does not use these functions but Hush Smart Chains can opt-in to using more bleeding edge DAA's
|
||||
// ASIC chains do not need these protections as much -- Duke Leto
|
||||
unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
{
|
||||
return lwmaCalculateNextWorkRequired(pindexLast, params);
|
||||
@@ -564,7 +588,6 @@ unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const
|
||||
unsigned int nProofOfWorkLimit = bnLimit.GetCompact();
|
||||
|
||||
//printf("PoWLimit: %u\n", nProofOfWorkLimit);
|
||||
|
||||
// Find the first block in the averaging interval as we total the linearly weighted average
|
||||
const CBlockIndex* pindexFirst = pindexLast;
|
||||
const CBlockIndex* pindexNext;
|
||||
@@ -652,7 +675,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],uint32_t blocktimes[66],int32_t height,uint8_t pubkey33[33],uint32_t blocktime);
|
||||
int32_t komodo_currentheight();
|
||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
|
||||
@@ -687,7 +710,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
}
|
||||
if ( height > 34000 && SMART_CHAIN_SYMBOL[0] == 0 ) // 0 -> non-special notary
|
||||
{
|
||||
special = komodo_chosennotary(¬aryid,height,pubkey33,tiptime);
|
||||
special = hush_chosennotary(¬aryid,height,pubkey33,tiptime);
|
||||
for (i=0; i<33; i++)
|
||||
{
|
||||
if ( pubkey33[i] != 0 )
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2016-2020 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -17,13 +17,11 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HUSH_POW_H
|
||||
#define HUSH_POW_H
|
||||
|
||||
#include "chain.h"
|
||||
#include "consensus/params.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class CBlockHeader;
|
||||
@@ -35,7 +33,7 @@ class arith_uint256;
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params&);
|
||||
unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
||||
int64_t nLastBlockTime, int64_t nFirstBlockTime,
|
||||
const Consensus::Params&);
|
||||
const Consensus::Params&, int32_t height);
|
||||
|
||||
/** Check whether the Equihash solution in a block header is valid */
|
||||
bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// Equihash solver
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
// Copyright (c) 2016-2016 John Tromp, The Zcash developers
|
||||
// Equihash solver
|
||||
|
||||
#include "sodium.h"
|
||||
#ifdef __APPLE__
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
// Equihash solver
|
||||
// Copyright (c) 2016-2020 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
// Copyright (c) 2016 John Tromp, The Zcash developers
|
||||
// Equihash solver
|
||||
|
||||
// Fix N, K, such that n = N/(k+1) is integer
|
||||
// Fix M = 2^{n+1} hashes each of length N bits,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Copyright (c) 2016-2020 The Hush developers
|
||||
// Distributed under the GPLv3 software license, see the accompanying
|
||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||
#ifdef __APPLE__
|
||||
|
||||
#ifndef PTHREAD_BARRIER_H_
|
||||
|
||||
@@ -59,7 +59,7 @@ int32_t hush_longestchain();
|
||||
int32_t hush_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
|
||||
bool komodo_txnotarizedconfirmed(uint256 txid);
|
||||
uint32_t komodo_chainactive_timestamp();
|
||||
int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
|
||||
int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
|
||||
extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
|
||||
extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC;
|
||||
extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
|
||||
@@ -284,7 +284,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
||||
if ( NOTARY_PUBKEY33[0] != 0 ) {
|
||||
char pubkeystr[65]; int32_t notaryid; std::string notaryname;
|
||||
if( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.LastTip()->GetHeight(),komodo_chainactive_timestamp())) >= 0 ) {
|
||||
if( (notaryid= hush_whoami(pubkeystr,(int32_t)chainActive.LastTip()->GetHeight(),komodo_chainactive_timestamp())) >= 0 ) {
|
||||
obj.push_back(Pair("notaryid", notaryid));
|
||||
if ( KOMODO_LASTMINED != 0 )
|
||||
obj.push_back(Pair("lastmined", KOMODO_LASTMINED));
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "test/test_bitcoin.h"
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(main_tests, TestingSetup)
|
||||
|
||||
/*
|
||||
static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams)
|
||||
{
|
||||
int maxHalvings = 64;
|
||||
@@ -101,5 +100,6 @@ BOOST_AUTO_TEST_CASE(test_combiner_all)
|
||||
Test.disconnect(&ReturnTrue);
|
||||
BOOST_CHECK(Test());
|
||||
}
|
||||
*/
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user