Skip to content

Commit

Permalink
Move ABI checks to be first in the code (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed May 13, 2020
1 parent 4d493e7 commit d18c12b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions deposit_contract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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(
Expand Down

0 comments on commit d18c12b

Please sign in to comment.