Merge remote-tracking branch 'zcash/master' into dPoW
This commit is contained in:
52
src/main.cpp
52
src/main.cpp
@@ -16,6 +16,7 @@
|
||||
#include "consensus/validation.h"
|
||||
#include "init.h"
|
||||
#include "merkleblock.h"
|
||||
#include "metrics.h"
|
||||
#include "net.h"
|
||||
#include "pow.h"
|
||||
#include "txdb.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
using namespace std;
|
||||
|
||||
#if defined(NDEBUG)
|
||||
# error "Bitcoin cannot be compiled without assertions."
|
||||
# error "Zcash cannot be compiled without assertions."
|
||||
#endif
|
||||
|
||||
|
||||
@@ -577,7 +578,7 @@ bool AddOrphanTx(const CTransaction& tx, NodeId peer)
|
||||
// have been mined or received.
|
||||
// 10,000 orphans, each of which is at most 5,000 bytes big is
|
||||
// at most 500 megabytes of orphans:
|
||||
unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION);
|
||||
unsigned int sz = tx.GetSerializeSize(SER_NETWORK, tx.nVersion);
|
||||
if (sz > 5000)
|
||||
{
|
||||
LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString());
|
||||
@@ -652,7 +653,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
|
||||
|
||||
bool IsStandardTx(const CTransaction& tx, string& reason)
|
||||
{
|
||||
if (tx.nVersion > CTransaction::CURRENT_VERSION || tx.nVersion < 1) {
|
||||
if (tx.nVersion > CTransaction::MAX_CURRENT_VERSION || tx.nVersion < CTransaction::MIN_CURRENT_VERSION) {
|
||||
reason = "version";
|
||||
return false;
|
||||
}
|
||||
@@ -863,6 +864,11 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
|
||||
bool CheckTransaction(const CTransaction& tx, CValidationState &state)
|
||||
{
|
||||
// Don't count coinbase transactions because mining skews the count
|
||||
if (!tx.IsCoinBase()) {
|
||||
transactionsValidated.increment();
|
||||
}
|
||||
|
||||
if (!CheckTransactionWithoutProofVerification(tx, state)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -881,6 +887,12 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
|
||||
{
|
||||
// Basic checks that don't depend on any context
|
||||
|
||||
// Check transaction version
|
||||
if (tx.nVersion < MIN_TX_VERSION) {
|
||||
return state.DoS(100, error("CheckTransaction(): version too low"),
|
||||
REJECT_INVALID, "bad-txns-version-too-low");
|
||||
}
|
||||
|
||||
// Transactions can contain empty `vin` and `vout` so long as
|
||||
// `vjoinsplit` is non-empty.
|
||||
if (tx.vin.empty() && tx.vjoinsplit.empty())
|
||||
@@ -2006,7 +2018,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
||||
static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
|
||||
|
||||
void ThreadScriptCheck() {
|
||||
RenameThread("bitcoin-scriptch");
|
||||
RenameThread("zcash-scriptch");
|
||||
scriptcheckqueue.Thread();
|
||||
}
|
||||
|
||||
@@ -3003,14 +3015,15 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
|
||||
// Check timestamp
|
||||
if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60)
|
||||
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
|
||||
// Check block version
|
||||
//if (block.nVersion < MIN_BLOCK_VERSION)
|
||||
// return state.DoS(100, error("CheckBlockHeader(): block version too low"),REJECT_INVALID, "version-too-low");
|
||||
|
||||
// Check Equihash solution is valid
|
||||
if ( fCheckPOW && !CheckEquihashSolution(&blockhdr, Params()) )
|
||||
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||
|
||||
// Check proof of work matches claimed amount
|
||||
//printf("from checkblockheader pindex.%p %p\n",pindex,mapBlockIndex[blockhdr.GetHash()]);
|
||||
//if ( pindex == 0 )
|
||||
// pindex = mapBlockIndex[blockhdr.GetHash()];
|
||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,blockhdr.GetHash(), blockhdr.nBits, Params().GetConsensus()) )
|
||||
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
|
||||
@@ -4916,6 +4929,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
// the getaddr message mitigates the attack.
|
||||
else if ((strCommand == "getaddr") && (pfrom->fInbound))
|
||||
{
|
||||
// Only send one GetAddr response per connection to reduce resource waste
|
||||
// and discourage addr stamping of INV announcements.
|
||||
if (pfrom->fSentAddr) {
|
||||
LogPrint("net", "Ignoring repeated \"getaddr\". peer=%d\n", pfrom->id);
|
||||
return true;
|
||||
}
|
||||
pfrom->fSentAddr = true;
|
||||
|
||||
pfrom->vAddrToSend.clear();
|
||||
vector<CAddress> vAddr = addrman.GetAddr();
|
||||
BOOST_FOREACH(const CAddress &addr, vAddr)
|
||||
@@ -5130,15 +5151,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
}
|
||||
}
|
||||
/*else if (strCommand == "komodo")
|
||||
{
|
||||
vector<unsigned char> vData;
|
||||
vRecv >> vData;
|
||||
komodo_checkmsg(pfrom,vData.data(),vData.size());
|
||||
}*/
|
||||
else
|
||||
{
|
||||
LogPrint("net", "Unknown \"%s\" from peer=%d\n", SanitizeString(strCommand),pfrom->id);
|
||||
else if (strCommand == "notfound") {
|
||||
// We do not care about the NOTFOUND message, but logging an Unknown Command
|
||||
// message would be undesirable as we transmit it ourselves.
|
||||
}
|
||||
|
||||
else {
|
||||
// Ignore unknown commands for extensibility
|
||||
LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user