renproject/ren-js

Query gateway pubkeys when building gateway addresses

Closed this issue · 1 comments

Currently, RenJS cannot handle gateway pubkeys that change over time. During SubZero, this is not an issue, because there is only one gateway pubkey and it does not change. However, for future compatibility, RenJS should not rely on this behaviour.

Instead, RenJS should call the ren_queryShards RPC to get back a list of all the shards, and all the gateways within each shard. From this, RenJS can calculate which shard is the least utilised, and use the gateway pubkey from that shard to construct a gateway address.

Design

The frontend must go through the following steps when building gateways (it can optimise slightly by doing it on load, and make the assumption the page will be refreshed at least once per epoch):

  • Call the ren_queryShards RPC.
  • Filter to only keep shards that are online.
  • Find the shard with the lowest total value locked (sum all the locked amounts from all gateways in a shard, after converting to a consistent currencies using the CoinMarketCap API).
  • Get the gateway pubkey from the gateway with the right asset within the shard with the lowest total value locked.
  • Use this gateway pubkey to build the gateway address.

Depends on

https://github.com/renproject/darknode/issues/232

0x31 commented

Closed in #29.