Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upper bound for get_pessimistic_udc_balance #1090

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/monitoring_service/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,11 @@ def action_monitoring_triggered_event_handler(event: Event, context: Context) ->
)
return

latest_block = context.web3.eth.block_number
last_confirmed_block = context.latest_confirmed_block
user_address = monitor_request.non_closing_signer
user_deposit = get_pessimistic_udc_balance(
udc=context.user_deposit_contract,
address=user_address,
from_block=last_confirmed_block,
to_block=latest_block,
address=monitor_request.non_closing_signer,
from_block=context.latest_confirmed_block,
to_block=context.get_latest_unconfirmed_block(),
)
if monitor_request.reward_amount < context.min_reward:
log.info(
Expand All @@ -488,7 +485,9 @@ def action_monitoring_triggered_event_handler(event: Event, context: Context) ->
min_reward=context.min_reward,
)
context.database.upsert_scheduled_event(
ScheduledEvent(trigger_block_number=BlockNumber(last_confirmed_block + 1), event=event)
ScheduledEvent(
trigger_block_number=BlockNumber(context.latest_confirmed_block + 1), event=event
)
)
return

Expand Down
2 changes: 1 addition & 1 deletion src/raiden_libs/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def get_pessimistic_udc_balance(
"""
return min(
udc.functions.effectiveBalance(address).call(block_identifier=BlockNumber(block))
for block in [from_block, to_block + 1]
for block in (from_block, to_block)
)


Expand Down