Motoro icon indicating copy to clipboard operation
Motoro copied to clipboard

Versioning

Open patrykmat opened this issue 6 years ago • 3 comments

Feature request

As a CTO I want to be able to upload different versions of the smart contracts then I expect to have an additional smart contract Where I can redirect all requests from the old version of contract to a new one

patrykmat avatar Feb 20 '18 17:02 patrykmat

There is a couple of ways of achieving that:

You can use delegatecall available in solidity that will call a method in another smart contract together with changeable variable currentVersionAddress we can call 'current' version of the contract from our 'proxy'.

example from https://github.com/shaunazzopardi/smart-contract-versioning called 'Proxy/Interface method'


    address currentVersion = <someAddress>;
    
    <type> <varName>;
    function <methodName>() public returns(<type>){
        if(currentVersion.delegatecall(msg.data)){
            returns <varName>;
        }
        else{
            revert();
        }
    }

Only Owner of the contract can modify the currentVersionAddress.

In more details it concept is explained on https://ethereum.stackexchange.com/questions/2404/upgradeable-smart-contracts

One of the limits of that approach is that you can have only variables available in the original contract, meaning you would have to either know a priori what will you require or provide a magic map of anything.

Sources:

  1. https://github.com/shaunazzopardi/smart-contract-versioning
  2. https://ethereum.stackexchange.com/questions/2404/upgradeable-smart-contracts
  3. https://forum.ethereum.org/discussion/4595/versioning-of-smart-contracts

jaszczw avatar Feb 20 '18 19:02 jaszczw

Versioning best practices https://blog.zeppelin.solutions/proxy-libraries-in-solidity-79fbe4b970fd https://medium.com/rocket-pool/upgradable-solidity-contract-design-54789205276d

michalmikolajczyk avatar Mar 20 '18 18:03 michalmikolajczyk

Consider moving to Zeppelin OS https://docs.zeppelinos.org/docs/start.html

michalmikolajczyk avatar Jun 26 '18 15:06 michalmikolajczyk