Skip to content

Prevent underflow in Amount #1866

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

robinbb
Copy link
Member

@robinbb robinbb commented Apr 12, 2025

@Isaac-DeFrain Please have a look at the changes in this PR.

Note that, as-is, it passes tier-1 and tier-2 tests. Tier-3 fails like so:

2025-04-11T19:37:18.102140-07:00 - ERROR Underflow in Sub<Amount>: self.0: 0 rhs.0: 1000       
                                                                                               
thread 'tokio-runtime-worker' panicked at src/ledger/account/mod.rs:259:17:                    
Underflow in Account::debit. pk: B62qix9vooX5NqJYo8nT6xWqCeQu5AJoS1ng6FRnUpVAra6PAZZ1CU4 balance: 0 amount: 0.000001
stack backtrace:                                                                               
   0:     0x5b51de66a129 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfc616348d9ad0abc
   1:     0x5b51de0419f3 - core::fmt::write::h7ca648217bc79799                                                                                                                                
   2:     0x5b51de6696c2 - std::io::Write::write_fmt::h7960c58bfa5ccbcb                        
   3:     0x5b51de669f83 - std::sys::backtrace::BacktraceLock::print::h3fb349e80cbe0423                                                                                                       
   4:     0x5b51de669339 - std::panicking::rust_panic_with_hook::h66e909d048c263a9                                                                                                            
   5:     0x5b51de6a7758 - std::panicking::begin_panic_handler::{{closure}}::h8d9aa8be7e8634cf 
   6:     0x5b51de6a76b9 - std::sys::backtrace::__rust_end_short_backtrace::h7d7e47ef99abf6aa  
   7:     0x5b51de6a7c9c - rust_begin_unwind                                                   
   8:     0x5b51de03fedf - core::panicking::panic_fmt::hf8ffc7c15bfb58a0                       
   9:     0x5b51de45c4e1 - mina_indexer::ledger::account::Account::payment::h177b06f13ab13075  
  10:     0x5b51de45ef72 - mina_indexer::ledger::account::Account::apply_account_diff::habeeacd59917c716
  11:     0x5b51de1e2da7 - mina_indexer::ledger::Ledger::_apply_account_diff::h070c7ce5a8b814fd                                                                                               
  12:     0x5b51ddd6ee73 - mina_indexer::server::IndexerConfiguration::initialize::{{closure}}::h18a91e59b79d441c.4219

Do you expect this underflow to occur? Can you point to what should change in the code to ensure that it does not?

@robinbb robinbb requested a review from Isaac-DeFrain April 12, 2025 04:05
@robinbb robinbb requested a review from jhult as a code owner April 12, 2025 04:05
@robinbb robinbb marked this pull request as draft April 12, 2025 04:06
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.

1 participant