plebbit / plebbit-js

A Javascript API to build applications using plebbit
GNU General Public License v2.0
41 stars 7 forks source link

Improve ENS resolving #8

Open estebanabaroa opened 1 year ago

estebanabaroa commented 1 year ago

Ideas to improving ENS resolving:

  1. Adding a cache that persist (both in browser and node), the cached value should always be used if it exist even if stale. But if stale, it should revalidate (use stale value immediately and revalidate async, dont revalidate sync or it wastes too much time). I think it should be considered stale after 5 minutes.
  2. If resolving fails because of network, it should be retried 3 times, with delays 0ms, 100ms, 1000ms, If resolving fails because the name isn't set, it shouldn't retry. (I'm not sure how to differentiate the 2, it needs to be tested). can use lib p-retry for that.
  3. Updating ethers.js to the latest version might improve reliability, not sure. The API changes between major version so it should be tested manually to make sure it still works.
Rinse12 commented 1 year ago

1 and 2 are implemented with commit #7b833a65f6470ab2fdc4f0f945c173434a67223e, although a resolve result is considered stale only after 24 hours. I do think that's too much, but also 5m is too low. Maybe 1 hour is good?

I updated ethers.js to 6.3.0 but it requires tsconfig to upgrade to ES2015, which changes a few things in our setup. Maybe not worth the effort for now

estebanabaroa commented 1 year ago

1 and 2 are implemented with commit #7b833a65f6470ab2fdc4f0f945c173434a67223e, although a resolve result is considered stale only after 24 hours. I do think that's too much, but also 5m is too low. Maybe 1 hour is good?

I updated ethers.js to 6.3.0 but it requires tsconfig to upgrade to ES2015, which changes a few things in our setup. Maybe not worth the effort for now

I dont think 1 hour is good, the user won't be able to set up his own sub ENS and see it working for 1 hour. assuming the user has 100 subscriptions, that means he makes 100 eth calls every 5 minutes, that seems fine to me. especially since at some point we should use multicall to bulk them up.