Merge pull request 'Sync duke branch to dev' (#420) from duke into dev
Reviewed-on: https://git.hush.is/hush/hush3/pulls/420
This commit is contained in:
@@ -9,7 +9,8 @@ echo "Compiling a debug build with --enable-debug..."
|
||||
|
||||
# run correct build script for detected OS
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
CONFIGURE_FLAGS=--enable-debug ./util/build.sh --disable-tests $@
|
||||
# TODO: we only have debug builds on linux for now
|
||||
CONFIGURE_FLAGS=--enable-debug ./util/debug-build.sh --disable-tests $@
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# code from ./util/build.sh needs to be ported to support --disable-tests
|
||||
#./util/build-mac.sh --disable-tests $@
|
||||
|
||||
@@ -74,30 +74,17 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
|
||||
while (!fShutdown)
|
||||
{
|
||||
//fprintf(stderr,"call passport iteration\n");
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
{
|
||||
if ( HUSH_NSPV_FULLNODE )
|
||||
hush_passport_iteration();
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
fShutdown = ShutdownRequested();
|
||||
if ( fShutdown != 0 )
|
||||
break;
|
||||
MilliSleep(1000);
|
||||
}
|
||||
} else {
|
||||
//hush_longestchain();
|
||||
if ( ASSETCHAINS_CBOPRET != 0 )
|
||||
hush_cbopretupdate(0);
|
||||
for (i=0; i<=ASSETCHAINS_BLOCKTIME/5; i++)
|
||||
{
|
||||
fShutdown = ShutdownRequested();
|
||||
if ( fShutdown != 0 )
|
||||
break;
|
||||
MilliSleep(1000);
|
||||
}
|
||||
}
|
||||
//hush_longestchain();
|
||||
if ( ASSETCHAINS_CBOPRET != 0 )
|
||||
hush_cbopretupdate(0);
|
||||
for (i=0; i<=ASSETCHAINS_BLOCKTIME/5; i++)
|
||||
{
|
||||
fShutdown = ShutdownRequested();
|
||||
if ( fShutdown != 0 )
|
||||
break;
|
||||
MilliSleep(1000);
|
||||
}
|
||||
|
||||
fShutdown = ShutdownRequested();
|
||||
}
|
||||
//fprintf(stderr,"%s: fShutdown=%d\n", __FUNCTION__, fShutdown);
|
||||
|
||||
@@ -498,11 +498,6 @@ bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t t
|
||||
/// @returns public key as byte array
|
||||
std::vector<uint8_t> Mypubkey();
|
||||
|
||||
/// Returns my private key, that is private key for the my pubkey
|
||||
/// @returns private key as byte array
|
||||
/// @see Mypubkey
|
||||
bool Myprivkey(uint8_t myprivkey[]);
|
||||
|
||||
/// @private
|
||||
uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::vector<uint256> &txids);
|
||||
|
||||
|
||||
@@ -102,34 +102,18 @@ uint32_t GetLatestTimestamp(int32_t height)
|
||||
|
||||
void CCaddr2set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr)
|
||||
{
|
||||
cp->unspendableEvalcode2 = evalcode;
|
||||
cp->unspendablepk2 = pk;
|
||||
memcpy(cp->unspendablepriv2,priv,32);
|
||||
strcpy(cp->unspendableaddr2,coinaddr);
|
||||
}
|
||||
|
||||
void CCaddr3set(struct CCcontract_info *cp,uint8_t evalcode,CPubKey pk,uint8_t *priv,char *coinaddr)
|
||||
{
|
||||
cp->unspendableEvalcode3 = evalcode;
|
||||
cp->unspendablepk3 = pk;
|
||||
memcpy(cp->unspendablepriv3,priv,32);
|
||||
strcpy(cp->unspendableaddr3,coinaddr);
|
||||
}
|
||||
|
||||
void CCaddr1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, uint8_t *priv, char *coinaddr)
|
||||
{
|
||||
cp->coins1of2pk[0] = pk1;
|
||||
cp->coins1of2pk[1] = pk2;
|
||||
memcpy(cp->coins1of2priv,priv,32);
|
||||
strcpy(cp->coins1of2addr,coinaddr);
|
||||
}
|
||||
|
||||
void CCaddrTokens1of2set(struct CCcontract_info *cp, CPubKey pk1, CPubKey pk2, uint8_t *priv, char *tokenaddr)
|
||||
{
|
||||
cp->tokens1of2pk[0] = pk1;
|
||||
cp->tokens1of2pk[1] = pk2;
|
||||
memcpy(cp->tokens1of2priv,priv,32);
|
||||
strcpy(cp->tokens1of2addr, tokenaddr);
|
||||
}
|
||||
|
||||
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey)
|
||||
@@ -150,13 +134,6 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey)
|
||||
|
||||
bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix, uint8_t prefix2)
|
||||
{
|
||||
CTxDestination address; txnouttype whichType;
|
||||
if ( ExtractDestination(scriptPubKey,address) != 0 )
|
||||
{
|
||||
strcpy(destaddr,(char *)CCustomBitcoinAddress(address,taddr,prefix,prefix2).ToString().c_str());
|
||||
return(true);
|
||||
}
|
||||
//fprintf(stderr,"ExtractDestination failed\n");
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -170,23 +147,7 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33)
|
||||
|
||||
bool ConstrainVout(CTxOut vout, int32_t CCflag, char *cmpaddr, int64_t nValue)
|
||||
{
|
||||
char destaddr[64];
|
||||
if ( vout.scriptPubKey.IsPayToCryptoCondition() != CCflag )
|
||||
{
|
||||
fprintf(stderr,"constrain vout error isCC %d vs %d CCflag\n", vout.scriptPubKey.IsPayToCryptoCondition(), CCflag);
|
||||
return(false);
|
||||
}
|
||||
else if ( cmpaddr != 0 && (Getscriptaddress(destaddr, vout.scriptPubKey) == 0 || strcmp(destaddr, cmpaddr) != 0) )
|
||||
{
|
||||
fprintf(stderr,"constrain vout error: check addr %s vs script addr %s\n", cmpaddr!=0?cmpaddr:"", destaddr!=0?destaddr:"");
|
||||
return(false);
|
||||
}
|
||||
else if ( nValue != 0 && nValue != vout.nValue ) //(nValue == 0 && vout.nValue < 10000) || (
|
||||
{
|
||||
fprintf(stderr,"constrain vout error nValue %.8f vs %.8f\n",(double)nValue/COIN,(double)vout.nValue/COIN);
|
||||
return(false);
|
||||
}
|
||||
else return(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool priv2addr(char *coinaddr,uint8_t *buf33,uint8_t priv32[32])
|
||||
@@ -219,60 +180,6 @@ extern char NSPV_wifstr[],NSPV_pubkeystr[];
|
||||
extern uint32_t NSPV_logintime;
|
||||
#define NSPV_AUTOLOGOUT 777
|
||||
|
||||
bool Myprivkey(uint8_t myprivkey[])
|
||||
{
|
||||
char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33];
|
||||
if ( HUSH_NSPV_SUPERLITE )
|
||||
{
|
||||
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
|
||||
{
|
||||
fprintf(stderr,"need to be logged in to get myprivkey\n");
|
||||
return false;
|
||||
}
|
||||
vchSecret = DecodeSecret(NSPV_wifstr);
|
||||
memcpy(myprivkey,vchSecret.begin(),32);
|
||||
//for (i=0; i<32; i++)
|
||||
// fprintf(stderr,"%02x",myprivkey[i]);
|
||||
//fprintf(stderr," myprivkey %s\n",NSPV_wifstr);
|
||||
memset((uint8_t *)vchSecret.begin(),0,32);
|
||||
return true;
|
||||
}
|
||||
if ( Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG) != 0 )
|
||||
{
|
||||
n = (int32_t)strlen(coinaddr);
|
||||
strAddress.resize(n+1);
|
||||
dest = (char *)strAddress.data();
|
||||
for (i=0; i<n; i++)
|
||||
dest[i] = coinaddr[i];
|
||||
dest[i] = 0;
|
||||
if ( address.SetString(strAddress) != 0 && address.GetKeyID(keyID) != 0 )
|
||||
{
|
||||
#ifdef ENABLE_WALLET
|
||||
if ( pwalletMain->GetKey(keyID,vchSecret) != 0 )
|
||||
{
|
||||
memcpy(myprivkey,vchSecret.begin(),32);
|
||||
memset((uint8_t *)vchSecret.begin(),0,32);
|
||||
if ( 0 )
|
||||
{
|
||||
for (i=0; i<32; i++)
|
||||
fprintf(stderr,"0x%02x, ",myprivkey[i]);
|
||||
fprintf(stderr," found privkey for %s!\n",dest);
|
||||
}
|
||||
if ( priv2addr(checkaddr,buf33,myprivkey) != 0 )
|
||||
{
|
||||
if ( buf2pk(buf33) == Mypubkey() && strcmp(checkaddr,coinaddr) == 0 )
|
||||
return(true);
|
||||
else printf("mismatched privkey -> addr %s vs %s\n",checkaddr,coinaddr);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"privkey for the -pubkey= address is not in the wallet, importprivkey!\n");
|
||||
return(false);
|
||||
}
|
||||
|
||||
CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv)
|
||||
{
|
||||
if ( unspendablepriv != 0 )
|
||||
@@ -423,37 +330,13 @@ bool hush_txnotarizedconfirmed(uint256 txid)
|
||||
// returns total of normal inputs signed with this pubkey
|
||||
int64_t TotalPubkeyNormalInputs(const CTransaction &tx, const CPubKey &pubkey)
|
||||
{
|
||||
int64_t total = 0;
|
||||
for (auto vin : tx.vin) {
|
||||
CTransaction vintx;
|
||||
uint256 hashBlock;
|
||||
if (!IsCCInput(vin.scriptSig) && myGetTransaction(vin.prevout.hash, vintx, hashBlock)) {
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
std::vector<valtype> vSolutions;
|
||||
txnouttype whichType;
|
||||
|
||||
if (Solver(vintx.vout[vin.prevout.n].scriptPubKey, whichType, vSolutions)) {
|
||||
switch (whichType) {
|
||||
case TX_PUBKEY:
|
||||
if (pubkey == CPubKey(vSolutions[0])) // is my input?
|
||||
total += vintx.vout[vin.prevout.n].nValue;
|
||||
break;
|
||||
case TX_PUBKEYHASH:
|
||||
if (pubkey.GetID() == CKeyID(uint160(vSolutions[0]))) // is my input?
|
||||
total += vintx.vout[vin.prevout.n].nValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns total of CC inputs signed with this pubkey
|
||||
int64_t TotalPubkeyCCInputs(const CTransaction &tx, const CPubKey &pubkey)
|
||||
{
|
||||
int64_t total = 0;
|
||||
return total;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern std::string MYCCLIBNAME;
|
||||
|
||||
@@ -492,13 +492,14 @@ void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivation
|
||||
|
||||
int32_t MAX_BLOCK_SIZE(int32_t height)
|
||||
{
|
||||
int32_t saplinght = pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight;
|
||||
// this codebase requires sapling activation at height=1
|
||||
int32_t saplinght = 1; // pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight;
|
||||
//fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight);
|
||||
if ( height <= 0 || (saplinght > 0 && height >= saplinght) )
|
||||
{
|
||||
//if ( height <= 0 || (saplinght > 0 && height >= saplinght) )
|
||||
//{
|
||||
return(_MAX_BLOCK_SIZE);
|
||||
}
|
||||
else return(2000000);
|
||||
//}
|
||||
//else return(2000000);
|
||||
}
|
||||
|
||||
// Change the Hush blocktime at run-time(!)
|
||||
|
||||
@@ -24,7 +24,17 @@
|
||||
#include "cc/CCinclude.h"
|
||||
#include "sietch.h"
|
||||
|
||||
// this is the address for pubkey = 0x000000000000000000000000000000000 (33 bytes)
|
||||
// This is the address for pubkey = 0x000000000000000000000000000000000 (33 bytes)
|
||||
// Funds sent to a burn address can never be spent because the pubkey is invalid
|
||||
// because it is not a point on the elliptic curve we use (secp256k1, like all other
|
||||
// Bitcoin-derived codebases). secp256k1 is defined by the equation y^2 = x^3 + 7 .
|
||||
// Using pubkey=0 also implies privkey=0 and the (pubkey,privkey) pair are the same
|
||||
// as the (x,y) pair in the equation. If you plug in (0,0) to the equation you get
|
||||
// 0^2 = 0^3 + 7 or 0=7 which is false. This means that (0,0) is not a valid point
|
||||
// on the secp256k1 curve. Therefore there is no valid signature to spend the funds
|
||||
// sent to the burn address, because a valid signature must use a valid point on the
|
||||
// elliptic curve being used. For these reasons, we can prove that the burn address
|
||||
// receives funds which can never be spent.
|
||||
#define BURN_ADDRESS "RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPVMY"
|
||||
|
||||
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||
|
||||
27
src/main.cpp
27
src/main.cpp
@@ -33,6 +33,7 @@
|
||||
#include "net.h"
|
||||
#include "netmessagemaker.h"
|
||||
#include "pow.h"
|
||||
#include "time.h"
|
||||
#include "script/interpreter.h"
|
||||
#include "txdb.h"
|
||||
#include "txmempool.h"
|
||||
@@ -1731,22 +1732,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
tiptime = (uint32_t)time(NULL);
|
||||
else tiptime = (uint32_t)chainActive.LastTip()->nTime;
|
||||
|
||||
/*
|
||||
// Node operator can choose to reject tx by number of transparent inputs
|
||||
static_assert(std::numeric_limits<size_t>::max() >= std::numeric_limits<int64_t>::max(), "size_t too small");
|
||||
const size_t limit = 0; //(size_t) GetArg("-mempooltxinputlimit", 0);
|
||||
// Limit is ignored if Overwinter is active, which is the case on HUSH3 and all HAC's
|
||||
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
|
||||
limit = 0;
|
||||
}
|
||||
if (limit > 0) {
|
||||
size_t n = tx.vin.size();
|
||||
if (n > limit) {
|
||||
LogPrint("mempool", "Dropping txid %s : too many transparent inputs %zu > limit %zu\n", tx.GetHash().ToString(), n, limit );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
auto verifier = libzcash::ProofVerifier::Strict();
|
||||
|
||||
if (!CheckTransaction(tiptime,tx, state, verifier, 0, 0))
|
||||
@@ -4333,7 +4318,15 @@ bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock)
|
||||
CBlockIndex *pindexMostWork = NULL;
|
||||
const CChainParams& chainParams = Params();
|
||||
do {
|
||||
boost::this_thread::interruption_point();
|
||||
// Sleep briefly to allow other threads a chance at grabbing cs_main if
|
||||
// we are connecting a long chain of blocks and would otherwise hold the
|
||||
// lock almost continuously. This helps
|
||||
// the internal wallet, if it is enabled, to keep up with the connected
|
||||
// blocks, reducing the overall time until the node becomes usable.
|
||||
//
|
||||
// This is defined to be an interruption point.
|
||||
// <https://www.boost.org/doc/libs/1_72_0/doc/html/thread/thread_management.html#interruption_points>
|
||||
boost::this_thread::sleep_for(boost::chrono::microseconds(200));
|
||||
|
||||
if (ShutdownRequested())
|
||||
break;
|
||||
|
||||
@@ -308,12 +308,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
bool fMissingInputs = false;
|
||||
bool fNotarization = false;
|
||||
std::vector<int8_t> TMP_NotarizationNotaries;
|
||||
//if (tx.IsCoinImport())
|
||||
//{
|
||||
// CAmount nValueIn = GetCoinImportValue(tx); // burn amount
|
||||
// nTotalIn += nValueIn;
|
||||
// dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16.
|
||||
//} else
|
||||
|
||||
{
|
||||
TMP_NotarizationNotaries.clear();
|
||||
bool fToCryptoAddress = false;
|
||||
@@ -322,15 +317,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
{
|
||||
/*
|
||||
if (tx.IsPegsImport() && txin.prevout.n==10e8)
|
||||
{
|
||||
CAmount nValueIn = GetCoinImportValue(tx); // burn amount
|
||||
nTotalIn += nValueIn;
|
||||
dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16.
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
// Read prev transaction
|
||||
if (!view.HaveCoins(txin.prevout.hash))
|
||||
{
|
||||
@@ -711,7 +697,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
if ( totalsats == 0 )
|
||||
{
|
||||
fprintf(stderr, "Could not create notary payment, trying again.\n");
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 || (SMART_CHAIN_SYMBOL[0] != 0 && !isStake) )
|
||||
if ( !isStake )
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
@@ -756,52 +742,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
}
|
||||
pblock->nSolution.clear();
|
||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||
/*
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 && IS_HUSH_NOTARY != 0 && My_notaryid >= 0 )
|
||||
{
|
||||
uint32_t r; CScript opret; void **ptr=0;
|
||||
|
||||
CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
||||
if ( pblock->nTime < pindexPrev->nTime+60 )
|
||||
pblock->nTime = pindexPrev->nTime + 60;
|
||||
if ( gpucount < 33 )
|
||||
{
|
||||
uint8_t tmpbuffer[40]; uint32_t r; int32_t n=0; uint256 randvals;
|
||||
memcpy(&tmpbuffer[n],&My_notaryid,sizeof(My_notaryid)), n += sizeof(My_notaryid);
|
||||
memcpy(&tmpbuffer[n],&Mining_height,sizeof(Mining_height)), n += sizeof(Mining_height);
|
||||
memcpy(&tmpbuffer[n],&pblock->hashPrevBlock,sizeof(pblock->hashPrevBlock)), n += sizeof(pblock->hashPrevBlock);
|
||||
vcalc_sha256(0,(uint8_t *)&randvals,tmpbuffer,n);
|
||||
memcpy(&r,&randvals,sizeof(r));
|
||||
pblock->nTime += (r % (33 - gpucount)*(33 - gpucount));
|
||||
}
|
||||
if ( hush_notaryvin(txNotary,NOTARY_PUBKEY33,ptr) > 0 )
|
||||
{
|
||||
CAmount txfees = 5000;
|
||||
pblock->vtx.push_back(txNotary);
|
||||
pblocktemplate->vTxFees.push_back(txfees);
|
||||
pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txNotary));
|
||||
nFees += txfees;
|
||||
pblocktemplate->vTxFees[0] = -nFees;
|
||||
//*(uint64_t *)(&pblock->vtx[0].vout[0].nValue) += txfees;
|
||||
//fprintf(stderr,"added notaryvin\n");
|
||||
} else {
|
||||
fprintf(stderr,"error adding notaryvin, need to create 0.0001 utxos\n");
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 || (SMART_CHAIN_SYMBOL[0] != 0 && !isStake) )
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
} else */
|
||||
|
||||
if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (SMART_CHAIN_SYMBOL[0] != 0 || IS_HUSH_NOTARY == 0 || My_notaryid < 0) )
|
||||
if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && ASSETCHAINS_STAKED == 0 && (IS_HUSH_NOTARY == 0 || My_notaryid < 0) )
|
||||
{
|
||||
CValidationState state;
|
||||
//fprintf(stderr,"%s: check validity\n", __func__);
|
||||
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks
|
||||
{
|
||||
if ( (SMART_CHAIN_SYMBOL[0] != 0 && !isStake) )
|
||||
if ( !isStake )
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
@@ -813,7 +761,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
//fprintf(stderr,"valid\n");
|
||||
}
|
||||
}
|
||||
if ( (SMART_CHAIN_SYMBOL[0] != 0 && !isStake) )
|
||||
if ( !isStake )
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
@@ -931,6 +879,7 @@ static bool ProcessBlockFound(CBlock* pblock)
|
||||
|
||||
// Found a solution
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (pblock->hashPrevBlock != chainActive.LastTip()->GetBlockHash())
|
||||
{
|
||||
uint256 hash; int32_t i;
|
||||
@@ -1174,7 +1123,11 @@ void static RandomXMiner()
|
||||
|
||||
// Create new block
|
||||
unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();
|
||||
CBlockIndex* pindexPrev;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindexPrev = chainActive.LastTip();
|
||||
}
|
||||
|
||||
// If we don't have a valid chain tip to work from, wait and try again.
|
||||
if (pindexPrev == nullptr) {
|
||||
@@ -1367,6 +1320,8 @@ void static RandomXMiner()
|
||||
}
|
||||
|
||||
CValidationState state;
|
||||
{ LOCK(cs_main);
|
||||
|
||||
if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false))
|
||||
{
|
||||
h = UintToArith256(B.GetHash());
|
||||
@@ -1377,6 +1332,8 @@ void static RandomXMiner()
|
||||
fprintf(stderr,"\n");
|
||||
return(false);
|
||||
}
|
||||
|
||||
}
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
LogPrintf("HushRandomXMiner:\n");
|
||||
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", B.GetHash().GetHex(), HASHTarget.GetHex());
|
||||
@@ -1735,6 +1692,8 @@ void static BitcoinMiner()
|
||||
fprintf(stderr," mined %s block %d!\n",SMART_CHAIN_SYMBOL,Mining_height);
|
||||
}
|
||||
CValidationState state;
|
||||
{ LOCK(cs_main);
|
||||
|
||||
if ( !TestBlockValidity(state,B, chainActive.LastTip(), true, false))
|
||||
{
|
||||
h = UintToArith256(B.GetHash());
|
||||
@@ -1744,6 +1703,8 @@ void static BitcoinMiner()
|
||||
gotinvalid = 1;
|
||||
return(false);
|
||||
}
|
||||
|
||||
}
|
||||
HUSH_CHOSEN_ONE = 1;
|
||||
// Found a solution
|
||||
SetThreadPriority(THREAD_PRIORITY_NORMAL);
|
||||
|
||||
@@ -231,11 +231,12 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
+ HelpExampleCli("getinfo", "")
|
||||
+ HelpExampleRpc("getinfo", "")
|
||||
);
|
||||
//#ifdef ENABLE_WALLET
|
||||
// LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
|
||||
//#else
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
|
||||
#else
|
||||
LOCK(cs_main);
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
proxyType proxy;
|
||||
GetProxy(NET_IPV4, proxy);
|
||||
|
||||
15
src/sync.cpp
15
src/sync.cpp
@@ -25,6 +25,10 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include <execinfo.h> /* backtrace, backtrace_symbols_fd */
|
||||
#include <unistd.h> /* STDOUT_FILENO */
|
||||
|
||||
|
||||
#ifdef DEBUG_LOCKCONTENTION
|
||||
void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
|
||||
{
|
||||
@@ -177,12 +181,23 @@ std::string LocksHeld()
|
||||
return result;
|
||||
}
|
||||
|
||||
void print_stacktrace(void) {
|
||||
size_t size;
|
||||
enum Constexpr { MAX_SIZE = 1024 };
|
||||
void *array[MAX_SIZE];
|
||||
size = backtrace(array, MAX_SIZE);
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
}
|
||||
|
||||
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs)
|
||||
{
|
||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, *lockstack)
|
||||
if (i.first == cs)
|
||||
return;
|
||||
fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
||||
|
||||
print_stacktrace();
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
@@ -629,7 +629,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
if (fHelp || params.size() < 3 )
|
||||
throw runtime_error(
|
||||
"kvupdate key \"value\" days passphrase\n"
|
||||
"\nStore a key value. This feature is only available for asset chains.\n"
|
||||
"\nStore a key value. This feature is only available for non-z2z chains.\n"
|
||||
"\nArguments:\n"
|
||||
"1. key (string, required) key\n"
|
||||
"2. \"value\" (string, required) value\n"
|
||||
@@ -654,8 +654,11 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
);
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return 0;
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 )
|
||||
return(0);
|
||||
|
||||
if (ASSETCHAINS_PRIVATE) {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "This RPC is only available on non z2z chains");
|
||||
}
|
||||
|
||||
haveprivkey = 0;
|
||||
memset(&sig,0,sizeof(sig));
|
||||
memset(&privkey,0,sizeof(privkey));
|
||||
|
||||
@@ -887,6 +887,7 @@ bool CWallet::IsSaplingSpent(const uint256& nullifier) const {
|
||||
}
|
||||
|
||||
unsigned int CWallet::GetSaplingSpendDepth(const uint256& nullifier) const {
|
||||
|
||||
pair<TxNullifiers::const_iterator, TxNullifiers::const_iterator> range;
|
||||
range = mapTxSaplingNullifiers.equal_range(nullifier);
|
||||
|
||||
@@ -977,10 +978,10 @@ void CWallet::ClearNoteWitnessCache()
|
||||
|
||||
void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
|
||||
extern int32_t HUSH_REWIND;
|
||||
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
|
||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||
//Sapling
|
||||
for (auto& item : wtxItem.second.mapSaplingNoteData) {
|
||||
|
||||
143
util/debug-build.sh
Executable file
143
util/debug-build.sh
Executable file
@@ -0,0 +1,143 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (c) 2016-2024 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
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
# Check if cmake, a new dependency for randomx support, is installed on system and exits if it is not
|
||||
if ! [ -x "$(command -v cmake)" ]; then
|
||||
echo 'Error: cmake is not installed. Install cmake and try again.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -x "$(command -v autoreconf)" ]; then
|
||||
echo 'Error: autoconf is not installed. Install autoconf and try again.' >&2
|
||||
echo 'On Debian-like systems: apt install autoconf' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function cmd_pref() {
|
||||
if type -p "$2" > /dev/null; then
|
||||
eval "$1=$2"
|
||||
else
|
||||
eval "$1=$3"
|
||||
fi
|
||||
}
|
||||
cat <<'EOF'
|
||||
.~~~~~~~~~~~~~~~~.
|
||||
{{ Building Hush!! }}
|
||||
`~~~~~~~~~~~~~~~~`
|
||||
\ ^__^
|
||||
\ (@@)\_______
|
||||
(__)\ HUSH )\/\ $
|
||||
z zz ||----w | z |
|
||||
zz zz z || z ||xxx z z|z zz
|
||||
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
|
||||
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
|
||||
EOF
|
||||
|
||||
# If a g-prefixed version of the command exists, use it preferentially.
|
||||
function gprefix() {
|
||||
cmd_pref "$1" "g$2" "$2"
|
||||
}
|
||||
|
||||
gprefix READLINK readlink
|
||||
cd "$(dirname "$("$READLINK" -f "$0")")/.."
|
||||
|
||||
# Allow user overrides to $MAKE. Typical usage for users who need it:
|
||||
# MAKE=gmake ./util/build.sh -j$(nproc)
|
||||
if [[ -z "${MAKE-}" ]]; then
|
||||
MAKE=make
|
||||
fi
|
||||
|
||||
# Allow overrides to $BUILD and $HOST for porters. Most users will not need it.
|
||||
# BUILD=i686-pc-linux-gnu ./util/build.sh
|
||||
if [[ -z "${BUILD-}" ]]; then
|
||||
BUILD="$(./depends/config.guess)"
|
||||
fi
|
||||
if [[ -z "${HOST-}" ]]; then
|
||||
HOST="$BUILD"
|
||||
fi
|
||||
|
||||
# Allow users to set arbitrary compile flags. Most users will not need this.
|
||||
if [[ -z "${CONFIGURE_FLAGS-}" ]]; then
|
||||
CONFIGURE_FLAGS=""
|
||||
fi
|
||||
|
||||
if [ "x$*" = 'x--help' ]
|
||||
then
|
||||
cat ./util/dragon.txt
|
||||
cat <<EOF
|
||||
Welcome To The Hush Build System, Here Be Dragons!
|
||||
Usage:
|
||||
$0 --help
|
||||
Show this help message and exit.
|
||||
$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --disable-libs ] [ MAKEARGS... ]
|
||||
Build Hush and most of its transitive dependencies from source. MAKEARGS are applied to both dependencies and Hush itself.
|
||||
If --enable-lcov is passed, Hush is configured to add coverage instrumentation, thus enabling "make cov" to work.
|
||||
If --disable-tests is passed instead, the Hush tests are not built.
|
||||
If --disable-mining is passed, Hush is configured to not build any mining code. It must be passed after the test arguments, if present.
|
||||
It must be passed after the test/mining arguments, if present.
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
# If --enable-lcov is the first argument, enable lcov coverage support:
|
||||
LCOV_ARG=''
|
||||
HARDENING_ARG='--enable-hardening'
|
||||
TEST_ARG=''
|
||||
if [ "x${1:-}" = 'x--enable-lcov' ]
|
||||
then
|
||||
LCOV_ARG='--enable-lcov'
|
||||
HARDENING_ARG='--disable-hardening'
|
||||
shift
|
||||
elif [ "x${1:-}" = 'x--disable-tests' ]
|
||||
then
|
||||
TEST_ARG='--enable-tests=no'
|
||||
shift
|
||||
fi
|
||||
|
||||
# If --disable-mining is the next argument, disable mining code:
|
||||
MINING_ARG=''
|
||||
if [ "x${1:-}" = 'x--disable-mining' ]
|
||||
then
|
||||
MINING_ARG='--enable-mining=no'
|
||||
shift
|
||||
fi
|
||||
|
||||
# Just show the useful info
|
||||
eval "$MAKE" --version | head -n2
|
||||
as --version | head -n1
|
||||
as --version | tail -n1
|
||||
ld -v
|
||||
|
||||
HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1
|
||||
|
||||
./autogen.sh
|
||||
|
||||
CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g -rdynamic'
|
||||
|
||||
# Build CryptoConditions stuff
|
||||
WD=$PWD
|
||||
cd src/cc
|
||||
echo $PWD
|
||||
./makecustom
|
||||
cd $WD
|
||||
|
||||
# Build RandomX
|
||||
cd src/RandomX
|
||||
if [ -d "build" ]
|
||||
then
|
||||
ls -la build/librandomx*
|
||||
else
|
||||
mkdir build && cd build
|
||||
cmake -DARCH=native ..
|
||||
make
|
||||
fi
|
||||
|
||||
cd $WD
|
||||
|
||||
"$MAKE" "$@" V=1
|
||||
Reference in New Issue
Block a user