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

Merged
merged 6 commits into from
Feb 11, 2025
Merged

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

domains/client/domain-operator/src/aux_schema.rs Outdated Show resolved Hide resolved
crates/sp-domains-fraud-proof/src/verification.rs Outdated Show resolved Hide resolved
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

@teor2345 teor2345 force-pushed the invalid-fp-test-tweaks branch from 13df0e2 to 2966cb0 Compare February 10, 2025 21:57
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 final review.

@teor2345 teor2345 added this pull request to the merge queue Feb 11, 2025
Copy link
Member

@vedhavyas vedhavyas left a comment

Choose a reason for hiding this comment

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

LGTM apart from the suggestion. Feel free to ignore if you have a strong opinion on this

/// Proof data of the invalid bundle
/// If `true`, the fraud proof must prove the bundle was correctly marked invalid.
/// If `false`, it must prove the bundle was marked invalid, but is actually valid.
pub is_good_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.

Honestly, I would prefer the previous naming itself.
Here is my thought process

  • is_true_invalid_fraud_proof signifies whether fraud proof is targetting a truly invalid bundle or if false signifies if targetting a proof to show incorrectly marked invalid bundle.

When it comes to is_good_invalid_fraud_proof, I'm not sure, without context, understand what good signifies here unlike TrueInvalid which brings more context self contained.

It could be that my grammer maybe off here.
I do not want to block this PR on this name change but in the past there was a similar dicussion and final result ended up being going with True Prefix since the variants in it are just 2 and easily understood

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, looks like this already merged.

Yep, naming things is hard, particularly when we have multiple layers of negatives: “fraud”, “invalid”, and then the bool possibly being false.

It might be there is no perfect solution here, happy to have it changed back to “truly” (which is different enough from a true bool to make it a bit easier).

Merged via the queue into main with commit c8b57a9 Feb 11, 2025
8 checks passed
@teor2345 teor2345 deleted the invalid-fp-test-tweaks branch February 11, 2025 07:16
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