-
Notifications
You must be signed in to change notification settings - Fork 113
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
Conversation
(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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'
quarkchain/evm/specials.py
Outdated
if to == decode_hex(b"000000000000000000000000000000514b430002"): | ||
return 0, 0, [] | ||
|
||
gascost = 700 # gascost of CALL |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
gas calculation should be similar to how CALL is being handled: intrinsic gas + value transfer cost