Skip to content

Commit

Permalink
Fix: Reduce RPC calls to every 30 seconds instead every 10 seconds an…
Browse files Browse the repository at this point in the history
…d added to config settings.

Co-authored-by: Bram <[email protected]>
  • Loading branch information
nesitor and Psycojoker authored Dec 5, 2024
1 parent faeefc2 commit 23cb8f9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/aleph/chains/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ async def _get_logs(config, web3: Web3, contract, start_height):
yield log

if not logs:
LOGGER.info("No recent transactions, waiting 10 seconds.")
await asyncio.sleep(10)
LOGGER.info(
f"No recent transaction, waiting {config.ethereum.archive_delay.value} seconds."
)
await asyncio.sleep(config.ethereum.archive_delay.value)

except ValueError as e:
# we got an error, let's try the pagination aware version.
Expand All @@ -130,8 +132,10 @@ async def _get_logs(config, web3: Web3, contract, start_height):
yield log

if not logs:
LOGGER.info("Processed all transactions, waiting 10 seconds.")
await asyncio.sleep(10)
LOGGER.info(
f"Processed all transactions, waiting {config.ethereum.archive_delay.value} seconds."
)
await asyncio.sleep(config.ethereum.archive_delay.value)

start_height = end_height + 1
end_height = start_height + 1000
Expand Down Expand Up @@ -243,8 +247,10 @@ async def fetch_sync_events_task(self, config: Config):
"relaunching Ethereum message sync in 10 seconds"
)
else:
LOGGER.info("Processed all transactions, waiting 10 seconds.")
await asyncio.sleep(10)
LOGGER.info(
f"Processed all transactions, waiting {config.ethereum.message_delay.value} seconds."
)
await asyncio.sleep(config.ethereum.message_delay.value)

async def fetcher(self, config: Config):
message_event_task = self.indexer_reader.fetcher(
Expand Down
4 changes: 4 additions & 0 deletions src/aleph/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def get_defaults():
"max_gas_price": 150000000000,
# Authorized publishers for sync events.
"authorized_emitters": ["0x23eC28598DCeB2f7082Cc3a9D670592DfEd6e0dC"],
# Delay in seconds between archive checks.
"archive_delay": 30,
# Delay in seconds between blockchain message checks.
"message_delay": 30,
},
"tezos": {
# Whether to fetch transactions from Tezos.
Expand Down

0 comments on commit 23cb8f9

Please sign in to comment.