Commit b0a2d00d authored by OptimismBot's avatar OptimismBot Committed by GitHub

Merge pull request #5362 from ethereum-optimism/inphi/batcher-sane

op-batcher: Sanity check block for non-empty transactions
parents 5eae8164 db9b0867
...@@ -206,6 +206,9 @@ func BlockToBatch(block *types.Block) (*BatchData, L1BlockInfo, error) { ...@@ -206,6 +206,9 @@ func BlockToBatch(block *types.Block) (*BatchData, L1BlockInfo, error) {
} }
opaqueTxs = append(opaqueTxs, otx) opaqueTxs = append(opaqueTxs, otx)
} }
if len(block.Transactions()) == 0 {
return nil, L1BlockInfo{}, fmt.Errorf("block %v has no transactions", block.Hash())
}
l1InfoTx := block.Transactions()[0] l1InfoTx := block.Transactions()[0]
if l1InfoTx.Type() != types.DepositTxType { if l1InfoTx.Type() != types.DepositTxType {
return nil, L1BlockInfo{}, ErrNotDepositTx return nil, L1BlockInfo{}, ErrNotDepositTx
......
...@@ -132,3 +132,9 @@ func TestForceCloseTxData(t *testing.T) { ...@@ -132,3 +132,9 @@ func TestForceCloseTxData(t *testing.T) {
} }
} }
} }
func TestBlockToBatchValidity(t *testing.T) {
block := new(types.Block)
_, _, err := BlockToBatch(block)
require.ErrorContains(t, err, "has no transactions")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment