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: eds mutation #134

Merged
merged 6 commits into from
Jan 22, 2023
Merged

Conversation

rahulghangas
Copy link
Contributor

Call to eds.row returns a slice to the underlying row/col data. Hence, when rebuilt shares are added to this slice, the underlying data is being mutated before correct validation is done. On the other hand, using eds.Row is too expensive, since it makes a copy of the underlying data. This PR fixes the first issue while avoiding expensive copying by passing the rebuilt share and/or index to relevant methods

@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Merging #134 (cda0a15) into master (80d231f) will increase coverage by 0.17%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   81.76%   81.93%   +0.17%     
==========================================
  Files           8        8              
  Lines         521      537      +16     
==========================================
+ Hits          426      440      +14     
- Misses         58       59       +1     
- Partials       37       38       +1     
Impacted Files Coverage Δ
extendeddatacrossword.go 76.53% <87.50%> (+0.97%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@musalbas
Copy link
Member

musalbas commented Oct 5, 2022

Is this still ready for review @rahulghangas? I recall you said you had an idea about something yesterday

@rahulghangas
Copy link
Contributor Author

I thought about how to replace -1 with something better, but didn't come up with anything. Thoughts?

@Wondertan
Copy link
Member

Wondertan commented Oct 5, 2022

@musalbas, I liked your solution in #114 so much that removing it now while introducing more ugly branchiness in the code is disappointing, but it is what it is.

@rahulghangas rahulghangas mentioned this pull request Oct 21, 2022
1 task
@liamsi

This comment was marked as duplicate.

extendeddatacrossword.go Outdated Show resolved Hide resolved
@rahulghangas rahulghangas requested review from liamsi and removed request for adlerjohn, musalbas and Wondertan October 21, 2022 17:16
@rahulghangas
Copy link
Contributor Author

@musalbas I think I can request only one review, so pinging you here. Do the new changes work?

@musalbas
Copy link
Member

If we can't think of a cleaner way it's ok with me. NoShareInsertion shouldn't be exported though.

extendeddatacrossword.go Outdated Show resolved Hide resolved
Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

LGTM. One question though: would it be too difficult to test the change in bahviour as it only affects internals of the implementation?

@rahulghangas
Copy link
Contributor Author

rahulghangas commented Oct 22, 2022

The only behaviour that has changed (been corrected) is for the state of the underlying eds when trying to repair from incorrect data. I guess we should add a test for that

@liamsi
Copy link
Member

liamsi commented Oct 23, 2022

I guess we should add a test for that

Yes, please do 👍🏼 Ideally, a test that would have failed without this fix specifically.

@liamsi liamsi requested a review from Wondertan October 24, 2022 20:33
extendeddatacrossword.go Show resolved Hide resolved
@@ -274,9 +274,16 @@ func (eds *ExtendedDataSquare) rebuildShares(
func (eds *ExtendedDataSquare) verifyAgainstRowRoots(
rowRoots [][]byte,
r uint,
shares [][]byte,
oldShares [][]byte,
rebuiltIndex int,
Copy link
Member

Choose a reason for hiding this comment

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

[code quality, blocking] Honestly I would just make these into new functions, instead of passing in a magic value for branching logic. If rebuiltIndex is noShareInsertion, then rebuiltShare must be nil, but this isn't enforced by the compiler since it's all one function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separating out leads to a lot of code duplication because noShareInsertion needs to be propagated all the way inside to the last function call. Which is why I included noShareInsertion in the first place

@evan-forbes
Copy link
Member

evan-forbes commented Nov 25, 2022

is this still being worked on? if so what is left? @rahulghangas

@rahulghangas rahulghangas merged commit 2348d8d into celestiaorg:master Jan 22, 2023
@rahulghangas rahulghangas deleted the fix/eds-mutation branch January 22, 2023 17:47
@gitpoap-bot
Copy link

gitpoap-bot bot commented Jan 22, 2023

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2023 Celestia Contributor:

GitPOAP: 2023 Celestia Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

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.

solveCrosswordRow/Col mutates underlying data square, when it shouldn't be
6 participants