Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion op-node/rollup/derive/blob_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
3 changes: 3 additions & 0 deletions op-node/rollup/derive/espresso_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 16 additions & 0 deletions op-node/rollup/derive/espresso_batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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.
Expand Down
Loading