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

Handle V2 Malfeasance proofs in V2 ATX handler #6133

Closed
wants to merge 37 commits into from

Conversation

fasmat
Copy link
Member

@fasmat fasmat commented Jul 12, 2024

Motivation

This adds the first two malfeasance proofs for ATXv2: double publish and double marry.

Description

Double Publish

TODO: Update to instead check if 2 ATXs in the same epoch contain a PoST by the same identity.

If an identity publishes two ATXs with the same publish epoch they become malfeasant. This proof verifies that a given ATX was created by the same identity and targets the same epoch. It works basically the same as the previous double publish proof, except that merkle trees are used instead of a signature where the payloads first 4 bytes are the publish epoch.

Double Marry

If an identity is part of more than one marriage it is considered malfeasant. This Proof shows that two ATXs containing marriage certificates contain certificates signed by the same identity.

To simplify this proof the main identity (the one that signs the ATX) has to include a marriage certificate marrying themselves, otherwise we would need additional proofs: i.e. 2 ATXs signed by the same identity containing marriage certificates and one for the case where one ATX containing marriage certificates is signed by identity A and another ATX signed by B contains a marriage certificate of A.

Creating and verifying proofs

Both types of proofs have a New...Proof function that creates them. This function does some basic checks to prevent creating an invalid malfeasance proof if two ATXs that do not show malfeasant behaviour are passed as arguments.

The wire types for the malfeasance proofs have a Valid method that can be called to check if the malfeasance proof is valid. It returns an error that is not nil when the proof is invalid and explains why it is invalid.

Publishing Proofs

The ATX handler has been updated to first store the (syntactically valid) ATX before checking if the ATX is contextually invalid and creating a malfeasance proof for it. If a malfeasance proof is created it is immediately published.

The malfeasance publisher will take care that the internal state of the node (tortoise, etc.) is informed about the detected malicious identity and only gossip the proof if we are already synced.

Test Plan

For both malfeasance proofs multiple tests have been added to verify they are working correctly.

TODO

  • Explain motivation or link existing issue(s)
  • Test changes and document test plan
  • Update documentation as needed
  • Update changelog as needed

@fasmat fasmat self-assigned this Jul 12, 2024
@fasmat fasmat force-pushed the malfeasance-v2-foundations branch from d672779 to 88a0601 Compare July 12, 2024 08:43
Copy link

codecov bot commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 43.17181% with 129 lines in your changes missing coverage. Please review.

Project coverage is 81.5%. Comparing base (5b44c29) to head (0cb82ca).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
activation/wire/malfeasance_invalid_post.go 0.0% 82 Missing ⚠️
activation/malfeasance2_handler.go 0.0% 34 Missing ⚠️
activation/wire/malfeasance_double_publish.go 89.1% 4 Missing and 4 partials ⚠️
activation/handler_v2.go 50.0% 3 Missing ⚠️
activation/malfeasance2_publisher.go 0.0% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #6133     +/-   ##
=========================================
- Coverage     81.7%   81.5%   -0.3%     
=========================================
  Files          312     315      +3     
  Lines        34613   34802    +189     
=========================================
+ Hits         28297   28368     +71     
- Misses        4479    4594    +115     
- Partials      1837    1840      +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mathcrypto mathcrypto self-requested a review July 26, 2024 13:13
@fasmat
Copy link
Member Author

fasmat commented Aug 29, 2024

  • Double marry malfeasance has been added in this PR: [Merged by Bors] - Add double marry malfeasance proof #6219
  • Double publish malfeasance is obsolete: any double publish will be provable by showing that 2 ATXs by the same identity reference the same previous ATX.
  • Additional malfeasance proofs will be added as dedicated PRs
  • The remaining changes of this PR have been added to its successor

Superseded by #6307

@fasmat fasmat closed this Aug 29, 2024
@fasmat fasmat deleted the malfeasance-v2-foundations branch August 29, 2024 19:22
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.

1 participant