From b33091d0010a90a94f6429f08e6e4fa32fbbf491 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 19 Jun 2025 16:01:23 +0000 Subject: [PATCH 1/4] improve(SpokePoolClient): Negate non-EVM SpeedUp recipients SpeedUp events are not supported for EVM -> SVM or SVM -> any, so they can be discarded immediately. --- src/clients/SpokePoolClient/SpokePoolClient.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/clients/SpokePoolClient/SpokePoolClient.ts b/src/clients/SpokePoolClient/SpokePoolClient.ts index 58473a9e0..82d422527 100644 --- a/src/clients/SpokePoolClient/SpokePoolClient.ts +++ b/src/clients/SpokePoolClient/SpokePoolClient.ts @@ -569,18 +569,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient { for (const event of speedUpEvents) { const speedUp = { ...event, originChainId: this.chainId }; - assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]); // Find deposit hash matching this speed up event and update the deposit data associated with the hash, // if the hash+data exists. const deposit = this.getDeposit(speedUp.depositId); + // SpeedUp requests are only supported EVM -> EVM. + // nb. Relying on depositId alone check can collide; + if (!isDefined(deposit) || !chainIsEvm(deposit.destinationChainId)) { + continue; + } + + assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]); + // We can assume all deposits in this lookback window are loaded in-memory already so if the depositHash // is not mapped to a deposit, then we can throw away the speedup as it can't be applied to anything. - if (isDefined(deposit)) { - const eventKey = getRelayEventKey(deposit); - this.depositHashes[eventKey] = this.appendMaxSpeedUpSignatureToDeposit(deposit); - } + const eventKey = getRelayEventKey(deposit); + this.depositHashes[eventKey] = this.appendMaxSpeedUpSignatureToDeposit(deposit); } }; From 6a6a8a371b4d61b911090ff0b0d65c2217dc88af Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 19 Jun 2025 16:16:11 +0000 Subject: [PATCH 2/4] Fix test --- src/clients/SpokePoolClient/SpokePoolClient.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/clients/SpokePoolClient/SpokePoolClient.ts b/src/clients/SpokePoolClient/SpokePoolClient.ts index 82d422527..169d72e82 100644 --- a/src/clients/SpokePoolClient/SpokePoolClient.ts +++ b/src/clients/SpokePoolClient/SpokePoolClient.ts @@ -569,6 +569,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient { for (const event of speedUpEvents) { const speedUp = { ...event, originChainId: this.chainId }; + assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]); // Find deposit hash matching this speed up event and update the deposit data associated with the hash, // if the hash+data exists. @@ -576,16 +577,12 @@ export abstract class SpokePoolClient extends BaseAbstractClient { // SpeedUp requests are only supported EVM -> EVM. // nb. Relying on depositId alone check can collide; - if (!isDefined(deposit) || !chainIsEvm(deposit.destinationChainId)) { - continue; + if (isDefined(deposit) && chainIsEvm(deposit.destinationChainId)) { + // We can assume all deposits in this lookback window are loaded in-memory already so if the depositHash + // is not mapped to a deposit, then we can throw away the speedup as it can't be applied to anything. + const eventKey = getRelayEventKey(deposit); + this.depositHashes[eventKey] = this.appendMaxSpeedUpSignatureToDeposit(deposit); } - - assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]); - - // We can assume all deposits in this lookback window are loaded in-memory already so if the depositHash - // is not mapped to a deposit, then we can throw away the speedup as it can't be applied to anything. - const eventKey = getRelayEventKey(deposit); - this.depositHashes[eventKey] = this.appendMaxSpeedUpSignatureToDeposit(deposit); } }; From 2c4de14236f479f099bdf4cf2add648443c6eb03 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 19 Jun 2025 16:17:38 +0000 Subject: [PATCH 3/4] reflow --- src/clients/SpokePoolClient/SpokePoolClient.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/clients/SpokePoolClient/SpokePoolClient.ts b/src/clients/SpokePoolClient/SpokePoolClient.ts index 169d72e82..bbc0d05b2 100644 --- a/src/clients/SpokePoolClient/SpokePoolClient.ts +++ b/src/clients/SpokePoolClient/SpokePoolClient.ts @@ -572,11 +572,10 @@ export abstract class SpokePoolClient extends BaseAbstractClient { assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]); // Find deposit hash matching this speed up event and update the deposit data associated with the hash, - // if the hash+data exists. + // if the hash+data exists. nb. Relying on depositId alone can produce collisions on deterministic deposit IDs. const deposit = this.getDeposit(speedUp.depositId); // SpeedUp requests are only supported EVM -> EVM. - // nb. Relying on depositId alone check can collide; if (isDefined(deposit) && chainIsEvm(deposit.destinationChainId)) { // We can assume all deposits in this lookback window are loaded in-memory already so if the depositHash // is not mapped to a deposit, then we can throw away the speedup as it can't be applied to anything. From 07f480fefb09c60501f5299496917a00730a50c1 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 26 Jun 2025 16:37:10 +0000 Subject: [PATCH 4/4] Require depositors to match --- src/clients/SpokePoolClient/SpokePoolClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clients/SpokePoolClient/SpokePoolClient.ts b/src/clients/SpokePoolClient/SpokePoolClient.ts index a09b4ae43..5097f3224 100644 --- a/src/clients/SpokePoolClient/SpokePoolClient.ts +++ b/src/clients/SpokePoolClient/SpokePoolClient.ts @@ -576,7 +576,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient { const deposit = this.getDeposit(speedUp.depositId); // SpeedUp requests are only supported EVM -> EVM. - if (isDefined(deposit) && chainIsEvm(deposit.destinationChainId)) { + if (isDefined(deposit) && chainIsEvm(deposit.destinationChainId) && deposit.depositor === speedUp.depositor) { // We can assume all deposits in this lookback window are loaded in-memory already so if the depositHash // is not mapped to a deposit, then we can throw away the speedup as it can't be applied to anything. const eventKey = getRelayEventKey(deposit);