Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/types/tx_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick

diff --git a/core/types/tx_blob.go b/core/types/tx_blob.go
index bbfd3c98db..464e294218 100644
--- a/core/types/tx_blob.go
+++ b/core/types/tx_blob.go
@@ -401,13 +401,18 @@ func (tx *BlobTx) decode(input []byte) error {
 	if err != nil {
 		return err
 	}
-	var payload blobTxWithBlobs
+	var (
+		payload blobTxWithBlobs
+		version byte
+	)
 	if secondElemKind == rlp.List {
 		// No version byte: blob sidecar v0.
 		payload = new(blobTxWithBlobsV0)
+		version = BlobSidecarVersion0
 	} else {
 		// It has a version byte. Decode as v1, version is checked by assign()
 		payload = new(blobTxWithBlobsV1)
+		version = BlobSidecarVersion1
 	}
 	if err := rlp.DecodeBytes(input, payload); err != nil {
 		return err
@@ -416,6 +421,9 @@ func (tx *BlobTx) decode(input []byte) error {
 	if err := payload.assign(sc); err != nil {
 		return err
 	}
+	if sc.Version != version {
+		return fmt.Errorf("unexpected sidecar version, want: %d, got: %d", version, sc.Version)
+	}
 	*tx = *payload.tx()
 	tx.Sidecar = sc
 	return nil

return errors.New("invalid blob encoding structure for version 0")
}
*tx = *payload.tx()
tx.Sidecar = sc
return nil
Expand Down