---
# System prepended metadata

title: 'Open Discussion: Libraries 2.0'

---

# Open Discussion: Libraries 2.0

*These are collaborative notes from the open discussion round about "Libraries 2.0" at the [Solidity Summit 2020](https://solidity-summit.ethereum.org/).*

Slides: https://chriseth.github.io/notes/talks/solidity_summit_2020/libraries_2.0/

Next steps: Let's talk to some groups that had the code size limit prolbem and see what they did and what other solution migth be there.


group funcitons into modules, a contract is a set of modules.
call functions of the same module with functionName()
and of other module using moduleName.functionName() - using delegatecall (all modules can directly access state variables of the contract)
(see below)

Francisco: Better ways of sharing the storage layout with libraries are needed. Currently you have to put the storage variables of your contract into a `struct` to easily pass them into library functions.

Francisco: The tooling around libraries is not up to the task yet.

Nicolas: proposal on the Ethereum Magicians forum (by Vitalik) to make CALL cost proportional to bytecode size: https://ethereum-magicians.org/t/protocol-changes-to-bound-witness-size/3885

Nicholas: Modules need to know each other's addresses and thus they need to be deployed together, which is a problem with the transaction size
Chris: Potential solution: store addresses in storage instead - could also be used for upgrades

Make address deterministic somehow?

Poll: [Marking areas where to split contracts?](https://www.strawpoll.me/19900469)
Poll: [Should we remove the delegatecall aspect of libraries? (without alternative for now)](https://www.strawpoll.me/19900522)

Module example:

```solidity
contract c2 {
    uint x;

    constructor() {
        
    }

    module A {
        function f1()public view returns (uint) { return x; }
        function f2()public view returns (uint) {
            f1(); // uses jump
            g.g2(); // uses delegatecall
        }
        function f3()public view returns (uint) { }
        function f4()public view returns (uint) { }
    }
    module B {
        function g1()public view returns (uint) { return x; }
        function g2()public view returns (uint) { 
            A.f2(); // uses delegatecall
        }
        function g3()public view returns (uint) { }
        function g4()public view returns (uint) { }
        function g5()public view returns (uint) { }
        function g6()public view returns (uint) { }
    }
    module C {
        function f1()public view returns (uint) { }
    }
}
```