Skip to content

Commit

Permalink
fix: limit max cocurrent validators to prevent OOM
Browse files Browse the repository at this point in the history
  • Loading branch information
kp2pml30 committed Dec 30, 2024
1 parent 7a7c93e commit df2596d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/consensus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,9 +1114,14 @@ async def handle(self, context):
]

# Execute the transaction on each validator node and gather the results
sem = asyncio.Semaphore(8)

async def run_single_validator(validator: Node) -> Receipt:
async with sem:
return await validator.exec_transaction(context.transaction)

validation_tasks = [
validator.exec_transaction(context.transaction)
for validator in context.validator_nodes
run_single_validator(validator) for validator in context.validator_nodes
]
context.validation_results = await asyncio.gather(*validation_tasks)

Expand Down

0 comments on commit df2596d

Please sign in to comment.