Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Code Jar Factory #138

Closed

Conversation

hayesgm
Copy link
Contributor

@hayesgm hayesgm commented Dec 14, 2023

This patch changes CodeJar to be deployed from a factory, which just... deploys it. But it uses CREATE2 such that CodeJar is guaranteed to be the same bytecode if it's the same deployment address. This removes the vast majority of "attack vectors" from depending on CodeJar to be at the same address on all chains.

This patch improves Code Jar to use CodeJarStub, which is a stub that's semi-verifiable on Etherscan for deployments, and significantly reduces the complexity/noise of how CodeJar works. This is also the basis for CodeJar deployments, which will be included in a different branch.
This patch changes CodeJar to be deployed from a factory, which just... deploys it. But it uses `CREATE2` such that CodeJar is _guaranteed_ to be the same bytecode if it's the same deployment address. This removes the vast majority of "attack vectors" from depending on CodeJar to be at the same address on all chains.
Copy link
Collaborator

@fluffywaffles fluffywaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I increasingly feel as though we actually shouldn't be deploying anything from the QuarkWalletFactory... well, except for wallet / proxy instances.

I was tempted in the QuarkWalletProxyFactory to rewrite it with a constructor that takes as an argument walletImplementation, and does not depend on CodeJar or QuarkStateManager at all... 🤔

@fluffywaffles fluffywaffles self-requested a review December 14, 2023 21:25
Copy link
Collaborator

@fluffywaffles fluffywaffles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be a fluke, but gas snapshot run is failing and not producing any diffs.

@hayesgm
Copy link
Contributor Author

hayesgm commented Dec 14, 2023

I increasingly feel as though we actually shouldn't be deploying anything from the QuarkWalletFactory... well, except for wallet / proxy instances.

I was tempted in the QuarkWalletProxyFactory to rewrite it with a constructor that takes as an argument walletImplementation, and does not depend on CodeJar or QuarkStateManager at all... 🤔

If I had may way, there'd be no constructors. Only immutables.

FYI: with this, you can still do initiation. You just need to check for initialization first, so it's not even that bad for cases that realllllly need constructors. The only other thing is msg.sender but I think that's pointless too, since the msg.sender could just pass itself in as a parameter that becomes a const immutable. /rant about how I want to make a new blockchain language

constructor() {
codeJar = new CodeJar();
constructor(CodeJar codeJar_) {
codeJar = codeJar_;
stateManager = new QuarkStateManager();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might as well pass in the stateManager too. Feels weird to pass in one in the constructor and not the other.

console.log("=============================================================");
console.log("Deploying QuarkWalletFactory");

quarkWalletFactory = new QuarkWalletFactory();
quarkWalletFactory = new QuarkWalletFactory(codeJar);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The downside of this approach is we now require the first two txns to be submitted perfectly on each chain instead of just one txn.

Although it's neat that we can prove CodeJar was deployed via a factory using CREATE2, this decision does slightly complicate our deployment process and increase the operational burden.

It almost feels like CodeJar is just its own separate project at this point and should be deployed independently using a separate EOA.

Copy link
Collaborator

@fluffywaffles fluffywaffles Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 🧑‍🍳 would prefer for codejar to be a (sub)project that is deployed independently.

I believe we can accomplish that without separating it out into its own repo, but we can also take the step of doing the necessary surgery to separate it entirely if we want.

I agree it increasingly feels most "correct" to not consider codejar itself a part of quark-core, but a separate project upon which quark-core depends.

@hayesgm hayesgm force-pushed the hayesgm/code-jar-improvements branch 6 times, most recently from 0499de8 to ca843bb Compare December 20, 2023 23:54
@hayesgm hayesgm closed this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants