Skip to content

Conversation

@bertllll
Copy link
Contributor

@bertllll bertllll commented Nov 29, 2025

Note

Adjust receivables scheduling and rescheduling on errors, replace/extend scanner error-hint enum, rename scan interval API, and propagate these changes across scanners, mocks, and tests.

  • Scheduling and Error Handling:
    • Receivables: ScanForReceivables now respects rescheduling hints; ReceivedPayments schedules the next receivable scan when no UI response.
    • Centralize start-scan error handling via handle_start_scan_error; add support for Receivables in rescheduling logic.
    • Add reset_scan_timer() call when initiating new payables.
  • Enums and APIs:
    • Replace PayableSequenceScanner with UnableToStartScanner (includes Receivables).
    • Rename interval API time_until_next_scan() to compute_time_to_next_scan() (real + mock + callers).
    • Use StartScanError::nothing_to_process(response_skeleton_opt) in payable and pending-payable scanners.
  • Pending Payables:
    • Extract and simplify prechecks via check_pending_payable_existence; adjust guard logic.
  • Tests and Utilities:
    • Update tests to new enums, interval API, and receivables behavior; tweak timings/assertions.
    • Recorder: rename build_and_provide_addresses() to build_with_addresses(); update call sites.

Written by Cursor Bugbot for commit 8c5f218. This will update automatically on new commits. Configure here.

impl RescheduleScanOnErrorResolverReal {
fn resolve_new_payables(
err: &StartScanError,
is_externally_triggered: bool,
Copy link
Collaborator

@utkarshg6 utkarshg6 Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an idea!

How about StartScanError are of following types:

enum StartScanError {
  Automatic(AutomaticError),
  Manual(ManualError),
  Test
}

enum AutomaticError {
      ScanAlreadyRunning {
        cross_scan_cause_opt: Option<ScanType>,
        started_at: SystemTime,
    },
    Common(CommonError)
}

enum ManualError {
  AutomaticScanConflict,
  UnnecessaryRequest { hint_opt: Option<String> },
  Common(CommonError)
}

enum CommonError {
  NothingToProcess,
  NoConsumingWalletFound
}

This way, we can get rid of the flag is_externally_triggered and hopefully unreachable!() too if we refactor it further.

Copy link
Contributor Author

@bertllll bertllll Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This costs me a lot of pain for little in return 🤕

I gave up, this idea was a no-pass-through.

pub fn build_and_provide_addresses(self) -> (PeerActors, PeerActorAddrs) {
//
// The addresses may be helpful for setting up the Counter Messages.
pub fn build_providing_addresses(self) -> (PeerActors, PeerActorAddrs) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_and_provide_addresses was a better name.

Copy link
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

)
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Receivables can stall if completion message missing

Handler<ScanForReceivables> no longer schedules the next receivables scan; scheduling now happens only when ReceivedPayments arrives. If the receivable scan starts but the expected completion message never reaches Accountant (lost, actor stopped, bridge misbehavior without ScanError), periodic receivables scanning can stop indefinitely.

Additional Locations (1)

Fix in Cursor Fix in Web

Err(StartScanError::no_consuming_wallet_found(
response_skeleton_opt,
))
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: NullScanner error semantics changed unexpectedly

NullScanner::start_scan now returns StartScanError::no_consuming_wallet_found(...) instead of a dedicated “null scanner invoked” error. If NullScanner ever leaks into non-test paths (miswiring, partial replacement), it can be misdiagnosed as a missing wallet and feed into rescheduling/error-handling decisions incorrectly.

Fix in Cursor Fix in Web

let scheduling_hint = self.handle_request_of_scan_for_receivable(msg.response_skeleton_opt);

match scheduling_hint {
ScanReschedulingAfterEarlyStop::Schedule(other_scan_type) => unreachable!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that we are never scheduling another scan? (it's confusing why is it like that)

Copy link
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continue at node/src/accountant/mod.rs:415

expected = "internal error: entered unreachable code: Early stopped receivable scan \
was suggested to be followed up by the scan for PendingPayables, which is not supported though"
)]
fn start_scan_error_in_receivables_and_unexpected_instruction_from_early_stop_scan_rescheduling(
Copy link
Collaborator

@utkarshg6 utkarshg6 Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you've written the code with utmost confidence that we'll never hit the unreachable!() statements and I respect that. At the same time, I feel concerned that the testing team/user might encounter this and will end up panicking their Node. To prevent such cases, I'd appreciate if we avoid such panicking statements in the future if possible. 🙏

PS: This comments is not directly related to this case, but a generic statement.

Copy link
Collaborator

@utkarshg6 utkarshg6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@bertllll bertllll merged commit 06dd374 into GH-598 Dec 17, 2025
1 check passed
@bertllll bertllll deleted the GH-598-receivables-scheduling-hot-fix branch December 17, 2025 12:11
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.

3 participants