Skip to content

Commit

Permalink
Merge pull request #212 from VerusCoin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Asherda committed Feb 3, 2019
2 parents 2860ece + 513ed67 commit d5b301e
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stages:
####START#### PROJECT LEVEL VARIABLES ####START####
########################################################################################################################
variables:
VERSION: 0.5.5
VERSION: 0.5.5b
VERUS_CLI_LINUX: Verus-CLI-Linux-v${VERSION}.tar.gz
VERUS_CLI_WINDOWS: Verus-CLI-Windows-v${VERSION}.zip
VERUS_CLI_MACOS: Verus-CLI-MacOS-v${VERSION}.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## VerusCoin version 0.5.5 with VerusHash 2.0
## VerusCoin version 0.5.5b with VerusHash 2.0

Arguably the world's most advanced technology, zero knowledge privacy-centric blockchain, Verus Coin brings Sapling performance and zero knowledge features to an intelligent system with interchain smart contracts and a completely original, combined proof of stake/proof of work consensus algorithm that solves the nothing at stake problem. With this and its approach towards CPU mining and ASICs, Verus Coin strives to be one of the most naturally decentralizing and attack resistant blockchains in existence.

Expand Down
2 changes: 1 addition & 1 deletion doc/man/verus-cli/linux/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VerusCoin Command Line Tools v0.5.5
VerusCoin Command Line Tools v0.5.5b

Contents:
komodod - VerusCoin's enhanced Komodo daemon
Expand Down
2 changes: 1 addition & 1 deletion doc/man/verus-cli/mac/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VerusCoin Command Line Tools v0.5.5
VerusCoin Command Line Tools v0.5.5b
Contents:
komodod - VerusCoin's enhanced Komodo daemon.
komodo-cli - VerusCoin's enhanced Komodo command line utility.
Expand Down
2 changes: 1 addition & 1 deletion doc/man/verus-cli/windows/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VerusCoin Command Line Tools v0.5.5
VerusCoin Command Line Tools v0.5.5b
Contents:
komodod.exe - VerusCoin's enhanced Komodo daemon
komodo-cli.exe - VerusCoin's Komodo command line utility
Expand Down
12 changes: 8 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,11 +1168,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
CBlockHeader::SetVerusV2Hash();
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
CConstVerusSolutionVector::activationHeight.SetActivationHeight(1, 310000);
CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV2, 310000);
}
else
{
CConstVerusSolutionVector::activationHeight.SetActivationHeight(1, 1);
CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV2, 1);
CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV3, 1);
}
}

Expand Down Expand Up @@ -1878,16 +1879,19 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
StartNode(threadGroup, scheduler);

VERUS_CHEATCATCHER = GetArg("-cheatcatcher", "");
bool gen = GetBoolArg("-gen", false);

#ifdef ENABLE_MINING
// Generate coins in the background
#ifdef ENABLE_WALLET
VERUS_MINTBLOCKS = GetBoolArg("-mint", false);
mapArgs["-gen"] = gen || VERUS_MINTBLOCKS ? "1" : "0";
mapArgs["-genproclimit"] = itostr(GetArg("-genproclimit", gen ? -1 : 0));

if (pwalletMain || !GetArg("-mineraddress", "").empty())
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0));
GenerateBitcoins(gen || VERUS_MINTBLOCKS, pwalletMain, GetArg("-genproclimit", gen ? -1 : 0));
#else
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 0));
GenerateBitcoins(gen, GetArg("-genproclimit", -1));
#endif
#endif

Expand Down
9 changes: 8 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4976,7 +4976,14 @@ CBlockIndex *komodo_ensure(CBlock *pblock, uint256 hash)
CBlockIndex *oldkomodo_ensure(CBlock *pblock, uint256 hash)
{
CBlockIndex *pindex=0,*previndex=0;
if ( (pindex = mapBlockIndex[hash]) == 0 )

BlockMap::iterator mi = mapBlockIndex.find(hash);
if (mi != mapBlockIndex.end())
{
pindex = (*mi).second;
}

if ( pindex == 0 )
{
pindex = new CBlockIndex();
if (!pindex)
Expand Down
31 changes: 18 additions & 13 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1994,24 +1994,29 @@ void static BitcoinMiner()
}
}

VERUS_MINTBLOCKS = (VERUS_MINTBLOCKS && pwallet != NULL && ASSETCHAINS_LWMAPOS != 0);
VERUS_MINTBLOCKS = (VERUS_MINTBLOCKS && ASSETCHAINS_LWMAPOS != 0);

if ((fGenerate == true || VERUS_MINTBLOCKS) && VERUS_CHEATCATCHER.size() > 0)
if (fGenerate == true || VERUS_MINTBLOCKS)
{
if (cheatCatcher == boost::none)
{
LogPrintf("ERROR: -cheatcatcher parameter is invalid Sapling payment address\n");
fprintf(stderr, "-cheatcatcher parameter is invalid Sapling payment address\n");
}
else
mapArgs["-gen"] = "1";

if (VERUS_CHEATCATCHER.size() > 0)
{
LogPrintf("StakeGuard searching for double stakes on %s\n", VERUS_CHEATCATCHER.c_str());
fprintf(stderr, "StakeGuard searching for double stakes on %s\n", VERUS_CHEATCATCHER.c_str());
if (cheatCatcher == boost::none)
{
LogPrintf("ERROR: -cheatcatcher parameter is invalid Sapling payment address\n");
fprintf(stderr, "-cheatcatcher parameter is invalid Sapling payment address\n");
}
else
{
LogPrintf("StakeGuard searching for double stakes on %s\n", VERUS_CHEATCATCHER.c_str());
fprintf(stderr, "StakeGuard searching for double stakes on %s\n", VERUS_CHEATCATCHER.c_str());
}
}
}

static boost::thread_group* minerThreads = NULL;

if (nThreads < 0)
nThreads = GetNumCores();

Expand All @@ -2026,13 +2031,13 @@ void static BitcoinMiner()
if ( nThreads == 0 && ASSETCHAINS_STAKED )
nThreads = 1;

if (!fGenerate && !VERUS_MINTBLOCKS)
if (!fGenerate)
return;

minerThreads = new boost::thread_group();

#ifdef ENABLE_WALLET
if (VERUS_MINTBLOCKS)
if (VERUS_MINTBLOCKS && pwallet != NULL)
{
minerThreads->create_thread(boost::bind(&VerusStaker, pwallet));
}
Expand Down
19 changes: 18 additions & 1 deletion src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,23 @@ class CBlockHeader
return 0;
}

// return a vector of bytes that contains the internal data for this solution vector
void GetExtraData(std::vector<unsigned char> &dataVec)
{
CVerusSolutionVector(nSolution).GetExtraData(dataVec);
}

// set the extra data with a pointer to bytes and length
bool SetExtraData(const unsigned char *pbegin, uint32_t len)
{
return CVerusSolutionVector(nSolution).SetExtraData(pbegin, len);
}

void ResizeExtraData(uint32_t newSize)
{
CVerusSolutionVector(nSolution).ResizeExtraData(newSize);
}

// returns -1 on failure, upon failure, pbbh is undefined and likely corrupted
int32_t GetPBaaSHeader(CPBaaSBlockHeader &pbh, const uint256 &cID)
{
Expand Down Expand Up @@ -400,7 +417,7 @@ class CBlockHeader

bool IsVerusPOSBlock() const
{
return nNonce.IsPOSNonce(nVersion);
return nNonce.IsPOSNonce(nVersion) && GetVerusPOSTarget() != 0;
}

void SetVerusPOSTarget(uint32_t nBits)
Expand Down
14 changes: 13 additions & 1 deletion src/primitives/solutiondata.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ class CVerusSolutionVector
return len < 0 ? 0 : (uint32_t)len;
}

uint32_t GetRequiredSolutionSize(uint32_t extraDataLen)
{
// round up to nearest 32 bytes
return extraDataLen + OVERHEAD_SIZE + (32 - ((extraDataLen + OVERHEAD_SIZE + HEADER_BASESIZE) % 32));
}

void ResizeExtraData(uint32_t newSize)
{
vch.resize(GetRequiredSolutionSize(newSize));
}

// return a vector of bytes that contains the internal data for this solution vector
unsigned char *ExtraDataPtr()
{
Expand All @@ -228,7 +239,7 @@ class CVerusSolutionVector
}

// return a vector of bytes that contains the internal data for this solution vector
void GetExtraData(std::vector<unsigned char *> &dataVec)
void GetExtraData(std::vector<unsigned char> &dataVec)
{
int len = ExtraDataLen();

Expand Down Expand Up @@ -260,6 +271,7 @@ class CVerusSolutionVector
else
{
std::memcpy(&(vch.data()[4]), pbegin, len);
return true;
}
}
};
Expand Down
23 changes: 17 additions & 6 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,23 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
if (params.size() > 0)
fGenerate = params[0].get_bool();

int nGenProcLimit = GetArg("-genproclimit", -1);;
int nGenProcLimit = GetArg("-genproclimit", -1);
int gpl = -1;
if (params.size() > 1)
{
nGenProcLimit = params[1].get_int();
//if (nGenProcLimit == 0)
// fGenerate = false;
gpl = params[1].get_int();
if (gpl != 0)
{
nGenProcLimit = gpl;
}
}
else
{
VERUS_MINTBLOCKS = 1;
KOMODO_MININGTHREADS = -1;
}

if (fGenerate && !nGenProcLimit && params.size() > 1)
if (fGenerate && !gpl && params.size() > 1)
{
VERUS_MINTBLOCKS = 1;
}
Expand All @@ -349,7 +357,10 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
VERUS_MINTBLOCKS = 0;
KOMODO_MININGTHREADS = 0;
}
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
else
{
KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
}

mapArgs["-gen"] = (fGenerate ? "1" : "0");
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ uint32_t komodo_segid32(char *coinaddr);
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
#define KOMODO_VERSION "0.2.1"
#define VERUS_VERSION "0.5.5"
#define VERUS_VERSION "0.5.5b"
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAINS_CC;
extern uint32_t ASSETCHAINS_MAGIC;
Expand Down
40 changes: 39 additions & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,25 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
stakeSource = *(pwinner->tx);
voutNum = pwinner->i;
pBlock->nNonce = curNonce;

if (CConstVerusSolutionVector::activationHeight.ActiveVersion(nHeight) > CActivationHeight::SOLUTION_VERUSV2)
{
CDataStream txStream = CDataStream(SER_NETWORK, PROTOCOL_VERSION);
std::vector<unsigned char> exData;

// store entire source transaction in header
txStream << *(CMerkleTx *)pwinner->tx;

// make the extra data exactly the size of the source merkletx
pBlock->nSolution.resize((pBlock->nSolution.size() + (txStream.end() - txStream.begin())) - exData.size());
pBlock->GetExtraData(exData);

std::vector<unsigned char> stx = std::vector<unsigned char>(txStream.begin(), txStream.end());
printf("\nFound Stake transaction... MerkleTx serialized size == %d\n", stx.size());
memcpy(exData.data(), stx.data(), stx.size());

pBlock->SetExtraData(exData.data(), exData.size());
}
return true;
}
}
Expand All @@ -1383,7 +1402,7 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe

bnTarget = lwmaGetNextPOSRequired(tipindex, Params().GetConsensus());

if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, tipindex->GetHeight() + 1, bnTarget) ||
if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, stakeHeight, bnTarget) ||
!Solver(stakeSource.vout[voutNum].scriptPubKey, whichType, vSolutions))
{
LogPrintf("Searched for eligible staking transactions, no winners found\n");
Expand Down Expand Up @@ -1482,6 +1501,25 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
siglen = sigdata.scriptSig.size();
for (int i=0; i<siglen; i++)
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
if (CConstVerusSolutionVector::activationHeight.ActiveVersion(stakeHeight) > CActivationHeight::SOLUTION_VERUSV2)
{
std::vector<unsigned char> exData;
pBlock->GetExtraData(exData);
CDataStream txStream = CDataStream(exData, SER_NETWORK, PROTOCOL_VERSION);

// add spend transaction to header
txStream << CTransaction(txNew);

// make the extra data at least the size of the stream
pBlock->ResizeExtraData(txStream.end() - txStream.begin());
pBlock->GetExtraData(exData);

std::vector<unsigned char> stx = std::vector<unsigned char>(txStream.begin(), txStream.end());
printf("\nFound Stake transaction... MerkleTx serialized size == %d\n", stx.size());
memcpy(exData.data(), stx.data(), stx.size());

pBlock->SetExtraData(exData.data(), exData.size());
}
}
return(siglen);
}
Expand Down

0 comments on commit d5b301e

Please sign in to comment.