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

WiP: Malfeasance v2: Handlers and Publishers #6307

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft

Conversation

fasmat
Copy link
Member

@fasmat fasmat commented Aug 29, 2024

Motivation

This PR adds handlers and publishers for malfeasance v2 proofs. This is a pre-requisite for enabling v2 ATXs on mainnet.

Closes #6143

Description

For this the existing malfeasance handler has been simplified again to only handle v1 proofs, with the goal of eventually retiring v1 malfeasance proofs in a future release. For malfeasance v2 new handlers and publishers were added.

Dedicated publishers for v1 and v2 proofs have been added, shifting the responsibility for publishing proofs from the handlers of components (activation, hare etc.) to dedicated services. This also allows to simplify handling proof publication since the components now don't need to keep track any more if they are in sync or not before publishing a proof (the publisher now keeps track of this instead).

The new DB table malfeasance requires foreign key constraints so these have now been enabled using PRAGMA foreign_keys = ON;. The new table will keep track of malicious identities and their proofs. The existing identities table will in future only be used to keep track of which identities belong to which marriage set. The proofs in them will be dropped when the publisher / handler of malfeasance v1 proofs are retired and existing proofs will be migrated to V2.

The general pattern for handling malfeasance v2 proofs is:

  1. receive proof via sync or gossip (malfeasance hander)
    • if the sender of the proof is self (because we just published the proof) return without doing anything (proof is already validated and persisted during publish)
  2. call domain specific malfeasance handler to validate the proof for the identity marked as malicious by the proof (e.g. atx malfeasance handler)
  3. if proof is valid evaluate the provided certificates to be valid (in the general malfeasance handler)
  4. store proof for the given identity and update the equivocation set to contain all identities that were not known to be part of the set before

The general pattern for publishing a malfeasance proof is:

  1. in some domain malicious behavior is detected and a domain specific proof is created for it (eg. double marry in activation domain)
  2. proof is passed to the domain specific publisher, which validates the proof to ensure that if we publish it others will also consider it valid
  3. domain specific publisher passes the proof along to the general malfeasance publisher that stores the proof
  4. if the node is in sync the general publisher publishes the proof to the network via libp2p (otherwise it is only persisted)

Test Plan

  • existing tests were updated
  • tests have been added for the new functionalities

TODO

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

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 63.98714% with 112 lines in your changes missing coverage. Please review.

Project coverage is 81.6%. Comparing base (f5f96b9) to head (ab0142b).

Files with missing lines Patch % Lines
malfeasance2/publisher.go 0.0% 28 Missing ⚠️
activation/malfeasance2_handler.go 0.0% 26 Missing ⚠️
sql/malfeasance/malfeasance.go 81.1% 12 Missing and 8 partials ⚠️
malfeasance/publisher.go 0.0% 18 Missing ⚠️
malfeasance/handler.go 73.9% 3 Missing and 3 partials ⚠️
activation/malfeasance2_publisher.go 0.0% 5 Missing ⚠️
malfeasance2/handler.go 90.4% 2 Missing and 2 partials ⚠️
sql/database.go 0.0% 2 Missing and 1 partial ⚠️
activation/wire/malfeasance_double_marry.go 0.0% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #6307     +/-   ##
=========================================
- Coverage     81.8%   81.6%   -0.2%     
=========================================
  Files          312     317      +5     
  Lines        34603   34817    +214     
=========================================
+ Hits         28310   28422    +112     
- Misses        4458    4551     +93     
- Partials      1835    1844      +9     

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

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

Successfully merging this pull request may close these issues.

Malfeasance V2: Publisher and Handler
1 participant