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: 3 additions & 2 deletions op-alt-da/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"

"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum/go-ethereum/crypto"
)

Expand Down Expand Up @@ -115,7 +116,7 @@ func (c Keccak256Commitment) Encode() []byte {

// TxData adds an extra version byte to signal it's a commitment.
func (c Keccak256Commitment) TxData() []byte {
return append([]byte{TxDataVersion1}, c.Encode()...)
return append([]byte{params.DerivationVersion1}, c.Encode()...)
}

// Verify checks if the commitment matches the given input.
Expand Down Expand Up @@ -155,7 +156,7 @@ func (c GenericCommitment) Encode() []byte {

// TxData adds an extra version byte to signal it's a commitment.
func (c GenericCommitment) TxData() []byte {
return append([]byte{TxDataVersion1}, c.Encode()...)
return append([]byte{params.DerivationVersion1}, c.Encode()...)
}

// Verify always returns true for GenericCommitment because the DA Server must validate the data before returning it to the op-node.
Expand Down
3 changes: 2 additions & 1 deletion op-alt-da/commitment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package altda
import (
"testing"

"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -54,7 +55,7 @@ func TestCommitmentData(t *testing.T) {
// Test that reencoding the commitment returns the same data
require.Equal(t, tc.commData, comm.Encode())
// Test that TxData() returns the same data as the original, prepended with a version byte
require.Equal(t, append([]byte{TxDataVersion1}, tc.commData...), comm.TxData())
require.Equal(t, append([]byte{params.DerivationVersion1}, tc.commData...), comm.TxData())

// Test that Verify() returns no error for the correct data
require.NoError(t, comm.Verify(tc.commData))
Expand Down
5 changes: 0 additions & 5 deletions op-alt-da/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@ package altda
// challenge in the Data Availability Challenge contract. Value in number of bytes.
// This value can only be changed in a hard fork.
const MaxInputSize = 130672

// TxDataVersion1 is the version number for batcher transactions containing
// altDA commitments. It should not collide with DerivationVersion which is still
// used downstream when parsing the frames.
const TxDataVersion1 = 1
5 changes: 3 additions & 2 deletions op-batcher/batcher/tx_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
)

Expand Down Expand Up @@ -35,7 +36,7 @@ func (td *txData) ID() txID {
// It's a version byte (0) followed by the concatenated frames for this transaction.
func (td *txData) CallData() []byte {
data := make([]byte, 1, 1+td.Len())
data[0] = derive.DerivationVersion0
data[0] = params.DerivationVersion0
for _, f := range td.frames {
data = append(data, f.data...)
}
Expand All @@ -46,7 +47,7 @@ func (td *txData) Blobs() ([]*eth.Blob, error) {
blobs := make([]*eth.Blob, 0, len(td.frames))
for _, f := range td.frames {
var blob eth.Blob
if err := blob.FromData(append([]byte{derive.DerivationVersion0}, f.data...)); err != nil {
if err := blob.FromData(append([]byte{params.DerivationVersion0}, f.data...)); err != nil {
return nil, err
}
blobs = append(blobs, &blob)
Expand Down
5 changes: 3 additions & 2 deletions op-e2e/actions/helpers/l2_batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
derive_params "github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
)
Expand Down Expand Up @@ -295,7 +296,7 @@ func (s *L2Batcher) ReadNextOutputFrame(t Testing) []byte {
}
// Collect the output frame
data := new(bytes.Buffer)
data.WriteByte(derive.DerivationVersion0)
data.WriteByte(derive_params.DerivationVersion0)
// subtract one, to account for the version byte
if _, err := s.L2ChannelOut.OutputFrame(data, s.l2BatcherCfg.MaxL1TxSize-1); err == io.EOF {
s.L2ChannelOut = nil
Expand Down Expand Up @@ -400,7 +401,7 @@ func (s *L2Batcher) ActL2BatchSubmitMultiBlob(t Testing, numBlobs int) {
blobs := make([]*eth.Blob, numBlobs)
for i := 0; i < numBlobs; i++ {
data := new(bytes.Buffer)
data.WriteByte(derive.DerivationVersion0)
data.WriteByte(derive_params.DerivationVersion0)
// write only a few bytes to all but the last blob
l := uint64(derive.FrameV0OverHeadSize + 4) // 4 bytes content
if i == numBlobs-1 {
Expand Down
3 changes: 2 additions & 1 deletion op-node/rollup/derive/altda_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"

altda "github.com/ethereum-optimism/optimism/op-alt-da"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum/go-ethereum/log"
)
Expand Down Expand Up @@ -56,7 +57,7 @@ func (s *AltDADataSource) Next(ctx context.Context) (eth.Data, error) {
}
// If the tx data type is not altDA, we forward it downstream to let the next
// steps validate and potentially parse it as L1 DA inputs.
if data[0] != altda.TxDataVersion1 {
if data[0] != params.DerivationVersion1 {
return data, nil
}

Expand Down
3 changes: 2 additions & 1 deletion op-node/rollup/derive/channel_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -275,7 +276,7 @@ func ForceCloseTxData(frames []Frame) ([]byte, error) {
}

var out bytes.Buffer
out.WriteByte(DerivationVersion0)
out.WriteByte(params.DerivationVersion0)

if !closed {
f := Frame{
Expand Down
4 changes: 3 additions & 1 deletion op-node/rollup/derive/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"errors"
"fmt"
"io"

"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
)

// Frames cannot be larger than 1 MB.
Expand Down Expand Up @@ -130,7 +132,7 @@ func ParseFrames(data []byte) ([]Frame, error) {
if len(data) == 0 {
return nil, errors.New("data array must not be empty")
}
if data[0] != DerivationVersion0 {
if data[0] != params.DerivationVersion0 {
return nil, fmt.Errorf("invalid derivation format byte: got %d", data[0])
}
buf := bytes.NewBuffer(data[1:])
Expand Down
8 changes: 5 additions & 3 deletions op-node/rollup/derive/frame_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import (
"log/slog"
"testing"

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive/mocks"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

func TestPruneFrameQueue(t *testing.T) {
Expand Down Expand Up @@ -126,7 +128,7 @@ func testFrameQueue_NextFrame(t *testing.T, holocene bool) {
}

var inBuf bytes.Buffer
inBuf.WriteByte(DerivationVersion0)
inBuf.WriteByte(params.DerivationVersion0)
for _, f := range inFrames {
require.NoError(t, f.MarshalBinary(&inBuf))
}
Expand Down
8 changes: 5 additions & 3 deletions op-node/rollup/derive/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-service/testutils"
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-node/rollup/derive/params"
"github.com/ethereum-optimism/optimism/op-service/testutils"
)

func FuzzFrameUnmarshalBinary(f *testing.F) {
Expand Down Expand Up @@ -164,7 +166,7 @@ func TestParseFramesInvalidVer(t *testing.T) {
}

func TestParseFramesOnlyVersion(t *testing.T) {
frames, err := ParseFrames([]byte{DerivationVersion0})
frames, err := ParseFrames([]byte{params.DerivationVersion0})
require.Empty(t, frames)
require.Error(t, err)
}
Expand Down Expand Up @@ -206,7 +208,7 @@ func TestParseFramesTruncated(t *testing.T) {
// frames.
func txMarshalFrames(frames []Frame) ([]byte, error) {
var data bytes.Buffer
if err := data.WriteByte(DerivationVersion0); err != nil {
if err := data.WriteByte(params.DerivationVersion0); err != nil {
return nil, err
}
for _, frame := range frames {
Expand Down
7 changes: 0 additions & 7 deletions op-node/rollup/derive/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/hex"
"errors"
"fmt"

altda "github.com/ethereum-optimism/optimism/op-alt-da"
)

// count the tagging info as 200 in terms of buffer size.
Expand All @@ -19,11 +17,6 @@ func frameSize(frame Frame) uint64 {
return uint64(len(frame.Data)) + frameOverhead
}

const DerivationVersion0 = 0

// DerivationVersion1 is reserved for batcher transactions containing altDA commitments.
const DerivationVersion1 = altda.TxDataVersion1

// MaxSpanBatchElementCount is the maximum number of blocks, transactions in total,
// or transaction per block allowed in a span batch.
const MaxSpanBatchElementCount = 10_000_000
Expand Down
6 changes: 6 additions & 0 deletions op-node/rollup/derive/params/versions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package params

const DerivationVersion0 = 0

// DerivationVersion1 is reserved for batcher transactions containing altDA commitments.
const DerivationVersion1 = 1