Skip to content

Conversation

@islishude
Copy link
Contributor

Don't let v0 blob use v1 encoding structure.

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

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

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

Thanks for catching it, and I would appreciate if you can also add the associated unit test.

@rjl493456442
Copy link
Member

rjl493456442 commented Oct 29, 2025

I just realized that we do have the validation for version tag.

func (btx *blobTxWithBlobsV1) assign(sc *BlobTxSidecar) error {
	if btx.Version != BlobSidecarVersion1 {
		return fmt.Errorf("unsupported blob tx version %d", btx.Version)
	}
	sc.Version = BlobSidecarVersion1
	sc.Blobs = btx.Blobs
	sc.Commitments = btx.Commitments
	sc.Proofs = btx.Proofs
	return nil
}

I think the extra validation you have added is redundant. Close it.

@islishude islishude deleted the fix-blob-version-check branch October 29, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants