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: verify encoding of shares in case when axis is fully reconstructed from orthogonal #313

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

walldiss
Copy link
Member

@walldiss walldiss commented Apr 9, 2024

If axis is fully recomputed from orthogonal axises, we need to verify correct encoding on top of verification of roots.
Test coverage should happen by #312

vectorData := eds.row(uint(r))
for c := 0; c < int(eds.width); c++ {
shares[c] = vectorData[c]
}
copy(shares, eds.row(uint(r)))
Copy link
Member Author

@walldiss walldiss Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated, just small simplification change to use builtin func instead of loop

Copy link

codecov bot commented Apr 9, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 81.15%. Comparing base (d6c118c) to head (ff65800).
Report is 16 commits behind head on main.

Files Patch % Lines
extendeddatacrossword.go 50.00% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #313      +/-   ##
==========================================
+ Coverage   80.89%   81.15%   +0.25%     
==========================================
  Files           8        7       -1     
  Lines         869      626     -243     
==========================================
- Hits          703      508     -195     
+ Misses        119       72      -47     
+ Partials       47       46       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Wondertan
Copy link
Member

Do you know why codecov failed? 🤔

@Wondertan
Copy link
Member

This seems like an important case we missed before and needs rsmt2d OGs to review it
сс @adlerjohn and @musalbas

@musalbas
Copy link
Member

I think this makes sense, nice catch.

@adlerjohn should also have a look.

adlerjohn
adlerjohn previously approved these changes Apr 10, 2024
Copy link
Member

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cute edge case, good catch.

@rootulp
Copy link
Collaborator

rootulp commented Apr 10, 2024

Do you know why codecov failed? 🤔

codecov/patch is failing because not enough lines are covered. IMO we can ignore that CI check if this fix is verified via the tests in #312

rootulp
rootulp previously approved these changes Apr 10, 2024
staheri14
staheri14 previously approved these changes Apr 11, 2024
extendeddatacrossword.go Show resolved Hide resolved
@walldiss walldiss dismissed stale reviews from staheri14, rootulp, and adlerjohn via ff65800 April 13, 2024 16:04
walldiss added a commit that referenced this pull request Apr 15, 2024
ErrByzantine encompasses numerous edge cases. To address this, I
implemented randomized fuzzing tests, which identified instances where
shares encoding was not properly verified.

While I am neutral about maintaining the pretty printing code (as it
looks kinda off), I retained it because it proved extremely useful for
understanding the reasons behind test failures during extensive
debugging. Should these tests fail in the future for any reason, having
a visual representation of the issues will expedite debugging for future
developers.

Allowed to discover #313
Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -177,6 +174,10 @@ func (eds *ExtendedDataSquare) solveCrosswordRow(
}
return false, false, err
}

if eds.verifyEncoding(col, r, rebuiltShares[c]) != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something worth consideration is the the precedence of these returned errors i.e., 1) root mismatch (due to the call to verifyAgainstColRoots) and 2) the encoding error (caused by verifyEncoding). I think if the encoding is already wrong, perhaps it does not matter whether the roots match or not, so returning the encoding verification error would be more accurate and informative. Depending on this decision, we may want to swap the order of the returned errors. This can be tackled in a separate issue though if further discussion is needed.

@walldiss walldiss merged commit d2da725 into celestiaorg:main Apr 16, 2024
4 of 5 checks passed
walldiss added a commit that referenced this pull request Apr 29, 2024
The VerifyEncoding function introduced in PR #313 might not revert
changes to the original row or column after successful verification.
This could lead to a scenario where one of the fields, either squareRow
or squareCol, retains a rebuilt share, resulting in only partial repair.
This oversight would leave some repaired data unavailable when it should
be accessible. Existing tests did not cover this scenario. This PR
addresses the issue and includes randomized repair tests to ensure the
fix is effective.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants