ProsusCorp / ProsusMoney

The Chilean Cryptocurrency
http://www.prosusmoney.cl
9 stars 13 forks source link

Assertion failed when doing a transfer in testnet #39

Closed driquelme closed 2 years ago

driquelme commented 2 years ago

When I attempt a transfer using a wallet with enough balance in testnet I get the following assertion failure.

[wallet Prosus]: transfer 1 Prosus23a548CfzKnXrXZC9Sz3uTQPzeWWWL721PkyPkQBMbjNH85FgdLvzCLG4ooQEUP3VvCmDz26UraS2XFPcZBnf6St3Zq7A4N 1000000 -f 1000000
Assertion failed: (!vec.empty()), function popRandomValue, file /cli/src/WalletLegacy/WalletTransactionSender.cpp, line 334.
[1]    98873 abort      ./binaries/prosus-wallet --testnet

cc: @yerkobits

yerkobits commented 2 years ago

https://github.com/ProsusCorp/prosusmoney/blob/4080794cb80234620f8a988151eea442c8bb150d/cli/src/WalletLegacy/WalletTransactionSender.cpp#L332

template<typename URNG, typename T>
T popRandomValue(URNG& randomGenerator, std::vector<T>& vec) {
  assert(!vec.empty());

  if (vec.empty()) {
    return T();
  }

  std::uniform_int_distribution<size_t> distribution(0, vec.size() - 1);
  size_t idx = distribution(randomGenerator);

  T res = vec[idx];
  if (idx + 1 != vec.size()) {
    vec[idx] = vec.back();
  }
  vec.resize(vec.size() - 1);

  return res;
}
driquelme commented 2 years ago

Another instance of this problem is when I attempt a transfer using an RPC wallet. I get the following error. The wallet has funds and its height matches the daemon height. Mining is pauses at the time of transfer. It sometimes works, but generally,

Unable to make transfer, code: -4, Internal node error
driquelme commented 2 years ago

I figured it out, I was sending a smaller fee than the lower limit.

image