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.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) diff --git a/op-node/rollup/derive/espresso_batch_test.go b/op-node/rollup/derive/espresso_batch_test.go index 353d78c555d..05ef9c2f9d3 100644 --- a/op-node/rollup/derive/espresso_batch_test.go +++ b/op-node/rollup/derive/espresso_batch_test.go @@ -14,6 +14,8 @@ 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" + "github.com/stretchr/testify/require" ) var defaultTestRollUpConfig = &rollup.Config{ @@ -81,6 +83,20 @@ 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) + require.Error(t, err, "expected error for %d-byte input", 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.