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

non-party node must refund gas for private transactions #739

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

trung
Copy link
Contributor

@trung trung commented Jun 12, 2019

Summary

Gas pool subtracts transaction gas limit initially prior to processing the transaction.
For private transactions, only intrinsic gas are used.
The remaining (transaction gas limit - intrinsic gas) is refunded to the gas pool.
This logic is supposed to be applied for both party and non-party nodes.

This PR is to make sure non-party node following the above logic.

Root cause

Under load, non-party node may see bad blocks due to gas limit reached. This happens when intrinsic gas is reasonably smaller than transaction gas limit. In this case, party node (as a miner) may include lots of transactions to fill up the block gas limit. However, when non-party node inserts the block into its chain, the gas pool gets exhausted quickly due to only subtracting transaction gas limit and not refunding the remaining gas. This causes bad block with gas limit reached error being reported.

@zzy96
Copy link
Contributor

zzy96 commented Jun 13, 2019

Hi Trung, I am thinking if st.state.AddBalance(st.evm.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice)) should be added also after the refund. It will not affect current quorum implementation since gasPrice is always zero, but if we reenable gasPrice at some time, the used gas should be recycled the same way for all transactions.

@jpmsam jpmsam merged commit 53105b1 into Consensys:master Jun 14, 2019
@trung trung deleted the non-party-refund-gas branch July 26, 2019 13:59
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.

4 participants