Skip to content

Add epoch-0 and slot-0 slashing protection tests - #101

Open
AntiD2ta wants to merge 5 commits into
masterfrom
test/epoch-0-attestation
Open

Add epoch-0 and slot-0 slashing protection tests#101
AntiD2ta wants to merge 5 commits into
masterfrom
test/epoch-0-attestation

Conversation

@AntiD2ta

@AntiD2ta AntiD2ta commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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=0 and slot=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.

AntiD2ta added 4 commits April 7, 2026 15:50
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.
@AntiD2ta AntiD2ta changed the title test: add epoch-0 and slot-0 slashing protection tests Add epoch-0 and slot-0 slashing protection tests Apr 9, 2026
@AntiD2ta AntiD2ta self-assigned this Apr 9, 2026
@AntiD2ta
AntiD2ta requested a review from Bez625 April 9, 2026 15:21
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.
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