Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Minor update to address locking (#513)
Browse files Browse the repository at this point in the history
* Fix db sync error at BH-434382
  • Loading branch information
goldworm-icon authored Sep 2, 2020
1 parent 8c8a308 commit c7d11e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions iconservice/iconscore/icon_pre_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from iconcommons.logger import Logger

from .icon_score_context import IconScoreContextType
from .icon_score_step import get_input_data_size
from ..base.address import Address, SYSTEM_SCORE_ADDRESS, generate_score_address
from ..base.exception import InvalidRequestException, InvalidParamsException, OutOfBalanceException
Expand Down Expand Up @@ -320,13 +319,10 @@ def _validate_new_score_address_on_deploy_transaction(cls, context: 'IconScoreCo
def _check_balance(cls, context: 'IconScoreContext', from_: 'Address', value: int, fee: int):
balance = context.engine.icx.get_balance(context, from_)

if is_address_locked(from_) and (
context.type == IconScoreContextType.QUERY or
(context.type == IconScoreContextType.INVOKE and
context.revision == Revision.LOCK_ADDRESS.value)):
if context.revision >= Revision.LOCK_ADDRESS.value and is_address_locked(from_):
Logger.warning(
tag="LOCK",
msg=f"Address is locked: balance={balance} from={str(from_)} value={value} fee={fee}"
msg=f"Address is locked: balance={balance} from={from_} value={value} fee={fee}"
)
raise InvalidRequestException(f"Address is locked: {from_}")

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_test/iconscore/test_icon_pre_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TestTransactionValidator:
@pytest.mark.parametrize(
"context_type,revision,blocked",
[
(IconScoreContextType.QUERY, 9, True),
(IconScoreContextType.QUERY, 9, False),
(IconScoreContextType.INVOKE, 9, False),
(IconScoreContextType.QUERY, Revision.LOCK_ADDRESS.value, True),
(IconScoreContextType.INVOKE, Revision.LOCK_ADDRESS.value, True),
Expand Down

0 comments on commit c7d11e6

Please sign in to comment.