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

improve(spokePoolProcessor): improved logic for setting refunded status #109

Merged

Conversation

melisaguevara
Copy link
Contributor

@melisaguevara melisaguevara commented Nov 20, 2024

Previously, we were querying the expired deposits and then querying its possible refunds. Now, we are getting from the database only the deposits that might be refunded based on the bundle events that are stored in the db.

This PR also fixes the bug we were having before (Cannot read properties of undefined, reading relayerRefundRoot). The issue was fixed by including the inner join with the bundle table when querying bundle events.

Copy link

linear bot commented Nov 20, 2024

Comment on lines +179 to +188
const refundEvents = await bundleEventsRepository
.createQueryBuilder("be")
.innerJoinAndSelect("be.bundle", "bundle")
.innerJoin(entities.RelayHashInfo, "rhi", "be.relayHash = rhi.relayHash")
.where("be.type = :expiredDeposit", {
expiredDeposit: entities.BundleEventType.ExpiredDeposit,
})
.andWhere("rhi.status = :expired", {
expired: entities.RelayStatus.Expired,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this generate a list of refunds without needing to do it iteratively in the loop below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes exactly

.createQueryBuilder()
.update()
.set({
status: entities.RelayStatus.Refunded,
depositRefundTxHash: executedRelayerRefundRootEvent.transactionHash,
})
.where("relayHash = :relayHash", {
relayHash: expiredDeposit.relayHash,
relayHash: refundEvent.relayHash,
Copy link
Contributor

Choose a reason for hiding this comment

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

was the previous used value incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, is just that we're not querying the deposits now, only the bundle events.

Comment on lines 228 to 239
await this.postgres
.getRepository(entities.RelayHashInfo)
.createQueryBuilder()
.update()
.set({
status: entities.RelayStatus.Refunded,
depositRefundTxHash: executedRelayerRefundRootEvent.transactionHash,
})
.where("relayHash = :relayHash", {
relayHash: expiredDeposit.relayHash,
relayHash: refundEvent.relayHash,
})
.execute();
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good! Only one improvement suggestion. We need to emit webhook notifications from here with a payload like

{ depositId, originChainId, status, depositTxHash }

Any thoughts what's the best way to do 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.

I think this should help to integrate the webhook function next 48f3d16

@melisaguevara melisaguevara merged commit c5bab8b into master Nov 21, 2024
3 checks passed
@melisaguevara melisaguevara deleted the mguevara/acx-3352-reading-relayerrefundroot-of-undefined branch November 21, 2024 21:19
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