From b473ed168b744240c0f3b2f12f6d5acbfd07e396 Mon Sep 17 00:00:00 2001 From: Keyao Shen Date: Tue, 7 Apr 2026 12:19:50 -0700 Subject: [PATCH 1/4] Fix unmarshal panic --- op-node/rollup/derive/espresso_batch.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/op-node/rollup/derive/espresso_batch.go b/op-node/rollup/derive/espresso_batch.go index 8367770c104..fc22780bfd5 100644 --- a/op-node/rollup/derive/espresso_batch.go +++ b/op-node/rollup/derive/espresso_batch.go @@ -97,6 +97,9 @@ func CreateEspressoBatchUnmarshaler() func(data []byte) (*EspressoBatch, error) } func UnmarshalEspressoTransaction(data []byte) (*EspressoBatch, error) { + if len(data) < crypto.SignatureLength { + return nil, fmt.Errorf("transaction data too short: %d bytes, need at least %d", len(data), crypto.SignatureLength) + } signatureData, batchData := data[:crypto.SignatureLength], data[crypto.SignatureLength:] batchHash := crypto.Keccak256(batchData) From 6ae48302c2e5c3a5f96adc7fff809c0fd6ae2567 Mon Sep 17 00:00:00 2001 From: Keyao Shen Date: Tue, 7 Apr 2026 12:49:28 -0700 Subject: [PATCH 2/4] Fix the build and add a test --- op-node/rollup/derive/blob_data_source_test.go | 2 +- op-node/rollup/derive/espresso_batch_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/op-node/rollup/derive/blob_data_source_test.go b/op-node/rollup/derive/blob_data_source_test.go index 8bf51c51f2d..02e20c1b65f 100644 --- a/op-node/rollup/derive/blob_data_source_test.go +++ b/op-node/rollup/derive/blob_data_source_test.go @@ -381,7 +381,7 @@ func TestBlobDataSourceL1FetcherErrors(t *testing.T) { blob := new(eth.Blob) err = blob.FromData(blobInput) require.NoError(t, err) - _, blobHashes, err := txmgr.MakeSidecar([]*eth.Blob{blob}) + _, blobHashes, err := txmgr.MakeSidecar([]*eth.Blob{blob}, false) require.NoError(t, err) blobTxData := &types.BlobTx{ Nonce: rng.Uint64(), diff --git a/op-node/rollup/derive/espresso_batch_test.go b/op-node/rollup/derive/espresso_batch_test.go index 353d78c555d..e8309aecde5 100644 --- a/op-node/rollup/derive/espresso_batch_test.go +++ b/op-node/rollup/derive/espresso_batch_test.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" ) var defaultTestRollUpConfig = &rollup.Config{ @@ -81,6 +82,22 @@ func compareBody(a, b *gethTypes.Body) int { return 0 } +// TestUnmarshalEspressoTransactionTooShort verifies that UnmarshalEspressoTransaction +// returns an error (rather than panicking) when the input is shorter than a signature. +func TestUnmarshalEspressoTransactionTooShort(t *testing.T) { + cases := [][]byte{ + nil, + {}, + make([]byte, crypto.SignatureLength-1), + } + for _, data := range cases { + _, err := derive.UnmarshalEspressoTransaction(data) + if err == nil { + t.Errorf("expected error for %d-byte input, got nil", len(data)) + } + } +} + // TestEspressoBatchConversion tests the conversion of a block to an Espresso // Batch, and ensures that the recovery of the original Block is possible with // the contents of the Espresso Batch. From 9bc82ed869f43ae49e3d266bd7a41e80aa8bf0ca Mon Sep 17 00:00:00 2001 From: Keyao Shen Date: Tue, 7 Apr 2026 13:06:27 -0700 Subject: [PATCH 3/4] Update op-node/rollup/derive/espresso_batch_test.go Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> --- op-node/rollup/derive/espresso_batch_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/op-node/rollup/derive/espresso_batch_test.go b/op-node/rollup/derive/espresso_batch_test.go index e8309aecde5..f8cdffc7644 100644 --- a/op-node/rollup/derive/espresso_batch_test.go +++ b/op-node/rollup/derive/espresso_batch_test.go @@ -92,8 +92,7 @@ func TestUnmarshalEspressoTransactionTooShort(t *testing.T) { } for _, data := range cases { _, err := derive.UnmarshalEspressoTransaction(data) - if err == nil { - t.Errorf("expected error for %d-byte input, got nil", len(data)) + require.Error(t, err, "expected error for %d-byte input", len(data)) } } } From 5b37b9a3d7eba438dace68b612fa5226ee45a317 Mon Sep 17 00:00:00 2001 From: Keyao Shen Date: Wed, 8 Apr 2026 12:36:18 -0700 Subject: [PATCH 4/4] Fix syntax --- op-node/rollup/derive/espresso_batch_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op-node/rollup/derive/espresso_batch_test.go b/op-node/rollup/derive/espresso_batch_test.go index f8cdffc7644..05ef9c2f9d3 100644 --- a/op-node/rollup/derive/espresso_batch_test.go +++ b/op-node/rollup/derive/espresso_batch_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/common" gethTypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/stretchr/testify/require" ) var defaultTestRollUpConfig = &rollup.Config{ @@ -93,7 +94,6 @@ func TestUnmarshalEspressoTransactionTooShort(t *testing.T) { for _, data := range cases { _, err := derive.UnmarshalEspressoTransaction(data) require.Error(t, err, "expected error for %d-byte input", len(data)) - } } }