1

I'm building upgradeable infrastructure for the project and noticed that creation of proxy using Zeppelin OS always uses the same amount of gas.

How I understand, during the setting implementation to a proxy, it copies all storage of contract with the implementation. Logically, a different amount of gas should be used because of the different size of the data, but it always uses 592.000 of gas

Could anybody explain this?

Thanks!

0

There are several articles explainning how the contracts work.

The idea is you have a smart contract A used for storage, and a second contract B used for code.

Contract A contains a reference to contract B, and when someone invokes contract A it will make a delegatecall to contract B preserving the sender but storage modifications will be make to contract A storage.

To upgrade you deploy a new contract C, and updates the reference in contract A to point to the new contract. No migrations of data is necessary.

For all of this to work both contract B and C have to have a compatible data storage layout, ie the same storage variables and have to be defined in the same order.

I encourage you to read those articles for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.