yeagerai / genlayer-simulator

MIT License
16 stars 8 forks source link

Update transactions based on subscriptions events and remove polling #581

Closed cristiam86 closed 1 week ago

denishacquin commented 2 weeks ago

I have successfully switched to a subscription model, however, because our websocket connections are scoped to a socketio client id and that client ID is renewed on reload by socketio and because we don't have the polling anymore, we have a slight edge case where the browser won't be notified of a tx being updated if it's pending when the page loads. (but reloading the page after the tx is finalized correctly updates the tx since we still do an initial request to update all pending txs).

This is not a huge deal breaker for now since the user has to reload while some txs are pending for this symptom to appear + one more reload and the tx get updated by the initial query.

This is because we had to scope the socketio connections to clientIds while hosting, otherwise all users would have gotten all events from other users.

Some solutions:

Thoughts welcome @cristiam86 @AgustinRamiroDiaz

AgustinRamiroDiaz commented 2 weeks ago

@denishacquin sorry but I don't quite understand the problem.

On another topic, I thought the idea was to do broadcasting of all events, an then each client would just subscribe to the events they are interested in (by transaction hash for example)

denishacquin commented 2 weeks ago

You're right, I'll add tx-scoped subs then. I think we can have the transaction-based events scoped by transaction room/subscription and the other events can remain scoped to the socketio client IDs.

AgustinRamiroDiaz commented 2 weeks ago

Awesome! Let me know if there's still an edge case I didn't think of One key thing would be to remove the client ID from the Transactions table

denishacquin commented 2 weeks ago

Removed the column from the model, as well as all occurences and added migration.

To sum it up: transactions are scoped to clients based on client-side explicit subscriptions to specific rooms (=hash), while the other logs are still scoped to socket client IDs.

github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 0.20.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: