Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle submitBlockReward correctly when processing system transanctions #259

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

minh-bq
Copy link
Contributor

@minh-bq minh-bq commented Apr 12, 2023

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

@minh-bq minh-bq requested review from DNK90 and linh-1 April 12, 2023 15:16
@minh-bq minh-bq marked this pull request as draft April 12, 2023 15:24
@minh-bq minh-bq force-pushed the fix/debug-api branch 2 times, most recently from 3b40591 to e23079b Compare April 13, 2023 04:57
@minh-bq minh-bq changed the title fix: handle submitBlockReward correctly in debug API fix: handle submitBlockReward correctly when processing system transanctions Apr 13, 2023
@minh-bq minh-bq marked this pull request as ready for review April 13, 2023 06:24
…ctions

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.
Copy link
Contributor

@DNK90 DNK90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@minh-bq minh-bq merged commit 5e2deba into axieinfinity:master Apr 14, 2023
@minh-bq minh-bq deleted the fix/debug-api branch April 14, 2023 03:01
andicrypt pushed a commit to andicrypt/ronin that referenced this pull request Nov 1, 2023
…ctions (axieinfinity#259)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debug_traceBlockByNumber cannot process block
2 participants