Skip to content

Commit

Permalink
Merge branch 'master' into rp/comments-about-extending
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp authored Jun 22, 2023
2 parents da4e3f5 + 328fe4d commit b18292e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
5 changes: 2 additions & 3 deletions datasquare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ func TestLazyRootGeneration(t *testing.T) {
err = square.computeRoots()
assert.NoError(t, err)

if !reflect.DeepEqual(square.rowRoots, rowRoots) && !reflect.DeepEqual(square.colRoots, colRoots) {
t.Error("getRowRoot or getColRoot did not produce identical roots to computeRoots")
}
assert.Equal(t, square.rowRoots, rowRoots)
assert.Equal(t, square.colRoots, colRoots)
}

func TestComputeRoots(t *testing.T) {
Expand Down
28 changes: 11 additions & 17 deletions extendeddatacrossword.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,8 @@ func (eds *ExtendedDataSquare) prerepairSanityCheck(

for i := uint(0); i < eds.width; i++ {
i := i
rowIsComplete := noMissingData(eds.row(i), noShareInsertion)
colIsComplete := noMissingData(eds.col(i), noShareInsertion)

rowIsComplete := noMissingData(eds.row(i), noShareInsertion)
// if there's no missing data in this row
if rowIsComplete {
errs.Go(func() error {
Expand All @@ -348,37 +347,32 @@ func (eds *ExtendedDataSquare) prerepairSanityCheck(
}
return nil
})
}

// if there's no missing data in this col
if colIsComplete {
errs.Go(func() error {
// ensure that the roots are equal
colRoot, err := eds.getColRoot(i)
parityShares, err := eds.codec.Encode(eds.rowSlice(i, 0, eds.originalDataWidth))
if err != nil {
return err
}
if !bytes.Equal(colRoots[i], colRoot) {
return fmt.Errorf("bad root input: col %d expected %v got %v", i, colRoots[i], colRoot)
if !bytes.Equal(flattenChunks(parityShares), flattenChunks(eds.rowSlice(i, eds.originalDataWidth, eds.originalDataWidth))) {
return &ErrByzantineData{Row, i, eds.row(i)}
}
return nil
})
}

if rowIsComplete {
colIsComplete := noMissingData(eds.col(i), noShareInsertion)
// if there's no missing data in this col
if colIsComplete {
errs.Go(func() error {
parityShares, err := eds.codec.Encode(eds.rowSlice(i, 0, eds.originalDataWidth))
// ensure that the roots are equal
colRoot, err := eds.getColRoot(i)
if err != nil {
return err
}
if !bytes.Equal(flattenChunks(parityShares), flattenChunks(eds.rowSlice(i, eds.originalDataWidth, eds.originalDataWidth))) {
return &ErrByzantineData{Row, i, eds.row(i)}
if !bytes.Equal(colRoots[i], colRoot) {
return fmt.Errorf("bad root input: col %d expected %v got %v", i, colRoots[i], colRoot)
}
return nil
})
}

if colIsComplete {
errs.Go(func() error {
parityShares, err := eds.codec.Encode(eds.colSlice(0, i, eds.originalDataWidth))
if err != nil {
Expand Down
9 changes: 4 additions & 5 deletions extendeddatacrossword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,11 @@ func TestCorruptedEdsReturnsErrByzantineData(t *testing.T) {
shareSize int
cells [][]byte
values [][]byte
axis Axis
}{
{"BadRow/OriginalData", bufferSize, [][]byte{{0, 0}}, [][]byte{corruptChunk}, Row},
{"BadRow/ExtendedData", bufferSize, [][]byte{{0, 3}}, [][]byte{corruptChunk}, Row},
{"BadColumn/OriginalData", bufferSize, [][]byte{{0, 0}, {0, 1}, {0, 2}, {0, 3}}, [][]byte{corruptChunk, nil, nil, nil}, Col},
{"BadColumn/OriginalData", bufferSize, [][]byte{{3, 0}, {0, 1}, {0, 2}, {0, 3}}, [][]byte{corruptChunk, nil, nil, nil}, Col},
{"BadRow/OriginalData", bufferSize, [][]byte{{0, 0}}, [][]byte{corruptChunk}},
{"BadRow/ExtendedData", bufferSize, [][]byte{{0, 3}}, [][]byte{corruptChunk}},
{"BadColumn/OriginalData", bufferSize, [][]byte{{0, 0}, {0, 1}, {0, 2}, {0, 3}}, [][]byte{corruptChunk, nil, nil, nil}},
{"BadColumn/OriginalData", bufferSize, [][]byte{{3, 0}, {0, 1}, {0, 2}, {0, 3}}, [][]byte{corruptChunk, nil, nil, nil}},
}

for codecName, codec := range codecs {
Expand Down

0 comments on commit b18292e

Please sign in to comment.