15
15
from ethereum .pruning_trie import Trie
16
16
from ethereum .securetrie import SecureTrie
17
17
from ethereum import utils
18
- from ethereum .utils import address , int256 , trie_root , hash32 , to_string , big_endian_to_int
18
+ from ethereum .utils import (
19
+ address ,
20
+ int256 ,
21
+ trie_root ,
22
+ hash32 ,
23
+ to_string ,
24
+ big_endian_to_int ,
25
+ TT256 ,
26
+ )
19
27
from ethereum import processblock
20
28
from ethereum .transactions import Transaction
21
29
from ethereum import bloom
30
38
else :
31
39
from functools import lru_cache
32
40
33
-
34
41
log = get_logger ('eth.block' )
35
42
log_state = get_logger ('eth.msg.state' )
36
43
Log = processblock .Log
@@ -920,7 +927,10 @@ def get_balance(self, address):
920
927
921
928
:param address: the address of the account (binary or hex string)
922
929
"""
923
- return self ._get_acct_item (address , 'balance' )
930
+ balance = self ._get_acct_item (address , 'balance' )
931
+ if balance >= TT256 :
932
+ raise ValueError ("balance too high" )
933
+ return balance
924
934
925
935
def set_balance (self , address , value ):
926
936
"""Set the balance of an account.
@@ -929,6 +939,8 @@ def set_balance(self, address, value):
929
939
:param value: the new balance
930
940
:returns: `True` if successful, otherwise `False`
931
941
"""
942
+ if value >= TT256 :
943
+ raise ValueError ("value too high" )
932
944
self ._set_acct_item (address , 'balance' , value )
933
945
934
946
def delta_balance (self , address , value ):
@@ -950,7 +962,7 @@ def transfer_value(self, from_addr, to_addr, value):
950
962
:param value: the (positive) value to send
951
963
:returns: `True` if successful, otherwise `False`
952
964
"""
953
- assert value >= 0
965
+ assert value >= 0 and value < TT256
954
966
if self .delta_balance (from_addr , - value ):
955
967
return self .delta_balance (to_addr , value )
956
968
return False
0 commit comments