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

chore!: improve start/end row proof validation #1476

Draft
wants to merge 4 commits into
base: v0.34.x-celestia
Choose a base branch
from

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Sep 11, 2024

Description

Closes #1475

@rach-id rach-id requested a review from a team as a code owner September 11, 2024 18:53
@rach-id rach-id requested review from rootulp and evan-forbes and removed request for a team September 11, 2024 18:53
Comment on lines 37 to 41
if len(rp.Proofs) != 0 &&
(int64(rp.StartRow) != rp.Proofs[0].Index ||
int64(rp.StartRow) != rp.Proofs[len(rp.Proofs)-1].Index) {
return fmt.Errorf("invalid start/end row")
}
Copy link
Collaborator

@rootulp rootulp Sep 11, 2024

Choose a reason for hiding this comment

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

I'm a bit lost on why this conditional is an invalid start or end row. EndRow isn't used in the conditional so how can it be deemed invalid?

Can this PR please include a unit test?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch

Copy link
Member Author

Choose a reason for hiding this comment

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

rootulp
rootulp previously approved these changes Sep 11, 2024
Comment on lines 37 to 41
if len(rp.Proofs) != 0 &&
(int64(rp.StartRow) != rp.Proofs[0].Index ||
int64(rp.EndRow) != rp.Proofs[len(rp.Proofs)-1].Index) {
return fmt.Errorf("invalid start/end row")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] this could be split into two separate checks with two separate errors: one for start row and one for end row. That way the error message is precise.

Copy link
Member Author

Choose a reason for hiding this comment

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

return proof
}(),
root: root,
wantErr: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: this test could be improved by verifying that the error is fmt.Errorf("invalid start/end row") in case some other validation check is erroring before the expected error is encountered.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's fine as long as we're attesting that some error happens. Changing this would mean refactoring the whole test + it's not something that's being done consistently in this repo, most tests are just wanting an error.

If you feel strongly about it, I can refactor, no issue

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not blocking on it. It's just a nice to have

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.

Thanks for addressing #1475; however, I noticed there's one more item in that issue that isn't covered in the PR:

However, I think it is still a valid check (and orthogonal to StartRow and EndRow) to see if the Total field is the same across all the proofs in Proofs. Again, will leave the decision to you.

If you plan to add it in another PR, then perhaps the Closes in the PR description can be rephrased.

types/row_proof.go Outdated Show resolved Hide resolved
@rach-id rach-id marked this pull request as draft September 13, 2024 09:26
@rach-id rach-id changed the title chore: improve start/end row proof validation chore!: improve start/end row proof validation Sep 13, 2024
@rach-id
Copy link
Member Author

rach-id commented Sep 13, 2024

This is becoming a breaking change since we're adding more constraints on the proofs. I'm not sure if it's worth merging or not

@staheri14
Copy link
Contributor

This is becoming a breaking change since we're adding more constraints on the proofs. I'm not sure if it's worth merging or not

I don't have a strong opinion on this, but if introducing a breaking change is not desirable, I'm fine with holding off on this PR.

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.

Enhance the row proofs validation
3 participants