mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 03:15:11 -05:00
Move ABI checks to be first in the code (#10)
This commit is contained in:
@@ -75,6 +75,11 @@ contract DepositContract is IDepositContract {
|
||||
bytes calldata signature,
|
||||
bytes32 deposit_data_root
|
||||
) override external payable {
|
||||
// Extended ABI length checks since dynamic types are used.
|
||||
require(pubkey.length == PUBKEY_LENGTH);
|
||||
require(withdrawal_credentials.length == WITHDRAWAL_CREDENTIALS_LENGTH);
|
||||
require(signature.length == SIGNATURE_LENGTH);
|
||||
|
||||
// Avoid overflowing the Merkle tree (and prevent edge case in computing `branch`)
|
||||
require(deposit_count < MAX_DEPOSIT_COUNT);
|
||||
|
||||
@@ -84,11 +89,6 @@ contract DepositContract is IDepositContract {
|
||||
uint deposit_amount = msg.value / GWEI;
|
||||
require(deposit_amount < 2**64);
|
||||
|
||||
// Length checks for safety
|
||||
require(pubkey.length == PUBKEY_LENGTH);
|
||||
require(withdrawal_credentials.length == WITHDRAWAL_CREDENTIALS_LENGTH);
|
||||
require(signature.length == SIGNATURE_LENGTH);
|
||||
|
||||
// Emit `DepositEvent` log
|
||||
bytes memory amount = to_little_endian_64(uint64(deposit_amount));
|
||||
emit DepositEvent(
|
||||
|
||||
Reference in New Issue
Block a user