Verify deposit_data.json amounts within [1, 32] ETH

This commit is contained in:
Carl Beekhuizen 2020-09-16 22:38:44 +02:00
parent b9975f2fed
commit 5e3300d387
No known key found for this signature in database
GPG Key ID: 8F29E54F49E7AAB5
2 changed files with 8 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import json
from typing import Dict, List
from py_ecc.bls import G2ProofOfPossession as bls
from eth2deposit.exceptions import ValidationError
from eth2deposit.key_handling.key_derivation.path import mnemonic_and_path_to_key
from eth2deposit.key_handling.keystore import (
Keystore,
@ -11,6 +12,8 @@ from eth2deposit.key_handling.keystore import (
)
from eth2deposit.utils.constants import (
BLS_WITHDRAWAL_PREFIX,
ETH2GWEI,
MAX_DEPOSIT_AMOUNT,
)
from eth2deposit.utils.crypto import SHA256
from eth2deposit.utils.ssz import (
@ -57,6 +60,8 @@ class Credential:
@property
def deposit_message(self) -> DepositMessage:
if self.amount > MAX_DEPOSIT_AMOUNT:
raise ValidationError(f"{self.amount / ETH2GWEI} ETH is more than the maximum allowed deposit.")
return DepositMessage(
pubkey=self.signing_pk,
withdrawal_credentials=self.withdrawal_credentials,

View File

@ -7,8 +7,9 @@ ZERO_BYTES32 = b'\x00' * 32
DOMAIN_DEPOSIT = bytes.fromhex('03000000')
BLS_WITHDRAWAL_PREFIX = bytes.fromhex('00')
MIN_DEPOSIT_AMOUNT = 2 ** 0 * 10 ** 9
MAX_DEPOSIT_AMOUNT = 2 ** 5 * 10 ** 9
ETH2GWEI = 10 ** 9
MIN_DEPOSIT_AMOUNT = 2 ** 0 * ETH2GWEI
MAX_DEPOSIT_AMOUNT = 2 ** 5 * ETH2GWEI
# File/folder constants