From 81e6da4c1197bf7a88d88af7e739c5d9c9a3844b Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Fri, 9 Aug 2024 22:30:11 +0200 Subject: [PATCH] fix: Try to lessen Linea finalizer RPC burden The Linea SDK implements some unfortunate RPC queries that are not well-suited to being called in parallel. This seems to be resulting in errors being returned by upstream RPC providers. Serialise some queries, with a longer delay on retry, in order to try to lessen the load and reduce the error rate. This will inevitably lead to a longer execution time, but might help to save the bot from throwing. --- src/finalizer/utils/linea/common.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/finalizer/utils/linea/common.ts b/src/finalizer/utils/linea/common.ts index 75ada8abf..8319c3828 100644 --- a/src/finalizer/utils/linea/common.ts +++ b/src/finalizer/utils/linea/common.ts @@ -84,11 +84,15 @@ export function makeGetMessagesWithStatusByTxHash( }; }); - // The Linea SDK MessageServiceContract constructs its own Provider without our retry logic so we retry each call - // twice with a 1 second delay between in case of intermittent RPC failures. - const messageStatus = await Promise.all( - messages.map((message) => retryAsync(() => dstClaimingService.getMessageStatus(message.messageHash), 2, 1)) - ); + // The Linea SDK MessageServiceContract constructs its own Provider without our caching, rate-limiting or retry + // logic. In particular, it scrapes logs over 0 -> latest and can heavily load the RPC provider. Query message + // up to twice, with a 1 second delay between, in case of intermittent RPC failures. + const messageStatus: OnChainMessageStatus[] = []; + for (const message of messages) { + const status = await retryAsync(() => dstClaimingService.getMessageStatus(message.messageHash), 2, 1); + messageStatus.push(status); + } + return messages.map((message, index) => ({ ...message, status: messageStatus[index],