feat(rewarding): EpochDrainCursor scaffolding for IIP-59 era drain (PR C1)#4941
Closed
envestcc wants to merge 1 commit into
Closed
feat(rewarding): EpochDrainCursor scaffolding for IIP-59 era drain (PR C1)#4941envestcc wants to merge 1 commit into
envestcc wants to merge 1 commit into
Conversation
Introduces the state schema + Go helpers for a multi-block era-boundary
drain of PendingBlockRewardPool balances into voter accounts, without
wiring it into GrantEpochReward yet. The wiring lands in the next
change; this PR isolates the additive schema/helper piece so the diff
stays readable.
Additions:
proto rewardingpb.EpochDrainCursor {target_era, delegate_index,
repeated EpochDrainDelegateWork} — cursor payload persisted at
state.EpochDrainCursorKey (singleton in RewardingNamespace).
Absence = no drain in progress. Presence carries the frozen work
list captured at Phase A so chunks in later blocks read stable
inputs even if the live pool keeps accruing behind the drain.
proto rewardingpb.EpochDrainDelegateWork {candidate_identifier,
pool_amount_frozen} — one frozen per-delegate work item.
state.EpochDrainCursorKey — singleton key prefix "edc" in
RewardingNamespace, mirroring the sentinel patterns already in
state/tables.go for block/epoch reward history.
action/protocol/rewarding/epoch_drain_cursor.go — cursor Go struct
+ Serialize / Deserialize + readEpochDrainCursor(returns nil,nil
when absent) / writeEpochDrainCursor(overwrites) /
deleteEpochDrainCursor (idempotent via existing deleteState
ErrStateNotExist swallow).
Test coverage:
round-trip (target_era, delegate_index, delegate list, big.Int pool
amounts including zero); empty delegate list; missing key returns
(nil, nil); write→read→delete lifecycle; second delete no-ops;
write overwrites rather than merges.
Explicitly deferred (follow-up PRs):
- GrantEpochReward refactor into chunked Phase A/B/C
- CreatePostSystemActions continuation dispatch on cursor presence
- IsEraBoundary gate (arrives with the PR A era genesis params)
- EpochDrainChunkSize genesis field / CompoundBatchSize wiring
Depends on: IIP-59 PR A (#4939) for the IsEraBoundary helper the
follow-up chunked-drain PR will use.
|
20 tasks
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.



Summary
Adds the state schema + Go helpers for a multi-block era-boundary drain
of `PendingBlockRewardPool` balances into voter accounts. This PR is
additive only — the cursor is not yet read or written by
`GrantEpochReward`. That wiring lands in PR C2. Splitting it off
isolates the schema/helper piece so the follow-up refactor diff stays
readable.
What's in
EpochDrainDelegateWork}` and `EpochDrainDelegateWork` in
`rewardingpb/rewarding.proto`.
`RewardingNamespace`, mirroring the sentinel patterns for block/epoch
reward history already there).
Serialize/Deserialize, and read/write/delete helpers
(`readEpochDrainCursor` returns `(nil, nil)` when absent; delete is
idempotent via the existing `deleteState` `ErrStateNotExist`
swallow).
Test plan
round-trip, empty delegate list, zero pool amount, missing-key
returns nil, write→read→delete lifecycle + idempotent second delete,
write overwrites rather than merges.
Stack
feat(IIP-59): PR A — era-based genesis params + IsEraBoundary helper #4939 (PR A — `IsEraBoundary` helper the follow-up chunked-drain PR
will use for the era-boundary trigger).
Explicitly deferred (PR C2 / C3)
presence
🤖 Generated with Claude Code