snapshot-labs / sx-monorepo

Snapshot X monorepo
https://docs.snapshotx.xyz
MIT License
11 stars 10 forks source link

fix: use contract to map timestamp to block number #446

Closed Sekhmet closed 3 days ago

Sekhmet commented 1 week ago

Summary

This PR solves issue with Timestamp not cached being thrown when waiting for EVMSlotValue/OZVotesStorage strategies.

Previously we used Herodotus API to read block number for given timestamp. This is not ideal because it doesn't actually mean that this mapping is already available on the network (because mana needs time to process it and create transaction out of it).

This commit removes dependency on Herodotus API on UI. Now mapping timestamp to block number is done on strategy contract directly. If it resolves it means that it will also be available for contract when casting a vote or computing VP. If it's not available we are marking it as NOT_READY_YET so UI displays appropriate message.

How to test

  1. Create new proposal that uses EVMSlotValue/OZVotesStorage.
  2. Message tells you that you have to wait for VP to be visible.
  3. Wait for some time, refresh periodically, you can monitor mana logs (if you see Cannot read properties of undefined (reading 'onchain_remapper_id') then it's close) to see when status changes (or explorer if on mainnet). Generally once you see cached proposal with txId in mana logs it would be where it would break.
  4. No error shows up at any point, you see "Wait" message which then turns into VP.
Sekhmet commented 4 days ago

For votes it will only use contract, Herodotus api is only used when processing proposal.

bonustrack commented 4 days ago

Great great