Merge pull request #298 from ethereum/update_vyper_contract
deposit contract: reduce on-chain computation
This commit is contained in:
commit
eaab06f2dd
|
@ -627,6 +627,7 @@ MAX_DEPOSIT: constant(uint256) = 32 # ETH
|
||||||
GWEI_PER_ETH: constant(uint256) = 1000000000 # 10**9
|
GWEI_PER_ETH: constant(uint256) = 1000000000 # 10**9
|
||||||
CHAIN_START_FULL_DEPOSIT_THRESHOLD: constant(uint256) = 16384 # 2**14
|
CHAIN_START_FULL_DEPOSIT_THRESHOLD: constant(uint256) = 16384 # 2**14
|
||||||
DEPOSIT_CONTRACT_TREE_DEPTH: constant(uint256) = 32
|
DEPOSIT_CONTRACT_TREE_DEPTH: constant(uint256) = 32
|
||||||
|
TWO_TO_POWER_OF_TREE_DEPTH: constant(uint256) = 4294967296 # 2**32
|
||||||
SECONDS_PER_DAY: constant(uint256) = 86400
|
SECONDS_PER_DAY: constant(uint256) = 86400
|
||||||
|
|
||||||
Eth1Deposit: event({previous_receipt_root: bytes32, data: bytes[2064], deposit_count: uint256})
|
Eth1Deposit: event({previous_receipt_root: bytes32, data: bytes[2064], deposit_count: uint256})
|
||||||
|
@ -642,7 +643,7 @@ def deposit(deposit_input: bytes[2048]):
|
||||||
assert msg.value >= as_wei_value(MIN_DEPOSIT, "ether")
|
assert msg.value >= as_wei_value(MIN_DEPOSIT, "ether")
|
||||||
assert msg.value <= as_wei_value(MAX_DEPOSIT, "ether")
|
assert msg.value <= as_wei_value(MAX_DEPOSIT, "ether")
|
||||||
|
|
||||||
index: uint256 = self.deposit_count + 2**DEPOSIT_CONTRACT_TREE_DEPTH
|
index: uint256 = self.deposit_count + TWO_TO_POWER_OF_TREE_DEPTH
|
||||||
msg_gwei_bytes8: bytes[8] = slice(concat("", convert(msg.value / GWEI_PER_ETH, bytes32)), start=24, len=8)
|
msg_gwei_bytes8: bytes[8] = slice(concat("", convert(msg.value / GWEI_PER_ETH, bytes32)), start=24, len=8)
|
||||||
timestamp_bytes8: bytes[8] = slice(concat("", convert(block.timestamp, bytes32)), start=24, len=8)
|
timestamp_bytes8: bytes[8] = slice(concat("", convert(block.timestamp, bytes32)), start=24, len=8)
|
||||||
deposit_data: bytes[2064] = concat(msg_gwei_bytes8, timestamp_bytes8, deposit_input)
|
deposit_data: bytes[2064] = concat(msg_gwei_bytes8, timestamp_bytes8, deposit_input)
|
||||||
|
|
Loading…
Reference in New Issue