Move ABI checks to be first in the code (#10)
This commit is contained in:
parent
4d493e70af
commit
d18c12b776
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue