-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Define, check, and use MIN_TRANSACTION_SIZE as a const #9621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ static const unsigned int MAX_BLOCK_WEIGHT = 4000000; | |
| static const unsigned int MAX_BLOCK_BASE_SIZE = 1000000; | ||
| /** The maximum allowed number of signature check operations in a block (network rule) */ | ||
| static const int64_t MAX_BLOCK_SIGOPS_COST = 80000; | ||
| /** Smallest possible transaction size */ | ||
| static const unsigned int MIN_TRANSACTION_SIZE = 60; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment to explain that this is not an independent consensus rule, but just the shortest otherwise valid serialized transaction? |
||
| /** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ | ||
| static const int COINBASE_MATURITY = 100; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -693,6 +693,16 @@ bool InitSanityCheck(void) | |
| if (!glibc_sanity_test() || !glibcxx_sanity_test()) | ||
| return false; | ||
|
|
||
| CMutableTransaction tx; | ||
| tx.vin.resize(1); | ||
| tx.vout.resize(1); | ||
| size_t nMinTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); | ||
| size_t nMinStrippedTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS); | ||
| if (MIN_TRANSACTION_SIZE != nMinTxSize || MIN_TRANSACTION_SIZE != nMinStrippedTxSize) { | ||
| InitError(strprintf("MIN_TRANSACTION_SIZE verification failure: const %u vs min=%u vs minstripped=%u", MIN_TRANSACTION_SIZE, nMinTxSize, nMinStrippedTxSize)); | ||
| return false; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For clarity, why not put this in an individual function called here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for a comment here. |
||
|
|
||
| return true; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is technically incorrect...someone relaying you a valid-to-deserialize and valid-work block which contained a 10-byte transaction would get banned, despite the BIP pretty clearly indicating they should be allowed to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. So compact blocks effectively force a specific deserialisation implementation into a consensus-critical status? (Or was it already for some reason I'm not thinking of?)