Merge remote-tracking branch 'zcash/master' into dPoW
This commit is contained in:
76
src/main.cpp
76
src/main.cpp
@@ -646,16 +646,6 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extremely large transactions with lots of inputs can cost the network
|
||||
// almost as much to process as they cost the sender in fees, because
|
||||
// computing signature hashes is O(ninputs*txsize). Limiting transactions
|
||||
// to MAX_STANDARD_TX_SIZE mitigates CPU exhaustion attacks.
|
||||
unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION);
|
||||
if (sz >= MAX_STANDARD_TX_SIZE) {
|
||||
reason = "tx-size";
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
{
|
||||
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
|
||||
@@ -873,7 +863,8 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
|
||||
REJECT_INVALID, "bad-txns-vout-empty");
|
||||
|
||||
// Size limits
|
||||
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
|
||||
BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE); // sanity
|
||||
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE)
|
||||
return state.DoS(100, error("CheckTransaction(): size limits failed"),
|
||||
REJECT_INVALID, "bad-txns-oversize");
|
||||
|
||||
@@ -2052,8 +2043,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
// Special case for the genesis block, skipping connection of its transactions
|
||||
// (its coinbase is unspendable)
|
||||
if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
|
||||
if (!fJustCheck)
|
||||
if (!fJustCheck) {
|
||||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
// Before the genesis block, there was an empty tree
|
||||
ZCIncrementalMerkleTree tree;
|
||||
pindex->hashAnchor = tree.root();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2099,6 +2094,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
// Construct the incremental merkle tree at the current
|
||||
// block position,
|
||||
auto old_tree_root = view.GetBestAnchor();
|
||||
// saving the top anchor in the block index as we go.
|
||||
if (!fJustCheck) {
|
||||
pindex->hashAnchor = old_tree_root;
|
||||
}
|
||||
ZCIncrementalMerkleTree tree;
|
||||
// This should never fail: we should always be able to get the root
|
||||
// that is on the tip of our chain
|
||||
@@ -3103,26 +3102,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
}
|
||||
}
|
||||
|
||||
// Coinbase transaction must include an output sending 20% of
|
||||
// the block reward to `FOUNDERS_REWARD_SCRIPT` until the first
|
||||
// subsidy halving block, with exception to the genesis block.
|
||||
/*if ((nHeight > 0) && (nHeight < consensusParams.nSubsidyHalvingInterval)) {
|
||||
bool found = false;
|
||||
|
||||
BOOST_FOREACH(const CTxOut& output, block.vtx[0].vout) {
|
||||
if (output.scriptPubKey == ParseHex(FOUNDERS_REWARD_SCRIPT)) {
|
||||
if (output.nValue == (GetBlockSubsidy(nHeight, consensusParams) / 5)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return state.DoS(100, error("%s: founders reward missing", __func__), REJECT_INVALID, "cb-no-founders-reward");
|
||||
}
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4089,6 +4068,9 @@ string GetWarnings(string strFor)
|
||||
{
|
||||
nPriority = alert.nPriority;
|
||||
strStatusBar = alert.strStatusBar;
|
||||
if (alert.nPriority >= ALERT_PRIORITY_SAFE_MODE) {
|
||||
strRPC = alert.strRPCError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4677,13 +4659,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
bool fMissingInputs = false;
|
||||
CValidationState state;
|
||||
|
||||
pfrom->setAskFor.erase(inv.hash);
|
||||
mapAlreadyAskedFor.erase(inv);
|
||||
|
||||
// Check for recently rejected (and do other quick existence checks)
|
||||
if (AlreadyHave(inv))
|
||||
return true;
|
||||
|
||||
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
|
||||
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
|
||||
{
|
||||
mempool.check(pcoinsTip);
|
||||
RelayTransaction(tx);
|
||||
@@ -4764,13 +4743,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
|
||||
if (pfrom->fWhitelisted) {
|
||||
// Always relay transactions received from whitelisted peers, even
|
||||
// if they were rejected from the mempool, allowing the node to
|
||||
// function as a gateway for nodes hidden behind it.
|
||||
// if they were already in the mempool or rejected from it due
|
||||
// to policy, allowing the node to function as a gateway for
|
||||
// nodes hidden behind it.
|
||||
//
|
||||
// FIXME: This includes invalid transactions, which means a
|
||||
// whitelisted peer could get us banned! We may want to change
|
||||
// that.
|
||||
RelayTransaction(tx);
|
||||
// Never relay transactions that we would assign a non-zero DoS
|
||||
// score for, as we expect peers to do the same with us in that
|
||||
// case.
|
||||
int nDoS = 0;
|
||||
if (!state.IsInvalid(nDoS) || nDoS == 0) {
|
||||
LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", tx.GetHash().ToString(), pfrom->id);
|
||||
RelayTransaction(tx);
|
||||
} else {
|
||||
LogPrintf("Not relaying invalid transaction %s from whitelisted peer=%d (%s (code %d))\n",
|
||||
tx.GetHash().ToString(), pfrom->id, state.GetRejectReason(), state.GetRejectCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
int nDoS = 0;
|
||||
@@ -5475,6 +5462,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
pto->PushMessage("getdata", vGetData);
|
||||
vGetData.clear();
|
||||
}
|
||||
} else {
|
||||
//If we're not going to ask, don't expect a response.
|
||||
pto->setAskFor.erase(inv.hash);
|
||||
}
|
||||
pto->mapAskFor.erase(pto->mapAskFor.begin());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user