Modify Replica.sol to manage multiple Replicas for all remote domains in 1 contract #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, Replica.sol only allows for one replica at a time per contract, making it extremely inefficient to manage as the number of chains Home's are deployed on increases.
For example, if we deploy on 10 chains, each chain needs to maintain 9 different replicas, resulting in 90 different
Replica
, and 10Home
s.This is untenable to manage long-term, since Synapse is already deployed on 15 chains. There are two solutions:
ReplicaRouter
, an advanced version ofXAppConfig
, which would route the relevant function calls to the most recently enrolled Replica. The main consideration with this is that events won't bubble up top-level, thus making it difficult for off-chain agents to track all events, including most relevantly, watch-towers.Replica
to allow for multiple different states to exist inside of mappings which are keyed byuint32 remoteDomain
. This approach increases gas, but allows for events to bubble on one address.TODOs / Questions:
archivedReplicas
? Can we rely on off-chain event data to re-build the previous Replicas if needed in the future? Is a major benefit of multiple Replica contracts being able to leave a Replica in a failed state and re-deploying a new clean one?Replica
contractGas Considerations:
Multi-Replica modified contract (not yet gas optimized):
Original Replica