-
Notifications
You must be signed in to change notification settings - Fork 249
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
Fraud proof naming, test & comment cleanups #3369
base: main
Are you sure you want to change the base?
Conversation
pub is_true_invalid_fraud_proof: bool, | ||
/// If `true`, the fraud proof must prove the local bundle is invalid. | ||
/// If `false`, the fraud proof must prove the remote's claimed invalid bundle is wrong. | ||
pub prove_local_is_invalid_fraud_proof: bool, |
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.
local does not signify what you mean here.
What this actually means is whether we are proving if a bundle is actually invalid or prove if the invallid marked bundle is actually valid
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.
Yeah, both TrueInvalid
and FalseInvalid
are attested against a (remote) ER, TrueInvalid
means the fraud proof needs to prove something the ER claimed is valid is actually invalid, FalseInvalid
means the fraud proof needs to prove something the ER claimed is invalid is actually valid.
Local/remote is a bit more confusing to me, because the meaning changed in different places (e.g. in the domain node when generating FP vs in the consensus node when verifying FP).
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 changed it to:
- use_bundle_is_invalid_fraud_proof
- InvalidProofIsWrong
- InvalidProofIsCorrect
- ValidBundleContents
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.
Still, I prefer the original TrueInvalid/FalseInvalid
, because the BundleMismatchType
is about the mismatch of the BundleValidity
in the ER, while use_bundle_is_invalid_fraud_proof
seems to claim a bundle is valid or not and InvalidProofIsWrong/InvalidProofIsCorrect
seems to claim "there is a proof of invalidity and it is correct/wrong"
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.
Ok, I see your point. But I'm still not quite understanding the code from the type names, the existing comments, and your explanations. So maybe we could make some improvements here?
Here's what I find confusing:
TrueInvalid
is confusing English grammar, which makes it harder for me to understand what it meansis_true_invalid_fraud_proof: bool
is both confusing grammar, and an unusual use of types, so it's hard for me to work out what the double negativeis_true_invalid_fraud_proof: false
meansBundleMismatchType
is a negative, which makesBundleMismatchType::FalseInvalid
a confusing double-negative
Would you be happy with these name changes?
- is_true_invalid_fraud_proof -> is_{good,correct,accurate,(nothing)}_invalid_fraud_proof
- TrueInvalid -> {Good,Correct,Accurate,(nothing)}Invalid
- FalseInvalid -> {Bad,Wrong,Faulty}Invalid
- Valid -> ValidBundleContents
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.
So maybe we could make some improvements here?
Definitely! The above suggestion looks good to me as they reflect "the mismatch of the BundleValidity", feel free to choose one you think is the best, and thanks for being patient!
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.
Rest LGTM, thanks!
pub is_true_invalid_fraud_proof: bool, | ||
/// If `true`, the fraud proof must prove the local bundle is invalid. | ||
/// If `false`, the fraud proof must prove the remote's claimed invalid bundle is wrong. | ||
pub prove_local_is_invalid_fraud_proof: bool, |
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.
Yeah, both TrueInvalid
and FalseInvalid
are attested against a (remote) ER, TrueInvalid
means the fraud proof needs to prove something the ER claimed is valid is actually invalid, FalseInvalid
means the fraud proof needs to prove something the ER claimed is invalid is actually valid.
Local/remote is a bit more confusing to me, because the meaning changed in different places (e.g. in the domain node when generating FP vs in the consensus node when verifying FP).
de3dd60
to
786d5fc
Compare
332eef9
to
13df0e2
Compare
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.
This should be ready for review again.
Sorry for the rebase, GitHub kept saying there was a merge error when the commits applied fine in git
.
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.
Happy to drop this change if we can't sort it out this time around. I'll take it to a ticket instead.
(The comment notes are for me for the next revision.)
/// because the bundle is actually an invalid bundle, but it is either marked as valid, | ||
/// or as a lower priority invalid type. | ||
InvalidProofIsCorrect(InvalidBundleType), | ||
/// The fraud proof needs to prove the proof of `InvalidBundleType` is incorrect, |
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.
/// The fraud proof needs to prove the proof of `InvalidBundleType` is incorrect, | |
/// The fraud proof needs to prove the `InvalidBundleType` is incorrect, |
let is_expected = if !is_true_invalid_fraud_proof { | ||
// `FalseInvalid` | ||
let is_expected = if !use_bundle_is_invalid_fraud_proof { | ||
// `InvalidProofIsWrong` | ||
// The proof trying to prove `bad_receipt_bundle`'s `invalid_bundle_type` is wrong, | ||
// so the proof should contains the same `invalid_bundle_type` |
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.
// so the proof should contains the same `invalid_bundle_type` | |
// so the proof should contain the same `invalid_bundle_type` |
pub is_true_invalid_fraud_proof: bool, | ||
/// If `true`, the fraud proof must prove the local bundle is invalid. | ||
/// If `false`, the fraud proof must prove the remote's claimed invalid bundle is wrong. | ||
pub prove_local_is_invalid_fraud_proof: bool, |
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.
Ok, I see your point. But I'm still not quite understanding the code from the type names, the existing comments, and your explanations. So maybe we could make some improvements here?
Here's what I find confusing:
TrueInvalid
is confusing English grammar, which makes it harder for me to understand what it meansis_true_invalid_fraud_proof: bool
is both confusing grammar, and an unusual use of types, so it's hard for me to work out what the double negativeis_true_invalid_fraud_proof: false
meansBundleMismatchType
is a negative, which makesBundleMismatchType::FalseInvalid
a confusing double-negative
Would you be happy with these name changes?
- is_true_invalid_fraud_proof -> is_{good,correct,accurate,(nothing)}_invalid_fraud_proof
- TrueInvalid -> {Good,Correct,Accurate,(nothing)}Invalid
- FalseInvalid -> {Bad,Wrong,Faulty}Invalid
- Valid -> ValidBundleContents
How to review this PR
The real diff starts at aa63e5d, the other commits are from the
main
branch. (They'll disappear once #3368 merges.)What it does
This PR refactors some fraud proof code so it's easier to use and understand:
HashingFor
rather than complex trait type paths (some added in Fix inconsistency of bundle digest generation and add invalid fraud proof integration test #3368)IsFalseInvalid
because double negatives are confusing, and make comments clearerignore_invalid_proof
argument in production builds (added in Fix inconsistency of bundle digest generation and add invalid fraud proof integration test #3368)Code contributor checklist: