hirosystems / stacks-blockchain-api

API for the Stacks blockchain
https://stacks-blockchain-api.vercel.app
GNU General Public License v3.0
178 stars 114 forks source link

"@stacks/blockchain-api-client" is actively monitoring certain transactions, but is not capturing all subscribed transactions #1693

Closed mefrem closed 1 year ago

mefrem commented 1 year ago

Describe the bug [This is a repost from zeroauthority-dao Issue zeroauthority-dao/Cerulean-MP#46 posted by @Sushilbro]

Problem: "In our attempt to listen to real-time transactions using websockets, we receive a response from the called function and update our off-chain database only if the transaction ID (txid) is confirmed in the anchor block. However, we are experiencing a limitation where not all subscribed transactions are being captured."

To Reproduce "The code to listen to WebSocket connections is housed in the upsertGig.js file, accessible through this GitHub link: https://github.com/zeroauthority-dao/za-website/blob/Sushil-branch-master/pages/api/upsertGig.js. "

Additional context I personally think that a Hiro Chainhook solution would serve the zeroauthority-dao team well, however I wanted to make sure there wasn't a lingering error or missing coverage in our API.

xyzerobtc commented 1 year ago

If someone could help us that would be much appreciated. Reply here or https://github.com/zeroauthority-dao/Cerulean-MP/issues/46 posted by @SushilBro you can email us as well dao@zeroauthority.xyz

xyzerobtc commented 1 year ago

Hi @lgalabru - Jude said you may be able to help us resolve this issue for the webhook. @sushilbro

xyzerobtc commented 1 year ago

cc: @HodlSTX

sabbyanandan commented 1 year ago

Hi, @xyzerobtc @HodlSTX. I am sharing some context behind WebSockets/Socket.io support in Stacks Blockchain API.

The support for WebSockets/Socket.io is geared towards Explorer-like apps where data loss is not a paramount concern. And for that reason, @stacks/blockchain-api-client includes a best-effort implementation of WebSockets/Socket.io.

For a highly performant, resilient, and near-real-time event-streaming of transactions, and any related events from upstream blockchains, including Stacks or Bitcoin, we are bullish and highly recommend switching to Chainhook (what @mefrem was recommending early-on, also). Data loss is a paramount concern with Chainhook, and we keep this bar high! As a case study, we deeply care about the data consistency with our Ordinals API and Ordinals Explorer products, and Chainhooks is powering both behind the scenes (in production).

A few benefits of Chainhooks approach:

Lastly, we are adding new DevEx to Chainhook creation, management, and monitoring in the Hiro Platform. Below is an example screenshot of what is in the works, which I believe can dramatically simplify your requirements to pipe + ingest + process transactions and other interesting events you care for, from Bitcoin, Stacks, or both in real-time!

image

As the next steps:

sabbyanandan commented 1 year ago

Also, as an FYI @xyzerobtc, when clicking "LEARN" top-nav link at https://zeroauthority.xyz/, it results in 404.

SushilBro commented 1 year ago

Do we need to set up our own Bitcoin and stacks node to use Chainhook with stacks.?

sabbyanandan commented 1 year ago

Do we need to set up our own Bitcoin and stacks node to use Chainhook with stacks.?

Hi, @SushilBro! If you're using the Chainhooks support in the Hiro Platform, no, you don't have to. However, you also have the option to run Chainhooks in your infrastructure. To that extent, you can override the Stacks and Bitcoin node/ports if you'd prefer managing them independently, pointing to your custom deployed services in your infra. We have a few how-to guides on custom deployments as a service.

@lgalabru: Feel free to correct me if my interpretation is wrong with the above.

xyzerobtc commented 1 year ago

@sabbyanandan thank you for the note on the 404 error. Really appreciate the guidance and giving us feedback on how to implement chainhooks in the zero authority cerulean marketplace. Here is the link to testnet to give you an idea how the marketplace works. site: https://za-website-staging.vercel.app/

instructions: (1) connect wallet (2) make an offer to someone (3) web3 creator accept the offer. (4) clarity contract deposits reward (5) clarity contract releases reward (6) both creators earn reputation on-chain & emissions

what is zero authority & what is the cerulean marketplace? https://www.canva.com/design/DAFoj8ydBhM/qQBzWijW2QGw398QDUU0RQ/view?utm_content=DAFoj8ydBhM&utm_campaign=designshare&utm_medium=link&utm_source=publishsharelink

smcclellan commented 1 year ago

I'll close this ticket as it looks like @SushilBro (and @xyzerobtc) have received guidance here. Feel free to reopen if there's a further need.

SushilBro commented 1 year ago

hey, @sabbyanandan can you explain how can i create Chainhooks in Hiro Platform, i could not see any options to create Chainhooks there.

sabbyanandan commented 1 year ago

hey, @sabbyanandan can you explain how can i create Chainhooks in Hiro Platform, i could not see any options to create Chainhooks there.

Hello, @SushilBro! We aim to release the Chainhooks support in the Hiro Platform by ~ the 2nd week of August, so it is coming soon! In the meantime, if you're up for it, I can work with you to have you try it out in a non-prod environment and engage on any feedback loops.

Please feel free to find a slot that works best for you: https://calendly.com/sabbyanandan/platform-office-hours