mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
core/types: enhance BlobTx decode to validate blob sidecar version
This commit is contained in:
parent
0413af40f6
commit
87f25b9b12
1 changed files with 5 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue