Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add updated UMIP invalidity cases #831

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Conversation

bmzig
Copy link
Contributor

@bmzig bmzig commented Jan 21, 2025

A deposit refund is now "invalid" if the depositor specified cannot be repaid (since the origin chain is an EVM chain and the depositor address is not a bytes20 address).
A fill is invalid if the relayer supplies a 32 byte address and requests repayment on an EVM chain and the msg.sender is a 32-byte address when inspecting the destination chain fill.

@bmzig bmzig requested review from nicholaspai, mrice32 and pxrl January 21, 2025 21:17
src/utils/AddressUtils.ts Outdated Show resolved Hide resolved
src/utils/NetworkUtils.ts Outdated Show resolved Hide resolved
@bmzig bmzig marked this pull request as ready for review January 23, 2025 18:20
@bmzig bmzig requested a review from pxrl January 23, 2025 18:20
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

I think the implementation of the Bundle Data Client changes can be refactored to make sure we're capturing all cases where we're validating deposits and refunds

@@ -805,8 +808,15 @@ export class BundleDataClient {
return;
}

// A deposit refund for a deposit is invalid if the depositor has a bytes32 address input for an EVM chain. It is valid otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it more inclusive to check if the address is a bytes20 address? Can use an ethers is address function for example.

I can imagine that an input here is not bytes32 but also not a valid address.

Copy link
Contributor Author

@bmzig bmzig Jan 23, 2025

Choose a reason for hiding this comment

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

Fair enough. Updated here: 59315b8. Although, note that we assume that the refund will be valid all times if the chain is non-evm, which is probably fine for SVM, since the event should always give us a bytes32.

@@ -914,11 +924,32 @@ export class BundleDataClient {
bundleInvalidFillsV3.push(fill);
return;
}
// If the fill's repayment address is not a valid EVM address and the repayment chain is an EVM chain, the fill is invalid.
if (chainIsEvm(fill.repaymentChainId) && isAddressBytes32(fill.relayer)) {
Copy link
Member

Choose a reason for hiding this comment

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

I would do this checking higher up when creating bundle refunds https://github.com/across-protocol/sdk/blob/bz/newInvalidityCases/src/clients/BundleDataClient/BundleDataClient.ts#L76

Here is also where we check if the fill is a slow fill in which case we ignore it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I move this to that function linked, then it would need to be async, right? Since we need to fallback to the msg.sender if this first conditional is true. Also, moving it up would mean we can't reliably update bundleInvalidFillsV3, right? Unless that function tells us if it successfully updated the dictionary or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Never mind. Updated here: 76de69a

@@ -816,7 +826,7 @@ export class BundleDataClient {
// that would eliminate any deposits in this bundle with a very low fillDeadline like equal to 0
// for example. Those should be impossible to create but technically should be included in this
// bundle of refunded deposits.
if (deposit.fillDeadline < bundleBlockTimestamps[destinationChainId][1]) {
if (deposit.fillDeadline < bundleBlockTimestamps[destinationChainId][1] && refundIsValid(deposit)) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit uncomfortable adding this check here in case it's not all inclusive of all expired deposits. Can we instead add it to this function such that we are safer about all expired deposits refund cases go through this check? https://github.com/across-protocol/sdk/blob/bz/newInvalidityCases/src/clients/BundleDataClient/BundleDataClient.ts#L60

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. Refactored here: 59315b8

Base automatically changed from bz/depositIds to master January 24, 2025 18:24
@bmzig bmzig requested a review from nicholaspai January 24, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants