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

[Merged by Bors] - Minify slashing protection interchange data #2380

Closed

Conversation

michaelsproul
Copy link
Member

Issue Addressed

Closes #2354

Proposed Changes

Add a minify method to slashing_protection::Interchange that keeps only the maximum-epoch attestation and maximum-slot block for each validator. Specifically, minify constructs "synthetic" attestations (with no signing_root) containing the maximum source epoch and the maximum target epoch from the input. This is equivalent to the minify_synth algorithm that I've formally verified in this repository:

https://github.com/michaelsproul/slashing-proofs

Additional Info

Includes the JSON loading optimisation from #2347

@michaelsproul michaelsproul added work-in-progress PR is a work-in-progress v1.5.0 For inclusion in v1.5.0 release labels May 31, 2021
@michaelsproul michaelsproul added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Jun 16, 2021
@michaelsproul
Copy link
Member Author

I'm marking this as ready for review.

I've made some more changes in the last few days, including removing partial imports. The rationale for doing so is in the release notes of the EIP-3076 tests here: https://github.com/eth2-clients/slashing-protection-interchange-tests/releases/tag/v5.1.0-alpha.1

Pending approval from other implementers of those changes, the only change required to this PR will be renaming allow_partial_import to contains_slashable_data, and bumping the tag in the Makefile.

Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Looks good, nice work!

Looking at the docs, I notice we don't make a clear statement about whether or not IIFs containing slashable data are Good or Bad. I'm a bit conflicted here; on the one hand it's nice to avoid making a statement about the integrity of some external input (the IIF). But, on the other hand, I'm struggling to think of a scenario where you would want to abort an import because there's slashable data there. Perhaps the double-signing would indicate a corruption in the data?

I don't really have a concrete suggestion and I think what you have is choosing safety from uncertainty, which is sensible. I thought I'd just raise it and see if it inspires anything in you.

I'm happy to merge as is 🙂

@paulhauner paulhauner added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Jun 21, 2021
@michaelsproul
Copy link
Member Author

Looking at the docs, I notice we don't make a clear statement about whether or not IIFs containing slashable data are Good or Bad.

Hmm, you're right that the docs don't say this explicitly. Part of the issue is that there are legitimate cases where the data will fail to import because it appears slashable (e.g. importing the same file twice), which we don't differentiate from the input data being slashable w.r.t. to itself.

My hope is that by doing minification by default we'll provide safe and error-free behaviour for 99% of users, and the ones that run into oddities will either wade through the intricacies themselves or contact us on Discord so we can help them.

I'm struggling to think of a scenario where you would want to abort an import because there's slashable data there.

I think if you're not expecting there to be slashable data, and you opt into --minify=false and find that there is slashable data, then stopping the import and forcing you to reconsider is OK.

I don't have any concrete ideas for improving the docs right now, so I think we merge and see how this is understood.

bors r+

bors bot pushed a commit that referenced this pull request Jun 21, 2021
## Issue Addressed

Closes #2354

## Proposed Changes

Add a `minify` method to `slashing_protection::Interchange` that keeps only the maximum-epoch attestation and maximum-slot block for each validator. Specifically, `minify` constructs "synthetic" attestations (with no `signing_root`) containing the maximum source epoch _and_ the maximum target epoch from the input. This is equivalent to the `minify_synth` algorithm that I've formally verified in this repository:

https://github.com/michaelsproul/slashing-proofs

## Additional Info

Includes the JSON loading optimisation from #2347
@bors bors bot changed the title Minify slashing protection interchange data [Merged by Bors] - Minify slashing protection interchange data Jun 21, 2021
@bors bors bot closed this Jun 21, 2021
@michaelsproul michaelsproul deleted the slashing-protection-minify branch June 21, 2021 07:40
bors bot pushed a commit that referenced this pull request Oct 13, 2021
## Issue Addressed

Closes #2419

## Proposed Changes

Address a long-standing issue with the import of slashing protection data where the import would fail due to the data appearing slashable w.r.t the existing database. Importing is now idempotent, and will have no issues importing data that has been handed back and forth between different validator clients, or different implementations.

The implementation works by updating the high and low watermarks if they need updating, and not attempting to check if the input is slashable w.r.t itself or the database. This is a strengthening of the minification that we started to do by default since #2380, and what Teku has been doing since the beginning.

## Additional Info

The only feature we lose by doing this is the ability to do non-minified imports of clock drifted messages (cf. Prysm on Medalla). In theory, with the previous implementation we could import all the messages in case of clock drift and be aware of the "gap" between the real present time and the messages signed in the far future. _However_ for attestations this is close to useless, as the source epoch will advance as soon as justification occurs, which will require us to make slashable attestations with respect to our bogus attestation(s). E.g. if I sign an attestation 100=>200 when the current epoch is 101, then I won't be able to vote in any epochs prior to 101 becoming justified because 101=>102, 101=>103, etc are all surrounded by 100=>200. Seeing as signing attestations gets blocked almost immediately in this case regardless of our import behaviour, there's no point trying to handle it. For blocks the situation is more hopeful due to the lack of surrounds, but losing block proposals from validators who by definition can't attest doesn't seem like an issue (the other block proposers can pick up the slack).
bors bot pushed a commit that referenced this pull request Oct 13, 2021
## Issue Addressed

Closes #2419

## Proposed Changes

Address a long-standing issue with the import of slashing protection data where the import would fail due to the data appearing slashable w.r.t the existing database. Importing is now idempotent, and will have no issues importing data that has been handed back and forth between different validator clients, or different implementations.

The implementation works by updating the high and low watermarks if they need updating, and not attempting to check if the input is slashable w.r.t itself or the database. This is a strengthening of the minification that we started to do by default since #2380, and what Teku has been doing since the beginning.

## Additional Info

The only feature we lose by doing this is the ability to do non-minified imports of clock drifted messages (cf. Prysm on Medalla). In theory, with the previous implementation we could import all the messages in case of clock drift and be aware of the "gap" between the real present time and the messages signed in the far future. _However_ for attestations this is close to useless, as the source epoch will advance as soon as justification occurs, which will require us to make slashable attestations with respect to our bogus attestation(s). E.g. if I sign an attestation 100=>200 when the current epoch is 101, then I won't be able to vote in any epochs prior to 101 becoming justified because 101=>102, 101=>103, etc are all surrounded by 100=>200. Seeing as signing attestations gets blocked almost immediately in this case regardless of our import behaviour, there's no point trying to handle it. For blocks the situation is more hopeful due to the lack of surrounds, but losing block proposals from validators who by definition can't attest doesn't seem like an issue (the other block proposers can pick up the slack).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge. v1.5.0 For inclusion in v1.5.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants