Skip to content

Conversation

@utkarshg6
Copy link
Collaborator

@utkarshg6 utkarshg6 commented Jul 2, 2025

Note

Implement a new templated New/Retry payable pipeline with batch submission and BTreeSet-backed DAOs, refactoring scanners, bridge/interfaces, and error/typing across the stack.

  • Core architecture:
    • Replace legacy payable scanner with new modular pipeline using initial/priced/signable tx templates and payment-adjuster integration.
    • Introduce explicit New vs Retry payable flows and scheduling; PendingPayableScanner result handling refined.
  • Blockchain layer:
    • Refactor bridge/interface to submit batches and return BatchResults (sent/failed txs); add detailed error typing (LocalPayableError, AppRpcErrorKind, etc.).
    • Outbound/qualified messages now carry Either priced templates; add gas-price ceiling handling and transmission logging.
  • DAOs/Models:
    • Switch collections to BTreeSet, add Ord/PartialOrd impls and deterministic ordering for tx/status types.
    • Add FailedTx conversions and new retrieval/update helpers (e.g., by receiver addresses); enhance PayableDao retrieval with conditions.
  • Utils:
    • Add join_with_commas/join_with_separator and btreeset! macro; remove old scanner utils.
  • Tests:
    • Broad updates to reflect new types/flows, deterministic ordering, and batch semantics.

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

utkarshg6 added 30 commits July 11, 2025 15:04
…h_same_hash_are_present_in_the_input intermittently passes or fails
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
Copy link

Choose a reason for hiding this comment

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

Bug: Variable Shadowing Causes Compilation Error

Duplicate let declarations for failed_payable_dao_factory and sent_payable_dao_factory shadow their initial assignments. This makes the original assignments redundant and causes a compilation error.

Fix in Cursor Fix in Web

fn cmp(&self, other: &Self) -> Ordering {
todo!()
}
}
Copy link

Choose a reason for hiding this comment

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

Bug: Enum Comparison Methods Panic

The ValidationStatus enum's PartialOrd and Ord implementations use todo!(). This causes runtime panics when comparison methods are called, leading to crashes in contexts requiring ordering.

Fix in Cursor Fix in Web

let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
Copy link

Choose a reason for hiding this comment

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

Bug: DAO Factory Overwriting Causes Memory Leak

The failed_payable_dao_factory and sent_payable_dao_factory are each declared twice. The first failed_payable_dao_factory instance is immediately overwritten and leaked, while the second sent_payable_dao_factory declaration overwrites the initial one. This duplication suggests a copy-paste error, resulting in unused resources and a memory leak.

Fix in Cursor Fix in Web

}
if failed > 0 {
self.insert_records_in_failed_payables(&batch_results.failed_txs);
}
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Transaction Records in Sent Payables

The PayableScanner is redundantly inserting successful transaction records into the sent_payable table during SentPayables message processing. This occurs in both new and retry scan handlers, even though these records are already handled by the BlockchainBridge.

Additional Locations (1)

Fix in Cursor Fix in Web

let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
Copy link

Choose a reason for hiding this comment

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

Bug: Factory Declaration Overwrite Error

Duplicate declarations for failed_payable_dao_factory and sent_payable_dao_factory appear to be a copy-paste error. This creates redundant factory instances and overwrites their initial assignments.

Fix in Cursor Fix in Web

let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Factory Declarations Overwrite Instances

The failed_payable_dao_factory and sent_payable_dao_factory variables are declared twice consecutively. The second declaration for each immediately shadows and overwrites the first, causing the initially created factory instances to be dropped unused. This wastes resources and appears to be a copy-paste error.

Fix in Cursor Fix in Web

let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Factory Declarations

The failed_payable_dao_factory and sent_payable_dao_factory variables are declared and assigned twice consecutively. The second declarations shadow the initial ones, making the first factory instances redundant and unused. This appears to be a copy-paste error.

Fix in Cursor Fix in Web

.map(|signable_tx_template| signable_tx_template.amount_in_wei)
.max()
.expect("there aren't any templates")
}
Copy link

Choose a reason for hiding this comment

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

Bug: Empty Collection Handling Issues

When SignableTxTemplates is empty, the largest_amount() method panics, which could crash the application. Separately, nonce_range() returns (0, 0) for an empty collection, which is ambiguous since 0 is a valid nonce.

Fix in Cursor Fix in Web

let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let failed_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
let sent_payable_dao_factory = Box::new(Accountant::dao_factory(data_directory));
Copy link

Choose a reason for hiding this comment

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

Bug: Duplicate Factory Declarations Cause Compilation Error

There are duplicate let bindings for failed_payable_dao_factory and sent_payable_dao_factory. This causes a compilation error and results in redundant factory creations, as the initial declarations are overwritten and unused.

Fix in Cursor Fix in Web

let pending_tx_hashes_opt = self.harvest_pending_payables();
let failure_hashes_opt = self.harvest_unproven_failures();
eprintln!("ph: {:?}", pending_tx_hashes_opt);
eprintln!("fail: {:?}", failure_hashes_opt);
Copy link

Choose a reason for hiding this comment

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

Bug: Sensitive Data Exposure in Debug Statements

Debug eprintln! statements were accidentally committed, printing potentially sensitive transaction hash information to stderr in production.

Additional Locations (1)

Fix in Cursor Fix in Web

@utkarshg6 utkarshg6 merged commit 2d7c20e into GH-598 Sep 29, 2025
1 check passed
match self.sent_payable_dao.insert_new_records(&msg.new_sent_txs) {
let sent_txs: BTreeSet<SentTx> = msg.new_sent_txs.iter().cloned().collect();

match self.sent_payable_dao.insert_new_records(&sent_txs) {
Copy link

Choose a reason for hiding this comment

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

Bug: Silent Deduplication Causes Data Loss

Converting Vec<SentTx> to BTreeSet<SentTx> before insertion silently deduplicates transactions. This can lead to data loss if legitimate duplicate entries need individual processing, or mask error conditions where duplicates should be explicitly flagged by insert_new_records.

Fix in Cursor Fix in Web

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.

4 participants