-
Notifications
You must be signed in to change notification settings - Fork 0
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
improve(spokePoolProcessor): improved logic for setting refunded status #109
Conversation
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, | ||
}) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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.