Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

thread 'main' panicked at 'attempt to subtract with overflow', offline-election/src/subcommands/staking.rs:344:22 #22

Closed
atorrente75 opened this issue Jul 10, 2020 · 1 comment

Comments

@atorrente75
Copy link

Commit hash:

2dd3e622be6392d3e790faed8868293ac28fd77e

Command:

cargo run -- staking -i 10 -r

Output:

Finished dev [unoptimized + debuginfo] target(s) in 0.23s
Running /home/polkast/offline-phragmen/target/debug/offline-election staking -i 10 -r
[2020-07-10T23:03:37Z INFO ] program args: Opt { at: Some(0xddf3ed5fc4c8faa952f31a27d622bc91bef38590f4a0a965b3365032a267b181), uri: "ws://localhost:9944", network: "polkadot", verbosity: 0, cmd: Staking(StakingConfig { count: None, output: None, iterations: 10, reduce: true }) }
[2020-07-10T23:03:37Z INFO ] total_issuance = 8315411,309DOT (8,315,411,309,643,337,742)
[2020-07-10T23:03:51Z DEBUG] ⏳ data_scrape took 14772ms.
[2020-07-10T23:03:53Z DEBUG] ⏳ phragmen_run took 1378ms.
[2020-07-10T23:03:53Z DEBUG] ⏳ ratio_into_staked_run took 9ms.
[2020-07-10T23:03:53Z DEBUG] ⏳ build_support_map_run took 11ms.
[2020-07-10T23:03:54Z DEBUG] ⏳ equalize_post_processing took 929ms.
thread 'main' panicked at 'attempt to subtract with overflow', offline-election/src/subcommands/staking.rs:344:22
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1069
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1504
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
9: std::panicking::default_hook
at src/libstd/panicking.rs:218
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:511
11: rust_begin_unwind
at src/libstd/panicking.rs:419
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:111
13: core::panicking::panic
at src/libcore/panicking.rs:54
14: offline_election::subcommands::staking::run::{{closure}}
at offline-election/src/subcommands/staking.rs:344
15: <core::future::from_generator::GenFuture as core::future::future::Future>::poll
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/future/mod.rs:66
16: offline_election::main::main::{{closure}}
at offline-election/src/main.rs:248
17: <core::future::from_generator::GenFuture as core::future::future::Future>::poll
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/future/mod.rs:66
18: offline_election::main::{{closure}}
at offline-election/src/main.rs:199
19: <core::future::from_generator::GenFuture as core::future::future::Future>::poll
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/future/mod.rs:66
20: async_std::task::block_on::block_on::{{closure}}
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/block_on.rs:68
21: <core::future::from_generator::GenFuture as core::future::future::Future>::poll
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libcore/future/mod.rs:66
22: async_std::task::block_on::run::{{closure}}
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/block_on.rs:128
23: std::thread::local::LocalKey::try_with
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/thread/local.rs:263
24: std::thread::local::LocalKey::with
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/thread/local.rs:239
25: async_std::task::block_on::run
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/block_on.rs:118
26: async_std::task::block_on::block_on::{{closure}}
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/block_on.rs:72
27: async_std::task::task::Task::set_current::{{closure}}
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/task.rs:129
28: std::thread::local::LocalKey::try_with
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/thread/local.rs:263
29: std::thread::local::LocalKey::with
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/thread/local.rs:239
30: async_std::task::task::Task::set_current
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/task.rs:124
31: async_std::task::block_on::block_on
at /home/polkast/.cargo/registry/src/github.com-1ecc6299db9ec823/async-std-1.5.0/src/task/block_on.rs:72
32: offline_election::main
at offline-election/src/main.rs:199
33: std::rt::lang_start::{{closure}}
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/rt.rs:67
34: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:52
35: std::panicking::try::do_call
at src/libstd/panicking.rs:331
36: std::panicking::try
at src/libstd/panicking.rs:274
37: std::panic::catch_unwind
at src/libstd/panic.rs:394
38: std::rt::lang_start_internal
at src/libstd/rt.rs:51
39: std::rt::lang_start
at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7/src/libstd/rt.rs:67
40: main
41: __libc_start_main
42: _start

@kianenigma
Copy link
Collaborator

So apparently for some particular set, the equalise resulted in a solution which has a slightly lower score than the original score.

This is related to paritytech/substrate#6693 and will be fixed asap. In the meantime, I'll change the subtract to be checked_sub and show a warning if in any case this happened.

Thanks for the report!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants