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

Fraud proof naming, test & comment cleanups #3369

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

teor2345
Copy link
Member

@teor2345 teor2345 commented Feb 6, 2025

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:

Code contributor checklist:

@teor2345 teor2345 self-assigned this Feb 6, 2025
Base automatically changed from invalid-fp-test to main February 6, 2025 15:12
@teor2345 teor2345 marked this pull request as ready for review February 6, 2025 23:02
@teor2345 teor2345 enabled auto-merge February 6, 2025 23:02
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,
Copy link
Member

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

Copy link
Member

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).

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 changed it to:

  • use_bundle_is_invalid_fraud_proof
  • InvalidProofIsWrong
  • InvalidProofIsCorrect
  • ValidBundleContents

Copy link
Member

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"

Copy link
Member Author

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 means
  • is_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 negative is_true_invalid_fraud_proof: false means
  • BundleMismatchType is a negative, which makes BundleMismatchType::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

Copy link
Member

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!

domains/client/domain-operator/src/fraud_proof.rs Outdated Show resolved Hide resolved
Copy link
Member

@NingLin-P NingLin-P left a 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,
Copy link
Member

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).

@teor2345 teor2345 force-pushed the invalid-fp-test-tweaks branch from de3dd60 to 786d5fc Compare February 10, 2025 01:33
@teor2345 teor2345 force-pushed the invalid-fp-test-tweaks branch from 332eef9 to 13df0e2 Compare February 10, 2025 01:51
Copy link
Member Author

@teor2345 teor2345 left a 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.

Copy link
Member Author

@teor2345 teor2345 left a 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,
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
/// 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`
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
// 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,
Copy link
Member Author

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 means
  • is_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 negative is_true_invalid_fraud_proof: false means
  • BundleMismatchType is a negative, which makes BundleMismatchType::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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants