Add epoch-0 and slot-0 slashing protection tests - #101
Open
AntiD2ta wants to merge 5 commits into
Open
Conversation
Add test cases for genesis (epoch 0 / slot 0) slashing protection behavior to establish baseline before investigating the runtime epoch 0 finalization issue. Attestation tests (TestSignBeaconAttestationEpochZero): - GenesisAttestation: fresh state → APPROVED - GenesisAttestationRetry: same epoch → DENIED - PostGenesisAttestation: advance to epoch 1 → APPROVED - PostGenesisAttestationHigher: advance to epoch 2 → APPROVED Proposal tests (TestSignBeaconProposalSlotZero): - GenesisSlotProposal: fresh state → APPROVED - GenesisSlotRetry: same slot → DENIED - PostGenesisSlotProposal: advance to slot 1 → APPROVED
Remove implementation detail (sentinel value -1) from doc comments, describe behavior in terms of state absence instead.
Add TestSignBeaconAttestationsEpochZero covering OnSignBeaconAttestations at genesis: batch approval with multiple validators, retry denial, and epoch advancement. Uses distinct pubkeys to verify per-validator state tracking in the batch path.
Use assert.Equal instead of require.Equal in the sequential state-accumulating test to avoid masking later subtest results. Add clarifying comment on the equal-epoch genesis special case. Add inline sequential-state comment matching single-path test style.
Replace the fragile signbeaconattestations.go:142 line reference with the actual condition string. Add PostGenesisBatchMixed test case to verify per-validator independence in the batch attestation path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The rules layer's behavior at epoch 0 and slot 0 had no dedicated test coverage. During a devnet investigation, we confirmed the behavior is correct — Dirk's slashing protection correctly denies re-signing at
targetEpoch=0andslot=0— but there were no tests documenting this as intentional.Solution
Add test cases covering single-path and batch-path attestation signing at epoch 0, as well as proposal signing at slot 0. These tests confirm that Dirk correctly enforces slashing protection at genesis boundaries and serve as regression tests for this behavior.