From 02b0a42c0d385f4478e94b350b10419c354f4dab Mon Sep 17 00:00:00 2001 From: Mark Toda Date: Thu, 24 Oct 2024 08:24:47 -0700 Subject: [PATCH] fix: remove unnecessary base snaps --- snapshots/DutchOrderReactorTest.json | 18 +++++------ snapshots/ExclusiveDutchOrderReactorTest.json | 18 +++++------ snapshots/LimitOrderReactorTest.json | 18 +++++------ snapshots/PriorityOrderReactorTest.json | 26 ++++++++-------- snapshots/V2DutchOrderTest.json | 24 +++++++------- snapshots/V3DutchOrderTest.json | 24 +++++++------- test/base/BaseReactor.t.sol | 31 ++++++------------- test/reactors/PriorityOrderReactor.t.sol | 12 +++---- test/reactors/V2DutchOrderReactor.t.sol | 9 ++---- test/reactors/V3DutchOrderReactor.t.sol | 9 ++---- 10 files changed, 83 insertions(+), 106 deletions(-) diff --git a/snapshots/DutchOrderReactorTest.json b/snapshots/DutchOrderReactorTest.json index 47827314..420ce66b 100644 --- a/snapshots/DutchOrderReactorTest.json +++ b/snapshots/DutchOrderReactorTest.json @@ -1,11 +1,11 @@ { - "Base-DutchOrder-BaseExecuteSingleWithFee": "181438", - "Base-DutchOrder-ExecuteBatch": "196244", - "Base-DutchOrder-ExecuteBatchMultipleOutputs": "205893", - "Base-DutchOrder-ExecuteBatchMultipleOutputsDifferentTokens": "259435", - "Base-DutchOrder-ExecuteBatchNativeOutput": "189770", - "Base-DutchOrder-ExecuteSingle": "147820", - "Base-DutchOrder-ExecuteSingleNativeOutput": "133383", - "Base-DutchOrder-ExecuteSingleValidation": "157131", - "Base-DutchOrder-RevertInvalidNonce": "26372" + "BaseExecuteSingleWithFee": "176379", + "ExecuteBatch": "188624", + "ExecuteBatchMultipleOutputs": "197968", + "ExecuteBatchMultipleOutputsDifferentTokens": "251215", + "ExecuteBatchNativeOutput": "184650", + "ExecuteSingle": "142762", + "ExecuteSingleNativeOutput": "130824", + "ExecuteSingleValidation": "152072", + "RevertInvalidNonce": "22192" } \ No newline at end of file diff --git a/snapshots/ExclusiveDutchOrderReactorTest.json b/snapshots/ExclusiveDutchOrderReactorTest.json index 077a7717..c290b013 100644 --- a/snapshots/ExclusiveDutchOrderReactorTest.json +++ b/snapshots/ExclusiveDutchOrderReactorTest.json @@ -1,11 +1,11 @@ { - "Base-ExclusiveDutchOrder-BaseExecuteSingleWithFee": "181682", - "Base-ExclusiveDutchOrder-ExecuteBatch": "196730", - "Base-ExclusiveDutchOrder-ExecuteBatchMultipleOutputs": "206374", - "Base-ExclusiveDutchOrder-ExecuteBatchMultipleOutputsDifferentTokens": "259924", - "Base-ExclusiveDutchOrder-ExecuteBatchNativeOutput": "190250", - "Base-ExclusiveDutchOrder-ExecuteSingle": "148073", - "Base-ExclusiveDutchOrder-ExecuteSingleNativeOutput": "133635", - "Base-ExclusiveDutchOrder-ExecuteSingleValidation": "157383", - "Base-ExclusiveDutchOrder-RevertInvalidNonce": "26629" + "BaseExecuteSingleWithFee": "176480", + "ExecuteBatch": "188814", + "ExecuteBatchMultipleOutputs": "198158", + "ExecuteBatchMultipleOutputsDifferentTokens": "251405", + "ExecuteBatchNativeOutput": "184840", + "ExecuteSingle": "142871", + "ExecuteSingleNativeOutput": "130933", + "ExecuteSingleValidation": "152181", + "RevertInvalidNonce": "22290" } \ No newline at end of file diff --git a/snapshots/LimitOrderReactorTest.json b/snapshots/LimitOrderReactorTest.json index d880b6a2..7c6e4670 100644 --- a/snapshots/LimitOrderReactorTest.json +++ b/snapshots/LimitOrderReactorTest.json @@ -1,11 +1,11 @@ { - "Base-LimitOrderReactor-BaseExecuteSingleWithFee": "177666", - "Base-LimitOrderReactor-ExecuteBatch": "188610", - "Base-LimitOrderReactor-ExecuteBatchMultipleOutputs": "197369", - "Base-LimitOrderReactor-ExecuteBatchMultipleOutputsDifferentTokens": "250029", - "Base-LimitOrderReactor-ExecuteBatchNativeOutput": "182131", - "Base-LimitOrderReactor-ExecuteSingle": "144054", - "Base-LimitOrderReactor-ExecuteSingleNativeOutput": "129612", - "Base-LimitOrderReactor-ExecuteSingleValidation": "153360", - "Base-LimitOrderReactor-RevertInvalidNonce": "22590" + "BaseExecuteSingleWithFee": "172831", + "ExecuteBatch": "181452", + "ExecuteBatchMultipleOutputs": "189990", + "ExecuteBatchMultipleOutputsDifferentTokens": "242428", + "ExecuteBatchNativeOutput": "177478", + "ExecuteSingle": "139215", + "ExecuteSingleNativeOutput": "127277", + "ExecuteSingleValidation": "148525", + "RevertInvalidNonce": "18656" } \ No newline at end of file diff --git a/snapshots/PriorityOrderReactorTest.json b/snapshots/PriorityOrderReactorTest.json index f89d0e25..281e495c 100644 --- a/snapshots/PriorityOrderReactorTest.json +++ b/snapshots/PriorityOrderReactorTest.json @@ -1,15 +1,15 @@ { - "Base-PriorityOrderReactor-BaseExecuteSingleWithFee": "184270", - "Base-PriorityOrderReactor-ExecuteBatch": "201986", - "Base-PriorityOrderReactor-ExecuteBatchMultipleOutputs": "211513", - "Base-PriorityOrderReactor-ExecuteBatchMultipleOutputsDifferentTokens": "264944", - "Base-PriorityOrderReactor-ExecuteBatchNativeOutput": "195506", - "Base-PriorityOrderReactor-ExecuteSingle": "150656", - "Base-PriorityOrderReactor-ExecuteSingleNativeOutput": "136223", - "Base-PriorityOrderReactor-ExecuteSingleValidation": "159971", - "Base-PriorityOrderReactor-InputPriorityFee": "152964", - "Base-PriorityOrderReactor-OutputPriorityFee": "152968", - "Base-PriorityOrderReactor-OutputPriorityFeeAndBaselinePriorityFee": "152962", - "Base-PriorityOrderReactor-OverrideAuctionTargetBlock": "130099", - "Base-PriorityOrderReactor-RevertInvalidNonce": "13608" + "BaseExecuteSingleWithFee": "178696", + "ExecuteBatch": "193279", + "ExecuteBatchMultipleOutputs": "202497", + "ExecuteBatchMultipleOutputsDifferentTokens": "255617", + "ExecuteBatchNativeOutput": "189305", + "ExecuteSingle": "145087", + "ExecuteSingleNativeOutput": "133149", + "ExecuteSingleValidation": "154397", + "InputPriorityFee": "147392", + "OutputPriorityFee": "147396", + "OutputPriorityFeeAndBaselinePriorityFee": "147396", + "OverrideAuctionTargetBlock": "124529", + "RevertInvalidNonce": "8853" } \ No newline at end of file diff --git a/snapshots/V2DutchOrderTest.json b/snapshots/V2DutchOrderTest.json index ff1a75ed..269195bd 100644 --- a/snapshots/V2DutchOrderTest.json +++ b/snapshots/V2DutchOrderTest.json @@ -1,14 +1,14 @@ { - "Base-V2DutchOrder-BaseExecuteSingleWithFee": "188471", - "Base-V2DutchOrder-ExclusiveFiller": "158619", - "Base-V2DutchOrder-ExecuteBatch": "210402", - "Base-V2DutchOrder-ExecuteBatchMultipleOutputs": "220620", - "Base-V2DutchOrder-ExecuteBatchMultipleOutputsDifferentTokens": "274747", - "Base-V2DutchOrder-ExecuteBatchNativeOutput": "203928", - "Base-V2DutchOrder-ExecuteSingle": "154854", - "Base-V2DutchOrder-ExecuteSingleNativeOutput": "140416", - "Base-V2DutchOrder-ExecuteSingleValidation": "164166", - "Base-V2DutchOrder-InputOverride": "158697", - "Base-V2DutchOrder-OutputOverride": "158646", - "Base-V2DutchOrder-RevertInvalidNonce": "33425" + "BaseExecuteSingleWithFee": "182480", + "ExclusiveFiller": "152632", + "ExecuteBatch": "200865", + "ExecuteBatchMultipleOutputs": "210701", + "ExecuteBatchMultipleOutputsDifferentTokens": "264440", + "ExecuteBatchNativeOutput": "196891", + "ExecuteSingle": "148863", + "ExecuteSingleNativeOutput": "136925", + "ExecuteSingleValidation": "158173", + "InputOverride": "152710", + "OutputOverride": "152659", + "RevertInvalidNonce": "28213" } \ No newline at end of file diff --git a/snapshots/V3DutchOrderTest.json b/snapshots/V3DutchOrderTest.json index 8c8db7a8..2acf9882 100644 --- a/snapshots/V3DutchOrderTest.json +++ b/snapshots/V3DutchOrderTest.json @@ -1,14 +1,14 @@ { - "Base-V3DutchOrder-BaseExecuteSingleWithFee": "199526", - "Base-V3DutchOrder-ExecuteBatch": "232823", - "Base-V3DutchOrder-ExecuteBatchMultipleOutputs": "246882", - "Base-V3DutchOrder-ExecuteBatchMultipleOutputsDifferentTokens": "304875", - "Base-V3DutchOrder-ExecuteBatchNativeOutput": "226350", - "Base-V3DutchOrder-ExecuteSingle": "165913", - "Base-V3DutchOrder-ExecuteSingleNativeOutput": "151470", - "Base-V3DutchOrder-ExecuteSingleValidation": "175219", - "Base-V3DutchOrder-RevertInvalidNonce": "44536", - "Base-V3DutchOrder-V3-ExclusiveFiller": "169849", - "Base-V3DutchOrder-V3-InputOverride": "169930", - "Base-V3DutchOrder-V3-OutputOverride": "169873" + "BaseExecuteSingleWithFee": "192645", + "ExecuteBatch": "221374", + "ExecuteBatchMultipleOutputs": "234559", + "ExecuteBatchMultipleOutputsDifferentTokens": "291665", + "ExecuteBatchNativeOutput": "217400", + "ExecuteSingle": "159027", + "ExecuteSingleNativeOutput": "147089", + "ExecuteSingleValidation": "168337", + "RevertInvalidNonce": "38303", + "V3-ExclusiveFiller": "162895", + "V3-InputOverride": "162976", + "V3-OutputOverride": "162919" } \ No newline at end of file diff --git a/test/base/BaseReactor.t.sol b/test/base/BaseReactor.t.sol index 5a7baceb..9b583095 100644 --- a/test/base/BaseReactor.t.sol +++ b/test/base/BaseReactor.t.sol @@ -117,9 +117,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("ExecuteSingle"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteSingle"); assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - inputAmount); assertEq(tokenIn.balanceOf(address(fillContract)), fillContractInputBalanceStart + inputAmount); @@ -162,9 +161,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("BaseExecuteSingleWithFee"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("BaseExecuteSingleWithFee"); uint256 feeAmount = uint256(outputAmount) * feeBps / 10000; assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - inputAmount); @@ -202,9 +200,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("ExecuteSingleNativeOutput"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteSingleNativeOutput"); assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - inputAmount); assertEq(tokenIn.balanceOf(address(fillContract)), fillContractInputBalanceStart + inputAmount); @@ -246,9 +243,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("ExecuteSingleValidation"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteSingleValidation"); assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - inputAmount); assertEq(tokenIn.balanceOf(address(fillContract)), fillContractInputBalanceStart + inputAmount); @@ -297,9 +293,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true); emit Fill(orderHashes[1], address(fillContract), swapper, orders[1].info.nonce); - _snapStart("ExecuteBatch"); fillContract.executeBatch(signedOrders); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteBatch"); assertEq(tokenOut.balanceOf(swapper), totalOutputAmount); assertEq(tokenIn.balanceOf(address(fillContract)), totalInputAmount); @@ -345,9 +340,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true); emit Fill(orderHashes[1], address(fillContract), swapper, orders[1].info.nonce); - _snapStart("ExecuteBatchNativeOutput"); fillContract.executeBatch(signedOrders); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteBatchNativeOutput"); assertEq(swapper.balance, totalOutputAmount); assertEq(tokenIn.balanceOf(address(fillContract)), totalInputAmount); @@ -397,9 +391,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true); emit Fill(orderHashes[1], address(fillContract), swapper, orders[1].info.nonce); - _snapStart("ExecuteBatchMultipleOutputs"); fillContract.executeBatch(signedOrders); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteBatchMultipleOutputs"); assertEq(tokenOut.balanceOf(swapper), totalOutputAmount); assertEq(tokenIn.balanceOf(address(fillContract)), totalInputAmount); @@ -454,9 +447,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { vm.expectEmit(true, true, true, true); emit Fill(orderHashes[1], address(fillContract), swapper, orders[1].info.nonce); - _snapStart("ExecuteBatchMultipleOutputsDifferentTokens"); fillContract.executeBatch(signedOrders); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExecuteBatchMultipleOutputsDifferentTokens"); assertEq(tokenOut.balanceOf(swapper), totalOutputAmount1); assertEq(tokenOut2.balanceOf(swapper), totalOutputAmount2); @@ -555,9 +547,8 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { ? OrderAlreadyFilled.selector : InvalidNonce.selector; vm.expectRevert(revertData); - _snapStart("RevertInvalidNonce"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("RevertInvalidNonce"); } /// @dev Test executing two orders on two reactors at once @@ -856,8 +847,4 @@ abstract contract BaseReactorTest is ReactorEvents, Test, DeployPermit2 { swapperOutputBalanceStart = tokenOut.balanceOf(address(swapper)); fillContractOutputBalanceStart = tokenOut.balanceOf(address(fillContract)); } - - function _snapStart(string memory testName) internal { - vm.startSnapshotGas(string.concat("Base-", name(), "-", testName)); - } } diff --git a/test/reactors/PriorityOrderReactor.t.sol b/test/reactors/PriorityOrderReactor.t.sol index 96cead56..b0fff28b 100644 --- a/test/reactors/PriorityOrderReactor.t.sol +++ b/test/reactors/PriorityOrderReactor.t.sol @@ -129,9 +129,8 @@ contract PriorityOrderReactorTest is PermitSignature, DeployPermit2, BaseReactor vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("OutputPriorityFee"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("OutputPriorityFee"); assertEq(tokenOut.balanceOf(address(swapper)), swapperOutputBalanceStart + scaledOutputAmount); assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - inputAmount); @@ -182,9 +181,8 @@ contract PriorityOrderReactorTest is PermitSignature, DeployPermit2, BaseReactor vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("OutputPriorityFeeAndBaselinePriorityFee"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("OutputPriorityFeeAndBaselinePriorityFee"); assertEq(tokenOut.balanceOf(address(swapper)), swapperOutputBalanceStart + scaledOutputAmount); assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - inputAmount); @@ -286,9 +284,8 @@ contract PriorityOrderReactorTest is PermitSignature, DeployPermit2, BaseReactor vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("InputPriorityFee"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("InputPriorityFee"); assertEq(tokenIn.balanceOf(address(swapper)), swapperInputBalanceStart - scaledInputAmount); assertEq(tokenOut.balanceOf(address(swapper)), swapperOutputBalanceStart + outputAmount); @@ -321,9 +318,8 @@ contract PriorityOrderReactorTest is PermitSignature, DeployPermit2, BaseReactor vm.expectEmit(true, true, true, true, address(reactor)); emit Fill(orderHash, address(fillContract), swapper, order.info.nonce); // execute order - _snapStart("OverrideAuctionTargetBlock"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("OverrideAuctionTargetBlock"); } /// @notice an order can be filled at any time after the auctionStartBlock and before the deadline diff --git a/test/reactors/V2DutchOrderReactor.t.sol b/test/reactors/V2DutchOrderReactor.t.sol index d79ccb0f..1c23cd04 100644 --- a/test/reactors/V2DutchOrderReactor.t.sol +++ b/test/reactors/V2DutchOrderReactor.t.sol @@ -275,9 +275,8 @@ contract V2DutchOrderTest is PermitSignature, DeployPermit2, BaseDutchOrderReact SignedOrder memory signedOrder = SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order)); - _snapStart("InputOverride"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("InputOverride"); assertEq(tokenIn.balanceOf(swapper), 0); assertEq(tokenOut.balanceOf(swapper), outputAmount); @@ -311,9 +310,8 @@ contract V2DutchOrderTest is PermitSignature, DeployPermit2, BaseDutchOrderReact SignedOrder memory signedOrder = SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order)); - _snapStart("OutputOverride"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("OutputOverride"); assertEq(tokenIn.balanceOf(swapper), 0); assertEq(tokenOut.balanceOf(swapper), overriddenOutputAmount); @@ -377,9 +375,8 @@ contract V2DutchOrderTest is PermitSignature, DeployPermit2, BaseDutchOrderReact SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order)); vm.prank(address(1)); - _snapStart("ExclusiveFiller"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("ExclusiveFiller"); assertEq(tokenIn.balanceOf(swapper), 0); assertEq(tokenOut.balanceOf(swapper), outputAmount); diff --git a/test/reactors/V3DutchOrderReactor.t.sol b/test/reactors/V3DutchOrderReactor.t.sol index b15e37ef..182db6f6 100644 --- a/test/reactors/V3DutchOrderReactor.t.sol +++ b/test/reactors/V3DutchOrderReactor.t.sol @@ -218,9 +218,8 @@ contract V3DutchOrderTest is PermitSignature, DeployPermit2, BaseReactorTest { SignedOrder memory signedOrder = SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order)); - _snapStart("V3-InputOverride"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("V3-InputOverride"); assertEq(tokenIn.balanceOf(swapper), 0); assertEq(tokenOut.balanceOf(swapper), outputAmount); @@ -256,9 +255,8 @@ contract V3DutchOrderTest is PermitSignature, DeployPermit2, BaseReactorTest { SignedOrder memory signedOrder = SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order)); - _snapStart("V3-OutputOverride"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("V3-OutputOverride"); assertEq(tokenIn.balanceOf(swapper), 0); assertEq(tokenOut.balanceOf(swapper), overriddenOutputAmount); @@ -326,9 +324,8 @@ contract V3DutchOrderTest is PermitSignature, DeployPermit2, BaseReactorTest { SignedOrder(abi.encode(order), signOrder(swapperPrivateKey, address(permit2), order)); vm.prank(address(1)); - _snapStart("V3-ExclusiveFiller"); fillContract.execute(signedOrder); - vm.stopSnapshotGas(); + vm.snapshotGasLastCall("V3-ExclusiveFiller"); assertEq(tokenIn.balanceOf(swapper), 0); assertEq(tokenOut.balanceOf(swapper), outputAmount);