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
5 changes: 5 additions & 0 deletions op-node/rollup/derive/channel_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)

var ErrNotDepositTx = errors.New("first transaction in block is not a deposit tx")

type ChannelOut struct {
id ChannelID
// Frame ID of the next frame to emit. Increment after emitting
Expand Down Expand Up @@ -153,6 +155,9 @@ func blockToBatch(block *types.Block, w io.Writer) error {
opaqueTxs = append(opaqueTxs, otx)
}
l1InfoTx := block.Transactions()[0]
if l1InfoTx.Type() != types.DepositTxType {
return ErrNotDepositTx
}
l1Info, err := L1InfoDepositTxData(l1InfoTx.Data())
if err != nil {
return err // TODO: wrap err
Expand Down
27 changes: 27 additions & 0 deletions op-node/rollup/derive/channel_out_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package derive

import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"
)

func TestChannelOutAddBlock(t *testing.T) {
cout, err := NewChannelOut()
require.NoError(t, err)

t.Run("returns err if first tx is not an l1info tx", func(t *testing.T) {
header := &types.Header{Number: big.NewInt(1), Difficulty: big.NewInt(100)}
block := types.NewBlockWithHeader(header).WithBody(
[]*types.Transaction{
types.NewTx(&types.DynamicFeeTx{}),
},
nil,
)
err := cout.AddBlock(block)
require.Error(t, err)
require.Equal(t, ErrNotDepositTx, err)
})
}