From 9e661e1b767890cd303a24ab300eb1709bb1ae7c Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 4 Oct 2024 11:14:14 +0100 Subject: [PATCH 1/4] chore: temporarily disable registry writting on chunks --- src/domain/polling/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domain/polling/index.ts b/src/domain/polling/index.ts index b9b8f69..85ee045 100644 --- a/src/domain/polling/index.ts +++ b/src/domain/polling/index.ts @@ -92,7 +92,7 @@ const API_ERRORS_DROP: DropApiErrorsArray = [ // ApiErrors.IncompatibleSigningScheme - we control this in the watch-tower // ApiErrors.AppDataHashMismatch - we never submit full appData -const CHUNK_SIZE = 20; // How many orders to process before saving +const CHUNK_SIZE = 100; // How many orders to process before saving /** * Watch for new blocks and check for orders to place @@ -149,7 +149,7 @@ export async function checkForAndPlaceOrder( log.debug(`Processed ${orderCounter}, saving registry`); // Save the registry after processing each chunk - await registry.write(); + // await registry.write(); // TODO: temporarily disabling save on chunk } const ownerRef = `${ownerCounter}.${orderCounter}`; From 0cd76e5aba77561b5b165f2d6d20201fe0a7616d Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 4 Oct 2024 13:24:42 +0100 Subject: [PATCH 2/4] fix: only save when there are changes to be saved --- src/domain/polling/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/domain/polling/index.ts b/src/domain/polling/index.ts index 85ee045..de55795 100644 --- a/src/domain/polling/index.ts +++ b/src/domain/polling/index.ts @@ -92,7 +92,7 @@ const API_ERRORS_DROP: DropApiErrorsArray = [ // ApiErrors.IncompatibleSigningScheme - we control this in the watch-tower // ApiErrors.AppDataHashMismatch - we never submit full appData -const CHUNK_SIZE = 100; // How many orders to process before saving +const CHUNK_SIZE = 50; // How many orders to process before saving /** * Watch for new blocks and check for orders to place @@ -115,6 +115,7 @@ export async function checkForAndPlaceOrder( let hasErrors = false; let ownerCounter = 0; let orderCounter = 0; + let updatedCount = 0; const log = getLogger( "checkForAndPlaceOrder:checkForAndPlaceOrder", @@ -140,13 +141,13 @@ export async function checkForAndPlaceOrder( orderCounter++; // Check if we reached the chunk size - if (orderCounter % CHUNK_SIZE === 1 && orderCounter > 1) { + if (updatedCount % CHUNK_SIZE === 1 && updatedCount > 1) { // Delete orders pending delete, if any _deleteOrders(ordersPendingDelete, conditionalOrders, log, chainId); // Reset tracker ordersPendingDelete = []; - log.debug(`Processed ${orderCounter}, saving registry`); + log.debug(`Processed ${updatedCount}, saving registry`); // Save the registry after processing each chunk // await registry.write(); // TODO: temporarily disabling save on chunk @@ -231,6 +232,8 @@ export async function checkForAndPlaceOrder( blockNumber: blockNumber, result: pollResult, }; + // Order needs saving! + updatedCount++; // Log the result const unexpectedError = From cd9e1ca1f3054b8ce24a84ed71a205b2fa774158 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 4 Oct 2024 13:26:59 +0100 Subject: [PATCH 3/4] chore: re-enable resgistry save --- src/domain/polling/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domain/polling/index.ts b/src/domain/polling/index.ts index de55795..9614705 100644 --- a/src/domain/polling/index.ts +++ b/src/domain/polling/index.ts @@ -150,7 +150,7 @@ export async function checkForAndPlaceOrder( log.debug(`Processed ${updatedCount}, saving registry`); // Save the registry after processing each chunk - // await registry.write(); // TODO: temporarily disabling save on chunk + await registry.write(); } const ownerRef = `${ownerCounter}.${orderCounter}`; From c930e2a195cc8271cba21c2dd6234116e584f5dd Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 4 Oct 2024 13:27:13 +0100 Subject: [PATCH 4/4] chore: add logging for deleted orders --- src/domain/polling/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/domain/polling/index.ts b/src/domain/polling/index.ts index 9614705..7b93eef 100644 --- a/src/domain/polling/index.ts +++ b/src/domain/polling/index.ts @@ -293,6 +293,8 @@ function _deleteOrders( log: LoggerWithMethods, chainId: SupportedChainId ) { + log.debug(`${ordersPendingDelete.length} to delete`); + for (const conditionalOrder of ordersPendingDelete) { const deleted = conditionalOrders.delete(conditionalOrder); const action = deleted ? "Stop Watching" : "Failed to stop watching";