-
Notifications
You must be signed in to change notification settings - Fork 23
feat: detecting accounts stuck in undelegating state and fixing that #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* master: fix: allow auto airdrop to pay for rent & simulate inner instructions response (#646)
* master: feat: use latest svm version (#657) chore: update solana account (#660) fix: better transaction diagnostics & rent exemption check (#642) chore: add access-control-max-age header to cors (#654) fix(aperture): prevent racy getLatestBlockhash (#649) fix: await until sub is established and perform them in parallel (#650) feat: persist all accounts (#648)
Manual Deploy AvailableYou can trigger a manual deploy of this PR branch to testnet: Alternative: Comment
Comment updated automatically when the PR is synchronized. |
WalkthroughAdds undelegation tracking and handling across chainlink and program code: marks accounts as undelegating, propagates delegation records through fetch/clone, skips refreshes when undelegation is still pending on-chain, and updates tests and mock helpers accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant Bank as Local Bank
participant Fetch as Fetch/Clone
participant OnChain as On-Chain RPC
participant Provider as Remote Provider
Fetch->>Bank: Inspect local account state
alt Local account marked undelegating
Fetch->>OnChain: Query DelegationRecord & remote slot
OnChain-->>Fetch: (DelegationRecord, remote_slot)
Fetch->>Fetch: account_still_undelegating_on_chain?
alt Still undelegating
Fetch-->>Provider: Block remote update (skip refresh)
Note over Fetch,Bank: keep local undelegating state
else Undelegation complete or re-delegated
Fetch->>Provider: Allow refresh / fetch latest account
Provider-->>Bank: Apply updated account (maybe unmark)
Note over Fetch,Bank: increment unstuck metric if applicable
end
else Not undelegating
Fetch->>Provider: Normal fetch/update flow
Provider-->>Bank: Apply update
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (5)📚 Learning: 2025-11-18T08:47:39.702ZApplied to files:
📚 Learning: 2025-11-19T09:34:37.917ZApplied to files:
📚 Learning: 2025-11-07T14:20:31.457ZApplied to files:
📚 Learning: 2025-10-21T14:00:54.642ZApplied to files:
📚 Learning: 2025-11-19T11:31:24.218ZApplied to files:
🧬 Code graph analysis (2)magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs (1)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (8)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
magicblock-chainlink/src/accounts_bank.rs (1)
49-56: Stub now tracksundelegatingflag; consider updatingforce_undelegationdocs
AccountsBankStub::undelegatenow setsundelegating = trueanddelegated = false, and the newset_undelegatinghelper mirrors the existingset_owner/set_delegatedpatterns (including panicking if the account is missing), which is appropriate for a test stub.The comment on
force_undelegationstill only mentionsset_ownerandset_delegated, but viaundelegateit now also sets theundelegatingflag. Consider updating the comment for clarity:- /// Here we mark the account as undelegated in our validator via: - /// - set_owner to delegation program - /// - set_delegated to false + /// Here we mark the account as undelegated in our validator via: + /// - set_owner to delegation program + /// - set_delegated to false + /// - set_undelegating to trueAlso applies to: 68-81
programs/magicblock/src/schedule_transactions/process_schedule_base_intent.rs (1)
17-21: Base-intent scheduling now marks undelegating accounts and logs themUsing
mark_account_as_undelegatingonundelegated_accounts_refensures the same owner+flag semantics as the commit path, and doing it before persistingScheduledBaseIntentkeeps the validator’s view consistent with what was scheduled.Collecting the affected pubkeys into
undelegated_pubkeysfor a singleic_msg!improves observability without affecting control flow; the extra allocation is minor given the expected account counts.Also applies to: 140-155
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (11)
magicblock-chainlink/src/accounts_bank.rs(2 hunks)magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs(1 hunks)magicblock-chainlink/src/chainlink/fetch_cloner.rs(16 hunks)magicblock-chainlink/src/chainlink/mod.rs(1 hunks)magicblock-chainlink/src/remote_account_provider/remote_account.rs(0 hunks)magicblock-chainlink/src/testing/mod.rs(2 hunks)magicblock-chainlink/tests/01_ensure-accounts.rs(4 hunks)programs/magicblock/src/mutate_accounts/process_mutate_accounts.rs(1 hunks)programs/magicblock/src/schedule_transactions/process_schedule_base_intent.rs(2 hunks)programs/magicblock/src/schedule_transactions/process_schedule_commit.rs(2 hunks)programs/magicblock/src/utils/account_actions.rs(1 hunks)
💤 Files with no reviewable changes (1)
- magicblock-chainlink/src/remote_account_provider/remote_account.rs
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579
Applied to files:
programs/magicblock/src/mutate_accounts/process_mutate_accounts.rsmagicblock-chainlink/src/chainlink/mod.rsprograms/magicblock/src/utils/account_actions.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_base_intent.rsmagicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsmagicblock-chainlink/tests/01_ensure-accounts.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.
Applied to files:
programs/magicblock/src/mutate_accounts/process_mutate_accounts.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_base_intent.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.
Applied to files:
magicblock-chainlink/src/chainlink/mod.rsmagicblock-chainlink/src/testing/mod.rsmagicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsmagicblock-chainlink/tests/01_ensure-accounts.rs
📚 Learning: 2025-11-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.
Applied to files:
programs/magicblock/src/utils/account_actions.rsmagicblock-chainlink/src/testing/mod.rsmagicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rsmagicblock-chainlink/tests/01_ensure-accounts.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.
Applied to files:
programs/magicblock/src/schedule_transactions/process_schedule_commit.rsprograms/magicblock/src/schedule_transactions/process_schedule_base_intent.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.
Applied to files:
magicblock-chainlink/src/testing/mod.rsmagicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsmagicblock-chainlink/tests/01_ensure-accounts.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.
Applied to files:
magicblock-chainlink/src/testing/mod.rs
📚 Learning: 2025-11-19T11:31:24.218Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-chainlink/tests/ix_01_ensure-accounts.rs:85-114
Timestamp: 2025-11-19T11:31:24.218Z
Learning: In the magicblock-validator codebase, compressed delegation records are never subscribed to by design. Tests for compressed delegation flows should focus on verifying that the delegated account (e.g., counter PDA) is cloned as delegated and not subscribed, but do not need to check for subscription to delegation-record-like PDAs in the compressed path because subscriptions to compressed delegation records never occur.
Applied to files:
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rsmagicblock-chainlink/src/chainlink/fetch_cloner.rsmagicblock-chainlink/tests/01_ensure-accounts.rs
🧬 Code graph analysis (7)
magicblock-chainlink/src/chainlink/mod.rs (1)
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs (1)
account_still_undelegating_on_chain(22-89)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
programs/magicblock/src/utils/account_actions.rs (1)
mark_account_as_undelegating(18-21)
magicblock-chainlink/src/testing/mod.rs (4)
magicblock-chainlink/src/remote_account_provider/remote_account.rs (4)
account(180-202)remote_slot(145-151)owner(54-60)owner(243-245)magicblock-chainlink/src/accounts_bank.rs (1)
get_account(106-108)test-kit/src/lib.rs (1)
get_account(282-292)magicblock-accounts-db/src/lib.rs (1)
get_account(335-338)
programs/magicblock/src/schedule_transactions/process_schedule_base_intent.rs (1)
programs/magicblock/src/utils/account_actions.rs (1)
mark_account_as_undelegating(18-21)
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs (2)
magicblock-metrics/src/metrics/mod.rs (1)
inc_undelegation_completed(491-493)magicblock-chainlink/src/remote_account_provider/remote_account.rs (1)
remote_slot(145-151)
magicblock-chainlink/src/chainlink/fetch_cloner.rs (4)
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs (1)
account_still_undelegating_on_chain(22-89)magicblock-chainlink/src/chainlink/blacklisted_accounts.rs (1)
blacklisted_accounts(6-29)magicblock-chainlink/src/remote_account_provider/remote_account.rs (3)
account(180-202)delegated(95-101)slot(203-215)magicblock-metrics/src/metrics/mod.rs (1)
inc_unstuck_undelegation_count(495-497)
magicblock-chainlink/tests/01_ensure-accounts.rs (1)
test-integration/test-magicblock-api/tests/test_claim_fees.rs (1)
validator_pubkey(31-34)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: run_make_ci_lint
🔇 Additional comments (17)
magicblock-chainlink/src/chainlink/mod.rs (1)
29-29: Wire-up ofaccount_still_undelegating_on_chainmodule looks correctThe new submodule declaration cleanly registers the helper without widening the public API; this matches the usage pattern from
fetch_clonerand keeps the decision logic encapsulated underchainlink.programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
17-25: Importingmark_account_as_undelegatingaligns with new undelegation helperSwitching the import to
account_actions::mark_account_as_undelegatingkeeps this call site in sync with the renamed/extended helper that also flips the undelegating flag, centralizing undelegation pre-state handling.
190-210: Usingmark_account_as_undelegatingwhen scheduling undelegation is consistent and safeCalling
mark_account_as_undelegating(acc)after the writability and ownership checks correctly:
- Locks the account by setting the owner to the delegation program.
- Marks it as
undelegatingso chainlink can apply the new stuck-undelegation logic.The extra commentary and log message accurately describe these side effects, and the borrow scopes around
accavoid RefCell borrow conflicts.programs/magicblock/src/mutate_accounts/process_mutate_accounts.rs (1)
129-133: Clearingundelegatingon mutation relies on global invariants—please confirmUntoggling the flag with
account.borrow_mut().set_undelegating(false);before applying modifications matches the design that only non-pending accounts are ever mutated, and Solana’s transaction semantics ensure this change is rolled back if the instruction fails later.This does, however, depend on the invariant stated in the comment—that accounts whose undelegation is still pending are never routed through
process_mutate_accounts. Please double‑check that the fetch/clone and scheduling flows fully enforce this, so we don’t accidentally drop theundelegatingflag while the on-chain undelegation is still incomplete.programs/magicblock/src/utils/account_actions.rs (1)
17-21:mark_account_as_undelegatingcorrectly encapsulates undelegation pre-stateHaving a single helper that sets the owner to
DELEGATION_PROGRAM_IDand flipsundelegatingtotruekeeps the undelegation pre-state consistent acrossprocess_schedule_base_intentandprocess_schedule_commit. The implementation is straightforward and matches the documented intent.magicblock-chainlink/tests/01_ensure-accounts.rs (3)
7-8: LGTM! Import changes support new undelegation test assertions.The new test helper imports (
assert_not_undelegating,assert_remain_undelegating,assert_subscribed_without_delegation_record) align with the expanded undelegation test coverage introduced in this PR.
178-215: LGTM! Test correctly validates re-delegation to another validator scenario.The renamed test now clearly describes the scenario: an account marked as undelegating in the bank is re-delegated to a different validator on-chain. The test setup properly:
- Creates a separate
other_authorityfor the on-chain delegation record- Marks the bank account as undelegating
- Asserts that the undelegating flag is cleared when the remote state is refreshed
This corresponds to Case C in the
account_still_undelegating_on_chainlogic.
217-256: LGTM! Test correctly validates pending undelegation scenario.This new test validates Case D from the
account_still_undelegating_on_chainlogic: when an account is marked as undelegating in the bank and remains delegated to the validator on-chain (with no newer delegation), the undelegating flag should persist. The test properly:
- Sets up the account as still delegated to the validator on-chain
- Marks the bank account as undelegating
- Verifies the undelegating flag remains set after the fetch
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs (2)
5-28: LGTM! Well-documented function signature with clear contract.The function documentation clearly explains the decision logic and the single case (Case D) where the undelegating flag should persist. The parameter list provides all necessary context for making the determination.
75-88: LGTM! Cases A and C correctly handle completed undelegations.Both cases appropriately return
false(indicating undelegation completed and account should be refreshed), increment the completion metric, and provide debug logging for observability.magicblock-chainlink/src/chainlink/fetch_cloner.rs (7)
208-241: LGTM! Subscription listener correctly integrates undelegation checks.The subscription update handler now:
- Retrieves delegation records alongside account data
- Checks if the bank account is marked as undelegating
- Uses
account_still_undelegating_on_chainto determine whether to skip the update (Case D)- Provides defensive logging for edge cases
The parameter passing to
account_still_undelegating_on_chainat lines 223-229 correctly provides:
account.delegated()foris_delegated_to_us_on_chainin_bank.remote_slot()forremote_slot_in_bankdeleg_recordwhich may be None
339-469: LGTM! Function signature updated to provide delegation record context.The
resolve_account_to_clone_from_forwarded_sub_with_unsubscribefunction now returns a tuple(Option<AccountSharedData>, Option<DelegationRecord>)instead of just the account. All return paths are consistently updated:
- Valid delegated account:
(Some(account), Some(delegation_record))- Account without delegation record:
(Some(account), None)- Error cases:
(None, None)This enables the caller to use the delegation record for undelegation decisions.
491-555: LGTM! Delegation record fetching handles subscription lifecycle correctly.The
fetch_and_parse_delegation_recordfunction properly:
- Tracks whether the delegation record was already being watched (line 498-500)
- Fetches and parses the delegation record
- Only unsubscribes if this call initiated the subscription AND the record wasn't cloned concurrently (lines 533-552)
The edge case handling at lines 537-540 defensively checks if the delegation record was cloned during the fetch operation to avoid unsubscribing from a record that's now in the bank.
1034-1074: LGTM! Function correctly determines when to refresh undelegating accounts.The
should_refresh_undelegating_in_bank_accountfunction:
- Checks if the bank account is marked as undelegating (line 1044)
- Fetches the current delegation record from chain (lines 1046-1051)
- Determines if the account is still delegated on-chain (lines 1052-1055)
- Calls
account_still_undelegating_on_chainand returns the inverse (lines 1056-1067)The logic inversion at line 1056-1062 is correct:
- If
account_still_undelegating_on_chainreturnstrue(Case D - still undelegating), this function returnsfalse(don't refresh)- If
account_still_undelegating_on_chainreturnsfalse(Cases A, B, C - undelegation completed), this function returnstrue(do refresh)
1110-1132: LGTM! Efficient pre-fetch filtering for undelegating accounts.The code adds an optimization to check undelegating accounts before fetching:
- For each account in the bank, checks if it's undelegating and needs refresh (lines 1115-1120)
- If undelegation completed, marks for re-fetch and increments the unstuck metric (lines 1121-1124)
- If still undelegating, skips the fetch (lines 1125-1129)
- Filters out accounts that don't need fetching (line 1132)
This prevents unnecessary network calls for accounts still in the undelegating state (Case D).
690-692: LGTM! Trace logging updated to reflect new account categorization.The trace logging now includes the
owned_by_delegcategory separately, aligning with the updated 4-way categorization (not_found, plain, owned_by_deleg, programs).
665-667: Remove suggestion to usepanic!()orunreachable!()—current error logging is appropriate.The filtering at line 1137 does remove accounts found in bank before calling
fetch_and_clone_accounts, upholding the invariant. However,ResolvedAccount::Bankcan still occur at lines 665-667 due to race conditions or concurrent access—a fetch initiated after filtering may encounter the account in the bank by the timetry_get_multi()returns. Error logging is defensive programming here, not an unreachable case.
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs
Show resolved
Hide resolved
magicblock-chainlink/src/chainlink/account_still_undelegating_on_chain.rs
Outdated
Show resolved
Hide resolved
* master: perf: allow pubsub actor messages to be handled in parallel (#659)
ChatThere are 3 ways to chat with CodeRabbit:
CodeRabbit commands
Other keywords and placeholders
CodeRabbit configuration file (
|
|
@coderabbitai configuration |
CodeRabbit configurationlanguage: en-US
tone_instructions: ''
early_access: true
enable_free_tier: true
reviews:
profile: assertive
request_changes_workflow: false
high_level_summary: true
high_level_summary_instructions: ''
high_level_summary_placeholder: Summary
high_level_summary_in_walkthrough: false
auto_title_placeholder: ''
auto_title_instructions: ''
review_status: true
commit_status: true
fail_commit_status: false
collapse_walkthrough: false
changed_files_summary: true
sequence_diagrams: true
estimate_code_review_effort: true
assess_linked_issues: true
related_issues: true
related_prs: true
suggested_labels: true
labeling_instructions: []
auto_apply_labels: true
suggested_reviewers: true
auto_assign_reviewers: false
in_progress_fortune: false
poem: false
path_filters: []
path_instructions: []
abort_on_close: true
disable_cache: false
auto_review:
enabled: true
auto_incremental_review: true
ignore_title_keywords: []
labels: []
drafts: false
base_branches: []
ignore_usernames: []
finishing_touches:
docstrings:
enabled: true
unit_tests:
enabled: true
pre_merge_checks:
docstrings:
mode: warning
threshold: 80
title:
mode: warning
requirements: ''
description:
mode: warning
issue_assessment:
mode: warning
custom_checks: []
tools:
ast-grep:
rule_dirs: []
util_dirs: []
essential_rules: true
packages: []
shellcheck:
enabled: true
ruff:
enabled: true
markdownlint:
enabled: true
github-checks:
enabled: true
timeout_ms: 90000
languagetool:
enabled: true
enabled_rules: []
disabled_rules: []
enabled_categories: []
disabled_categories: []
enabled_only: false
level: default
biome:
enabled: true
hadolint:
enabled: true
swiftlint:
enabled: true
phpstan:
enabled: true
level: default
phpmd:
enabled: true
phpcs:
enabled: true
golangci-lint:
enabled: true
yamllint:
enabled: true
gitleaks:
enabled: true
checkov:
enabled: true
detekt:
enabled: true
eslint:
enabled: true
flake8:
enabled: true
rubocop:
enabled: true
buf:
enabled: true
regal:
enabled: true
actionlint:
enabled: true
pmd:
enabled: true
clang:
enabled: true
cppcheck:
enabled: true
semgrep:
enabled: true
circleci:
enabled: true
clippy:
enabled: true
sqlfluff:
enabled: true
prismaLint:
enabled: true
pylint:
enabled: true
oxc:
enabled: true
shopifyThemeCheck:
enabled: true
luacheck:
enabled: true
brakeman:
enabled: true
dotenvLint:
enabled: true
htmlhint:
enabled: true
checkmake:
enabled: true
osvScanner:
enabled: true
chat:
art: true
auto_reply: true
integrations:
jira:
usage: auto
linear:
usage: auto
knowledge_base:
opt_out: false
web_search:
enabled: true
code_guidelines:
enabled: true
filePatterns: []
learnings:
scope: auto
issues:
scope: auto
jira:
usage: auto
project_keys: []
linear:
usage: auto
team_keys: []
pull_requests:
scope: auto
mcp:
usage: auto
disabled_servers: []
code_generation:
docstrings:
language: en-US
path_instructions: []
unit_tests:
path_instructions: []
issue_enrichment:
planning:
enabled: false
|
bmuddha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary by CodeRabbit
Bug Fixes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.
Refactored account undelegation handling to be more robust and maintainable. Introduced a centralized decision function to determine if an account has finished undelegating on chain, properly manages the
undelegatingflag throughout the account lifecycle, and removes unreliable account refetching logic that was attempting to detect undelegation completion.Details
The changes address issues with detecting when accounts have completed their undelegation process on chain. Previously, the system tried to infer undelegation completion from account owner changes, which was error-prone. Now there's a single source of truth for this decision.
Core Logic for Undelegation Detection
Created a new module
account_still_undelegating_on_chainthat centralizes the logic for deciding whether an account's undelegation is still pending or has completed. This function considers:Four cases are handled:
Account Undelegating Flag Management
Properly set and clear the
undelegatingflag in key locations:mark_account_as_undelegating)Subscription Update Handling
Updated the subscription update handler to:
undelegatingflag to allow later detection of completionFetch and Clone Logic Improvements
should_refresh_undelegating_in_bank_accountto check if an undelegating account has finished undelegating when it's fetchedis_still_delegated_to_usmethod and the refetching logic that tried to detect undelegation completion by periodically checking delegation stateTesting
assert_not_undelegatingmacro for test assertionsundelegatingflagtest_write_undelegating_account_undelegated_to_other_validatorto cover re-delegation to another validatortest_write_undelegating_account_still_being_undelegated