Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Verify all incoming txs unless too big or too much hashing #8593
Conversation
|
Added: Not verify if witness_stripped_size * accurately_counted_base_sigops > 10MB |
jl2012
changed the title from
Verify all incoming txs unless the witness stripped size is >100kB to Verify all incoming txs unless too big or too much hashing
Aug 28, 2016
jonasschnelli
added the
Mempool
label
Aug 29, 2016
jonasschnelli
added this to the
0.13.1
milestone
Aug 29, 2016
instagibbs
commented on the diff
Aug 29, 2016
| @@ -30,6 +30,8 @@ static const unsigned int MAX_STANDARD_TX_SIGOPS_COST = MAX_BLOCK_SIGOPS_COST/5; | ||
| static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300; | ||
| /** Default for -bytespersigop */ | ||
| static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20; | ||
| +/** Maximum amount of estimated hashing in base CHECKSIG operations */ |
|
|
instagibbs
commented on the diff
Aug 29, 2016
| @@ -153,3 +153,8 @@ int64_t GetTransactionWeight(const CTransaction& tx) | ||
| { | ||
| return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * (WITNESS_SCALE_FACTOR -1) + ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); | ||
| } | ||
| + | ||
| +int64_t GetWitnessStrippedTransactionWeight(const CTransaction& tx) | ||
| +{ | ||
| + return ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR; | ||
| +} |
|
|
instagibbs
commented on the diff
Aug 29, 2016
| + | ||
| + // Check against previous transactions | ||
| + if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true)) { | ||
| + // SCRIPT_VERIFY_CLEANSTACK requires SCRIPT_VERIFY_WITNESS, so we | ||
| + // need to turn both off, and compare against just turning off CLEANSTACK | ||
| + // to see if the failure is specifically due to witness validation. | ||
| + if (CheckInputs(tx, state, view, true, scriptVerifyFlags & ~(SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_CLEANSTACK), true) && | ||
| + !CheckInputs(tx, state, view, true, scriptVerifyFlags & ~SCRIPT_VERIFY_CLEANSTACK, true)) { | ||
| + // Only the witness is wrong, so the transaction itself may be fine. | ||
| + state.SetCorruptionPossible(); | ||
| + } | ||
| + return false; | ||
| + } | ||
| + | ||
| + // Now we know the witness is valid. We could check the size with witness | ||
| + if (fRequireStandard && GetTransactionWeight(tx) >= MAX_STANDARD_TX_WEIGHT) |
instagibbs
Member
|
jonasschnelli
added the
Needs backport
label
Aug 30, 2016
|
needs rebase |
|
rebased. @sipa has a better estimation of sighash size by removing the scriptSig |
laanwj
removed this from the
0.13.1
milestone
Sep 1, 2016
laanwj
removed the
Needs backport
label
Sep 1, 2016
|
Untagging this for 0.13.1 and tagging #8499 instead, this has been deemed too large a change for a minor version in today's meeting (2016-09-01). |
This was referenced Sep 13, 2016
|
This need a decent rebase. Do we still want this? I suppose we currently rely on "good" copies of txn which have been malleated in this way making it to us eventually? Is that good enough? |
jl2012 commentedAug 25, 2016
This should obsolete #8499