-
Notifications
You must be signed in to change notification settings - Fork 0
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
QuarkWalletProxyFactory and test suite #132
Conversation
uint96 nonce = stateManager.nextNonce(factory.walletAddressForSigner(alice)); | ||
QuarkWallet.QuarkOperation memory op = QuarkWallet.QuarkOperation({ | ||
scriptAddress: address(0), | ||
scriptSource: incrementer, | ||
scriptCalldata: abi.encodeWithSignature("incrementCounter(address)", counter), | ||
nonce: nonce, | ||
expiry: block.timestamp + 1000 | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This look like regular operation. I think we should use test/lib/QuarkOperationHelper.sol
as much as possible if we plan on using the helper, unless it's some special operation struct that helper can't create. (don't think having some use helper and some don't scattering across test cases :P )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, also copied. I guess it didn't use the helper. Will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, none of the tests in this suite were ever refactored to use the helper. Will update them now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, these tests cannot use the helper; the helper depends on the wallet already existing, so that it can use wallet.stateManager().nextNonce(address(wallet))
, which it cannot do if the wallet is not yet createAndExecute
d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 👍
It is good to have both versions of the factory in the repo for comparison's sake, but the extra inheritance does make it harder to read the contract. I'm slightly leaning towards removing the non-proxy factory just to make the contracts cleaner; but we can do that after we finish these gas comparisons.
Any way we can compare the execution costs of typical Quark operations? Would be good to quantify the execution overhead before we fully commit to the proxy approach.
function testCreatesCodejar() public { | ||
assertNotEq(address(factoryImplementation.codeJar()), address(0)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be put in the abstract test file right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, AbstractQuarkWalletFactory
does not have a codeJar
member. So not really.
I think having a codeJar
member is an implementation detail. Strictly speaking, the factory does not directly depend upon either of codeJar
or stateManager
. You could image a proxy factory that only takes a walletImplementation
to its constructor, and never references codeJar
or stateManager
at all.
Hmm, there are a couple of ways I think we could go about this. We could try to abstract the I wish it was possible to write a test suite that took its dependencies as arguments. It's annoying that you cannot. |
0cfb926
to
464275b
Compare
This was done in #141 to analyze the gas overhead introduced by the proxy. We will probably not merge this PR, but may wish to clean it up in the future to apply the quark wallet test suite to the proxy. |
closed out by #146 |
here's a summary side-by-side comparison from running
forge test --match-contract Factory
and adding some annotations that show the results of some simple math:Those are the costs per test-case; the traced cost of the actual call to
factory::create(..)
ranges from 88,000 to 100,000 gas depending on optimization settings. 88,000 seems to be the optimal result.This comes out to roughly $9 at an estimated cost-per-gas of 50 gwei with an Eth price of $2,000.
Deploys with salt are ~5-10k gas more expensive, due to added
call
overhead for computing the executor address.The factory test suite is abstracted and implemented for both
QuarkWalletFactory
andQuarkWalletProxyFactory
; if we commit to the proxy approach, we may choose to streamline things and get rid of the abstraction. Similar to how the factory implementations share an abstract base contract, themselves.I'm inclined to keep both approaches, and to keep sharing the test suite, although the indirection is a little unusual. Bike-sheds on how to structure this to make it less confusing or weird are welcome. I'm also open to arguments that we should remove the non-proxy factory code entirely.