Skip to content

Commit

Permalink
Merge pull request #194 from mantlenetworkio/oz_audit/l-02
Browse files Browse the repository at this point in the history
fix the oz audit issuse l-02
  • Loading branch information
adam-xu-mantle authored Feb 8, 2025
2 parents 863d85c + 2e4a3e0 commit d4fbcd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions op-batcher/batcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-service/eigenda"
"github.com/ethereum-optimism/optimism/op-service/eth"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
oppprof "github.com/ethereum-optimism/optimism/op-service/pprof"
Expand Down Expand Up @@ -188,6 +189,13 @@ func (c CLIConfig) Check() error {
if err := c.EigenDAConfig.Check(); err != nil {
return err
}

//Used to ensure that when using an Ethereum blob, a single frame is not larger than MaxBlobDataSize * MaxblobNum
//Considering that the frame needs to go through rlp. EncodeToBytes before submitting da, the maximum size after encoding cannot be accurately calculated.
//So MaxL1TxSize > MaxBlobDataSize is used here to make a rough judgment
if c.MaxL1TxSize > eth.MaxBlobDataSize {
return errors.New("MaxL1TxSize must less than MaxBlobDataSize")
}
return nil
}

Expand Down
5 changes: 5 additions & 0 deletions op-batcher/batcher/driver_da.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ func (l *BatchSubmitter) blobTxCandidates(data [][]byte) ([]*txmgr.TxCandidate,
}

if len(nextEncodeData) > se.MaxBlobDataSize*MaxblobNum {
if len(encodeData) == 0 {
err := fmt.Errorf("single frame data size %d larger than max blob transaction maximum size", len(nextEncodeData))
l.log.Error("empty encodeData", "err", err)
return nil, err
}
blobs := []*se.Blob{}
for idx := 0; idx < len(encodeData); idx += se.MaxBlobDataSize {
blobData := encodeData[idx : idx+minInt(len(encodeData)-idx, se.MaxBlobDataSize)]
Expand Down

0 comments on commit d4fbcd0

Please sign in to comment.