Skip to content

Conversation

@bertllll
Copy link
Contributor

@bertllll bertllll commented Nov 29, 2025

Note

Refactors scan scheduling/rescheduling to use a new unified scanner enum, adds explicit Receivables error handling, renames the interval-computation API, and updates tests and recorder utilities accordingly.

  • Scanning core:
    • Replace PayableSequenceScanner with unified StartScanFallibleScanner (adds Receivables variant) and update Display/FromScanType.
    • Centralize error handling/rescheduling: extend resolver for Receivables and CalledFromNullScanner; stricter unreachable cases.
    • Rename NewPayableScanIntervalComputer.time_until_next_scancompute_time_to_next_scan; propagate across schedulers, mocks, and callers.
  • Accountant behavior:
    • ScanForReceivables handler now delegates to handle_request_of_scan_for_receivable() returning ScanReschedulingAfterEarlyStop; unreachable follow-ups guarded.
    • ReceivedPayments now reschedules the receivable scan via scheduler; handle_request_of_scan_for_receivable() returns a hint and uses StartScanFallibleScanner::Receivables on errors.
    • Update all scan-start error paths to pass StartScanFallibleScanner::{New,Retry,Pending,Receivables}.
  • Test/infra updates:
    • Broad test adjustments to new API and behaviors; add receivables periodical scan tests and unexpected rescheduling panics.
    • Rename builder method build_and_provide_addressesbuild_providing_addresses; update usages.
    • Minor log message tweaks and parameter/var renames (e.g., compute_time_to_next_scan_params_*).

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


#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum PayableSequenceScanner {
pub enum StartScanFallibleScanner {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider renaming it to FallibleScanner.


pub fn schedule_new_payable_scan(&self, ctx: &mut Context<Accountant>, logger: &Logger) {
if let ScanTiming::WaitFor(interval) = self.interval_computer.time_until_next_scan() {
if let ScanTiming::WaitFor(interval) = self.interval_computer.compute_time_to_next_scan() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good!

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.

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.

Err(e) =>
// Any error here panics by design, so the return value is unreachable/ignored.
{
self.handle_start_scan_error_and_prevent_scan_stall_point(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This name's huge. Pick one: resolve_scan_error or handle_scan_error_and_reschedule.

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!

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