Replies: 15 comments 8 replies
-
|
Diamond generator to look at: https://github.com/JoshdfG/Foundry-Factory-Diamond-Template |
Beta Was this translation helpful? Give feedback.
-
|
How far would you want to take this factory process? I made a Diamond factory with hooks for using packages. https://github.com/cyotee/crane/blob/main/contracts/interfaces/IDiamondFactoryPackage.sol To summarize, the interface is for contracts to act as packges for use with factory. The factory defines a lifecycle that makes calls to a package to calculate a salt, process user arguments, initialize a new Diamond proxy, and process any post-deploy actions. It also inserts Diamond Loupe and ERC165 facets by default. Diamond Cut inclusion is handled by this package, Where it allows for providing the encoded call for the initialization code. My goal was to support all conceivable deployment scenarios, and standardize a lot of boilerplate logic. Trying to make it easy to deploy a Diamond by letting developers only worry about declaring their specific configuration. I also included CREATE2 metadata exposure. That allows the factory to be idempotent by checking and confirming if an instance was already deployed, and then just return that address. But it is likely a bit more opinionated them you might want. If something similar is desirable to you, I could make a more streamlined and less opinionated version that conforms with your project directives. |
Beta Was this translation helpful? Give feedback.
-
|
I did something basic as a factory for my project a couple of years ago Would be nice having a registry of facets per deployed chain. |
Beta Was this translation helpful? Give feedback.
-
|
This factory should probably have an opinion about initialization best practice. And since the project wants to promote reuse of on-chain code, it should probably group Diamond Cuts by facets and the initialization call relevant to those facets; emitting several DiamondCut events to record the several initialization calls. Something like struct DiamondCut { struct DiamondDeploymentArgs { function deployDiamond( Then execute this pseudocode for each DiamondCut process FacetCut[]; The Diamond proxy would be deployed with CREATE2/3 using a hash of the DiamondDeploymentArgs as the salt. That way the optionalSat can be defined to allow for deployments of duplicate proxies. |
Beta Was this translation helpful? Give feedback.
-
|
Facet Registry could expose sets of facets, grouped by exposed ERC165 interface ID/s, and storage namespaces. If a facet exposes a subset of a ERC's functions, then it just uses the ERC165 interface ID produced from those functions. Might need to also declare the interface ID the subset is from, but distinct from the fully implemented IDs so there's no confusion. |
Beta Was this translation helpful? Give feedback.
-
|
I stumbled upon this project by chance and am ready to fully participate because we're solving the same problem, except you're creating ready-made packages for my tool - https://github.com/EMVPack/core I think I've already started solving this problem without knowing about your project. Only more comprehensively. I'm annoyed that our implementation updates are chaotic, and we're not taking advantage of reusing ready-made implementations. I haven't gotten around to the diamond factory yet, but I created TransparentProxy because I already had a lot of experience with it, but I didn't have any experience with diamonds. But as I see it now, each diamond is a separate package with a package type of implementation and a proxy type of diamond. Diamonds have dependencies on faces, and each face is also a separate package and is effectively used only by diamonds. What this provides:
My goal: |
Beta Was this translation helpful? Give feedback.
-
That is correct!
Wonderful! Let's work together and make this happen. I would be happy for our facets/diamonds/packages to integrate and work with your tooling or however we can best work together. Together we can do more. |
Beta Was this translation helpful? Give feedback.
-
Okay, I'm ready to take on this task, implement the factory in my tool, create packages from all of ready facets (ERC173, ERC721, ERC20), and demonstrate how it works. What's the deadline for this task? I'm currently preparing for the release and will be working on other tasks for another 2-3 days. |
Beta Was this translation helpful? Give feedback.
-
|
Sounds great. Deadline is as soon as you can. Keep in mind that the contracts in Compose are not production ready yet but can be used for development, proof of concept and testing etc. |
Beta Was this translation helpful? Give feedback.
-
Yes, i understand, my tool in same stage. |
Beta Was this translation helpful? Give feedback.
-
|
I am converting this issue into a discussion. So let's use Github discussion functionality, to discuss! |
Beta Was this translation helpful? Give feedback.
-
|
Copying Discord messages here. not_cyotee — Yesterday at 19:31 I made a version of a Facet Registry. And considered there was no good solution to allowing public registration. If you let anyone register a Facet, then ethere's no way to know which are safe without an additional tagging process. But if you make a package for the Registry, then you can simply allow other devs to deploy their own Registry to declare their own Facets. And those Facets can alweays be promoted into other Registries if desired. Mikhail Ivantsov — Yesterday at 23:14 The package will be able to extend EVMPack's CLI. The audit functionality will also be wrapped in a separate package So, if i correct understand your case.
look at this architect like a linux, linux have paradigm one task=one program. In EVMPack i try to follow are same paradigm. not_cyotee — 08:43 And whom decides which is the current version? I think your Linux analogy breaks down. First, I run the kernal on my machine, so I control which kernal is available. And when I pick a distro, there's a specific, managed repo for that code. The repo inherits the level of trust I am willing to extend to the maintainer. Not just anyone can come along and upload kernal changes to the Ubuntu repo. — 08:52 — 08:56 not_cyotee — 09:12 Here is my factory. I removed my previous work on a Registry pending a reimplementation. My goal was to minimize the bytecode size being deployed and minimize duplication. The Factory itself defines a lifecycle based on frameworks like Spring and Hibernate. It also acts as a Facet for Diamond Lupe and ERC1655. Packages declare their configuration, that way the Diamond initialization logic remains consistent. Then the Package only has to worry about it's specific business logic initialization. Facet may optionally declare their interfaces and functions so Packages can reuse them. Otherwise, only the Package must make those declarations. I also followed the One Package = One Proxy model. https://github.com/cyotee/crane/blob/main/contracts/interfaces/IDiamondFactoryPackage.sol https://github.com/cyotee/crane/blob/main/contracts/interfaces/IFacet.sol And, so it doesn't get lost in the shuffle, my previous responses and reasons for eexpecting developers to deploy their own Registries. compose More then open to discussing the Registry point. But I will die on this hill after having spent a couple years mulling over this point. |
Beta Was this translation helpful? Give feedback.
-
|
I think 3 of them are valid use cases:
Whereas I think Compose can help a lot developers/users in terms of dev+CI/CD, I do think is the main target of the project because there is probably also a gas penalty that many dev teams would not want to pay. And focusing in this target could be the wrong goal. I think the main benefit of Compose (or a Compose spinoff, is fine) is creating a point of trust for retail investors in terms of security and transparency, regarding all the contract lifecycle (deployment, execution, upgrades..). This is what is failing today in crypto IMHO and retail investors have mostly run away. I see Compose as the oppportunity to bring them back. I also think, that several versions of every facet should coexist in the chain to allow adopters upgrade or not. In my understanding adopters should be able to involve investors somehow in the upgrade workflow (some kind of governance) and this is IMHO a feature to (be discussed and) include in Compose. |
Beta Was this translation helpful? Give feedback.
-
|
@pellyadolfo Why not split the difference? Have a Compose canonical Registry of Facets, as I concur with your point about presenting a reliable source for quality code. But make sure the Factory process can handle using other Registries. That allows for anyone to publish compatible code. And allows for other organizations to take on the burden of validating code. For example, promote Auditors to maintain their own Registries of Facet code they've audited as safe. Basically, anyone could be a publisher and cross-promote by deploying their own Registry. Just make sure a Registry can add any Facet the maintainer wishes. That also avoids Compose having to shift from primarily development to reviewing code if contributions grow. |
Beta Was this translation helpful? Give feedback.
-
|
I've been using a modified version of https://github.com/forgenie/diamond-foundry and it's worked well. I modified the diamond factory to use EIP-7955 for deterministic addresses on all EVM networks. The generic diamond factory simply emits
Since it's from a factory contract, correct? I create purpose-built factories that emit events (like I also use a Facet Registry, as supported by the forgenie diamond foundry project. I've found it useful to be able to give human-readable names to facets registered in the Facet Registry, as well as semantic versioning. Assuming a registry is even desirable, since the facet addresses are unique based on bytecode, salt (which should be the human-readable name in SNAKE_CASE) and version number, we can have a global facet registry. I wouldn't overcomplicate things, keeping it global makes it easier for developers to adopt, but I do see potential in unique registries etc., I just haven't thought it all the way through. Re: safety of registered facets, the registry could show who registered the facet (address) and rely on external identifiers like *.eth domain names or EAS attestations IMO. This way we can also filter registered facets by registrants for curation. Facet registry should be deployed using the EIP-7955 method so it has the same address across networks. Off-topic but kind of related: one of the biggest pain points for constructing diamonds via the factory is ensuring function selectors are all correct. Using AI-powered workflows like Cursor are super prone to hallucinating selectors, so having tools to ensure generation of selectors from contracts/artifacts is super helpful to have. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Need design ideas and proposals for implementing a diamond factory/generator for this library, that can be used by people to generate diamonds that reuse the onchain facets of this library. All kinds of aspects need to be designed and discussed and planned, including security and safety mechanisms and command line tools and user interfaces.
For now please submit ideas and suggestions and proposals and plans and concerns, and any thing as comments to this issue.
Beta Was this translation helpful? Give feedback.
All reactions