docs: clarify validator drain runbook#212
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe README.md "Manage → Drain" section is expanded from a brief 4-step outline into a comprehensive drain procedure. The documentation now details setting validator weight/base stake to zero, syncing validator accounting with explicit failure-retry behavior, verifying intermediate validator state before and after drain-unstake, settling unstaked balances, and how drain-withdraw restarts drained funds into epoch stake requests. ChangesDrain Procedure Documentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
README.md (1)
99-100: ⚡ Quick winMake the unstaked settlement threshold explicit in protocol units.
Using “
>= 1 NEAR” is readable, but runbooks are safer when they specify the exact comparison basis (human-readable NEAR vs on-chain yoctoNEAR) and why this threshold is chosen. A short note here would reduce operator ambiguity.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@README.md` around lines 99 - 100, Clarify the unstaked settlement threshold by specifying the on-chain units and rationale: update the sentence referencing get_validator and unstaked_amount to use an explicit yoctoNEAR comparison (e.g., "unstaked_amount >= 1 NEAR (>= 1_000_000_000_000_000_000_000_000 yoctoNEAR)") and add a short parenthetical explaining the basis for choosing 1 NEAR (e.g., minimum operator cost/rounding safety), so operators know the exact on-chain comparison and why epoch_withdraw should be called.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Line 110: The instruction "After 4 epochs, verify `get_validator` again" is
ambiguous; change it to a specific anchor such as "4 full epochs after the
successful `drain-unstake` callback has been confirmed on-chain (i.e., after the
`drain-unstake` transaction finalization)". Update the README step to explicitly
state "4 full epochs after successful `drain-unstake` callback confirmation" so
readers know to wait for transaction finalization and the callback success
before calling `get_validator` or attempting withdrawals.
---
Nitpick comments:
In `@README.md`:
- Around line 99-100: Clarify the unstaked settlement threshold by specifying
the on-chain units and rationale: update the sentence referencing get_validator
and unstaked_amount to use an explicit yoctoNEAR comparison (e.g.,
"unstaked_amount >= 1 NEAR (>= 1_000_000_000_000_000_000_000_000 yoctoNEAR)")
and add a short parenthetical explaining the basis for choosing 1 NEAR (e.g.,
minimum operator cost/rounding safety), so operators know the exact on-chain
comparison and why epoch_withdraw should be called.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
README.md (1)
105-111: 💤 Low valueConsider rephrasing for better readability.
The verification checklist items all follow the pattern "field
isvalue", which is clear but slightly repetitive. Consider introducing the list with a phrase like "Verify the following fields:" and then using a more concise format.📝 Alternative phrasing
-4. Verify `get_validator` before `drain-unstake`: - - `weight` is `0`. - - `base_stake_amount` is `0`. - - `pending_release` is `false`. - - `unstaked_amount` is less than `1 NEAR` - (`1_000_000_000_000_000_000_000_000 yoctoNEAR`). - - `draining` is `false`. +4. Verify `get_validator` returns the following before `drain-unstake`: + - `weight`: `0` + - `base_stake_amount`: `0` + - `pending_release`: `false` + - `unstaked_amount`: less than `1 NEAR` + (`1_000_000_000_000_000_000_000_000 yoctoNEAR`) + - `draining`: `false`🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@README.md` around lines 105 - 111, Update the README section that instructs to "Verify `get_validator` before `drain-unstake`" by introducing a short header like "Verify the following fields via get_validator before running drain-unstake:" and convert the repetitive sentences into a compact checklist (e.g., "weight: 0", "base_stake_amount: 0", "pending_release: false", "unstaked_amount: < 1 NEAR (1_000_000_000_000_000_000_000_000 yoctoNEAR)", "draining: false") so the same information remains but reads more concisely and consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 113-114: Clarify the epoch counting by anchoring it explicitly to
the callback success of the drain-unstake transaction: update the sentence
referencing "4 full epochs have passed since the `drain-unstake` transaction
finalized and its callback succeeded" to state that you must first wait for the
`drain-unstake` transaction's callback to succeed, then count 4 complete epochs
from the moment the callback succeeded, and only after those 4 full epochs run
the `get_validator` verification; reference the `drain-unstake` transaction and
the `get_validator` check to make the sequence unambiguous.
---
Nitpick comments:
In `@README.md`:
- Around line 105-111: Update the README section that instructs to "Verify
`get_validator` before `drain-unstake`" by introducing a short header like
"Verify the following fields via get_validator before running drain-unstake:"
and convert the repetitive sentences into a compact checklist (e.g., "weight:
0", "base_stake_amount: 0", "pending_release: false", "unstaked_amount: < 1 NEAR
(1_000_000_000_000_000_000_000_000 yoctoNEAR)", "draining: false") so the same
information remains but reads more concisely and consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
Summary
This PR updates the validator drain documentation to make the operational runbook explicit.
Problem
The existing drain instructions described the basic
drain-unstake/drain-withdrawflow, but they did not clearly require syncing validator accountingwith the staking pool before selecting the drain amount. They also did not mention the
base_stake_amount = 0precondition that the contract enforces.Update
The drain runbook now documents the required sequence:
0.0.epoch_update_rewardsbefore drain and wait for the callback to succeed.sync_balance_from_validatorand wait for the callback to succeed.drain-unstake.get_validatorfields beforedrain-unstakeand beforedrain-withdraw.Summary by CodeRabbit