-
Notifications
You must be signed in to change notification settings - Fork 267
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
base: v0.34.x-celestia
Are you sure you want to change the base?
Conversation
types/row_proof.go
Outdated
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") | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types/row_proof.go
Outdated
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") | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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
andEndRow
) to see if theTotal
field is the same across all the proofs inProofs
. 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.
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. |
Description
Closes #1475