core/types: enhance BlobTx decode to validate blob sidecar version

This commit is contained in:
islishude 2025-10-27 20:23:52 +08:00
parent 0413af40f6
commit 87f25b9b12

View file

@ -402,12 +402,14 @@ func (tx *BlobTx) decode(input []byte) error {
return err
}
var payload blobTxWithBlobs
var notV0 bool
if secondElemKind == rlp.List {
// No version byte: blob sidecar v0.
payload = new(blobTxWithBlobsV0)
} else {
// It has a version byte. Decode as v1, version is checked by assign()
payload = new(blobTxWithBlobsV1)
notV0 = true
}
if err := rlp.DecodeBytes(input, payload); err != nil {
return err
@ -416,6 +418,9 @@ func (tx *BlobTx) decode(input []byte) error {
if err := payload.assign(sc); err != nil {
return err
}
if notV0 && sc.Version == BlobSidecarVersion0 {
return errors.New("invalid blob encoding structure for version 0")
}
*tx = *payload.tx()
tx.Sidecar = sc
return nil