bulwark-crypto / Bulwark

The primary development repository for the Bulwark project
https://bulwarkcrypto.com/
MIT License
58 stars 57 forks source link

High CPU usage when staking an unstakable wallet #153

Open jagerman opened 5 years ago

jagerman commented 5 years ago

Describe the bug I have a masternode set up with a MN stake plus a bit of change insufficient for a PoS stake. When I unlock the wallet for staking, CPU load spikes (and stays) a little above 100% of one core (this is on a dedicated machine, not a shared CPU VPS). Relocking the wallet causes CPU to instantly drop back to normal (around 2-6%).

The spike seems to depend on whether the bulwarkd instance has seen a network block yet since startup--if it hasn't, the CPU won't spike until it sees one (if it has, the CPU spikes right away).

My wallet is set up with two accounts; account "" has a bit of change (well under 50 BWK), and account "MN1" has a balance of 5016.25000000 (MN stake + one received MN reward).

To Reproduce Steps to reproduce the behavior:

  1. Start bulwarkd (either with staking=1 explicitly set or omitted for the default).
  2. Unlock wallet using bulwark-cli walletpassphrase "$ENCRYPTIONKEY" 0 true
  3. Wait for network block (or, alternatively, wait for a network block before doing step 2).
  4. Watch CPU load go to 100%.
  5. bulwark-cli walletlock
  6. Watch CPU instantly load drop back to normal.

On the other hand, with staking=0 in the config file, unlocking the wallet doesn't cause any CPU load spike.

Expected behavior No high CPU load.

OS