mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-21 14:58:12 +00:00
Address final comments by HW and Danny
This commit is contained in:
parent
b60314e892
commit
abe48cc988
File diff suppressed because one or more lines are too long
@ -11,6 +11,7 @@ Deposit: event({
|
||||
withdrawal_credentials: bytes[32],
|
||||
amount: bytes[8],
|
||||
signature: bytes[96],
|
||||
index: bytes[8],
|
||||
})
|
||||
|
||||
branch: bytes32[DEPOSIT_CONTRACT_TREE_DEPTH]
|
||||
@ -24,7 +25,7 @@ def __init__():
|
||||
self.zero_hashes[i + 1] = sha256(concat(self.zero_hashes[i], self.zero_hashes[i]))
|
||||
|
||||
|
||||
@public
|
||||
@private
|
||||
@constant
|
||||
def to_little_endian_64(value: uint256) -> bytes[8]:
|
||||
# Reversing bytes using bitwise uint256 manipulations
|
||||
@ -87,6 +88,9 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH],
|
||||
sha256(concat(amount, slice(zero_bytes32, start=0, len=32 - AMOUNT_LENGTH), signature_root)),
|
||||
))
|
||||
|
||||
# Emit `Deposit` log
|
||||
log.Deposit(pubkey, withdrawal_credentials, amount, signature, self.to_little_endian_64(self.deposit_count))
|
||||
|
||||
# Add `DepositData` root to Merkle tree (update a single `branch` node)
|
||||
self.deposit_count += 1
|
||||
size: uint256 = self.deposit_count
|
||||
@ -97,5 +101,3 @@ def deposit(pubkey: bytes[PUBKEY_LENGTH],
|
||||
node = sha256(concat(self.branch[height], node))
|
||||
size /= 2
|
||||
|
||||
# Emit `Deposit` log
|
||||
log.Deposit(pubkey, withdrawal_credentials, amount, signature)
|
||||
|
@ -49,28 +49,6 @@ def deposit_input():
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'value,success',
|
||||
[
|
||||
(0, True),
|
||||
(10, True),
|
||||
(55555, True),
|
||||
(2**64 - 1, True),
|
||||
# (2**64, True), # Note that all calls to `to_little_endian_64` have an input less than 2**64
|
||||
]
|
||||
)
|
||||
def test_to_little_endian_64(registration_contract, value, success, assert_tx_failed):
|
||||
call = registration_contract.functions.to_little_endian_64(value)
|
||||
|
||||
if success:
|
||||
little_endian_64 = call.call()
|
||||
assert little_endian_64 == (value).to_bytes(8, 'little')
|
||||
else:
|
||||
assert_tx_failed(
|
||||
lambda: call.call()
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'success,deposit_amount',
|
||||
[
|
||||
@ -151,7 +129,7 @@ def test_deposit_log(registration_contract, a0, w3, deposit_input):
|
||||
assert log['withdrawal_credentials'] == deposit_input[1]
|
||||
assert log['amount'] == deposit_amount_list[i].to_bytes(8, 'little')
|
||||
assert log['signature'] == deposit_input[2]
|
||||
|
||||
assert log['index'] == i.to_bytes(8, 'little')
|
||||
|
||||
def test_deposit_tree(registration_contract, w3, assert_tx_failed, deposit_input):
|
||||
log_filter = registration_contract.events.Deposit.createFilter(
|
||||
@ -171,6 +149,8 @@ def test_deposit_tree(registration_contract, w3, assert_tx_failed, deposit_input
|
||||
assert len(logs) == 1
|
||||
log = logs[0]['args']
|
||||
|
||||
assert log["index"] == i.to_bytes(8, 'little')
|
||||
|
||||
deposit_data = DepositData(
|
||||
pubkey=deposit_input[0],
|
||||
withdrawal_credentials=deposit_input[1],
|
||||
|
Loading…
x
Reference in New Issue
Block a user