Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contracts/SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interface AcrossMessageHandler {
function handleAcrossMessage(
address tokenSent,
uint256 amount,
bool fillCompleted,
address relayer,
bytes memory message
) external;
}
Expand Down Expand Up @@ -1244,6 +1246,8 @@ abstract contract SpokePool is
AcrossMessageHandler(relayExecution.updatedRecipient).handleAcrossMessage(
relayData.destinationToken,
amountToSend,
relayFills[relayExecution.relayHash] >= relayData.amount,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the opposite? Wouldn't the stored fill amount be >= (really just ==, but >= just to be safe) the total fill amount when it's completely filled? Or am I missing something?

relayData.amount <= relayFills[relayExecution.relayHash].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the above equation exactly what I have in the PR?

Copy link
Contributor

@mrice32 mrice32 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yeah, the direction of the inequality just got twisted in my head. You're right!

msg.sender,
relayExecution.updatedMessage
);
}
Expand Down
2 changes: 2 additions & 0 deletions contracts/test/AcrossMessageHandlerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ contract AcrossMessageHandlerMock is AcrossMessageHandler {
function handleAcrossMessage(
address tokenSent,
uint256 amount,
bool fillCompleted,
address relayer,
bytes memory message
) external override {}
}
32 changes: 30 additions & 2 deletions test/SpokePool.Relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,37 @@ describe("SpokePool Relayer Logic", async function () {
expect(acrossMessageHandler.handleAcrossMessage).to.have.been.calledOnceWith(
weth.address,
consts.amountToRelay,
false,
relayer.address,
"0x1234"
);
});
it("Handler is called with correct params", async function () {
const acrossMessageHandler = await createFake("AcrossMessageHandlerMock");
const { relayData } = getRelayHash(
depositor.address,
acrossMessageHandler.address,
consts.firstDepositId,
consts.originChainId,
consts.destinationChainId,
weth.address,
undefined,
undefined,
undefined,
"0x1234"
);

// The collateral should have not unwrapped to ETH and then transferred to recipient.
expect(await weth.balanceOf(acrossMessageHandler.address)).to.equal(consts.amountToRelay);
// Handler is called with full fill and relayer address.
await spokePool
.connect(depositor)
.fillRelay(...getFillRelayParams(relayData, relayData.amount, consts.destinationChainId));
expect(acrossMessageHandler.handleAcrossMessage).to.have.been.calledOnceWith(
weth.address,
relayData.amount.mul(consts.totalPostFeesPct).div(toBN(consts.oneHundredPct)),
true, // True because fill completed deposit.
depositor.address, // Custom relayer
"0x1234"
);
});
it("Self-relay transfers no tokens", async function () {
const largeRelayAmount = consts.amountToSeedWallets.mul(100);
Expand Down Expand Up @@ -654,6 +680,8 @@ async function testfillRelayWithUpdatedDeposit(depositorAddress: string) {
expect(acrossMessageHandler.handleAcrossMessage).to.have.been.calledOnceWith(
relayData.destinationToken,
amountActuallySent,
false,
relayer.address,
updatedMessage
);

Expand Down