Basic Smart Contract Upgradeability Discussion

Hi @filip, @gabba,
I have few questions:

(I edited and deleted some questions regarding owner issue - find out my mistake :slight_smile:

Not yet mention about the upgradability, I understand that this is also a solution to go around the 24K limit issue, right? Can we make unlimited function contracts that controled from one proxy contract?
2. Can we make the storage some how to use more compicated data structures as STRUCT ?

  1. Yes the proxy can help you to save space in you main contract. You can also use a library and just call an other contract if some function are not directly related to your main contract.

You will not be able to make an unlimited amount of function in one contract even if you are using a proxy. But you can think about implementing a Diamond storage contract.
When the maximum size of 24K will be reach you will use an other storage.

  1. You can use a Struct in your storage, the pattern showed in this video is used as a generic mapping
    https://academy.ivanontech.com/products/ethereum-smart-contract-security/categories/1692009/posts/5681281

The problem with struct is they will have a different size regarding how many variable they are hosting.
You can use a generic struct with an int a bool and a mapping and use this STRUCT in a mapping.
But you will loose space in some case (for example when you don’t need one of the struct element)

5 Likes

@filip here is a basic question for you and it has been irritating :tired_face: me for a while now. How does one acheive the same ide layout in remix as you have in the remix ide workspace? Please advise. It would make life easier, if the layout was the same in my opinion.

Thanks

Hello @NLUGNER, hope you are ok.

I do not understand quite well the question, what do you mean to achieve the same layout than remix? like creating your own? or using other IDE to code?

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

@thecil, @filip

Hi Carlos, Thx for the reply. What I meant was how do you setup the same IDE gui AS FILIP ANDIVAN USE IN THEVIDEOS USING REMIX.

BR,
NILS

Hey @NLUGNER

Is that the GUI you are talking about?

If yes this is not remix but Atom, and he migrates the project using Truffle.

Cheers,
Dani

1 Like

@dan-i

Hi, Dani,

Thx for the reply but nope. Its the one with the light background that they use with the whiteboard in the centre with the lessons and the remix properties on the right.

Thank you,

NILS

I think you are referring to the Remix toolbar, it was on the right when the videos were created, now it has been moved to the left side. The tabs available however are exactly the same so you should be able to replicate what Filip does in the videos without problems :slight_smile:

Happy learning,
Dani

1 Like

Ok, understood.
Thx,

Nils

Hi Dan-i
Maybe because the Storage contract is meant to be like a Library.
So you use his functions too.
Just guessing…

You don’t need to deploy the Storage contract.
The data are being saved in the Proxy contract

@filip In Quiz the question number 3 How can the variable data remain even after we replace the functional contract? the correct answer I saw was “Because the variables are stored in the Proxy Contract”

The question I have is, we are actually setting the variable number in Storage contract by setNumber() function and in proxy contract even if we are delegating call to functional contract, the functional contract is actually calling the setNumber function from Storage contract which is basically setting the number variable in Storage contract. So just wonder how come the correct answer is “the variables are stored in the Proxy Contract”?

1 Like

Hi @kHarsh

That’s the magic of delegatecall() :slight_smile:
Highly suggest you to watch this video once again: https://academy.ivanontech.com/products/ethereum-smart-contract-security/categories/1691829/posts/5680740
And also to start practicing with the type of calls, the more you will use them the clearer they will be.

This is not an easy concept to grasp until you put your hands in it and you start play.

Happy learning,
Dani

@filip correct me pls but in your example of the dog and storage I see that you inherit from storage all functions and member variables. I used to work with Java in the dark old OOP days :smile: and as far I remember you never inherit the state of a class only the definition (unless using keyword static). Is here in solidity different?

1 Like

This made it clear why the data is stored in the proxy instead of the storage. Storage acts as an imported library only. Thanks a lot.

@filip assuming i want to pass and get more than one variable to the function how will i do that

Hi @chim4us

Can you elaborate your question?

Hey @dan-i from the lesson fillip was passing only one variable which is numofdogs. My question is now assuming i want to pass numofdogs and nameofdogs how will i go about it.

In a live mainnet project with upgradeable contract functionality,
where do we set the information of the token?

i.e. in a constructor for name, symbol, decimals, and totalSupply etc.

Do we do this in the constructor of the Storage contract or the Proxy contract?
Thanks guys!

1 Like

Hi @dan-i @filip the problem come when we write new version contract but must follow the interface of contract ( because proxy contract need contract interface to call function). Is there any ideas?

1 Like