-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EPIC] Support migrations and recoveries in IBC contracts #12
Comments
Reposting here for persistency: This PoC PR introduces a possible design of a governance framework to address #12 for the solidity-ibc-eureka contracts using a multisig approach based on Safe. The key features implemented include:
These components together enhance the security, flexibility, and decentralization of the IBC Solidity contracts, laying the groundwork for a robust governance model. Notes
TimeLockThe Timelock mechanism is not currently implemented in this PoC but could be introduced in the future to enhance transparency specifically for upgrades. By delaying the execution of administrative actions, it would allow stakeholders to review proposed changes and raise objections if necessary. This would work well for upgrades but should not be applied to emergency operations, such as pausing, to avoid delays in critical scenarios. Balancing the delay duration would be key to maintaining flexibility while ensuring community trust Security ConsiderationUsing proxy contracts requires careful security consideration. The aspect to be considered includes but are not limited to:
For an initial review of potential security concern refer to 1,2,3,4. |
Some thoughts on the storage collision topic that can lead to very subtle vulnerabilities. Storage Considerations in Upgradeable Proxy ContractsIn transparent upgradeable proxy contracts, the proxy and implementation contracts have distinct roles: the proxy manages persistent state and the upgrade logic, while the implementation provides the contract specific logic and the storage layout that is mapped into the proxy persistent state. This separation enables contract upgrades while maintaining the existing state. However, the design introduces specific storage considerations to ensure compatibility and prevent collisions during upgrades. The proxy contract does not explicitly declare state variables for the implementation's data. Instead, when a function is executed via
For example, if the implementation declares a Layout Consistency and Storage CollisionsSince the proxy contract persists the state, maintaining a consistent storage layout across upgrades is crucial. When upgrading to a new implementation, the new contract must follow the existing storage layout. Any mismatch can cause storage collisions, potentially overwriting critical data. Storage collisions occur when variables in the proxy or implementation contracts conflict over the same storage slot. This can lead to corrupted or overwritten data, undermining contract functionality. To Avoid Storage Collisions:
To safely introduce new state variables in future upgrades, you can reserve unused storage slots in the initial implementation. This approach ensures that new variables in upgraded implementations will not overwrite existing data. Example: Reserved Storage SlotsLogicV1 (Initial Implementation): contract LogicV1 {
uint256 public x; // Stored at slot 0
uint256 public y; // Stored at slot 1
uint256[50] private __gap; // Reserved slots 2-51
} In LogicV2 (Upgraded Implementation): contract LogicV2 is LogicV1 {
uint256 public z; // Uses slot 2 from the reserved __gap // Can be any type but MUST Fit in the reserved slot.
} When upgrading to
Implication for ERC20 escrow contracts in ICS20TranfserThe ICS20 Transfer implementation, under the Eureka upgrade model, stores the ERC-20 contract addresses directly in the proxy's storage, thus they will persist across upgrades. This is because the proxy contract retains the state, while the new implementation logic modifies how that state is interpreted or utilized. For example, if an ERC-20 contract address mapping was added in an earlier implementation, the addresses will remain intact post-upgrade. As a result, even after upgrading the logic, the functionality of existing transfers and interactions with those ERC-20 contracts will be preserved without needing to reinitialize or reconfigure the state. However some consideration around ownership needs to be done:
|
Description
solidity-ibc-eureka
is built under the assumption that each Cosmos chain will have their own deployment, as such, the contracts should be migrated the governance of these chains. (Note that this means that in theoryICS02Client.sol
can be removed.) There are two types of migrations we need to think about:These two cases should be handled separately because in the first case, we don't need to introduce any additional trust assumptions.
Upgrades
Since IBC is still functioning in this case, we can use IBC to upgrade the contracts. We can give the authority to upgrade IBC contracts to the validator set of the counterparty tendermint chain. This can be done via an interchain accounts or contract call IBC application.
Recovering
In this case, we cannot use an on-chain light client or any other type of trustless mechanism as we are working under the assumption that IBC itself is unusable. This means that we can no longer trust the light client representing the cosmos chain (for example, it may be frozen or expired). Then we propose that in this case, a security council (multisig) takeover the admin privileges. However, we don't want the security council to have the ability to steal any funds while IBC is functioning properly, this is why we propose:
Proposal
We should study the docs and tools here to add migrations to our contracts. We should also probably move IBCStore to it's own contract
Tasks
The text was updated successfully, but these errors were encountered: