mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
wire: remove erroneous witness size check in wire parsing
In this commit, we fix a bug that would cause nodes to be unable to parse a given block from the wire. The block would be properly accepted if fed in via other mechanisms. The issue here is that the old checks for the maximum witness size, circa segwit v0 where placed in the wire package _as well_ as the tx engine. This check should only be in the engine, since it's properly gated by other related scrip validation flags. The fix itself is simple: limit witnesses only based on the maximum block size in bytes, or ~4MB.
This commit is contained in:
parent
a0ff51b84a
commit
df89776a17
1 changed files with 6 additions and 6 deletions
|
@ -103,10 +103,9 @@ const (
|
||||||
maxWitnessItemsPerInput = 500000
|
maxWitnessItemsPerInput = 500000
|
||||||
|
|
||||||
// maxWitnessItemSize is the maximum allowed size for an item within
|
// maxWitnessItemSize is the maximum allowed size for an item within
|
||||||
// an input's witness data. This number is derived from the fact that
|
// an input's witness data. This value is bounded by the largest
|
||||||
// for script validation, each pushed item onto the stack must be less
|
// possible block size, post segwit v1 (taproot).
|
||||||
// than 10k bytes.
|
maxWitnessItemSize = 4_000_000
|
||||||
maxWitnessItemSize = 11000
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TxFlagMarker is the first byte of the FLAG field in a bitcoin tx
|
// TxFlagMarker is the first byte of the FLAG field in a bitcoin tx
|
||||||
|
@ -588,8 +587,9 @@ func (msg *MsgTx) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error
|
||||||
// item itself.
|
// item itself.
|
||||||
txin.Witness = make([][]byte, witCount)
|
txin.Witness = make([][]byte, witCount)
|
||||||
for j := uint64(0); j < witCount; j++ {
|
for j := uint64(0); j < witCount; j++ {
|
||||||
txin.Witness[j], err = readScript(r, pver,
|
txin.Witness[j], err = readScript(
|
||||||
maxWitnessItemSize, "script witness item")
|
r, pver, maxWitnessItemSize, "script witness item",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnScriptBuffers()
|
returnScriptBuffers()
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue