mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Make transactions larger than 100K non-standard
Extremely large transactions with lots of inputs can cost the network almost as much to process as they cost the sender in fees. We would never create transactions larger than 100K big; this change makes transactions larger than 100K non-standard, so they are not relayed/mined by default. This is most important for miners that might create blocks larger than 250K big, who could be vulnerable to a make-your-blocks-so-expensive-to-verify-they-get-orphaned attack.
This commit is contained in:
parent
353b7f4a9c
commit
41e1a0d766
3 changed files with 11 additions and 1 deletions
|
|
@ -362,6 +362,14 @@ bool CTransaction::IsStandard() const
|
|||
if (!IsFinal())
|
||||
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 = this->GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION);
|
||||
if (sz >= MAX_STANDARD_TX_SIZE)
|
||||
return false;
|
||||
|
||||
BOOST_FOREACH(const CTxIn& txin, vin)
|
||||
{
|
||||
// Biggest 'standard' txin is a 3-signature 3-of-3 CHECKMULTISIG
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue