Full Smart Contract Upgradeability Discussion

That is correct indeed.

1 Like

Cannot truffle compile keep getting
Compiling your contractsā€¦

Error: Could not find Compiling your contractsā€¦

Error: Could not find /Users/josephrogers/Documents/github/proxyContract/contracts/Storage.sol from any sources
at Resolver. (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:62:1)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:5:42)
Truffle v5.1.59 (core: 5.1.59)
Node v15.5.0
josephrogers@Josephs-MacBook-Pro contracts %
at Resolver. (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:62:1)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:5:42)
Truffle v5.1.59 (core: 5.1.59)
Node v15.5.0
Verified that Compiling your contractsā€¦

Error: Could not find /Users/josephrogers/Documents/github/proxyContract/contracts/Storage.sol from any sources
at Resolver. (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:62:1)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/resolver/dist/lib/resolver.js:5:42)
Truffle v5.1.59 (core: 5.1.59)
Node v15.5.0
Verified that the file exists
pragma solidity 0.5.1;
contract Storage {
mapping (string => uint256) _uintStorage;
mapping (string => address) _addressStorage;
mapping (string => bool) _boolStorage;
mapping (string => string) _stringStorage;
mapping (string => bytes4) _bytesStorage;
address public owner;
bool public _initialized;
}

I am using the following versions

Truffle v5.0.42 (core: 5.0.42)
Solidity v0.5.8 (solc-js)
Node v10.21.0
Web3.js v1.2.1

Do I need to install [email protected]?

Hey @Joe1

This looks like an error in the import statements of your contracts.
Double check that the path you specified for Storage.sol is correct.
If you are sure is right, push your project to github and send me the link to your repo.

Happy learning,
Dani

Hi @oneworldcoder

Do I need to install [email protected] ?

Are you facing issues with your current version?

I will try with the current version.

Iā€™ve been using 0.6.0 for a while now, not quite 7 yet. But it seems like the assembly function delegatecall() signature has been updated, or the function deprecated or somesuch. But Iā€™ve yet to track down a reference that saysā€¦to what, exactly. Can anyone point me to the right direction? The function doesnā€™t have a seperate entry in the Solidity docs by version site. Probably because itā€™s assembly.

1 Like

Hello @marsrvr Iā€™m having exactly the same problem when trying solc ^0.7.5 version.
This is what i found so far:
https://forum.openzeppelin.com/t/which-version-of-openzeppelin-is-stable-to-create-a-new-currency/4040
Iā€™m now working on implementing, let me know if you have any luck.
edit: This is working for me

  fallback () external payable {
    address implementation = currentAddress;
    require(currentAddress != address(0));
    bytes memory data = msg.data;

    assembly {
      let result := delegatecall(gas(), implementation, add(data, 0x20), mload(data), 0, 0)
      let size := returndatasize()
      let ptr := mload(0x40)
      returndatacopy(ptr, 0, size)
      switch result
      case 0 {revert(ptr, size)}
      default {return(ptr, size)}
    }
  }
    receive() external payable {
  }
2 Likes

Yup! That did it! It was that simple. Iā€™ve the whole ā€œAcademy stackā€ working in Scaffold-ETH, compiling in Solidity 0.8.0 now. Many thanks for the pointers nā€™ tips!

1 Like

Hi all, I love this course but I think I downloaded the wrong truffle version. The Truffle version Iā€™m working with is v5.2.2 and the Soldity version is v0.5.16.
When I wanted to compile my contract it said this

Compiling your contracts...
===========================
> Compiling ./contracts/Functional.sol
> Compiling ./contracts/Storage.sol
> Compilation warnings encountered:

    /Users/sk/proxyContract/contracts/Functional.sol:1:1: Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.5.16;"

^
,/Users/sk/proxyContract/contracts/Storage.sol:1:1: Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.5.16;"

^

> Everything is up to date, there is nothing to compile.

I donā€™t know what Iā€™ve to do to fix this, or is it good?
Tried to change the pragma solidity to

pragma solidity ^0.5.16;

but still the same error. Does anyone know what Iā€™ve to do?

I thought I fixed it by updating Truffle, but after that was done both the Storage.sol and Function.sol was gone. Had to make the contracts again, but it still gives me the same error.
I tried searching the web for the answer, but didnā€™t find anything that can help meā€¦

Hi @Sil

Please avoid to post the same question in two different threads, I look at all topics so you will always receive your answer no worries.

Thanks,
Dani

Sorry for that!

Just want to start as soon as possible again haha

@dan-i @filip thanks for the clarification of my previous question, one more question I have is in bonus section, we have inherited form the old functional contract and added initialize functionality. However we also wanted to upgrade the setNumberOfDogs() function with onlyModifier, so should we rewrite the setNumberOfDogs() in updated contract?

Hi there, i just wanted to know whether i should dive deep into Yul so as to be a serious developer or it is not that essential ? Meaning whenever we may need some Yul object, it will be easy to find a snippet ??

And a little contribution that could save some time for other students, since i am using solidity 0.8.1 the assembly code needs a few added details:

assembly {
       let result := delegatecall(gas(),implementation, add(data, 0x200),mload(data),0,0)
       let size := returndatasize()
       let ptr := mload(0x40) 
       returndatacopy(ptr, 0, size)
       switch result
       case 0 {revert(ptr,size)} 
       default {return(ptr,size)} 
    }

Any idea what is going on here ? Maybe im a bit burned by now, but if anyone notices anything please let me know!

1 Like

It is as if i couldnt fool truffle by indicating dogs.address, i am digging into this but there isnt much about proxyā€™s migration and the AT function

1 Like

Hey @ArgenFrank, hope you are ok.

Could you please share your code? I would like to replicate the issue by deploying the same contract and migrations files that you have :face_with_monocle:

You can use the ā€œPreformatted Textā€ Button to encapsulate any kind of code you want to show.


function formatText(){

let words = ā€œIā€™m a preformatted Text box, Please use me wisely!ā€

}

prefromatted_text-animated

preformatted text

Carlos Z.

Hi Carlos, thanks for answering! Here i posted it in stackoverflow a few days ago, full code is here !

https://stackoverflow.com/questions/66619894/revert-error-when-migrating-proxy-configuration-in-solidity

If you prefer i can copy the code here too, let me know :wink:

Hi @ArgenFrank

The issue is in your assembly code. The course was done with solidity 0.5 but you are using 0.8 therefore probably some things have changed.

Try this one

  fallback () payable external {
    address implementation = currentAddress;
    require(currentAddress != address(0));
    bytes memory data = msg.data;
    assembly {
        calldatacopy(0, 0, calldatasize())
        let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
        returndatacopy(0, 0, returndatasize())
        switch result
        case 0 { revert(0, returndatasize()) }
        default { return(0, returndatasize()) }
    }
  }

Screenshot 2021-03-17 at 22.08.15

I do not want to take any credit for the assembly code which is I language I am not familiar with, but in this case just let the other devs guide you.
Openzeppelin is the way: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Proxy.sol

3 Likes