-
Notifications
You must be signed in to change notification settings - Fork 935
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
Clean Up Deposit Contract #460
Conversation
There's a |
@nisdas |
Just tagged beta-7, please give it a shot :) |
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.
Tested here: ethereum/deposit_contract#4
Second thought, the bytecodes are exactly the same. So I don't feel strongly of having this refactoring or not because it brings the "ether" unit back to the spec again. /cc @terenc3t @ralexstokes @JustinDrake |
Hmmm I see , valid point. |
@hwwhww Is there any reason we shouldn't be using the |
@hwwhww ah , k , fair enough then. Yeah then it would make sense to keep it in gwei |
Ahh yes. I thought the direction we were heading is to normalize everything to Gwei : ) |
@hwwhww alright changed it to gwei :) |
specs/core/0_beacon-chain.md
Outdated
assert msg.value >= as_wei_value(MIN_DEPOSIT_AMOUNT, "gwei") | ||
assert msg.value <= as_wei_value(MAX_DEPOSIT_AMOUNT, "gwei") | ||
assert msg.value >= MIN_DEPOSIT | ||
assert msg.value <= MAX_DEPOSIT | ||
|
||
index: uint256 = self.deposit_count + TWO_TO_POWER_OF_TREE_DEPTH | ||
deposit_amount: bytes[8] = slice(concat("", convert(msg.value / GWEI_PER_ETH, bytes32)), start=24, len=8) |
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.
msg.value / GWEI_PER_ETH
is only "correct" by chance. It should be msg.value / WEI_PER_GWEI
.
specs/core/0_beacon-chain.md
Outdated
@@ -670,8 +670,8 @@ full_deposit_count: uint256 | |||
@payable | |||
@public | |||
def deposit(deposit_input: bytes[2048]): | |||
assert msg.value >= as_wei_value(MIN_DEPOSIT_AMOUNT, "gwei") | |||
assert msg.value <= as_wei_value(MAX_DEPOSIT_AMOUNT, "gwei") | |||
assert msg.value >= MIN_DEPOSIT |
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.
In line with using Gwei everywhere, my suggestion is to define deposit_amount
(e.g. deposit_amount = msg.value / WEI_PER_GWEI
) and then only deal with Gwei amounts (never msg.value
directly).
@JustinDrake Alright I changed all references to gwei. Also changed min/max deposits to be represented in terms of gwei |
* Use `self.get_deposit_root` instead of `self.deposit_tree[1]` * Use `self.to_bytes` instead of `slice(concat("", convert( , bytes32)), start=24, len=8)` * By consistent with naming (`deposit_amount` and `MAX_DEPOSIT_AMOUNT`) * Remove unnecessary intermediate variables * By consistent with comments (two spaces for inline comments, capitalise first letter) * Symbolic constant now supported for `get_branch` * Simplify code
@JustinDrake Hey, so I was testing this contract out and a bug came out, which is referenced here: We shouldn't call functions when emitting logs, as it leads to undecodable logs |
@nisdas Can you try making |
@JustinDrake The bug applies to both public and private function calls. This is our current test: And it breaks here: The abi decoder will fail to unpack the log data into the separate log arguments |
I suggest we wait until Vyper gets fixed vyperlang/vyper#1213 |
The approval was for denomination clean up. Need farther tests for of the latest branch and also pending on #490 discussion.
@JustinDrake Hey vyperlang/vyper#1213 is merged in now are we waiting on #490, or is this good to be merged in ? |
@JustinDrake Sounds good to me 👍 |
specs/core/0_beacon-chain.md
Outdated
@@ -667,45 +666,48 @@ deposit_tree: map(uint256, bytes32) | |||
deposit_count: uint256 | |||
full_deposit_count: uint256 | |||
|
|||
@private | |||
@constant | |||
def to_bytes(value: uint256) -> bytes[8]: |
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.
to_bytes -> to_bytes8
With regards to when beta8 will be released, I hope sometime next week, this will also include the bytes32 slice() fix, which one can then inline the |
@nisdas Can you sync this with the latest changes in master? |
…o depositContractFix
@djrtwo Alright, done |
With #562 being merged in, this PR doesnt make sense now. So I am closing it |
This PR cleans up the deposit contract, with changes in declarations, which was suggested by @jacqueswww.
Also another issue was that the vyper contract was not able to be compiled, however @jacqueswww has been kind enough to put up a quick fix here: vyperlang/vyper#1202. After that is merged in the deposit contract should have no issues being compiled.
Changes in Contract
Gwei_Per_Eth
toWei_Per_Gwei