-
Couldn't load subscription status.
- Fork 2
feat: send cctp burn transactions to pubsub #391
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
base: amatei/acx-4462-index-mint-and-burn-events-in-the-indexer
Are you sure you want to change the base?
feat: send cctp burn transactions to pubsub #391
Conversation
| await this.pubSubService.publishCctpFinalizerMessage( | ||
| transactionHash, | ||
| Number(chainId), | ||
| ); |
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.
So if this succeeds but the Cloud Run service fails for some reason, we will still update the CctpFinalizerJob table below right? Will it still retry in this case?
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, it won't retry. I will have a follow up PR which will check periodically for unfinalized old events
| const qb = this.postgres | ||
| .createQueryBuilder(DepositForBurn, "burnEvent") | ||
| .leftJoinAndSelect("burnEvent.finalizerJob", "job") | ||
| .where("job.id IS NULL") |
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.
Just trying to understand - when would job.id be null? Won't it be auto-incremented when the insert happens 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.
Exactly, but we search for burn events that don't have a job associated yet. Therefore we need to execut a LEFT JOIN where job's id is NULL (i.e doesn't exist)
| indexingDelaySeconds: | ||
| getIndexingDelaySeconds(chainId, this.config) * 2, |
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.
indexing CCTP events is much fast than SpokePool events via the SDK, so we can increase the delay a bit here
bb2a4aa to
c894c13
Compare
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!
| const topic = await this.pubSub.topic( | ||
| this.config.pubSubCctpFinalizerTopic, | ||
| ); |
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.
this.pubSub.topic() is not an async function right? Do we need the await?
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.
right. edited
| /** | ||
| * @notice Returns the CCTP domain for a given chain ID. Throws if the chain ID is not a CCTP domain. | ||
| * @param chainId | ||
| * @returns CCTP Domain ID | ||
| */ | ||
| export function getCctpDomainForChainId(chainId: number): number { | ||
| const cctpDomain = PUBLIC_NETWORKS[chainId]?.cctpDomain; | ||
| if (!across.utils.isDefined(cctpDomain) || cctpDomain === CCTP_NO_DOMAIN) { | ||
| throw new Error(`No CCTP domain found for chainId: ${chainId}`); | ||
| } | ||
| return cctpDomain; | ||
| } | ||
|
|
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.
This same function and fetchAttestationsForTxn is being used in the finalizer service too. Maybe we can consolidate in the SDK later.
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 @ashwinrava. Nick just merged a PR with CCTP utils which is going to be integrated soon in the indexer 👍
| const attestations = await fetchAttestationsForTxn( | ||
| getCctpDomainForChainId(Number(burnEvent.chainId)), | ||
| transactionHash, | ||
| true, |
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.
Would we ever need to handle testnets?
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.
you mean that getCctpDomainForChainId function doesn't handle testnets?
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 mean true is being passed to the isMainnet field on line 147. In the finalizer service I call chainIsProd(sourceChainId) and then pass that value to fetchAttestationsForTxn. Just thinking if we need to do something similar here.
This PR implements a new service that publishes CCTP (Cross-Chain Transfer Protocol) burn events to a GCP PubSub topic, enabling the finalization bot to process and finalize these transactions onchain.
Changes
Database Layer
CctpFinalizerJob- Tracks burn events that have been successfully sent to the finalizer botService Layer
CctpFinalizerService- Core service that runs on an intervalCctpFinalizerJobrecords to track published eventsIntegration Layer
Configuration
ENABLE_CCTP_FINALIZER- Feature flag to enable/disable the serviceCCTP_FINALIZER_PUBSUB_TOPIC- GCP PubSub topic URL for publishing messages