a16z / helios

A fast, secure, and portable light client for Ethereum
MIT License
1.81k stars 274 forks source link

feat: support tracking consensus updates in helios-ts #302

Open rdvorkin opened 10 months ago

rdvorkin commented 10 months ago

Support in some way tracking and getting notified when a new update is applied. The usecase I want to implement is setting a hook on new optimistic update, to do some action (For example, re-check a list of balances) when the update is applied.

Implementing something like https://nodejs.org/api/events.html#emitteroneventname-listener would be ideal, however even a function returning the current status (latest update applied, current block etc) would be great.

ncitron commented 10 months ago

Would something that mimics the websocket block subscription api make sense here potentially?

rdvorkin commented 10 months ago

@ncitron Yeah I suppose so, could you link an example of how that would look like?

ncitron commented 10 months ago

The eth_subscribe rpc method with the newHeads subscription type I think would make sense. We don't support these right now, but would something sort of inspired by this where you get new head blocks as they come work?

https://docs.alchemy.com/reference/newheads

rdvorkin commented 10 months ago

@ncitron Yes this seems perfect!