Closed mudgen closed 1 year ago
Hello, Nick. I am very happy to know we're using the Diamond pattern correctly in the Rollups project! Having said that, I agree that linking to libraries that contain only internal functions is not necessary, and so we hope to address this issue shortly. Thank you for the valuable input!
This issue has been addressed in release 0.6.0 and as a result, gas costs for some function calls have been reduced as some costly DELEGATECALL
opcodes are now simple JUMP
opcodes.
Thanks again, Nick! :-)
Great!
I briefly looked at the general implementation using EIP2535 Diamonds and it looks good. It is a good example of using Diamond Storage and Solidity libraries correctly in the code, in the implementation. Well done.
I noticed in the deployment that some Solidity libraries are being deployed and there is attempt to link them to some facets. For example this deployment file deploys the "LibClaimsMask" library and attempts to link it to several facets: https://github.com/cartesi/rollups/blob/main/onchain/rollups/deploy/03_facets.ts
However Solidity libraries that contain only internal functions do not need to be deployed and linked to contracts. Because internal functions of Solidity libraries are automatically added directly to the bytecode of contracts/facets that use them. Only Solidity libraries that contain external functions need to be deployed independently and linked. Attempting to deploy and link Solidity libraries with only internal functions is probably not doing anything. Some more information about this is here: https://eip2535diamonds.substack.com/p/how-to-share-functions-between-facets