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

Change gas logic (Qtum Core / QTUMCORE-72) #146

Merged
merged 1 commit into from
Jun 12, 2017
Merged

Conversation

designsters
Copy link
Contributor

We need a minor change into how we handle gasLimit and gasPrice in our current implementation in light of issue #113
The changes must be made on Qtum side, no change to the EVM submodule should be required

The new logic will be as follows:
1- when a Qtum tx is received, we make sure the fee covers gasLimit*gasPrice otherwise reject it
2- we pass the gasLimit to the EVM and pass 1 as gasPrice
3- after we get the execution results, two cases:

if an exception occurs (including out of gas), we consume all the gas (gasLimitgasPrice)
if the transaction is successfully executed, we consume gasUsed
gasPrice and send refund (gasLimit-gasUsed)*gasPrice ...

This will allow us to use gasLimit as intended in Qtum, and use gasPrice after the execution to charge the right values to the sender.

Example:
for example, if we call a contract with a gas limit of 50000 and a price of 0.00001, first we check if the tx fee is >= 500000.00001=0.5 then we pass 50000 to the EVM as gasLimit and 1 as gas price, let’s say the gas used was just 20000, then after execution, we should pay the miner 200000.00001=0.2 and refund the sender 30000*0.00001=0.3

This pull request was closed.
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.

3 participants