Skip to content

Commit

Permalink
fix: Handle sped-up deposits w/ nullified message
Browse files Browse the repository at this point in the history
The existing logic didn't work properly when a deposit with message was
subsequently sped-up with no message.
  • Loading branch information
pxrl committed Oct 9, 2023
1 parent 459f787 commit 44b3cee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 5 additions & 8 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,15 @@ export class Relayer {
// We need to build in better simulation logic for deposits with non-empty messages. Currently we only measure
// the fill's gas cost against a simple USDC fill with message=0x. This doesn't handle the case where the
// message is != 0x and it ends up costing a lot of gas to execute, resulting in a big loss to the relayer.
if (isDepositSpedUp(deposit) && deposit.updatedMessage !== "0x") {
this.logger.warn({
at: "Relayer",
message: "Skipping fill for sped-up deposit with message",
deposit,
});
continue;
} else if (deposit.message !== "0x") {
if (
(isDepositSpedUp(deposit) && deposit.updatedMessage !== "0x") ||
(!isDepositSpedUp(deposit) && deposit.message !== "0x")
) {
this.logger.warn({
at: "Relayer",
message: "Skipping fill for deposit with message",
deposit,
spedUp: isDepositSpedUp(deposit),
});
continue;
}
Expand Down
12 changes: 6 additions & 6 deletions test/Relayer.BasicFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
const newRelayerFeePct = toBNWei(0.1337);
const newMessage = "0x12";
const newRecipient = randomAddress();
const speedUpSignature = await modifyRelayHelper(
const { signature: speedUpSignature } = await modifyRelayHelper(
newRelayerFeePct,
deposit1.depositId.toString(),
deposit1.originChainId.toString(),
Expand All @@ -301,7 +301,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
message: "0x1212",
recipient: randomAddress(),
};
const unusedSpeedUpSignature = await modifyRelayHelper(
const { signature: unusedSpeedUpSignature } = await modifyRelayHelper(
unusedSpeedUp.relayerFeePct,
deposit1.depositId.toString(),
deposit1.originChainId.toString(),
Expand All @@ -316,27 +316,27 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
deposit1.depositId,
unusedSpeedUp.recipient,
unusedSpeedUp.message,
unusedSpeedUpSignature.signature
unusedSpeedUpSignature
);
await spokePool_1.speedUpDeposit(
depositor.address,
newRelayerFeePct,
deposit1.depositId,
newRecipient,
newMessage,
speedUpSignature.signature
speedUpSignature
);
await spokePool_1.speedUpDeposit(
depositor.address,
unusedSpeedUp.relayerFeePct,
deposit1.depositId,
unusedSpeedUp.recipient,
unusedSpeedUp.message,
unusedSpeedUpSignature.signature
unusedSpeedUpSignature
);
await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
expect(lastSpyLogIncludes(spy, "Skipping fill for sped-up deposit with message")).to.be.true;
expect(lastSpyLogIncludes(spy, "Skipping fill for deposit with message")).to.be.true;
expect(multiCallerClient.transactionCount()).to.equal(0);

// Now speed up deposit again with a higher fee and a message of 0x. This should be filled.
Expand Down

0 comments on commit 44b3cee

Please sign in to comment.