Closed diwu1989 closed 1 year ago
Pair state snapshot is implemented https://github.com/terminal-fi/swappa/pull/11
Next step is figure out how to cleanly snapshot / restore registries and pairs.
Now that pairs can be snapshotted, then we can make it possible to take a registry, and snapshot the information needed to re-initialize each pair, & then restoring the snapshot state into these re-initialized pairs.
For each pair, there's the static state that is discovered from the registry and this information does not change per-block. There's also the dynamic per-block pair state, that changes with each refresh()
Registry snapshot should only contain the static initialization data for all discovered pairs of that registry.
I need to complete this snapshotting feature now that there's helper smart contracts to accelerate the registry initialization and pair refresh process.
The idea is that the registry helper contracts need to provide enough information to generate a pair Snapshot
and then per block, we just restore the state in bulk from the helper contracts on-chain.
Right now, pairs are constructed by looking up the on-chain registry.
If a web UI is to be built on top of swappa, we need server-side acceleration. The way it could work:
This will reduce the load on Forno significantly and bypass the all pair discovery lag on the web clients.
My proposed API change to Pair interface to support streaming in a snapshot state:
Probably also need something in the registry to snapshot the list of all discovered pair & addresses (the arguments we need to initialize the pair). After the pairs are instantiated locally, the state can be restored.
The snapshot interface is something I need as well for arbbing because i snapshot & execute & restore states to pairs continuously.