Skip to content

Commit 6055ad6

Browse files
committed
Apply rounding in payment monitoring task too
1 parent 2de50e6 commit 6055ad6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/aleph/vm/orchestrator/tasks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from aleph.vm.conf import settings
2323
from aleph.vm.orchestrator.utils import (
24+
format_cost,
2425
get_community_wallet_address,
2526
is_after_community_wallet_start,
2627
)
@@ -238,9 +239,11 @@ async def check_payment(pool: VmPool):
238239
logger.info("flow community %s", executions_with_community)
239240
logger.info("flow without community %s", executions_without_community)
240241
required_stream_without_community = await compute_required_flow(executions_without_community)
241-
242-
required_crn_stream = required_stream * (1 - COMMUNITY_STREAM_RATIO) + required_stream_without_community
243-
required_community_stream = required_stream * COMMUNITY_STREAM_RATIO
242+
# TODO, rounding should be done per executions to not have the extra accumulate before rounding
243+
required_crn_stream = format_cost(
244+
required_stream * (1 - COMMUNITY_STREAM_RATIO) + required_stream_without_community
245+
)
246+
required_community_stream = format_cost(required_stream * COMMUNITY_STREAM_RATIO)
244247
logger.debug(
245248
f"Stream for senders {sender} {len(executions)} executions. CRN : {stream} / {required_crn_stream}."
246249
f"Community: {community_stream} / {required_community_stream}"

src/aleph/vm/orchestrator/views/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ async def notify_allocation(request: web.Request):
539539
required_crn_stream = format_cost(required_flow * (1 - COMMUNITY_STREAM_RATIO))
540540
required_community_stream = format_cost(required_flow * COMMUNITY_STREAM_RATIO)
541541
else: # No community wallet payment
542-
required_crn_stream = required_flow
542+
required_crn_stream = format_cost(required_flow)
543543
required_community_stream = Decimal(0)
544544

545545
if active_flow < (required_crn_stream - settings.PAYMENT_BUFFER):

0 commit comments

Comments
 (0)