Skip to content

Commit

Permalink
fix(avail): ignoring in case of garbage data on the avail DA (dymensi…
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Jan 23, 2025
1 parent 4f40cf0 commit 5e601a0
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions da/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/avast/retry-go/v4"
"github.com/dymensionxyz/dymint/da/stub"
"github.com/gogo/protobuf/proto"

"github.com/dymensionxyz/dymint/types"

Expand All @@ -25,7 +24,6 @@ import (
"github.com/dymensionxyz/dymint/da"
"github.com/dymensionxyz/dymint/store"
"github.com/dymensionxyz/dymint/types/metrics"
pb "github.com/dymensionxyz/dymint/types/pb/dymint"
)

const (
Expand Down Expand Up @@ -208,23 +206,24 @@ func (c *DataAvailabilityLayerClient) RetrieveBatches(daMetaData *da.DASubmitMet

data := ext.Method.Args
for 0 < len(data) {
var pbBatch pb.Batch
err := proto.Unmarshal(data, &pbBatch)
if err != nil {
c.logger.Error("unmarshal batch", "daHeight", daMetaData.Height, "error", err)
break
}
// Convert the proto batch to a batch
batch := &types.Batch{}
err = batch.FromProto(&pbBatch)
err := batch.UnmarshalBinary(data)
if err != nil {
c.logger.Error("batch from proto", "daHeight", daMetaData.Height, "error", err)
break
// try to parse from the next byte on the next iteration
data = data[1:]
continue
}

// Add the batch to the list
batches = append(batches, batch)
// Remove the bytes we just decoded.
data = data[proto.Size(&pbBatch):]
size := batch.ToProto().Size()
if len(data) < size {
// not supposed to happen, additional safety check
break
}

data = data[size:]
}
}
}
Expand Down

0 comments on commit 5e601a0

Please sign in to comment.