Skip to content

Update gas for transfer mnt precompiled #854

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

Merged
merged 5 commits into from
Mar 26, 2020

Conversation

ninjaahhh
Copy link
Contributor

gas calculation should be similar to how CALL is being handled: intrinsic gas + value transfer cost

@ninjaahhh ninjaahhh requested a review from a team March 23, 2020 17:01
(2, "no value transfer with min gas", sender, 0, 700, (1, 0, []), None),
(3, "value transfer needs more gas", sender, 1, 9699, (0, 0, []), None),
# Should have stipend gas left
(4, "value transfer needs more gas", sender, 1, 9700, (1, 2300, []), None),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@qizhou: this is how stipend would work, minimum gas cost met (GCALL 700 + GVALUETRANSFER 9000 = 9700), while still having 2300 left (GSTIPEND), which essentially lowers the cost of GVALUETRANSFER from 9000 to 6700

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! That is much clearer!

return 0, 0, []

# Doesn't allow target address to be this precompiled contract itself
if to == decode_hex(b"000000000000000000000000000000514b430002"):
Copy link
Contributor

Choose a reason for hiding this comment

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

b"000000000000000000000000000000514b430002" is already in bytes - should we do decode_hex() again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, since b"0000..." is not the real byte representation

In [1]: from quarkchain.evm.specials import *

In [2]: decode_hex(b"000000000000000000000000000000514b430002")
Out[2]: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00QKC\x00\x02'

if to == decode_hex(b"000000000000000000000000000000514b430002"):
return 0, 0, []

gascost = 700 # gascost of CALL
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the 700 gascost is already paid by the caller? The essential goal is that if we implement a CALLX with the same functionality as precompiled contracts, and the cost should be close.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i see

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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.

2 participants