Upgradable library.. supported?

Hi guys

I am just writing to see if Zeppelin had discontinued support for upgradable Libraries in Solidity or if not, whether they would even solve my use case :smile:

Right now, we would just love a sub-set of our contracts functionality to be isolated.

The functionality will ideally accept a storage struct as an arg so we can access an internal mapping. A library seems like a perfect use case for this - however we would love for it to be upgradable. Past the blog post (https://medium.com/zeppelin-blog/proxy-libraries-in-solidity-79fbe4b970fd) in 2017.. I can't see anything from Zeppelin on this. Is it possible? Does it function just the same as a regular solidity lib? Would some special delegateCall needed on the sending side to access storage, or is it even possible through a proxy contract?

Thanks!
Alex

1 Like

Hi @alsco77 welcome to the community forum :wave: I hope all is well settling in to Berlin life.

Could you isolate the functionality into a contract that can be upgradeable using OpenZeppelin SDK (ā€œunstructured storageā€ proxy pattern)?

As for using a library, hopefully someone in the community can give some input on making this upgradeable.

Thanks

Definitely could, but was hoping to be able to utilise the native functionality provided by libraries (passing storage args, cheaper gas costs), although I understand that it may not be possible due to how libraries actually workā€¦ and the best solution as you say may be to create a standard upgradable proxy.

It may be more efficient for us (in gas terms) to manage the version of the library that we are hoping to reference from within the contract (as we have system governors), rather than having some static proxy that requires an extra 1000 gas to pass through

1 Like

Hey there @alsco77! Welcome!

After that 2017 post by @maraoz we didnā€™t develop the idea any further, so we donā€™t have an offering that you would be able to use out of the box.

Note that any implementation of an upgradeable library requires a CALL operation in order to find out which is the current library address, because of the way storage and DELEGATECALL interact. This implies that there will be a base cost of 700 (the cost of a CALL) in any such implementation, which makes the gas overhead comparable to a normal proxy contract.

I agree though that the gas savings of passing storage args might be greater.

1 Like

Thanks for the info @frangio. This might be a stupid question, but do you know if it is possible to call a library at a specific address, rather than that which is compiled into the contract bytecode? Just wondering if itā€™s possible to upgrade that way

1 Like

I donā€™t believe itā€™s possible. :worried:

1 Like

I was looking for this too. Closest I came across was this article and this example

1 Like