From d12d6606393e225554ca7987f5e1940e238066b3 Mon Sep 17 00:00:00 2001 From: MrChico Date: Wed, 13 May 2020 17:45:05 +0200 Subject: [PATCH] Require deposit to be divisible by GWEI (#14) --- deposit_contract.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deposit_contract.sol b/deposit_contract.sol index 9c4c89eff0..93242c7267 100644 --- a/deposit_contract.sol +++ b/deposit_contract.sol @@ -29,7 +29,7 @@ interface IDepositContract { contract DepositContract is IDepositContract { uint constant GWEI = 1e9; - uint constant MIN_DEPOSIT_AMOUNT = 1000000000; // Gwei + uint constant MIN_DEPOSIT_AMOUNT = 1 ether; uint constant DEPOSIT_CONTRACT_TREE_DEPTH = 32; // NOTE: this also ensures `deposit_count` will fit into 64-bits uint constant MAX_DEPOSIT_COUNT = 2**DEPOSIT_CONTRACT_TREE_DEPTH - 1; @@ -79,8 +79,9 @@ contract DepositContract is IDepositContract { require(deposit_count < MAX_DEPOSIT_COUNT); // Check deposit amount + require(msg.value >= MIN_DEPOSIT_AMOUNT); + require(msg.value % GWEI == 0); uint deposit_amount = msg.value / GWEI; - require(deposit_amount >= MIN_DEPOSIT_AMOUNT); require(deposit_amount < 2**64); // Length checks for safety