ComposableFi / near-rs

Utilities that faciliatate a trust-less bridge between Near and Polkadot
The Unlicense
5 stars 2 forks source link

Listening to events from NEAR #15

Open vmarkushin opened 2 years ago

vmarkushin commented 2 years ago

According to the documentation, Near doesn't provide any convenient API for event subscription (new blocks, transactions, finalization, etc.). The existing RPC (HTTP) API doesn't seem to be a good option for the relayer, because requires initiating a new connection for each request, passing additional data to retrieve events at a particular block, and having multiple requests for each kind of message.

Continuous receipt of events can be implemented via indexer. The indexer runs a Near node internally and provides a stream of messages emitted by the blockchain. The only problem is that the crate can't act as an external service, so if we at some point will want to separate the blockchain node from the relayer, we'll have to create an additional layer that will be responsible for propagating the data (like Kafka or basic WebSockets).

The question is: is it a good solution to use for this project?

blasrodri commented 2 years ago

The approach seems correct to me. My only question is:

Do we want to persist the state in any way, or would fire and forget be good enough?

Mostly to understand whether we'd need to introduce an extra dependency like a MQ.

seunlanlege commented 2 years ago

For the first draft, let's just use Websockets