Skip to content

Commit

Permalink
Merge pull request jl777#263 from VerusCoin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Asherda authored Dec 22, 2019
2 parents fd371c1 + c65c1c4 commit a682ef2
Show file tree
Hide file tree
Showing 25 changed files with 229 additions and 151 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.6.0-5
VERSION: 0.6.0-6
VERUS_CLI_ARM64_LINUX: Verus-CLI-Linux-v${VERSION}-arm64.tar.gz
VERUS_CLI_LINUX: Verus-CLI-Linux-v${VERSION}-amd64.tar.gz
VERUS_CLI_WINDOWS: Verus-CLI-Windows-v${VERSION}.zip
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.6.0-5
## VerusCoin version 0.6.0-6

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.6.0-5
VerusCoin Command Line Tools v0.6.0-6

Contents:
verusd - VerusCoin 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.6.0-5
VerusCoin Command Line Tools v0.6.0-6
Contents:
verusd - VerusCoin daemon.
verus - VerusCoin 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.6.0-5
VerusCoin Command Line Tools v0.6.0-6
Contents:
verusd.exe - VerusCoin daemon
verus.exe - VerusCoin command line utility
Expand Down
6 changes: 5 additions & 1 deletion src/cc/CCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScrip
{
UpdateTransaction(mtx,vini,sigdata);
return(true);
} else fprintf(stderr,"signing error for SignTx vini.%d %.8f\n",vini,(double)utxovalue/COIN);
} else
{
fprintf(stderr,"signing error for SignTx vini.%d %.8f\n",vini,(double)utxovalue/COIN);
return(false);
}
#else
return(false);
#endif
Expand Down
1 change: 1 addition & 0 deletions src/cc/CCutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ CC* GetCryptoCondition(CScript const& scriptSig)
std::vector<unsigned char> ffbin;
if (scriptSig.GetOp(pc, opcode, ffbin))
return cc_readFulfillmentBinary((uint8_t*)ffbin.data(), ffbin.size()-1);
return nullptr;
}

bool IsCCInput(CScript const& scriptSig)
Expand Down
4 changes: 3 additions & 1 deletion src/cc/gateways.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ string oracles
*/


int32_t GatewaysAddQueue(std::string coin,uint256 txid,CScript scriptPubKey,int64_t nValue)
/*
int32_t GatewaysAddQueue(std::string coin,uint256 txid,CScript scriptPubKey,int64_t nValue) // commented, bcz unused
{
char destaddr[64],str[65];
Getscriptaddress(destaddr,scriptPubKey);
fprintf(stderr,"GatewaysAddQueue: %s %s %s %.8f\n",coin.c_str(),uint256_str(str,txid),destaddr,(double)nValue/COIN);
}
*/

// start of consensus code

Expand Down
1 change: 1 addition & 0 deletions src/cc/lotto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t tic
mtx.vout.push_back(MakeCC1vout(EVAL_LOTTO,funding,lottopk));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_LOTTO << (uint8_t)'F' << sbits << ticketsize << odds << firstheight << period << hentropy)));
}
return "";
}

std::string LottoTicket(uint64_t txfee,uint256 lottoid,int64_t numtickets)
Expand Down
1 change: 1 addition & 0 deletions src/cc/oracles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ int64_t correlate_price(int32_t height,int64_t *prices,int32_t n)
for (i=0; i<n; i++)
fprintf(stderr,"%llu ",(long long)prices[i]);
fprintf(stderr,"-> %llu ht.%d\n",(long long)price,height);
return (int64_t)price;
}

int64_t OracleCorrelatedPrice(int32_t height,std::vector <int64_t> origprices)
Expand Down
2 changes: 1 addition & 1 deletion src/cheatcatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool CCheatList::IsUTXOInList(COutPoint _utxo, uint32_t height)
return false;
}

bool CCheatList::Add(const CTxHolder &txh)
void CCheatList::Add(const CTxHolder &txh)
{
if (Params().GetConsensus().NetworkUpgradeActive(txh.height, Consensus::UPGRADE_SAPLING))
{
Expand Down
2 changes: 1 addition & 1 deletion src/cheatcatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class CCheatList
bool IsHeightOrGreaterInList(uint32_t height);

// add a potential cheat transaction to the list. we do this for all stake transactions from orphaned stakes
bool Add(const CTxHolder &txh);
void Add(const CTxHolder &txh);

// remove a transaction from the the list
void Remove(const CTxHolder &txh);
Expand Down
2 changes: 1 addition & 1 deletion src/deprecation.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Deprecation policy:
// * Shut down 20 weeks' worth of blocks after the estimated release block height.
// * A warning is shown during the 2 weeks' worth of blocks prior to shut down.
static const int APPROX_RELEASE_HEIGHT = 803400;
static const int APPROX_RELEASE_HEIGHT = 810000;
static const int WEEKS_UNTIL_DEPRECATION = 20;
static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + (WEEKS_UNTIL_DEPRECATION * 7 * 60 * 24);

Expand Down
1 change: 1 addition & 0 deletions src/keystore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ bool CBasicKeyStore::GetIdentity(const CIdentityID &idID, std::pair<CIdentityMap
{
return false;
}

itEnd--;
CIdentityMapKey foundKey(itEnd->first);
if (foundKey.idID != idID)
Expand Down
2 changes: 1 addition & 1 deletion src/komodo_bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ int8_t komodo_segid(int32_t nocache,int32_t height)
return(segid);
}

int32_t komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n)
void komodo_segids(uint8_t *hashbuf,int32_t height,int32_t n)
{
static uint8_t prevhashbuf[100]; static int32_t prevheight;
int32_t i;
Expand Down
4 changes: 2 additions & 2 deletions src/komodo_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1396,8 +1396,8 @@ void komodo_statefname(char *fname,char *symbol,char *str)

void komodo_configfile(char *symbol,uint16_t rpcport)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
static char myusername[512],mypassword[7168];
FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[7168]; uint32_t crc,r,r2,i;
if ( symbol != 0 && rpcport != 0 )
{
r = (uint32_t)time(NULL);
Expand Down
57 changes: 52 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4138,6 +4138,18 @@ bool static DisconnectTip(CValidationState &state, const CChainParams& chainpara
CBlock block;
if (!ReadBlockFromDisk(block, pindexDelete, chainparams.GetConsensus(), 1))
return AbortNode(state, "Failed to read block");

// do not disconnect a Komodo notarized tip
{
int32_t prevMoMheight; uint256 notarizedhash,txid;
komodo_notarized_height(&prevMoMheight, &notarizedhash, &txid);
if ( block.GetHash() == notarizedhash )
{
fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->GetHeight());
return(false);
}
}

// Apply the block atomically to the chain state.
uint256 sproutAnchorBeforeDisconnect = pcoinsTip->GetBestAnchor(SPROUT);
uint256 saplingAnchorBeforeDisconnect = pcoinsTip->GetBestAnchor(SAPLING);
Expand Down Expand Up @@ -4405,6 +4417,45 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
const CBlockIndex *pindexOldTip = chainActive.Tip();
const CBlockIndex *pindexFork = chainActive.FindFork(pindexMostWork);

// stop trying to reorg if the reorged chain is before last notarized height.
// stay on the same chain tip!
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( pindexFork != 0 && pindexOldTip->GetHeight() > notarizedht && pindexFork->GetHeight() < notarizedht )
{
LogPrintf("pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht);
// *** DEBUG ***
if (1)
{
const CBlockIndex *pindexLastNotarized = mapBlockIndex[notarizedhash];
auto msg = "- " + strprintf(_("Current tip : %s, height %d, work %s"),
pindexOldTip->phashBlock->GetHex(), pindexOldTip->GetHeight(), pindexOldTip->chainPower.chainWork.GetHex()) + "\n" +
"- " + strprintf(_("New tip : %s, height %d, work %s"),
pindexMostWork->phashBlock->GetHex(), pindexMostWork->GetHeight(), pindexMostWork->chainPower.chainWork.GetHex()) + "\n" +
"- " + strprintf(_("Fork point : %s, height %d"),
pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n" +
"- " + strprintf(_("Last ntrzd : %s, height %d"),
pindexLastNotarized->phashBlock->GetHex(), pindexLastNotarized->GetHeight());
LogPrintf("[ Debug ]\n%s\n",msg);

int nHeight = pindexFork ? pindexFork->GetHeight() : -1;
int nTargetHeight = std::min(nHeight + 32, pindexMostWork->GetHeight());

LogPrintf("[ Debug ] nHeight = %d, nTargetHeight = %d\n", nHeight, nTargetHeight);

CBlockIndex *pindexIter = pindexMostWork->GetAncestor(nTargetHeight);
while (pindexIter && pindexIter->GetHeight() != nHeight) {
LogPrintf("[ Debug -> New blocks list ] %s, height %d\n", pindexIter->phashBlock->GetHex(), pindexIter->GetHeight());
pindexIter = pindexIter->pprev;
}
}

CValidationState tmpstate;
InvalidateBlock(tmpstate, Params(), pindexMostWork); // trying to invalidate longest chain, which tried to reorg notarized chain (in case of fork point below last notarized block)
return state.DoS(100, error("ActivateBestChainStep(): pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht),
REJECT_INVALID, "past-notarized-height");
}

// - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks.
// - If pindexMostWork is in a chain that doesn't have the same genesis block as our chain,
// then pindexFork will be null, and we would need to remove the entire chain including
Expand Down Expand Up @@ -5182,12 +5233,8 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C

if (!success)
{
// remove coinbase and anything that depended on it sooner, rather than later, if failure
// remove coinbase and anything that depended on it sooner, rather than later
RemoveCoinbaseFromMemPool(block);
} else if (ptx && fCheckTxInputs)
{
// TODO:PBAAS - this may be unnecessary (maybe even leave a straggling tx in the wallet) sync should happen in connecttip, verify whether this can be removed or not
SyncWithWallets(*ptx, &block);
}
return success;
}
Expand Down
10 changes: 10 additions & 0 deletions src/mmr.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ class CChunkedLayer
{
return nodes[idx >> CHUNK_SHIFT][idx & chunkMask()];
}
else
{
std::__throw_length_error("CChunkedLayer [] index out of range");
return NODE_TYPE();
}
}

void push_back(NODE_TYPE node)
Expand Down Expand Up @@ -300,6 +305,11 @@ class COverlayNodeLayer
{
return nodeSource->GetMMRNode(idx);
}
else
{
std::__throw_length_error("COverlayNodeLayer [] index out of range");
return NODE_TYPE();
}
}

// node type must be moveable just to be passed here, but the default overlay has no control over the underlying storage
Expand Down
13 changes: 11 additions & 2 deletions src/pbaas/pbaas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ bool ValidateCrossChainExport(struct CCcontract_info *cp, Eval* eval, const CTra

bool IsCrossChainExportInput(const CScript &scriptSig)
{
return true;
}

// used to validate import of coins from one chain to another. if they are not native and are supported,
Expand All @@ -109,6 +110,7 @@ bool ValidateCrossChainImport(struct CCcontract_info *cp, Eval* eval, const CTra
}
bool IsCrossChainImportInput(const CScript &scriptSig)
{
return true;
}

// used to validate a specific service reward based on the spending transaction
Expand All @@ -122,6 +124,7 @@ bool ValidateServiceReward(struct CCcontract_info *cp, Eval* eval, const CTransa
}
bool IsServiceRewardInput(const CScript &scriptSig)
{
return true;
}

// used as a proxy token output for a reserve currency on its fractional reserve chain
Expand All @@ -131,6 +134,7 @@ bool ValidateReserveOutput(struct CCcontract_info *cp, Eval* eval, const CTransa
}
bool IsReserveOutputInput(const CScript &scriptSig)
{
return true;
}

bool ValidateReserveTransfer(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn, bool fulfilled)
Expand All @@ -139,6 +143,7 @@ bool ValidateReserveTransfer(struct CCcontract_info *cp, Eval* eval, const CTran
}
bool IsReserveTransferInput(const CScript &scriptSig)
{
return true;
}

bool ValidateReserveDeposit(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn, bool fulfilled)
Expand All @@ -147,6 +152,7 @@ bool ValidateReserveDeposit(struct CCcontract_info *cp, Eval* eval, const CTrans
}
bool IsReserveDepositInput(const CScript &scriptSig)
{
return true;
}

bool ValidateCurrencyState(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn, bool fulfilled)
Expand All @@ -155,6 +161,7 @@ bool ValidateCurrencyState(struct CCcontract_info *cp, Eval* eval, const CTransa
}
bool IsCurrencyStateInput(const CScript &scriptSig)
{
return true;
}

// used to convert a fractional reserve currency into its reserve and back
Expand All @@ -164,6 +171,7 @@ bool ValidateReserveExchange(struct CCcontract_info *cp, Eval* eval, const CTran
}
bool IsReserveExchangeInput(const CScript &scriptSig)
{
return true;
}


Expand All @@ -180,6 +188,7 @@ bool ValidateOpretProof(CScript &opRet, COpRetProof &orProof)
{
// enumerate through the objects and validate that they are objects of the expected type that hash
// to the value expected. return true if so
return true;
}

int8_t ObjTypeCode(const CBlockHeader &obj)
Expand Down Expand Up @@ -786,7 +795,7 @@ bool CConnectedChains::RemoveMergedBlock(uint160 chainID)
}

// remove merge mined chains added and not updated since a specific time
uint32_t CConnectedChains::PruneOldChains(uint32_t pruneBefore)
void CConnectedChains::PruneOldChains(uint32_t pruneBefore)
{
vector<uint160> toRemove;

Expand Down Expand Up @@ -858,7 +867,7 @@ CPBaaSMergeMinedChainData *CConnectedChains::GetChainInfo(uint160 chainID)
}
}

bool CConnectedChains::QueueNewBlockHeader(CBlockHeader &bh)
void CConnectedChains::QueueNewBlockHeader(CBlockHeader &bh)
{
//printf("QueueNewBlockHeader %s\n", bh.GetHash().GetHex().c_str());
{
Expand Down
4 changes: 2 additions & 2 deletions src/pbaas/pbaas.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,13 @@ class CConnectedChains
static void SubmissionThreadStub();
std::vector<std::pair<std::string, UniValue>> SubmitQualifiedBlocks();

bool QueueNewBlockHeader(CBlockHeader &bh);
void QueueNewBlockHeader(CBlockHeader &bh);
void QueueEarnedNotarization(CBlock &blk, int32_t txIndex, int32_t height);

bool AddMergedBlock(CPBaaSMergeMinedChainData &blkData);
bool RemoveMergedBlock(uint160 chainID);
bool GetChainInfo(uint160 chainID, CRPCChainData &rpcChainData);
uint32_t PruneOldChains(uint32_t pruneBefore);
void PruneOldChains(uint32_t pruneBefore);
uint32_t CombineBlocks(CBlockHeader &bh);

// returns false if destinations are empty or first is not either pubkey or pubkeyhash
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/crosschain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp)

UniValue crosschainproof(const UniValue& params, bool fHelp)
{

return NullUniValue;
}


Expand Down
8 changes: 3 additions & 5 deletions src/rpc/pbaasrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,7 @@ UniValue listreservetransactions(const UniValue& params, bool fHelp)
);
}
// lists all transactions in a wallet that are
return NullUniValue;
}

CCoinbaseCurrencyState GetInitialCurrencyState(CPBaaSChainDefinition &chainDef, int32_t definitionHeight)
Expand Down Expand Up @@ -4876,10 +4877,7 @@ UniValue getidentity(const UniValue& params, bool fHelp)
}
}

if (!found)
{
identity = CIdentity::LookupIdentity(CIdentityID(GetDestinationID(idID)), 0, &height, &idTxIn);
}
identity = CIdentity::LookupIdentity(CIdentityID(GetDestinationID(idID)), 0, &height, &idTxIn);

UniValue ret(UniValue::VOBJ);

Expand All @@ -4897,7 +4895,7 @@ UniValue getidentity(const UniValue& params, bool fHelp)
}
else
{
return NullUniValue;
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Identity not found");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ static const int MEMPOOL_GD_VERSION = 60002;
static const int NO_BLOOM_VERSION = 170004;

#define KOMODO_VERSION "0.2.1"
#define VERUS_VERSION "0.6.0-5"
#define VERUS_VERSION "0.6.0-6"

#endif // BITCOIN_VERSION_H
Loading

0 comments on commit a682ef2

Please sign in to comment.