fix: handle submitBlockReward correctly when processing system transanctions #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When getting over the DPoS hardfork, we get "insufficient funds for gas * price + value"
error when using debug API.
As the submitBlockReward is a system transaction, it's handled differently from
the normal transactions. When consensus processes submitBlockReward and there
are rewards from transaction fee in block, consensus transfers balance from
SystemAddress to miner address through the statedb.SetBalance directly. Later,
when the system transaction is created, this reward will be transfer from miner
to staking contract.
Currently, in debug API and state accessor, we treat all transactions as normal
transactions. Without special handling, we miss the state transaction to
transfer balance from SystemAddress to miner. Consequently, when the system
transaction is processed, we get the error because there is a transfer from
miner to staking contract but we see that miner's balance is not sufficient for
the transfer.
This commit checks whether the transaction is submitBlockReward with non-zero
msg.value then adds the state transition to transfer from SystemAddress to miner
to fix the above error.
Fixes: #260