diff --git a/.gas-snapshot b/.gas-snapshot index 9f5f63d8..fa4c4f10 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,19 +1,19 @@ -ApproveAndSwapTest:testSwap() (gas: 286224) -ApproveAndSwapTest:testSwapFailsIfWeExpectedTooMuch() (gas: 365531) -ApproveAndSwapTest:testSwapFailsWithNoApproval() (gas: 123096) -BatchExecutorTest:testBatchExecuteWithPartialFailures() (gas: 129654) -BatchExecutorTest:testBatchExecuteWithPartialFailuresDoesNotRevertIfAnyCallsRevert() (gas: 123218) -BatchExecutorTest:testBatchExecuteWithoutPartialFailures() (gas: 129918) -BatchExecutorTest:testBatchExecuteWithoutPartialFailuresRevertsIfAnyCallsRevert() (gas: 120539) -CallbacksTest:testAllowNestedCallbacks() (gas: 157613) -CallbacksTest:testCallbackFromCounter() (gas: 100713) -CallbacksTest:testCallcodeReentrancyExploitWithProtectedScript() (gas: 104576) -CallbacksTest:testCallcodeReentrancyExploitWithUnprotectedScript() (gas: 110480) -CallbacksTest:testCallcodeReentrancyProtectionWithProtectedScript() (gas: 198360) -CallbacksTest:testClearCallback() (gas: 141448) -CallbacksTest:testNestedCallWithNoCallbackSucceeds() (gas: 124401) -CallbacksTest:testPayableCallback() (gas: 108345) -CallbacksTest:testRevertsOnCallbackWhenNoActiveCallback() (gas: 98323) +ApproveAndSwapTest:testSwap() (gas: 286242) +ApproveAndSwapTest:testSwapFailsIfWeExpectedTooMuch() (gas: 365553) +ApproveAndSwapTest:testSwapFailsWithNoApproval() (gas: 123118) +BatchExecutorTest:testBatchExecuteWithPartialFailures() (gas: 129689) +BatchExecutorTest:testBatchExecuteWithPartialFailuresDoesNotRevertIfAnyCallsRevert() (gas: 123262) +BatchExecutorTest:testBatchExecuteWithoutPartialFailures() (gas: 129953) +BatchExecutorTest:testBatchExecuteWithoutPartialFailuresRevertsIfAnyCallsRevert() (gas: 120583) +CallbacksTest:testAllowNestedCallbacks() (gas: 157701) +CallbacksTest:testCallbackFromCounter() (gas: 100757) +CallbacksTest:testCallcodeReentrancyExploitWithProtectedScript() (gas: 104642) +CallbacksTest:testCallcodeReentrancyExploitWithUnprotectedScript() (gas: 110546) +CallbacksTest:testCallcodeReentrancyProtectionWithProtectedScript() (gas: 198448) +CallbacksTest:testClearCallback() (gas: 141519) +CallbacksTest:testNestedCallWithNoCallbackSucceeds() (gas: 124467) +CallbacksTest:testPayableCallback() (gas: 108389) +CallbacksTest:testRevertsOnCallbackWhenNoActiveCallback() (gas: 98345) CodeJarTest:testCodeJarCanBeWacky() (gas: 139555) CodeJarTest:testCodeJarCanDeployCodeThatHadEthSent() (gas: 4945665) CodeJarTest:testCodeJarCounter() (gas: 358702) @@ -30,169 +30,171 @@ CodeJarTest:testCodeJarStoresSelfReference() (gas: 107362) CodeJarTest:testCodeJarTickCounter() (gas: 176903) CodeJarTest:testRevertsOnConstructorRevert() (gas: 85881) CodeJarTest:testRevertsOnSelfDestructingConstructor() (gas: 54396) -CometClaimRewardsTest:testClaimComp() (gas: 132165) -CometRepayAndWithdrawMultipleAssetsTest:testInvalidInput() (gas: 68834) -CometRepayAndWithdrawMultipleAssetsTest:testRepayAndWithdrawMultipleAssets() (gas: 154630) -CometSupplyMultipleAssetsAndBorrowTest:testInvalidInput() (gas: 68785) -CometSupplyMultipleAssetsAndBorrowTest:testSupplyMultipleAssetsAndBorrow() (gas: 296264) -ConditionalMulticallTest:testConditionalRunEmptyInputIsValid() (gas: 52008) -ConditionalMulticallTest:testConditionalRunInvalidInput() (gas: 69646) -ConditionalMulticallTest:testConditionalRunMulticallError() (gas: 317465) -ConditionalMulticallTest:testConditionalRunOnPeriodicRepay() (gas: 344340) -ConditionalMulticallTest:testConditionalRunPassed() (gas: 285848) -ConditionalMulticallTest:testConditionalRunUnmet() (gas: 104592) -EIP1271Test:testReturnsMagicValueForValidSignature() (gas: 74942) +CometClaimRewardsTest:testClaimComp() (gas: 132187) +CometRepayAndWithdrawMultipleAssetsTest:testInvalidInput() (gas: 68856) +CometRepayAndWithdrawMultipleAssetsTest:testRepayAndWithdrawMultipleAssets() (gas: 154648) +CometSupplyMultipleAssetsAndBorrowTest:testInvalidInput() (gas: 68807) +CometSupplyMultipleAssetsAndBorrowTest:testSupplyMultipleAssetsAndBorrow() (gas: 296281) +ConditionalMulticallTest:testConditionalRunEmptyInputIsValid() (gas: 52025) +ConditionalMulticallTest:testConditionalRunInvalidInput() (gas: 69668) +ConditionalMulticallTest:testConditionalRunMulticallError() (gas: 317487) +ConditionalMulticallTest:testConditionalRunOnPeriodicRepay() (gas: 344428) +ConditionalMulticallTest:testConditionalRunPassed() (gas: 285870) +ConditionalMulticallTest:testConditionalRunUnmet() (gas: 104614) +EIP1271Test:testReturnsMagicValueForValidSignature() (gas: 74964) EIP1271Test:testRevertsIfSignerContractDoesNotReturnMagic() (gas: 18700) -EIP712Test:testExecuteQuarkOperation() (gas: 74353) -EIP712Test:testNonceIsNotSetForReplayableOperation() (gas: 143868) -EIP712Test:testRequirements() (gas: 175317) +EIP712Test:testExecuteQuarkOperation() (gas: 74375) +EIP712Test:testNonceIsNotSetForReplayableOperation() (gas: 143904) +EIP712Test:testRequirements() (gas: 175383) EIP712Test:testRevertBadRequirements() (gas: 27347) EIP712Test:testRevertsForBadCalldata() (gas: 21387) EIP712Test:testRevertsForBadCode() (gas: 23453) EIP712Test:testRevertsForBadExpiry() (gas: 21940) EIP712Test:testRevertsForExpiredSignature() (gas: 14842) EIP712Test:testRevertsInvalidS() (gas: 18518) -EIP712Test:testRevertsOnReusedNonce() (gas: 92910) +EIP712Test:testRevertsOnReusedNonce() (gas: 92932) EIP712Test:testStructHash() (gas: 9223372036854754743) -EthcallTest:testEthcallCallReraiseError() (gas: 77110) -EthcallTest:testEthcallCounter() (gas: 70478) -EthcallTest:testEthcallShouldReturnCallResult() (gas: 53239) -EthcallTest:testEthcallSupplyUSDCToComet() (gas: 173364) -EthcallTest:testEthcallWithdrawUSDCFromComet() (gas: 298157) -ExecutorTest:testExecutorCanDirectCall() (gas: 131488) -ExecutorTest:testExecutorCanDirectCallBySig() (gas: 118285) -GetDripTest:testDrip() (gas: 121425) -MulticallTest:testCallcodeToMulticallSucceedsWhenUninitialized() (gas: 84237) -MulticallTest:testCreateSubWalletAndExecute() (gas: 602104) -MulticallTest:testEmptyInputIsValid() (gas: 51524) -MulticallTest:testExecutorCanMulticallAcrossSubwallets() (gas: 304280) -MulticallTest:testInvalidInput() (gas: 69134) -MulticallTest:testInvokeCounterTwice() (gas: 84391) -MulticallTest:testMulticallError() (gas: 310674) -MulticallTest:testMulticallShouldReturnCallResults() (gas: 87537) +EthcallTest:testEthcallCallReraiseError() (gas: 77132) +EthcallTest:testEthcallCounter() (gas: 70500) +EthcallTest:testEthcallShouldReturnCallResult() (gas: 53256) +EthcallTest:testEthcallSupplyUSDCToComet() (gas: 173400) +EthcallTest:testEthcallWithdrawUSDCFromComet() (gas: 298210) +ExecutorTest:testExecutorCanDirectCall() (gas: 132195) +ExecutorTest:testExecutorCanDirectCallBySig() (gas: 118698) +GetDripTest:testDrip() (gas: 121447) +MulticallTest:testCallcodeToMulticallSucceedsWhenUninitialized() (gas: 84259) +MulticallTest:testCreateSubWalletAndExecute() (gas: 602979) +MulticallTest:testEmptyInputIsValid() (gas: 51541) +MulticallTest:testExecutorCanMulticallAcrossSubwallets() (gas: 305285) +MulticallTest:testInvalidInput() (gas: 69156) +MulticallTest:testInvokeCounterTwice() (gas: 84413) +MulticallTest:testMulticallError() (gas: 310696) +MulticallTest:testMulticallShouldReturnCallResults() (gas: 87559) MulticallTest:testRevertsForInvalidCallContext() (gas: 11778) -MulticallTest:testSupplyWETHWithdrawUSDCOnComet() (gas: 260780) +MulticallTest:testSupplyWETHWithdrawUSDCOnComet() (gas: 260802) NonceTest:testIsSet() (gas: 30425) NonceTest:testNextUnusedNonce() (gas: 40315) NonceTest:testNonLinearNonce() (gas: 30757) PaycallTest:testInitializeProperlyFromConstructor() (gas: 6581) -PaycallTest:testPaycallForPayWithUSDT() (gas: 122072) -PaycallTest:testPaycallForPayWithWBTC() (gas: 116552) -PaycallTest:testReturnCallResult() (gas: 90855) -PaycallTest:testRevertsForInvalidCallContext() (gas: 16800) -PaycallTest:testSimpleCounterAndPayWithUSDC() (gas: 144951) -PaycallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 140495) -PaycallTest:testSupplyWETHWithdrawUSDCOnCometAndPayWithUSDC() (gas: 301251) -QuarkFactoryTest:testInvariantAddressesBetweenNonces() (gas: 3309560) -QuarkFactoryTest:testQuarkFactoryDeployToDeterministicAddresses() (gas: 3309293) -QuarkFactoryTest:testQuarkFactoryDeployTwice() (gas: 3401228) -QuarkMinimalProxyTest:testSignerExecutor() (gas: 75496) -QuarkStateManagerTest:testNonceZeroIsValid() (gas: 91471) -QuarkStateManagerTest:testReadStorageForWallet() (gas: 148688) +PaycallTest:testPaycallForPayWithUSDT() (gas: 122194) +PaycallTest:testPaycallForPayWithWBTC() (gas: 116673) +PaycallTest:testReturnCallResult() (gas: 91007) +PaycallTest:testRevertsForInvalidCallContext() (gas: 16770) +PaycallTest:testRevertsWhenCostIsMoreThanMaxPaymentCost() (gas: 120332) +PaycallTest:testSimpleCounterAndPayWithUSDC() (gas: 145103) +PaycallTest:testSimpleTransferTokenAndPayWithUSDC() (gas: 140647) +PaycallTest:testSupplyWETHWithdrawUSDCOnCometAndPayWithUSDC() (gas: 301424) +QuarkFactoryTest:testInvariantAddressesBetweenNonces() (gas: 3359064) +QuarkFactoryTest:testQuarkFactoryDeployToDeterministicAddresses() (gas: 3358797) +QuarkFactoryTest:testQuarkFactoryDeployTwice() (gas: 3452021) +QuarkMinimalProxyTest:testSignerExecutor() (gas: 75518) +QuarkStateManagerTest:testNonceZeroIsValid() (gas: 91493) +QuarkStateManagerTest:testReadStorageForWallet() (gas: 148724) QuarkStateManagerTest:testRevertsForNoActiveNonce() (gas: 22564) -QuarkStateManagerTest:testRevertsIfScriptAddressIsEOA() (gas: 61786) -QuarkStateManagerTest:testRevertsIfScriptAddressIsNull() (gas: 42213) +QuarkStateManagerTest:testRevertsIfScriptAddressIsEOA() (gas: 61808) +QuarkStateManagerTest:testRevertsIfScriptAddressIsNull() (gas: 42235) QuarkStateManagerTest:testSetActiveNonceAndCallbackNotImplemented() (gas: 92067) QuarkStateManagerTest:testSetsAndGetsNextNonces() (gas: 810598) QuarkWalletProxyFactoryTest:testCreateAdditionalWalletWithSalt() (gas: 212726) -QuarkWalletProxyFactoryTest:testCreateAndExecuteCreatesWallet() (gas: 411984) -QuarkWalletProxyFactoryTest:testCreateAndExecuteMultiCreatesWallet() (gas: 446469) -QuarkWalletProxyFactoryTest:testCreateAndExecuteMultiWithSalt() (gas: 450642) -QuarkWalletProxyFactoryTest:testCreateAndExecuteSetsMsgSender() (gas: 223945) -QuarkWalletProxyFactoryTest:testCreateAndExecuteWithSalt() (gas: 416559) -QuarkWalletProxyFactoryTest:testCreateAndExecuteWithSaltSetsMsgSender() (gas: 396152) +QuarkWalletProxyFactoryTest:testCreateAndExecuteCreatesWallet() (gas: 412006) +QuarkWalletProxyFactoryTest:testCreateAndExecuteMultiCreatesWallet() (gas: 446513) +QuarkWalletProxyFactoryTest:testCreateAndExecuteMultiWithSalt() (gas: 450686) +QuarkWalletProxyFactoryTest:testCreateAndExecuteSetsMsgSender() (gas: 223967) +QuarkWalletProxyFactoryTest:testCreateAndExecuteWithSalt() (gas: 416581) +QuarkWalletProxyFactoryTest:testCreateAndExecuteWithSaltSetsMsgSender() (gas: 396196) QuarkWalletProxyFactoryTest:testCreateRevertsOnRepeat() (gas: 8937393460516733241) QuarkWalletProxyFactoryTest:testCreatesWalletAtDeterministicAddress() (gas: 222644) -QuarkWalletProxyFactoryTest:testExecuteMultiOnExistingWallet() (gas: 444791) -QuarkWalletProxyFactoryTest:testExecuteOnExistingWallet() (gas: 410694) -QuarkWalletProxyFactoryTest:testExecutorIsOtherWallet() (gas: 282099) +QuarkWalletProxyFactoryTest:testExecuteMultiOnExistingWallet() (gas: 444835) +QuarkWalletProxyFactoryTest:testExecuteOnExistingWallet() (gas: 410716) +QuarkWalletProxyFactoryTest:testExecutorIsOtherWallet() (gas: 313753) QuarkWalletProxyFactoryTest:testExecutorSetInCreate() (gas: 103646) QuarkWalletProxyFactoryTest:testVersion() (gas: 6130) -QuarkWalletTest:testAtomicIncrementer() (gas: 71908) -QuarkWalletTest:testAtomicMaxCounterScript() (gas: 270934) -QuarkWalletTest:testAtomicPing() (gas: 51700) -QuarkWalletTest:testAtomicPingWithExternalSignature() (gas: 98990) -QuarkWalletTest:testCanReplaySameScriptWithDifferentCall() (gas: 157158) -QuarkWalletTest:testDirectExecuteFromEOA() (gas: 68243) -QuarkWalletTest:testDirectExecuteFromOtherQuarkWallet() (gas: 117434) -QuarkWalletTest:testDisallowAllNullScriptAddress() (gas: 222194) -QuarkWalletTest:testEmitsEventsInDirectExecute() (gas: 46986) -QuarkWalletTest:testEmitsEventsInExecuteQuarkOperation() (gas: 88610) -QuarkWalletTest:testGetCodeJar() (gas: 11182) +QuarkWalletTest:testAtomicIncrementer() (gas: 71987) +QuarkWalletTest:testAtomicMaxCounterScript() (gas: 271134) +QuarkWalletTest:testAtomicPing() (gas: 51746) +QuarkWalletTest:testAtomicPingWithExternalSignature() (gas: 99075) +QuarkWalletTest:testCanReplaySameScriptWithDifferentCall() (gas: 157277) +QuarkWalletTest:testDirectExecuteFromEOA() (gas: 68704) +QuarkWalletTest:testDirectExecuteFromOtherQuarkWallet() (gas: 117804) +QuarkWalletTest:testDirectExecuteWithScriptSources() (gas: 286178) +QuarkWalletTest:testDisallowAllNullScriptAddress() (gas: 223275) +QuarkWalletTest:testEmitsEventsInDirectExecute() (gas: 47349) +QuarkWalletTest:testEmitsEventsInExecuteQuarkOperation() (gas: 88701) +QuarkWalletTest:testGetCodeJar() (gas: 11204) QuarkWalletTest:testGetExecutor() (gas: 5469) -QuarkWalletTest:testGetSigner() (gas: 8478) +QuarkWalletTest:testGetSigner() (gas: 8500) QuarkWalletTest:testGetStateManager() (gas: 10612) -QuarkWalletTest:testMultiQuarkOperationCanCallMultipleOperationsWithOneSignature() (gas: 108770) -QuarkWalletTest:testPrecompileBigModExp() (gas: 50991) -QuarkWalletTest:testPrecompileBlake2F() (gas: 53463) -QuarkWalletTest:testPrecompileBn256Add() (gas: 52459) -QuarkWalletTest:testPrecompileBn256ScalarMul() (gas: 56441) -QuarkWalletTest:testPrecompileDataCopy() (gas: 59403) -QuarkWalletTest:testPrecompileEcRecover() (gas: 56514) -QuarkWalletTest:testPrecompileRipemd160() (gas: 52478) -QuarkWalletTest:testPrecompileSha256() (gas: 52921) -QuarkWalletTest:testQuarkOperationRevertsIfCallReverts() (gas: 67518) -QuarkWalletTest:testRevertOnAllPrecompilesDirectCall() (gas: 632496) -QuarkWalletTest:testRevertsForBadInputsInMultiQuarkOperation() (gas: 13496) -QuarkWalletTest:testRevertsForDirectExecuteByNonExecutorSigner() (gas: 13460) -QuarkWalletTest:testRevertsForNonceReuse() (gas: 92971) -QuarkWalletTest:testRevertsForRandomEmptyScriptAddress() (gas: 116957) -QuarkWalletTest:testRevertsForReplayOfCanceledScript() (gas: 209602) -QuarkWalletTest:testRevertsForReusedNonceWithChangedScript() (gas: 106600) -QuarkWalletTest:testRevertsForUnauthorizedDirectExecuteByRandomAddress() (gas: 15647) -QuarkWalletTest:testSetsMsgSender() (gas: 51287) -QuarkWalletTest:testSetsMsgSenderDuringDirectExecute() (gas: 45002) -QuarkWalletTest:testSingleNonceCanCallDifferentScriptsAndCacheNonTargetScript() (gas: 135287) -ReplayableTransactionsTest:testCancelRecurringPurchase() (gas: 271072) -ReplayableTransactionsTest:testRecurringPurchaseHappyPath() (gas: 211813) -ReplayableTransactionsTest:testRecurringPurchaseMultiplePurchases() (gas: 369983) -ReplayableTransactionsTest:testRecurringPurchaseWithDifferentCalldata() (gas: 596826) +QuarkWalletTest:testMultiQuarkOperationCanCallMultipleOperationsWithOneSignature() (gas: 108861) +QuarkWalletTest:testPrecompileBigModExp() (gas: 51036) +QuarkWalletTest:testPrecompileBlake2F() (gas: 53508) +QuarkWalletTest:testPrecompileBn256Add() (gas: 52522) +QuarkWalletTest:testPrecompileBn256ScalarMul() (gas: 56487) +QuarkWalletTest:testPrecompileDataCopy() (gas: 59460) +QuarkWalletTest:testPrecompileEcRecover() (gas: 56560) +QuarkWalletTest:testPrecompileRipemd160() (gas: 52524) +QuarkWalletTest:testPrecompileSha256() (gas: 52967) +QuarkWalletTest:testQuarkOperationRevertsIfCallReverts() (gas: 67575) +QuarkWalletTest:testRevertOnAllPrecompilesDirectCall() (gas: 633031) +QuarkWalletTest:testRevertsForBadInputsInMultiQuarkOperation() (gas: 13531) +QuarkWalletTest:testRevertsForDirectExecuteByNonExecutorSigner() (gas: 13835) +QuarkWalletTest:testRevertsForNonceReuse() (gas: 93063) +QuarkWalletTest:testRevertsForRandomEmptyScriptAddress() (gas: 117042) +QuarkWalletTest:testRevertsForReplayOfCanceledScript() (gas: 209767) +QuarkWalletTest:testRevertsForReusedNonceWithChangedScript() (gas: 106673) +QuarkWalletTest:testRevertsForUnauthorizedDirectExecuteByRandomAddress() (gas: 16023) +QuarkWalletTest:testSetsMsgSender() (gas: 51350) +QuarkWalletTest:testSetsMsgSenderDuringDirectExecute() (gas: 45371) +QuarkWalletTest:testSingleNonceCanCallDifferentScriptsAndCacheNonTargetScript() (gas: 135418) +ReplayableTransactionsTest:testCancelRecurringPurchase() (gas: 271116) +ReplayableTransactionsTest:testRecurringPurchaseHappyPath() (gas: 211835) +ReplayableTransactionsTest:testRecurringPurchaseMultiplePurchases() (gas: 370049) +ReplayableTransactionsTest:testRecurringPurchaseWithDifferentCalldata() (gas: 596914) ReplayableTransactionsTest:testRevertsForExpiredQuarkOperation() (gas: 12385) -ReplayableTransactionsTest:testRevertsForExpiredUniswapParams() (gas: 119556) -ReplayableTransactionsTest:testRevertsForPurchaseBeforeNextPurchasePeriod() (gas: 286611) -ReplayableTransactionsTest:testRevertsForPurchasingOverTheLimit() (gas: 287164) -RevertsTest:testRevertsInteger() (gas: 66947) +ReplayableTransactionsTest:testRevertsForExpiredUniswapParams() (gas: 119578) +ReplayableTransactionsTest:testRevertsForPurchaseBeforeNextPurchasePeriod() (gas: 286655) +ReplayableTransactionsTest:testRevertsForPurchasingOverTheLimit() (gas: 287208) +RevertsTest:testRevertsInteger() (gas: 66969) RevertsTest:testRevertsInvalidOpcode() (gas: 8391762413094949948) -RevertsTest:testRevertsOutOfGas() (gas: 295978) -RevertsTest:testRevertsWhenDividingByZero() (gas: 66793) -SupplyActionsTest:testInvalidInput() (gas: 68414) -SupplyActionsTest:testRepayBorrow() (gas: 90514) -SupplyActionsTest:testSupply() (gas: 132696) -SupplyActionsTest:testSupplyFrom() (gas: 112700) -SupplyActionsTest:testSupplyMultipleCollateral() (gas: 271619) -SupplyActionsTest:testSupplyTo() (gas: 132392) -TransferActionsTest:testRevertsForTransferERC777ReentrancyAttackWithReentrancyGuard() (gas: 150228) -TransferActionsTest:testRevertsForTransferReentrancyAttackWithReentrancyGuard() (gas: 131508) -TransferActionsTest:testRevertsForTransferReentrancyAttackWithoutCallbackEnabled() (gas: 100244) -TransferActionsTest:testRevertsForTransferReentrantAttackWithStolenSignature() (gas: 111619) -TransferActionsTest:testTransferERC20TokenToEOA() (gas: 70952) -TransferActionsTest:testTransferERC20TokenToQuarkWallet() (gas: 72329) -TransferActionsTest:testTransferERC777SuccessWithEvilReceiverWithoutAttackAttempt() (gas: 107763) -TransferActionsTest:testTransferERC777TokenReentrancyAttackSuccessWithCallbackEnabled() (gas: 145910) -TransferActionsTest:testTransferNativeTokenToEOA() (gas: 80201) -TransferActionsTest:testTransferNativeTokenToQuarkWallet() (gas: 55601) -TransferActionsTest:testTransferReentrancyAttackSuccessWithCallbackEnabled() (gas: 129621) -TransferActionsTest:testTransferSuccessWithEvilReceiverWithoutAttackAttempt() (gas: 88166) -UniswapFlashLoanTest:testFlashLoanForCollateralSwapOnCompound() (gas: 428519) -UniswapFlashLoanTest:testRevertsForInsufficientFundsToRepayFlashLoan() (gas: 194178) -UniswapFlashLoanTest:testRevertsForInvalidCaller() (gas: 71169) +RevertsTest:testRevertsOutOfGas() (gas: 295979) +RevertsTest:testRevertsWhenDividingByZero() (gas: 66815) +SupplyActionsTest:testInvalidInput() (gas: 68436) +SupplyActionsTest:testRepayBorrow() (gas: 90532) +SupplyActionsTest:testSupply() (gas: 132714) +SupplyActionsTest:testSupplyFrom() (gas: 112718) +SupplyActionsTest:testSupplyMultipleCollateral() (gas: 271636) +SupplyActionsTest:testSupplyTo() (gas: 132409) +TransferActionsTest:testRevertsForTransferERC777ReentrancyAttackWithReentrancyGuard() (gas: 150272) +TransferActionsTest:testRevertsForTransferReentrancyAttackWithReentrancyGuard() (gas: 131552) +TransferActionsTest:testRevertsForTransferReentrancyAttackWithoutCallbackEnabled() (gas: 100266) +TransferActionsTest:testRevertsForTransferReentrantAttackWithStolenSignature() (gas: 111641) +TransferActionsTest:testTransferERC20TokenToEOA() (gas: 70970) +TransferActionsTest:testTransferERC20TokenToQuarkWallet() (gas: 72347) +TransferActionsTest:testTransferERC777SuccessWithEvilReceiverWithoutAttackAttempt() (gas: 107807) +TransferActionsTest:testTransferERC777TokenReentrancyAttackSuccessWithCallbackEnabled() (gas: 145954) +TransferActionsTest:testTransferNativeTokenToEOA() (gas: 80223) +TransferActionsTest:testTransferNativeTokenToQuarkWallet() (gas: 55619) +TransferActionsTest:testTransferReentrancyAttackSuccessWithCallbackEnabled() (gas: 129665) +TransferActionsTest:testTransferSuccessWithEvilReceiverWithoutAttackAttempt() (gas: 88210) +UniswapFlashLoanTest:testFlashLoanForCollateralSwapOnCompound() (gas: 428563) +UniswapFlashLoanTest:testRevertsForInsufficientFundsToRepayFlashLoan() (gas: 194222) +UniswapFlashLoanTest:testRevertsForInvalidCaller() (gas: 71191) UniswapFlashLoanTest:testRevertsIfCalledDirectly() (gas: 10769) -UniswapFlashLoanTest:testTokensOrderInvariant() (gas: 96191) -UniswapFlashSwapExactOutTest:testInvalidCallerFlashSwap() (gas: 71147) -UniswapFlashSwapExactOutTest:testNotEnoughToPayFlashSwap() (gas: 294917) +UniswapFlashLoanTest:testTokensOrderInvariant() (gas: 96235) +UniswapFlashSwapExactOutTest:testInvalidCallerFlashSwap() (gas: 71169) +UniswapFlashSwapExactOutTest:testNotEnoughToPayFlashSwap() (gas: 294961) UniswapFlashSwapExactOutTest:testRevertsIfCalledDirectly() (gas: 10871) -UniswapFlashSwapExactOutTest:testUniswapFlashSwapExactOutLeverageComet() (gas: 355056) -UniswapSwapActionsTest:testApprovalRefund() (gas: 164741) -UniswapSwapActionsTest:testBuyAssetOneStop() (gas: 252860) -UniswapSwapActionsTest:testBuyAssetTwoStops() (gas: 359417) -UniswapSwapActionsTest:testSellAssetOneStop() (gas: 250195) -UniswapSwapActionsTest:testSellAssetTwoStops() (gas: 363342) -WithdrawActionsTest:testBorrow() (gas: 154738) -WithdrawActionsTest:testInvalidInput() (gas: 68286) -WithdrawActionsTest:testWithdraw() (gas: 84456) -WithdrawActionsTest:testWithdrawFrom() (gas: 83982) -WithdrawActionsTest:testWithdrawMultipleAssets() (gas: 160180) -WithdrawActionsTest:testWithdrawTo() (gas: 84450) +UniswapFlashSwapExactOutTest:testUniswapFlashSwapExactOutLeverageComet() (gas: 355100) +UniswapSwapActionsTest:testApprovalRefund() (gas: 164763) +UniswapSwapActionsTest:testBuyAssetOneStop() (gas: 252895) +UniswapSwapActionsTest:testBuyAssetTwoStops() (gas: 359452) +UniswapSwapActionsTest:testSellAssetOneStop() (gas: 250230) +UniswapSwapActionsTest:testSellAssetTwoStops() (gas: 363377) +WithdrawActionsTest:testBorrow() (gas: 154760) +WithdrawActionsTest:testInvalidInput() (gas: 68308) +WithdrawActionsTest:testWithdraw() (gas: 84474) +WithdrawActionsTest:testWithdrawFrom() (gas: 84000) +WithdrawActionsTest:testWithdrawMultipleAssets() (gas: 160197) +WithdrawActionsTest:testWithdrawTo() (gas: 84468) isValidSignatureTest:testIsValidSignatureForEOAOwner() (gas: 13445) isValidSignatureTest:testReturnsMagicValueForValidSignature() (gas: 9376) isValidSignatureTest:testRevertsForEmptyContract() (gas: 11305) diff --git a/src/quark-core/src/QuarkWallet.sol b/src/quark-core/src/QuarkWallet.sol index 0accd5e4..cb40e45b 100644 --- a/src/quark-core/src/QuarkWallet.sol +++ b/src/quark-core/src/QuarkWallet.sol @@ -228,17 +228,25 @@ contract QuarkWallet is IERC1271 { * @param nonce Nonce for the operation; must be unused * @param scriptAddress Address for the script to execute * @param scriptCalldata Encoded call to invoke on the script + * @param scriptSources Creation codes Quark must ensure are deployed before executing the script * @return Return value from the executed operation */ - function executeScript(uint96 nonce, address scriptAddress, bytes calldata scriptCalldata) - external - returns (bytes memory) - { + function executeScript( + uint96 nonce, + address scriptAddress, + bytes calldata scriptCalldata, + bytes[] calldata scriptSources + ) external returns (bytes memory) { // only allow the executor for the wallet to use unsigned execution if (msg.sender != IHasSignerExecutor(address(this)).executor()) { revert Unauthorized(); } + // guarantee every script in scriptSources is deployed + for (uint256 i = 0; i < scriptSources.length; ++i) { + codeJar.saveCode(scriptSources[i]); + } + emit ExecuteQuarkScript(msg.sender, scriptAddress, nonce, ExecutionType.Direct); return stateManager.setActiveNonceAndCallback(nonce, scriptAddress, scriptCalldata); diff --git a/src/quark-core/src/interfaces/IQuarkWallet.sol b/src/quark-core/src/interfaces/IQuarkWallet.sol index 8c7e80a4..da423761 100644 --- a/src/quark-core/src/interfaces/IQuarkWallet.sol +++ b/src/quark-core/src/interfaces/IQuarkWallet.sol @@ -31,9 +31,12 @@ interface IQuarkWallet { bytes32 r, bytes32 s ) external returns (bytes memory); - function executeScript(uint96 nonce, address scriptAddress, bytes calldata scriptCalldata) - external - returns (bytes memory); + function executeScript( + uint96 nonce, + address scriptAddress, + bytes calldata scriptCalldata, + bytes[] calldata scriptSources + ) external returns (bytes memory); function getDigestForQuarkOperation(QuarkOperation calldata op) external view returns (bytes32); function getDigestForMultiQuarkOperation(bytes32[] memory opDigests) external pure returns (bytes32); function getDigestForQuarkMessage(bytes memory message) external view returns (bytes32); diff --git a/test/lib/ExecuteOnBehalf.sol b/test/lib/ExecuteOnBehalf.sol index e1f6ca45..0d70f12c 100644 --- a/test/lib/ExecuteOnBehalf.sol +++ b/test/lib/ExecuteOnBehalf.sol @@ -8,6 +8,6 @@ contract ExecuteOnBehalf { public returns (bytes memory) { - return targetWallet.executeScript(nonce, scriptAddress, scriptCalldata); + return targetWallet.executeScript(nonce, scriptAddress, scriptCalldata, new bytes[](0)); } } diff --git a/test/quark-core-scripts/Multicall.t.sol b/test/quark-core-scripts/Multicall.t.sol index 32c9dfd2..7648b55a 100644 --- a/test/quark-core-scripts/Multicall.t.sol +++ b/test/quark-core-scripts/Multicall.t.sol @@ -391,7 +391,7 @@ contract MulticallTest is Test { // 1. transfer 0.5 WETH from wallet A to wallet B wallets[0] = address(walletA); walletCalls[0] = abi.encodeWithSignature( - "executeScript(uint96,address,bytes)", + "executeScript(uint96,address,bytes,bytes[])", QuarkWallet(payable(factory.walletImplementation())).stateManager().nextNonce(address(walletA)), ethcallAddress, abi.encodeWithSelector( @@ -399,7 +399,8 @@ contract MulticallTest is Test { WETH, abi.encodeCall(IERC20.transfer, (address(walletB), 0.5 ether)), 0 // value - ) + ), + new bytes[](0) ); // 2. approve Comet cUSDCv3 to receive 0.5 WETH from wallet B @@ -407,7 +408,7 @@ contract MulticallTest is Test { QuarkWallet(payable(factory.walletImplementation())).stateManager().nextNonce(address(walletB)); wallets[1] = address(walletB); walletCalls[1] = abi.encodeWithSignature( - "executeScript(uint96,address,bytes)", + "executeScript(uint96,address,bytes,bytes[])", walletBNextNonce, ethcallAddress, abi.encodeWithSelector( @@ -415,13 +416,14 @@ contract MulticallTest is Test { WETH, abi.encodeCall(IERC20.approve, (cUSDCv3, 0.5 ether)), 0 // value - ) + ), + new bytes[](0) ); // 3. supply 0.5 WETH from wallet B to Comet cUSDCv3 wallets[2] = address(walletB); walletCalls[2] = abi.encodeWithSignature( - "executeScript(uint96,address,bytes)", + "executeScript(uint96,address,bytes,bytes[])", walletBNextNonce + 1, ethcallAddress, abi.encodeWithSelector( @@ -429,7 +431,8 @@ contract MulticallTest is Test { cUSDCv3, abi.encodeCall(IComet.supply, (WETH, 0.5 ether)), 0 // value - ) + ), + new bytes[](0) ); // okay, woof, now wrap all that in ethcalls... @@ -531,7 +534,8 @@ contract MulticallTest is Test { path: abi.encodePacked(USDC, uint24(500), WETH) // Path: USDC - 0.05% -> WETH }) ) - ) + ), + new bytes[](0) ) ), 0 // value @@ -546,7 +550,8 @@ contract MulticallTest is Test { ( nonce + 1, legendCometSupplyScriptAddress, - abi.encodeCall(CometSupplyActions.supply, (cWETHv3, WETH, 2 ether)) + abi.encodeCall(CometSupplyActions.supply, (cWETHv3, WETH, 2 ether)), + new bytes[](0) ) ), 0 // value diff --git a/test/quark-core/Executor.t.sol b/test/quark-core/Executor.t.sol index 5dd6c04a..57cabf3e 100644 --- a/test/quark-core/Executor.t.sol +++ b/test/quark-core/Executor.t.sol @@ -75,7 +75,8 @@ contract ExecutorTest is Test { abi.encodeWithSignature( "run(address,bytes,uint256)", address(counter), abi.encodeWithSignature("increment(uint256)", 5), 0 ) - ) + ), + new bytes[](0) ); assertEq(counter.number(), 5); diff --git a/test/quark-core/QuarkWallet.t.sol b/test/quark-core/QuarkWallet.t.sol index fb9e05ee..22f3fee5 100644 --- a/test/quark-core/QuarkWallet.t.sol +++ b/test/quark-core/QuarkWallet.t.sol @@ -124,7 +124,7 @@ contract QuarkWalletTest is Test { // gas: meter execute vm.resumeGasMetering(); - bytes memory result = aliceWalletExecutable.executeScript(nonce, scriptAddress, call); + bytes memory result = aliceWalletExecutable.executeScript(nonce, scriptAddress, call, new bytes[](0)); vm.stopPrank(); @@ -178,7 +178,7 @@ contract QuarkWalletTest is Test { vm.resumeGasMetering(); vm.expectEmit(true, true, true, true); emit ExecuteQuarkScript(address(aliceAccount), scriptAddress, nonce, ExecutionType.Direct); - aliceWalletExecutable.executeScript(nonce, scriptAddress, call); + aliceWalletExecutable.executeScript(nonce, scriptAddress, call, new bytes[](0)); } /* ===== general invariant tests ===== */ @@ -207,7 +207,7 @@ contract QuarkWalletTest is Test { uint96 nonce = stateManager.nextNonce(address(aliceWallet)); vm.prank(IHasSignerExecutor(address(aliceWallet)).executor()); vm.expectRevert(abi.encodeWithSelector(QuarkWallet.EmptyCode.selector)); - aliceWallet.executeScript(nonce, address(0), bytes("")); + aliceWallet.executeScript(nonce, address(0), bytes(""), new bytes[](0)); // gas: do not meter set-up vm.pauseGasMetering(); @@ -236,7 +236,7 @@ contract QuarkWalletTest is Test { uint96 nonce2 = stateManager.nextNonce(address(aliceWallet)); vm.prank(IHasSignerExecutor(address(aliceWallet)).executor()); vm.expectRevert(abi.encodeWithSelector(QuarkWallet.EmptyCode.selector)); - aliceWallet.executeScript(nonce2, emptyCodeAddress, bytes("")); + aliceWallet.executeScript(nonce2, emptyCodeAddress, bytes(""), new bytes[](0)); } function testRevertsForRandomEmptyScriptAddress() public { @@ -398,7 +398,7 @@ contract QuarkWalletTest is Test { // gas: meter execute vm.resumeGasMetering(); - aliceWalletExecutable.executeScript(nonce, incrementerAddress, call); + aliceWalletExecutable.executeScript(nonce, incrementerAddress, call, new bytes[](0)); assertEq(counter.number(), 3); assertEq(stateManager.nextNonce(address(aliceWalletExecutable)), 1); @@ -415,10 +415,11 @@ contract QuarkWalletTest is Test { Ethcall.run.selector, address(aliceWalletExecutable), abi.encodeWithSignature( - "executeScript(uint96,address,bytes)", + "executeScript(uint96,address,bytes,bytes[])", stateManager.nextNonce(address(aliceWalletExecutable)), incrementerAddress, - abi.encodeWithSignature("incrementCounter(address)", counter) + abi.encodeWithSignature("incrementCounter(address)", counter), + new bytes[](0) ), 0 // value ); @@ -439,6 +440,31 @@ contract QuarkWalletTest is Test { assertEq(stateManager.nextNonce(address(aliceWalletExecutable)), 1); } + function testDirectExecuteWithScriptSources() public { + // gas: disable metering except while executing operations + vm.pauseGasMetering(); + QuarkWallet aliceWalletExecutable = newWallet(aliceAccount, aliceAccount); + bytes memory incrementer = new YulHelper().getCode("Incrementer.sol/Incrementer.json"); + address incrementerAddress = codeJar.getCodeAddress(incrementer); + uint96 nonce = stateManager.nextNonce(address(aliceWalletExecutable)); + bytes memory call = abi.encodeWithSignature("incrementCounter(address)", counter); + bytes[] memory scriptSources = new bytes[](1); + scriptSources[0] = incrementer; + + assertEq(counter.number(), 0); + assertEq(stateManager.nextNonce(address(aliceWalletExecutable)), 0); + + // act as the executor for the wallet + vm.startPrank(aliceAccount); + + // gas: meter execute + vm.resumeGasMetering(); + aliceWalletExecutable.executeScript(nonce, incrementerAddress, call, scriptSources); + + assertEq(counter.number(), 3); + assertEq(stateManager.nextNonce(address(aliceWalletExecutable)), 1); + } + function testRevertsForDirectExecuteByNonExecutorSigner() public { // gas: disable metering except while executing operations vm.pauseGasMetering(); @@ -457,7 +483,7 @@ contract QuarkWalletTest is Test { vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(QuarkWallet.Unauthorized.selector)); - aliceWallet.executeScript(nonce, target, call); + aliceWallet.executeScript(nonce, target, call, new bytes[](0)); vm.stopPrank(); @@ -482,7 +508,7 @@ contract QuarkWalletTest is Test { vm.resumeGasMetering(); vm.expectRevert(abi.encodeWithSelector(QuarkWallet.Unauthorized.selector)); - aliceWallet.executeScript(nonce, target, call); + aliceWallet.executeScript(nonce, target, call, new bytes[](0)); vm.stopPrank();