Skip to content

feat(poll): gate IIP-59 poll snapshot on era boundary (IIP-59 PR B)#4940

Closed
envestcc wants to merge 1 commit into
iip-59/pr2-snapshot-writerfrom
iip-59/pr-b-era-boundary-gate
Closed

feat(poll): gate IIP-59 poll snapshot on era boundary (IIP-59 PR B)#4940
envestcc wants to merge 1 commit into
iip-59/pr2-snapshot-writerfrom
iip-59/pr-b-era-boundary-gate

Conversation

@envestcc

Copy link
Copy Markdown
Member

Summary

Gates freezeIIP59PollSnapshot on IsEraBoundary(epochNum, EpochsPerRewardEra)
so the DelegateProfile commission-rate snapshot only fires at era-cadence epochs
(default 24 = one 24-hour era) instead of every epoch. This is step B of the
IIP-59 v2 era-based distribution rollout, stacked on top of #4915.

Ordering

Fork gate first, era gate second — pre-fork behavior is unchanged. When
EpochsPerRewardEra == 0, the write is skipped for every non-zero epoch,
matching IsEraBoundary's own zero-cadence semantic.

Changes

  • action/protocol/poll/util.go — thread epochNum into
    freezeIIP59PollSnapshot and add the era-boundary short-circuit after the
    existing !NoVoterRewardDistribution gate.
  • action/protocol/poll/util_test.go — new tests covering the four gate
    states (non-boundary skip / boundary proceeds / zero-cadence disables /
    pre-fork gate still wins) with a strict mock so any unintended state write
    fails the test.

Stack

Test plan

  • go test ./action/protocol/poll/... — 56 passed / 3 packages
  • go build ./...
  • go vet ./action/protocol/poll/...

🤖 Generated with Claude Code

Add IsEraBoundary(epochNum, EpochsPerRewardEra) check to freezeIIP59PollSnapshot
so the snapshot writer only fires at era-cadence epochs (default 24) instead of
every epoch. Ordering is fork-gate first, era-gate second — the pre-fork legacy
path is unchanged; EpochsPerRewardEra=0 disables the write for every non-zero
epoch, matching IsEraBoundary's own zero-cadence semantic.

The call site in setCandidates now passes epochNum through. Tests cover the
four gate states (non-boundary skip, boundary proceeds, zero-cadence disables,
pre-fork gate still wins) with a strict mock so any unintended state write
fails the test.
@sonarqubecloud

Copy link
Copy Markdown

envestcc added a commit that referenced this pull request Jul 20, 2026
TestFreezeIIP59PollSnapshot_EraBoundaryProceeds's strict mock rejected
the ReadView("staking") call that 5.5a's FreezePollSnapshot issues via
voterWeightsFromSM. Return ErrStateNotExist so the freezer degrades to
Entries=nil — matches the "view not installed" branch already tested
directly in staking/poll_snapshot_test.go.

Compat fix for the interaction between #4940 (era-boundary gate) and
#4952 / 5.5a (VoterWeightView-populated snapshot). Both cherry-picks
apply cleanly in isolation.
@envestcc

Copy link
Copy Markdown
Member Author

Superseded by #4953 (consolidated IIP-59 stack). The era-boundary gate commit fd1b6e7a → d3b24d1c was cherry-picked verbatim onto iip-59/consolidated-pr-5-through-5.5b; freezeIIP59PollSnapshot there now takes epochNum and short-circuits when !IsEraBoundary(epochNum, EpochsPerRewardEra), matching this PR's behavior. Please move review to #4953.

@envestcc envestcc closed this Jul 20, 2026
envestcc added a commit that referenced this pull request Jul 21, 2026
TestFreezeIIP59PollSnapshot_EraBoundaryProceeds's strict mock rejected
the ReadView("staking") call that 5.5a's FreezePollSnapshot issues via
voterWeightsFromSM. Return ErrStateNotExist so the freezer degrades to
Entries=nil — matches the "view not installed" branch already tested
directly in staking/poll_snapshot_test.go.

Compat fix for the interaction between #4940 (era-boundary gate) and
#4952 / 5.5a (VoterWeightView-populated snapshot). Both cherry-picks
apply cleanly in isolation.
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