Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate shares in ErrByzantineData #190

Merged
merged 7 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions extendeddatacrossword.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ func (eds *ExtendedDataSquare) solveCrosswordRow(
if noMissingData(col, r) { // not completed
staheri14 marked this conversation as resolved.
Show resolved Hide resolved
err := eds.verifyAgainstColRoots(colRoots, uint(c), col, r, rebuiltShares[c])
if err != nil {
var byzErr *ErrByzantineData
if errors.As(err, &byzErr) {
byzErr.Shares = shares
rootulp marked this conversation as resolved.
Show resolved Hide resolved
}
return false, false, err
}
}
Expand Down Expand Up @@ -235,6 +239,10 @@ func (eds *ExtendedDataSquare) solveCrosswordCol(
if noMissingData(row, c) { // not completed
err := eds.verifyAgainstRowRoots(rowRoots, uint(r), row, c, rebuiltShares[r])
if err != nil {
var byzErr *ErrByzantineData
if errors.As(err, &byzErr) {
byzErr.Shares = shares
}
return false, false, err
}
}
Expand Down
18 changes: 18 additions & 0 deletions extendeddatacrossword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,22 @@ func TestCorruptedEdsReturnsErrByzantineData(t *testing.T) {
coords: [][]uint{{3, 0}, {0, 1}, {0, 2}, {0, 3}},
values: [][]byte{corruptChunk, nil, nil, nil},
},
{
// This test case sets all shares along the diagonal to nil so that
// the prerepairSanityCheck does not return an error and it can
// verify that solveCrossword returns an ErrByzantineData with
// shares populated.
name: "set all shares along the diagonal to nil and then corrupt the cell at (0, 1)",
// In the ASCII diagram below, _ represents a nil share and C
// represents a corrupted share.
//
// _ C O O
// O _ O O
// O O _ O
// O O O _
coords: [][]uint{{0, 0}, {1, 1}, {2, 2}, {3, 3}, {0, 1}},
values: [][]byte{nil, nil, nil, nil, corruptChunk},
},
}

for codecName, codec := range codecs {
Expand All @@ -214,6 +230,8 @@ func TestCorruptedEdsReturnsErrByzantineData(t *testing.T) {
// due to parallelisation, the ErrByzantineData axis may be either row or col
var byzData *ErrByzantineData
assert.ErrorAs(t, err, &byzData, "did not return a ErrByzantineData for a bad col or row")
assert.NotEmpty(t, byzData.Shares)
assert.Contains(t, byzData.Shares, corruptChunk)
})
}
})
Expand Down