You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The size and vsize of transactions, and the size and strippedsize of blocks are displayed identically even with witness transactions. When PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS is passed to GetSerializeSize, it has no effect because it is incorrectly passed as the nType and not the nVersion.
This is because nType was removed in eb696d7 but re-added in 195b0fa without reverting the function calls to include SER_NETWORK.
As witness bytes are no longer discounted due to this bug, the code should be altered to remove references to the WITNESS_SCALE_FACTOR. The nType in CSizeComputer and GetSerializeSize should be removed and all calls to these should be fixed.
My proposed fix:
Ensure there is a test to require that blocks with and without witness data cannot exceed 1MB (current and desired behaviour since this bug).
Change CSizeComputer to match how it was originally intended in commit eb696d7 and currently is in Bitcoin with nType removed.
Remove WITNESS_SCALE_FACTOR, MAX_BLOCK_WEIGHT and MAX_BLOCK_SERIALIZED_SIZE.
Revert to using MAX_BLOCK_SIZE as 1000000. Block size checks should be done against that.
MIN_TRANSACTION_WEIGHT and MIN_SERIALIZABLE_TRANSACTION_WEIGHT should reference size and not weight.
Remove GetTransactionWeight and use GetSerializeSize without SERIALIZE_TRANSACTION_NO_WITNESS for both size, weight and vsize.
Any other references to weight and vsize should be removed or made equivalent to size.
strippedsize in blocks should use SERIALIZE_TRANSACTION_NO_WITNESS. stippedsize, weight and vsize are only kept for RPC compatibility.
The text was updated successfully, but these errors were encountered:
In Bitcoin Core 26.0, nType has been removed in many more serialization-related classes (BufferedFile, CVectorWriter, CAutoFile...), so in order to keep maximum compatibility with the Bitcoin codebase, its removal has to be considered.
The
size
andvsize
of transactions, and thesize
andstrippedsize
of blocks are displayed identically even with witness transactions. WhenPROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS
is passed toGetSerializeSize
, it has no effect because it is incorrectly passed as thenType
and not thenVersion
.This is because
nType
was removed in eb696d7 but re-added in 195b0fa without reverting the function calls to includeSER_NETWORK
.As witness bytes are no longer discounted due to this bug, the code should be altered to remove references to the
WITNESS_SCALE_FACTOR
. ThenType
inCSizeComputer
andGetSerializeSize
should be removed and all calls to these should be fixed.My proposed fix:
CSizeComputer
to match how it was originally intended in commit eb696d7 and currently is in Bitcoin withnType
removed.WITNESS_SCALE_FACTOR
,MAX_BLOCK_WEIGHT
andMAX_BLOCK_SERIALIZED_SIZE
.MAX_BLOCK_SIZE
as 1000000. Block size checks should be done against that.MIN_TRANSACTION_WEIGHT
andMIN_SERIALIZABLE_TRANSACTION_WEIGHT
should reference size and not weight.GetTransactionWeight
and useGetSerializeSize
withoutSERIALIZE_TRANSACTION_NO_WITNESS
for bothsize
,weight
andvsize
.strippedsize
in blocks should useSERIALIZE_TRANSACTION_NO_WITNESS
.stippedsize
,weight
andvsize
are only kept for RPC compatibility.The text was updated successfully, but these errors were encountered: