Skip to content

Commit

Permalink
fix verify blob too large bug (#182)
Browse files Browse the repository at this point in the history
* Fix bugs find in stress testing
* Add metrics
  • Loading branch information
adam-xu-mantle committed Aug 16, 2024
1 parent 4044c87 commit 5140fd2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
10 changes: 5 additions & 5 deletions op-batcher/batcher/driver_da.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
DaLoopRetryNum = 10
EigenRPCRetryNum = 3
BytesPerCoefficient = 31
MaxblobNum = 3 // max number of blobs, the bigger the more possible of timeout
MaxblobNum = 4 // max number of blobs, the bigger the more possible of timeout
)

var ErrInitDataStore = errors.New("init data store transaction failed")
Expand Down Expand Up @@ -359,7 +359,6 @@ func (l *BatchSubmitter) blobTxCandidates(data [][]byte) ([]*txmgr.TxCandidate,
return nil, err
}
} else {
dataInTx = append(dataInTx, frameData)
encodeData = nextEncodeData
}

Expand Down Expand Up @@ -486,7 +485,7 @@ func (l *BatchSubmitter) txAggregator() ([]byte, error) {
}

func (l *BatchSubmitter) txAggregatorForEigenDa() ([][]byte, error) {
var txsData [][]byte
var tempTxsData, txsData [][]byte
var transactionByte []byte
sortTxIds := make([]txID, 0, len(l.state.daPendingTxData))
l.state.daUnConfirmedTxID = l.state.daUnConfirmedTxID[:0]
Expand All @@ -498,8 +497,8 @@ func (l *BatchSubmitter) txAggregatorForEigenDa() ([][]byte, error) {
})
for _, v := range sortTxIds {
txData := l.state.daPendingTxData[v]
txsData = append(txsData, txData.Bytes())
txnBufBytes, err := rlp.EncodeToBytes(txsData)
tempTxsData = append(tempTxsData, txData.Bytes())
txnBufBytes, err := rlp.EncodeToBytes(tempTxsData)
if err != nil {
l.log.Error("op-batcher unable to encode txn", "err", err)
return nil, err
Expand All @@ -509,6 +508,7 @@ func (l *BatchSubmitter) txAggregatorForEigenDa() ([][]byte, error) {
l.metr.RecordTxOverMaxLimit()
break
}
txsData = tempTxsData
transactionByte = txnBufBytes
l.state.daUnConfirmedTxID = append(l.state.daUnConfirmedTxID, v)
l.log.Info("added frame to daUnConfirmedTxID", "id", v.String())
Expand Down
Binary file modified op-batcher/resources/g1.point
Binary file not shown.
Binary file modified op-batcher/resources/g2.point.powerOf2
Binary file not shown.
10 changes: 2 additions & 8 deletions op-service/eigenda/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,13 @@ func (c *Config) GetMaxBlobLength() (uint64, error) {
}

func (c *Config) VerificationCfg() *verify.Config {
numBytes, err := c.GetMaxBlobLength()
if err != nil {
panic(fmt.Errorf("Check() was not called on config object, err is not nil: %w", err))
}

numPointsNeeded := uint64(math.Ceil(float64(numBytes) / BytesPerSymbol))

kzgCfg := &kzg.KzgConfig{
G1Path: c.G1Path,
G2PowerOf2Path: c.G2PowerOfTauPath,
CacheDir: c.CacheDir,
SRSOrder: numPointsNeeded,
SRSNumberToLoad: numPointsNeeded,
SRSOrder: 268435456, // 2 ^ 32
SRSNumberToLoad: 65536, // # of fp.Elements
NumWorker: uint64(runtime.GOMAXPROCS(0)),
}

Expand Down
2 changes: 2 additions & 0 deletions op-service/eigenda/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ func (m *EigenDA) RetrieveBlob(ctx context.Context, BatchHeaderHash []byte, Blob

ctxTimeout, cancel := context.WithTimeout(ctx, m.RPCTimeout)
defer cancel()
done := m.recordInterval("RetrieveBlob")
reply, err := daClient.RetrieveBlob(ctxTimeout, &disperser.RetrieveBlobRequest{
BatchHeaderHash: BatchHeaderHash,
BlobIndex: BlobIndex,
})
done(err)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion op-service/eigenda/verify/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (v *Verifier) Commit(blob []byte) (*bn254.G1Affine, error) {
// ChunkLength and TotalChunks aren't relevant for computing data
// commitment which is why they're currently set arbitrarily
encoder, err := v.prover.GetKzgEncoder(
encoding.ParamsFromSysPar(420, 69, uint64(len(blob))),
encoding.ParamsFromSysPar(1, 1, uint64(len(blob))),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 5140fd2

Please sign in to comment.