Skip to content

Commit

Permalink
refactor: bubble DA init error, offset constant
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Aug 12, 2024
1 parent eaddb0e commit 7b7729c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion eigenda/eigenda.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eigenda

import (
"context"
"errors"

"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -45,7 +46,7 @@ type EigenDA struct {

func NewEigenDA(config *EigenDAConfig) (*EigenDA, error) {
if !config.Enable {
panic("EigenDA is not enabled")
return nil, errors.New("EigenDA is not enabled")
}
client := NewEigenDAProxyClient(config.Rpc)

Expand Down
8 changes: 4 additions & 4 deletions eigenda/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type readerForEigenDA struct {
readerEigenDA EigenDAReader
}

const sequencerMsgOffset = 41

func (d *readerForEigenDA) IsValidHeaderByte(headerByte byte) bool {
return IsEigenDAMessageHeaderByte(headerByte)
}
Expand All @@ -35,8 +37,7 @@ func (d *readerForEigenDA) RecoverPayloadFromBatch(
preimageRecorder daprovider.PreimageRecorder,
validateSeqMsg bool,
) ([]byte, error) {
// offset sequencer message at 41
return RecoverPayloadFromEigenDABatch(ctx, sequencerMsg[41:], d.readerEigenDA, preimageRecorder, "binary")
return RecoverPayloadFromEigenDABatch(ctx, sequencerMsg[sequencerMsgOffset:], d.readerEigenDA, preimageRecorder, "binary")
}

func RecoverPayloadFromEigenDABatch(ctx context.Context,
Expand Down Expand Up @@ -139,6 +140,5 @@ func (d *binaryReaderForEigenDA) RecoverPayloadFromBatch(
preimageRecorder daprovider.PreimageRecorder,
validateSeqMsg bool,
) ([]byte, error) {
// offset sequencer message at 41
return RecoverPayloadFromEigenDABatch(ctx, sequencerMsg[41:], d.readerEigenDA, preimageRecorder, "binary")
return RecoverPayloadFromEigenDABatch(ctx, sequencerMsg[sequencerMsgOffset:], d.readerEigenDA, preimageRecorder, "binary")
}

0 comments on commit 7b7729c

Please sign in to comment.