Skip to content

Commit 4ccd151

Browse files
committed
Use chunks for batch_update_vault_state
Signed-off-by: cyc60 <avsysoev60@gmail.com>
1 parent 183290f commit 4ccd151

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

src/commands/internal/process_redeemer.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import sys
44
from dataclasses import replace
5+
from itertools import batched
56
from pathlib import Path
67

78
import click
@@ -30,7 +31,7 @@
3031
from src.common.utils import log_verbose
3132
from src.common.wallet import wallet
3233
from src.config.networks import AVAILABLE_NETWORKS, ZERO_CHECKSUM_ADDRESS
33-
from src.config.settings import settings
34+
from src.config.settings import MULTICALL_CHUNK_SIZE, settings
3435
from src.meta_vault.graph import graph_get_vaults
3536
from src.meta_vault.service import is_meta_vault, is_meta_vault_state_update_required
3637
from src.meta_vault.tasks import meta_vault_tree_update_state
@@ -358,18 +359,19 @@ async def update_vaults_state(
358359
if not vault_to_harvest_params:
359360
return
360361

361-
tx_hash = await os_token_redeemer_contract.batch_update_vault_state(vault_to_harvest_params)
362-
logger.info(
363-
'Waiting for OsTokenRedeemer updateVaultState multicall tx %s confirmation', tx_hash
364-
)
365-
tx_receipt = await execution_client.eth.wait_for_transaction_receipt(
366-
HexBytes(Web3.to_bytes(hexstr=tx_hash)), timeout=settings.execution_transaction_timeout
367-
)
368-
if not tx_receipt['status']:
369-
raise RuntimeError(
370-
f'OsTokenRedeemer updateVaultState multicall tx failed. Tx Hash: {tx_hash}'
362+
for chunk_items in batched(vault_to_harvest_params.items(), MULTICALL_CHUNK_SIZE):
363+
tx_hash = await os_token_redeemer_contract.batch_update_vault_state(dict(chunk_items))
364+
logger.info(
365+
'Waiting for OsTokenRedeemer updateVaultState multicall tx %s confirmation', tx_hash
371366
)
372-
logger.info('OsTokenRedeemer updateVaultState multicall confirmed. Tx Hash: %s', tx_hash)
367+
tx_receipt = await execution_client.eth.wait_for_transaction_receipt(
368+
HexBytes(Web3.to_bytes(hexstr=tx_hash)), timeout=settings.execution_transaction_timeout
369+
)
370+
if not tx_receipt['status']:
371+
raise RuntimeError(
372+
f'OsTokenRedeemer updateVaultState multicall tx failed. Tx Hash: {tx_hash}'
373+
)
374+
logger.info('OsTokenRedeemer updateVaultState multicall confirmed. Tx Hash: %s', tx_hash)
373375

374376

375377
async def redeem_positions(

src/config/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,5 @@ def network_config(self) -> NetworkConfig:
445445
LOG_WHITELISTED_DOMAINS = decouple_config(
446446
'LOG_WHITELISTED_DOMAINS', cast=Csv(), default='stakewise.io,localhost'
447447
)
448+
449+
MULTICALL_CHUNK_SIZE: int = decouple_config('MULTICALL_CHUNK_SIZE', default=20, cast=int)

0 commit comments

Comments
 (0)