-
Notifications
You must be signed in to change notification settings - Fork 999
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
Remove serialization from consensus #924
Conversation
Consensus now only cares about Merkleisation (i.e. `hash_tree_root`), not about serialization (i.e. `serialize`). This simplifies consensus code by a few tens of lines, is conceptually cleaner, and is more future proof. A corresponding change is required in the deposit contract.
@JustinDrake So regarding the deposit contract side, my understanding is:
Is it what you think? |
My suggestion would be to change the deposit contract API to |
@JustinDrake ahh right that would be more reasonable. 😅 Note that, having the fields in API would limit our options to update eth2 fields without forking eth1 or creating a new deposit contract. Although I remember the last time we discuss the upgradability of the deposit contract, the solution would just be just moving to a new contract, right? |
@@ -2230,7 +2230,7 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None: | |||
|
|||
# Verify the Merkle branch | |||
merkle_branch_is_valid = verify_merkle_branch( | |||
leaf=hash(serialize(deposit.data)), # 48 + 32 + 8 + 96 = 184 bytes serialization | |||
leaf=hash_tree_root(deposit.data), |
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.
Doesn't this mean that we also need to calculate the SSZ root of the deposit data in the Vyper contract?
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, we need to calculate hash_tree_root
in the contract. Assuming def deposit(pubkey: bytes[48], withdrawal_credentials: bytes[32], amount: bytes[8], signature: bytes[96])
it's something like:
pubkey_root = hash(pubkey + zero_hash[0:16])
signature_root = hash(
hash(signature[0:64]) +
hash(signature[64:96] + zero_hash)
)
hash_tree_root = hash(
hash(pubkey_root + withdrawal_credentials) +
hash(amount + zero_hash[0:24] + signature_root)
)
Right :) |
Opened ethereum/deposit_contract#29. |
link the contract side: ethereum/deposit_contract#31 |
@djrtwo ethereum/deposit_contract#31 is ready. :) |
Consensus now only cares about Merkleisation (i.e.
hash_tree_root
), not about serialization (i.e.serialize
). This simplifies consensus code by a few tens of lines, is conceptually cleaner, and is more future proof.A corresponding change in the deposit contract.