dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

Fix remote staking bugs #1017

Closed Nizametdinov closed 5 years ago

Nizametdinov commented 5 years ago

We found three issues with remote staking when testing on the testnet.

  1. Transaction picking might fail because of invalid coinbase transaction which sends remote-staking coins to non-remote staking script. That happened because transaction picking was via invoking BlockAssembler::CreateNewBlock. BlockAssembler::CreateNewBlock generates a coinbase transaction which sends the stake to the provided script and when it picks a remote-staking output it results in invalid coinbase transaction.
  2. A node can generate invalid coinbase transaction which tries to combine remote-staking and non-remote-staking outputs and send them to a non-remote-staking script.
  3. A node which has its own funds and remote staking funds can send its funds to remote staking script because of stake combining.

The first bug is fixed by introducing BlockAssembler::PickTransactions which only picks transactions and does not do an unnecessary job.

The second and the third bugs are fixed by disabling stake combination in BlockBuilder when staking a remote-staking coin and by skipping remote-staking coins in stake combination.

cmihai commented 5 years ago

Should #998 be closed now?