diff --git a/.gas-snapshot b/.gas-snapshot index 4b90960e8..fe6a27ab8 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,9 +1,9 @@ BaseRainterpreterExternNPE2IERC165Test:testRainterpreterExternNPE2IERC165(bytes4) (runs: 2055, μ: 320946, ~: 320946) BaseRainterpreterSubParserNPE2IERC165Test:testRainterpreterSubParserNPE2IERC165(uint32) (runs: 2055, μ: 678755, ~: 678755) -LibAllStandardOpsTest:testIntegrityAndOpcodeFunctionPointersLength() (gas: 48524) -LibAllStandardOpsTest:testIntegrityFunctionPointersLength() (gas: 8154) -LibAllStandardOpsTest:testOpcodeFunctionPointersLength() (gas: 8136) -LibEvalFBoundsTest:testEvalNPFBoundsModConstant(bytes32) (runs: 2055, μ: 84007, ~: 84007) +LibAllStandardOpsTest:testIntegrityAndOpcodeFunctionPointersLength() (gas: 50996) +LibAllStandardOpsTest:testIntegrityFunctionPointersLength() (gas: 8378) +LibAllStandardOpsTest:testOpcodeFunctionPointersLength() (gas: 8363) +LibEvalFBoundsTest:testEvalNPFBoundsModConstant(bytes32) (runs: 2055, μ: 84235, ~: 84235) LibExternCodecTest:testLibExternCodecEncodeExternCall(uint256,bytes32) (runs: 2055, μ: 9770, ~: 10284) LibExternCodecTest:testLibExternCodecEncodeExternDispatch(uint256,bytes32) (runs: 2055, μ: 8887, ~: 9401) LibInterpreterStateStackTraceTest:testStackTraceCall(uint256,uint256,uint256[]) (runs: 2055, μ: 43067, ~: 42630) @@ -19,10 +19,10 @@ LibOpAddTest:testOpAddEvalOperandDisallowed() (gas: 91501) LibOpAddTest:testOpAddEvalTwoOutput() (gas: 43976) LibOpAddTest:testOpAddEvalZeroInputs() (gas: 30212) LibOpAddTest:testOpAddEvalZeroOutputs() (gas: 42994) -LibOpAddTest:testOpAddIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18199, ~: 18427) +LibOpAddTest:testOpAddIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18199, ~: 18434) LibOpAddTest:testOpAddIntegrityUnhappyOneInput((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13868, ~: 13733) LibOpAddTest:testOpAddIntegrityUnhappyZeroInputs((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13865, ~: 13730) -LibOpAddTest:testOpAddRun(bytes32[]) (runs: 2049, μ: 52153, ~: 51723) +LibOpAddTest:testOpAddRun(bytes32[]) (runs: 2049, μ: 52173, ~: 52128) LibOpBinaryEqualToTest:testOpBinaryEqualToEval2() (gas: 207750) LibOpBinaryEqualToTest:testOpBinaryEqualToEval2InputsBothOne() (gas: 57822) LibOpBinaryEqualToTest:testOpBinaryEqualToEval2InputsFirstOneSecondZero() (gas: 58551) @@ -31,7 +31,7 @@ LibOpBinaryEqualToTest:testOpBinaryEqualToEval2ZeroInputs() (gas: 57867) LibOpBinaryEqualToTest:testOpBinaryEqualToEvalFail0Inputs() (gas: 30615) LibOpBinaryEqualToTest:testOpBinaryEqualToEvalFail1Input() (gas: 34935) LibOpBinaryEqualToTest:testOpBinaryEqualToEvalFail3Inputs() (gas: 43434) -LibOpBinaryEqualToTest:testOpBinaryEqualToIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19696, ~: 19966) +LibOpBinaryEqualToTest:testOpBinaryEqualToIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19688, ~: 19947) LibOpBinaryEqualToTest:testOpBinaryEqualToRun(bytes32,bytes32) (runs: 2055, μ: 16674, ~: 16674) LibOpBinaryEqualToTest:testOpBinaryEqualToTwoOutputs() (gas: 41593) LibOpBinaryEqualToTest:testOpBinaryEqualToZeroOutputs() (gas: 40524) @@ -53,33 +53,33 @@ LibOpBitwiseOrNPTest:testOpBitwiseORNPEvalZeroInputs() (gas: 30668) LibOpBitwiseOrNPTest:testOpBitwiseORNPEvalZeroOutputs() (gas: 40237) LibOpBitwiseOrNPTest:testOpBitwiseORNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 13747, ~: 13660) LibOpBitwiseOrNPTest:testOpBitwiseORNPRun(bytes32,bytes32) (runs: 2055, μ: 16628, ~: 16628) -LibOpBlockNumberTest:testOpBlockNumberEval(uint256) (runs: 2055, μ: 50954, ~: 50726) +LibOpBlockNumberTest:testOpBlockNumberEval(uint256) (runs: 2055, μ: 50952, ~: 50726) LibOpBlockNumberTest:testOpBlockNumberEvalOneInput() (gas: 35162) LibOpBlockNumberTest:testOpBlockNumberEvalTwoOutputs() (gas: 31463) LibOpBlockNumberTest:testOpBlockNumberEvalZeroOutputs() (gas: 30454) -LibOpBlockNumberTest:testOpBlockNumberIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19653, ~: 19915) -LibOpBlockNumberTest:testOpBlockNumberRun(uint256,uint16) (runs: 2055, μ: 20845, ~: 20508) +LibOpBlockNumberTest:testOpBlockNumberIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19644, ~: 19915) +LibOpBlockNumberTest:testOpBlockNumberRun(uint256,uint16) (runs: 2055, μ: 20844, ~: 20508) LibOpCallTest:testCallTraceInnerOnly() (gas: 62979) LibOpCallTest:testCallTraceOuterOnly() (gas: 45549) -LibOpCallTest:testOpCallNPIntegrityIO((uint256,uint256,uint256,bytes32[],uint256,bytes),uint256,uint256,uint8,bytes32) (runs: 2054, μ: 39770, ~: 38479) -LibOpCallTest:testOpCallNPIntegritySourceIndexOutOfBounds((uint256,uint256,uint256,bytes32[],uint256,bytes),uint256,uint256,uint256,uint256,bytes32) (runs: 2055, μ: 59250, ~: 58566) -LibOpCallTest:testOpCallNPIntegrityTooManyOutputs((uint256,uint256,uint256,bytes32[],uint256,bytes),uint256,uint256,uint8,bytes32) (runs: 2051, μ: 58500, ~: 58712) +LibOpCallTest:testOpCallNPIntegrityIO((uint256,uint256,uint256,bytes32[],uint256,bytes),uint256,uint256,uint8,bytes32) (runs: 2053, μ: 39779, ~: 38378) +LibOpCallTest:testOpCallNPIntegritySourceIndexOutOfBounds((uint256,uint256,uint256,bytes32[],uint256,bytes),uint256,uint256,uint256,uint256,bytes32) (runs: 2055, μ: 59390, ~: 58878) +LibOpCallTest:testOpCallNPIntegrityTooManyOutputs((uint256,uint256,uint256,bytes32[],uint256,bytes),uint256,uint256,uint8,bytes32) (runs: 2050, μ: 58949, ~: 59532) LibOpCallTest:testOpCallNPRunInputsMismatch() (gas: 71893) LibOpCallTest:testOpCallNPRunOutputsMismatch() (gas: 65508) LibOpCallTest:testOpCallNPRunSourceDoesNotExist() (gas: 350425) LibOpChainIdTest:testOpChainIDEval(uint64) (runs: 2055, μ: 47017, ~: 47017) -LibOpChainIdTest:testOpChainIDIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19677, ~: 19944) +LibOpChainIdTest:testOpChainIDIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19677, ~: 19906) LibOpChainIdTest:testOpChainIdEvalFail() (gas: 34336) LibOpChainIdTest:testOpChainIdRun(uint64,uint16) (runs: 2055, μ: 17123, ~: 17123) LibOpChainIdTest:testOpChainIdTwoOutputs() (gas: 31140) LibOpChainIdTest:testOpChainIdZeroOutputs() (gas: 30089) LibOpConstantTest:testOpConstantEvalNPE2E() (gas: 56065) LibOpConstantTest:testOpConstantEvalZeroConstants() (gas: 41509) -LibOpConstantTest:testOpConstantNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 19197, ~: 19102) -LibOpConstantTest:testOpConstantNPIntegrityOOBConstants((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 40155, ~: 39809) +LibOpConstantTest:testOpConstantNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 19194, ~: 19102) +LibOpConstantTest:testOpConstantNPIntegrityOOBConstants((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 40159, ~: 39809) LibOpConstantTest:testOpConstantNPMultipleOutputErrorSugared() (gas: 31648) LibOpConstantTest:testOpConstantNPMultipleOutputErrorUnsugared() (gas: 41588) -LibOpConstantTest:testOpConstantNPRun(bytes32[],uint16) (runs: 2055, μ: 52463, ~: 51854) +LibOpConstantTest:testOpConstantNPRun(bytes32[],uint16) (runs: 2055, μ: 52464, ~: 51854) LibOpConstantTest:testOpConstantNPZeroOutputErrorSugared() (gas: 30264) LibOpConstantTest:testOpConstantNPZeroOutputErrorUnsugared() (gas: 40216) LibOpContextNPTest:testOpContextNPEval00(bytes32[][]) (runs: 107, μ: 6552666, ~: 5288363) @@ -90,13 +90,13 @@ LibOpContextNPTest:testOpContextNPEvalOOBi(bytes32[]) (runs: 107, μ: 75273, ~: LibOpContextNPTest:testOpContextNPEvalOOBj(bytes32) (runs: 2055, μ: 48210, ~: 48210) LibOpContextNPTest:testOpContextNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 14499, ~: 14412) LibOpContextNPTest:testOpContextNPOneInput() (gas: 41587) -LibOpContextNPTest:testOpContextNPRun(bytes32[][],uint256,uint256) (runs: 107, μ: 10315057, ~: 7525557) -LibOpContextNPTest:testOpContextNPRunOOBi(bytes32[][],uint256,uint256) (runs: 107, μ: 10666713, ~: 8068784) -LibOpContextNPTest:testOpContextNPRunOOBj(bytes32[][],uint256,uint256) (runs: 107, μ: 10675800, ~: 8069699) +LibOpContextNPTest:testOpContextNPRun(bytes32[][],uint256,uint256) (runs: 107, μ: 10315059, ~: 7525557) +LibOpContextNPTest:testOpContextNPRunOOBi(bytes32[][],uint256,uint256) (runs: 107, μ: 10666711, ~: 8068784) +LibOpContextNPTest:testOpContextNPRunOOBj(bytes32[][],uint256,uint256) (runs: 107, μ: 10675801, ~: 8069699) LibOpContextNPTest:testOpContextNPTwoInputs() (gas: 46451) LibOpContextNPTest:testOpContextNPTwoOutputs() (gas: 37255) LibOpContextNPTest:testOpContextNPZeroOutputs() (gas: 36203) -LibOpCtPopNPTest:testOpCtPopNPEval(bytes32) (runs: 2055, μ: 74155, ~: 85238) +LibOpCtPopNPTest:testOpCtPopNPEval(bytes32) (runs: 2055, μ: 74578, ~: 85264) LibOpCtPopNPTest:testOpCtPopNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 13746, ~: 13659) LibOpCtPopNPTest:testOpCtPopNPRun(bytes32) (runs: 2055, μ: 16698, ~: 16698) LibOpCtPopNPTest:testOpCtPopNPTwoInputs() (gas: 41134) @@ -108,10 +108,10 @@ LibOpDecodeBitsNPTest:testOpDecodeBitsNPEvalTwoInputs() (gas: 46963) LibOpDecodeBitsNPTest:testOpDecodeBitsNPEvalTwoOutputs() (gas: 42815) LibOpDecodeBitsNPTest:testOpDecodeBitsNPEvalZeroInputs() (gas: 37145) LibOpDecodeBitsNPTest:testOpDecodeBitsNPEvalZeroOutputs() (gas: 41762) -LibOpDecodeBitsNPTest:testOpDecodeBitsNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint8,uint8) (runs: 2055, μ: 22124, ~: 22237) -LibOpDecodeBitsNPTest:testOpDecodeBitsNPIntegrityFail((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8) (runs: 2055, μ: 41495, ~: 41545) +LibOpDecodeBitsNPTest:testOpDecodeBitsNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint8,uint8) (runs: 2055, μ: 22114, ~: 22261) +LibOpDecodeBitsNPTest:testOpDecodeBitsNPIntegrityFail((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8) (runs: 2055, μ: 41496, ~: 41536) LibOpDecodeBitsNPTest:testOpDecodeBitsNPIntegrityFailZeroLength((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8) (runs: 2055, μ: 35686, ~: 35423) -LibOpDecodeBitsNPTest:testOpDecodeBitsNPRun(bytes32,uint8,uint8) (runs: 2055, μ: 21004, ~: 20814) +LibOpDecodeBitsNPTest:testOpDecodeBitsNPRun(bytes32,uint8,uint8) (runs: 2055, μ: 21008, ~: 20814) LibOpDivTest:testDebugOpDivRun() (gas: 13482) LibOpDivTest:testOpDivEvalOneInput() (gas: 126303) LibOpDivTest:testOpDivEvalOperandsDisallowed() (gas: 91477) @@ -124,12 +124,12 @@ LibOpDivTest:testOpDivEvalTwoInputsUnhappyOverflow() (gas: 56399) LibOpDivTest:testOpDivEvalTwoOutputs() (gas: 41216) LibOpDivTest:testOpDivEvalZeroInputs() (gas: 30168) LibOpDivTest:testOpDivEvalZeroOutputs() (gas: 40212) -LibOpDivTest:testOpDivIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18250, ~: 18486) +LibOpDivTest:testOpDivIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18249, ~: 18479) LibOpDivTest:testOpDivIntegrityUnhappyOneInput((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13821, ~: 13686) LibOpDivTest:testOpDivIntegrityUnhappyZeroInputs((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13844, ~: 13709) -LibOpDivTest:testOpDivRun(bytes32[]) (runs: 2049, μ: 37632, ~: 33610) +LibOpDivTest:testOpDivRun(bytes32[]) (runs: 2049, μ: 37542, ~: 33508) LibOpERC20AllowanceTest:testOpERC20AllowanceEvalFourInputs() (gas: 55846) -LibOpERC20AllowanceTest:testOpERC20AllowanceEvalHappy(uint256,uint8) (runs: 2055, μ: 72125, ~: 72039) +LibOpERC20AllowanceTest:testOpERC20AllowanceEvalHappy(uint256,uint8) (runs: 2055, μ: 72140, ~: 72039) LibOpERC20AllowanceTest:testOpERC20AllowanceEvalOneInput() (gas: 37102) LibOpERC20AllowanceTest:testOpERC20AllowanceEvalOperandDisallowed() (gas: 18606) LibOpERC20AllowanceTest:testOpERC20AllowanceEvalTwoInputs() (gas: 43633) @@ -137,11 +137,11 @@ LibOpERC20AllowanceTest:testOpERC20AllowanceEvalTwoOutputs() (gas: 50665) LibOpERC20AllowanceTest:testOpERC20AllowanceEvalZeroInputs() (gas: 31108) LibOpERC20AllowanceTest:testOpERC20AllowanceEvalZeroOutputs() (gas: 49641) LibOpERC20AllowanceTest:testOpERC20AllowanceIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 13710, ~: 13623) -LibOpERC20AllowanceTest:testOpERC20AllowanceRun(address,address,address,uint256,uint8) (runs: 2055, μ: 27669, ~: 27579) +LibOpERC20AllowanceTest:testOpERC20AllowanceRun(address,address,address,uint256,uint8) (runs: 2055, μ: 27668, ~: 27579) LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalHappy(uint256,uint8) (runs: 2051, μ: 66052, ~: 66052) LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalOneInput() (gas: 37207) LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalOperandDisallowed() (gas: 18664) -LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalOverflow(uint256,uint8) (runs: 2050, μ: 62325, ~: 62325) +LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalOverflow(uint256,uint8) (runs: 2049, μ: 62325, ~: 62325) LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalThreeInputs() (gas: 49534) LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalTwoOutputs() (gas: 44403) LibOpERC20BalanceOfTest:testOpERC20BalanceOfEvalZeroInputs() (gas: 31167) @@ -165,11 +165,23 @@ LibOpERC5313OwnerNPTest:testOpERC5313OwnerNPEvalZeroInputs() (gas: 30924) LibOpERC5313OwnerNPTest:testOpERC5313OwnerNPEvalZeroOutputs() (gas: 36624) LibOpERC5313OwnerNPTest:testOpERC5313OwnerOfNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 13748, ~: 13661) LibOpERC5313OwnerNPTest:testOpERC5313OwnerOfNPRun(address,address,uint16) (runs: 2055, μ: 23614, ~: 23614) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfEvalHappy(address,address,uint256) (runs: 2052, μ: 105309, ~: 105463) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19660, ~: 19920) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFail0() (gas: 30811) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFail1() (gas: 35101) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFail3() (gas: 44535) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFailOperand() (gas: 21548) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfOneInput() (gas: 35568) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfRun(address,address,uint256,uint16) (runs: 2052, μ: 26008, ~: 26008) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfThreeInputs() (gas: 45055) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfTwoOutputs() (gas: 41062) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfZeroInputs() (gas: 31245) +LibOpERC721BalanceOfTest:testOpERC721BalanceOfZeroOutputs() (gas: 39879) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalFail0() (gas: 30694) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalFail1() (gas: 34982) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalFail3() (gas: 44471) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalFailOperand() (gas: 18197) -LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalHappy(address,uint256,address) (runs: 2055, μ: 96390, ~: 92399) +LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalHappy(address,uint256,address) (runs: 2055, μ: 96647, ~: 93206) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalOneInput() (gas: 35440) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalThreeInputs() (gas: 44936) LibOpERC721OwnerOfTest:testOpERC721OwnerOfNPEvalZeroInputs() (gas: 31141) @@ -183,10 +195,10 @@ LibOpEncodeBitsNPTest:testOpEncodeBitsNPEvalThreeInputs() (gas: 51785) LibOpEncodeBitsNPTest:testOpEncodeBitsNPEvalTwoOutputs() (gas: 47611) LibOpEncodeBitsNPTest:testOpEncodeBitsNPEvalZeroInputs() (gas: 37059) LibOpEncodeBitsNPTest:testOpEncodeBitsNPEvalZeroOutputs() (gas: 46607) -LibOpEncodeBitsNPTest:testOpEncodeBitsNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8) (runs: 2055, μ: 18149, ~: 18135) -LibOpEncodeBitsNPTest:testOpEncodeBitsNPIntegrityFail((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8) (runs: 2055, μ: 41695, ~: 41753) +LibOpEncodeBitsNPTest:testOpEncodeBitsNPIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8) (runs: 2055, μ: 18140, ~: 18135) +LibOpEncodeBitsNPTest:testOpEncodeBitsNPIntegrityFail((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8) (runs: 2055, μ: 41706, ~: 41753) LibOpEncodeBitsNPTest:testOpEncodeBitsNPIntegrityFailZeroLength((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8) (runs: 2055, μ: 35815, ~: 35552) -LibOpEncodeBitsNPTest:testOpEncodeBitsNPRun(bytes32,bytes32,uint8,uint8) (runs: 2055, μ: 21398, ~: 21212) +LibOpEncodeBitsNPTest:testOpEncodeBitsNPRun(bytes32,bytes32,uint8,uint8) (runs: 2055, μ: 21403, ~: 21212) LibOpEnsureTest:testOpEnsureEvalBadOutputs() (gas: 34422) LibOpEnsureTest:testOpEnsureEvalBadOutputs2() (gas: 33947) LibOpEnsureTest:testOpEnsureEvalHappy() (gas: 166193) @@ -195,7 +207,7 @@ LibOpEnsureTest:testOpEnsureEvalThree() (gas: 45346) LibOpEnsureTest:testOpEnsureEvalUnhappy() (gas: 111833) LibOpEnsureTest:testOpEnsureEvalUnhappyOperand() (gas: 17047) LibOpEnsureTest:testOpEnsureEvalZero() (gas: 29624) -LibOpEnsureTest:testOpEnsureIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19720, ~: 20002) +LibOpEnsureTest:testOpEnsureIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19720, ~: 19989) LibOpEnsureTest:testOpEnsureIntegrityUnhappy((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13812, ~: 13677) LibOpEnsureTest:testOpEnsureOneOutput() (gas: 39583) LibOpEnsureTest:testOpEnsureRun(bytes32,string) (runs: 2051, μ: 18144, ~: 18151) @@ -208,14 +220,14 @@ LibOpEqualToNPTest:testOpEqualToEvalFail0Inputs() (gas: 30048) LibOpEqualToNPTest:testOpEqualToEvalFail1Input() (gas: 34359) LibOpEqualToNPTest:testOpEqualToEvalFail3Inputs() (gas: 42783) LibOpEqualToNPTest:testOpEqualToIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19675, ~: 19925) -LibOpEqualToNPTest:testOpEqualToRun(bytes32,bytes32) (runs: 2055, μ: 17541, ~: 17466) +LibOpEqualToNPTest:testOpEqualToRun(bytes32,bytes32) (runs: 2055, μ: 17542, ~: 17466) LibOpEqualToNPTest:testOpEqualToTwoOutputs() (gas: 41048) LibOpEqualToNPTest:testOpEqualToZeroOutputs() (gas: 39957) LibOpExternNPTest:testOpExternNPEvalHappy() (gas: 99749) LibOpExternNPTest:testOpExternNPEvalMultipleInputsOutputsHappy() (gas: 115319) -LibOpExternNPTest:testOpExternNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),address,uint16,uint8,uint8) (runs: 2054, μ: 34958, ~: 34884) -LibOpExternNPTest:testOpExternNPIntegrityNotAnExternContract((uint256,uint256,uint256,bytes32[],uint256,bytes),address,uint16,uint8,uint8) (runs: 2054, μ: 53463, ~: 53472) -LibOpExternNPTest:testOpExternNPRunHappy(address,bytes32[],uint16,bytes32[],bytes32[]) (runs: 2055, μ: 117800, ~: 117748) +LibOpExternNPTest:testOpExternNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),address,uint16,uint8,uint8) (runs: 2055, μ: 34923, ~: 34954) +LibOpExternNPTest:testOpExternNPIntegrityNotAnExternContract((uint256,uint256,uint256,bytes32[],uint256,bytes),address,uint16,uint8,uint8) (runs: 2055, μ: 53367, ~: 53346) +LibOpExternNPTest:testOpExternNPRunHappy(address,bytes32[],uint16,bytes32[],bytes32[]) (runs: 2055, μ: 117917, ~: 117763) LibOpGetTest:testLibOpGetEvalKeyNotSet() (gas: 308623) LibOpGetTest:testLibOpGetEvalOperandDisallowed() (gas: 57488) LibOpGetTest:testLibOpGetEvalSetThenGet() (gas: 522490) @@ -226,7 +238,7 @@ LibOpGetTest:testLibOpGetEvalTwoInputs() (gas: 39742) LibOpGetTest:testLibOpGetEvalTwoOutputs() (gas: 35334) LibOpGetTest:testLibOpGetEvalZeroInputs() (gas: 29757) LibOpGetTest:testLibOpGetEvalZeroOutputs() (gas: 34304) -LibOpGetTest:testLibOpGetIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 20559, ~: 20799) +LibOpGetTest:testLibOpGetIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 20557, ~: 20839) LibOpGetTest:testLibOpGetRunState(bytes32,bytes32,uint16) (runs: 2055, μ: 19634, ~: 19638) LibOpGetTest:testLibOpGetRunStateAndStore(bytes32,bytes32,bytes32,uint16) (runs: 2055, μ: 47596, ~: 47610) LibOpGetTest:testLibOpGetRunStore(bytes32,bytes32,uint16) (runs: 2055, μ: 49831, ~: 49835) @@ -243,8 +255,8 @@ LibOpGreaterThanTest:testOpGreaterThanEvalFail1Input() (gas: 34737) LibOpGreaterThanTest:testOpGreaterThanEvalFail3Inputs() (gas: 43078) LibOpGreaterThanTest:testOpGreaterThanEvalNeg1Gt0() (gas: 58666) LibOpGreaterThanTest:testOpGreaterThanEvalNeg1_1GtNeg1_2() (gas: 61370) -LibOpGreaterThanTest:testOpGreaterThanIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19683, ~: 19923) -LibOpGreaterThanTest:testOpGreaterThanRun(bytes32,bytes32) (runs: 2055, μ: 17419, ~: 17347) +LibOpGreaterThanTest:testOpGreaterThanIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19686, ~: 19961) +LibOpGreaterThanTest:testOpGreaterThanRun(bytes32,bytes32) (runs: 2055, μ: 17418, ~: 17347) LibOpGreaterThanTest:testOpGreaterThanTwoOutputs() (gas: 41835) LibOpGreaterThanTest:testOpGreaterThanZeroOutputs() (gas: 40787) LibOpHashNPTest:testOpHashNPEval0Inputs() (gas: 46285) @@ -252,13 +264,13 @@ LibOpHashNPTest:testOpHashNPEval1Input() (gas: 54893) LibOpHashNPTest:testOpHashNPEval2Inputs() (gas: 63237) LibOpHashNPTest:testOpHashNPEval2InputsDifferent() (gas: 63910) LibOpHashNPTest:testOpHashNPEval2InputsOtherStack() (gas: 78464) -LibOpHashNPTest:testOpHashNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19711, ~: 19956) +LibOpHashNPTest:testOpHashNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19711, ~: 19975) LibOpHashNPTest:testOpHashNPRun(bytes32[]) (runs: 2049, μ: 19459, ~: 19563) LibOpHashNPTest:testOpHashNPTwoOutputs() (gas: 30825) LibOpHashNPTest:testOpHashNPZeroOutputs() (gas: 29451) LibOpLessThanTest:testOpLessThanEval2InputsFirstZeroSecondOne() (gas: 58390) LibOpLessThanTest:testOpLessThanEval2ZeroInputs() (gas: 57639) -LibOpLessThanTest:testOpLessThanIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19697, ~: 19979) +LibOpLessThanTest:testOpLessThanIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19697, ~: 19947) LibOpLessThanTest:testOpLessThanNP1_0Lt1() (gas: 58392) LibOpLessThanTest:testOpLessThanNP1_1Lt1_2() (gas: 60882) LibOpLessThanTest:testOpLessThanNPEval2InputsBothOne() (gas: 57663) @@ -277,19 +289,19 @@ LibOpMaxTest:testOpMaxEvalOneInput() (gas: 129040) LibOpMaxTest:testOpMaxEvalOperandDisallowed() (gas: 58885) LibOpMaxTest:testOpMaxEvalTwoOutputs() (gas: 40731) LibOpMaxTest:testOpMaxEvalZeroInputs() (gas: 30170) -LibOpMaxTest:testOpMaxIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18205, ~: 18365) +LibOpMaxTest:testOpMaxIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18199, ~: 18381) LibOpMaxTest:testOpMaxIntegrityUnhappyOneInput((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13822, ~: 13687) LibOpMaxTest:testOpMaxIntegrityUnhappyZeroInputs((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13844, ~: 13709) -LibOpMaxTest:testOpMaxRun(bytes32[]) (runs: 2049, μ: 26607, ~: 26371) +LibOpMaxTest:testOpMaxRun(bytes32[]) (runs: 2049, μ: 26611, ~: 26345) LibOpMaxUint256Test:testOpMaxUint256Eval() (gas: 47280) LibOpMaxUint256Test:testOpMaxUint256EvalFail() (gas: 35109) -LibOpMaxUint256Test:testOpMaxUint256Integrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19652, ~: 19883) +LibOpMaxUint256Test:testOpMaxUint256Integrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19651, ~: 19924) LibOpMaxUint256Test:testOpMaxUint256Run() (gas: 15997) LibOpMaxUint256Test:testOpMaxUint256TwoOutputs() (gas: 31892) LibOpMaxUint256Test:testOpMaxUint256ZeroOutputs() (gas: 30797) LibOpMaxValueTest:testOpMaxValueEval() (gas: 46896) LibOpMaxValueTest:testOpMaxValueEvalFail() (gas: 34417) -LibOpMaxValueTest:testOpMaxValueIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19642, ~: 19877) +LibOpMaxValueTest:testOpMaxValueIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19648, ~: 19921) LibOpMaxValueTest:testOpMaxValueRun() (gas: 16217) LibOpMaxValueTest:testOpMaxValueTwoOutputs() (gas: 31266) LibOpMaxValueTest:testOpMaxValueZeroOutputs() (gas: 30171) @@ -298,10 +310,10 @@ LibOpMinTest:testOpMinEval3InputsHappy() (gas: 3458613) LibOpMinTest:testOpMinEvalOneInput() (gas: 126204) LibOpMinTest:testOpMinEvalOperandDisallowed() (gas: 58908) LibOpMinTest:testOpMinEvalZeroInputs() (gas: 30150) -LibOpMinTest:testOpMinIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18278, ~: 18516) +LibOpMinTest:testOpMinIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18281, ~: 18516) LibOpMinTest:testOpMinIntegrityUnhappyOneInput((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13845, ~: 13710) LibOpMinTest:testOpMinIntegrityUnhappyZeroInputs((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13822, ~: 13687) -LibOpMinTest:testOpMinRun(bytes32[],uint16) (runs: 2049, μ: 26539, ~: 26627) +LibOpMinTest:testOpMinRun(bytes32[],uint16) (runs: 2049, μ: 26553, ~: 26649) LibOpMulTest:testOpDecimal18MulNPIntegrityUnhappyOneInput((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13823, ~: 13688) LibOpMulTest:testOpMulEvalOneInput() (gas: 126238) LibOpMulTest:testOpMulEvalOperandsDisallowed() (gas: 91499) @@ -310,9 +322,9 @@ LibOpMulTest:testOpMulEvalThreeInputsUnhappyOverflow() (gas: 60803) LibOpMulTest:testOpMulEvalTwoInputsHappy() (gas: 522883) LibOpMulTest:testOpMulEvalTwoInputsUnhappyOverflow() (gas: 54354) LibOpMulTest:testOpMulEvalZeroInputs() (gas: 30213) -LibOpMulTest:testOpMulIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18243, ~: 18470) +LibOpMulTest:testOpMulIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18239, ~: 18470) LibOpMulTest:testOpMulIntegrityUnhappyZeroInputs((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13866, ~: 13731) -LibOpMulTest:testOpMulRun(bytes32[]) (runs: 2049, μ: 28977, ~: 26565) +LibOpMulTest:testOpMulRun(bytes32[]) (runs: 2049, μ: 28963, ~: 26565) LibOpMulTest:testOpMulTwoOutputs() (gas: 40752) LibOpMulTest:testOpMulZeroOutputs() (gas: 39706) LibOpSetTest:testLibOpSet(bytes32,bytes32) (runs: 2055, μ: 17660, ~: 17665) @@ -324,50 +336,50 @@ LibOpSetTest:testLibOpSetEvalThreeInputs() (gas: 44625) LibOpSetTest:testLibOpSetEvalTwoInputs() (gas: 258452) LibOpSetTest:testLibOpSetEvalTwoOutputs() (gas: 40451) LibOpSetTest:testLibOpSetEvalZeroInputs() (gas: 29372) -LibOpSetTest:testLibOpSetIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 20441, ~: 20691) +LibOpSetTest:testLibOpSetIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 20431, ~: 20673) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPEval() (gas: 878842) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityFailBadShiftAmount() (gas: 128113) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityFailTwoInputs() (gas: 44447) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityFailTwoOutputs() (gas: 40331) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityFailZeroInputs() (gas: 34606) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityFailZeroOutputs() (gas: 39256) -LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint8) (runs: 2054, μ: 19758, ~: 19739) +LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint8) (runs: 2054, μ: 19759, ~: 19698) LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityNoop((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8) (runs: 2055, μ: 35780, ~: 35518) -LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityZero((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 41983, ~: 42651) -LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPRun(bytes32,uint8) (runs: 2054, μ: 16833, ~: 16833) +LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPIntegrityZero((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 41979, ~: 42523) +LibOpShiftBitsLeftNPTest:testOpShiftBitsLeftNPRun(bytes32,uint8) (runs: 2055, μ: 16833, ~: 16833) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPEval() (gas: 1053755) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPIntegrityFailBadShiftAmount() (gas: 128703) -LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint8) (runs: 106, μ: 19584, ~: 18955) +LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint8) (runs: 106, μ: 19698, ~: 19207) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPIntegrityNoop((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8) (runs: 107, μ: 36662, ~: 36899) -LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPIntegrityZero((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 107, μ: 40506, ~: 41169) -LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPRun(bytes32,uint8) (runs: 2055, μ: 16836, ~: 16836) +LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPIntegrityZero((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 107, μ: 40486, ~: 41169) +LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPRun(bytes32,uint8) (runs: 2054, μ: 16836, ~: 16836) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPTwoInputs() (gas: 44571) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPTwoOutputs() (gas: 40391) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPZeroInputs() (gas: 34665) LibOpShiftBitsRightNPTest:testOpShiftBitsRightNPZeroOutputs() (gas: 39340) LibOpStackNPTest:testOpStackEval() (gas: 65313) LibOpStackNPTest:testOpStackEvalSeveral() (gas: 87151) -LibOpStackNPTest:testOpStackNPIntegrity(bytes,uint256,bytes32[],bytes32) (runs: 2055, μ: 18894, ~: 18656) -LibOpStackNPTest:testOpStackNPIntegrityOOBStack(bytes,uint16,bytes32[],uint16,uint256) (runs: 2055, μ: 41427, ~: 41563) +LibOpStackNPTest:testOpStackNPIntegrity(bytes,uint256,bytes32[],bytes32) (runs: 2055, μ: 18899, ~: 18713) +LibOpStackNPTest:testOpStackNPIntegrityOOBStack(bytes,uint16,bytes32[],uint16,uint256) (runs: 2055, μ: 41430, ~: 41563) LibOpStackNPTest:testOpStackNPMultipleOutputErrorSugared() (gas: 39336) LibOpStackNPTest:testOpStackNPMultipleOutputErrorUnsugared() (gas: 42996) -LibOpStackNPTest:testOpStackNPRun(bytes32[][],uint256) (runs: 107, μ: 2082715, ~: 1866817) +LibOpStackNPTest:testOpStackNPRun(bytes32[][],uint256) (runs: 107, μ: 2082720, ~: 1866817) LibOpStackNPTest:testOpStackNPZeroOutputErrorSugared() (gas: 37881) LibOpStackNPTest:testOpStackNPZeroOutputErrorUnsugared() (gas: 41506) LibOpSubTest:testOpSubEvalOneInput() (gas: 128861) LibOpSubTest:testOpSubEvalThreeInputs() (gas: 226150) LibOpSubTest:testOpSubEvalTwoInputs() (gas: 342286) LibOpSubTest:testOpSubEvalZeroInputs() (gas: 30131) -LibOpSubTest:testOpSubIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18244, ~: 18476) +LibOpSubTest:testOpSubIntegrityHappy((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint16) (runs: 2055, μ: 18239, ~: 18469) LibOpSubTest:testOpSubIntegrityUnhappyOneInput((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13822, ~: 13687) LibOpSubTest:testOpSubIntegrityUnhappyZeroInputs((uint256,uint256,uint256,bytes32[],uint256,bytes)) (runs: 2055, μ: 13823, ~: 13688) -LibOpSubTest:testOpSubRun(bytes32[]) (runs: 2049, μ: 55784, ~: 55579) +LibOpSubTest:testOpSubRun(bytes32[]) (runs: 2049, μ: 55778, ~: 54811) LibOpTimestampTest:testOpBlockTimestampNPEvalFail() (gas: 65815) LibOpTimestampTest:testOpBlockTimestampNPTwoOutputs() (gas: 58732) LibOpTimestampTest:testOpBlockTimestampNPZeroOutputs() (gas: 56607) -LibOpTimestampTest:testOpTimestampEval(uint256) (runs: 2055, μ: 84987, ~: 84663) -LibOpTimestampTest:testOpTimestampIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19670, ~: 19920) -LibOpTimestampTest:testOpTimestampRun(uint256) (runs: 2055, μ: 20591, ~: 20364) +LibOpTimestampTest:testOpTimestampEval(uint256) (runs: 2055, μ: 84981, ~: 84663) +LibOpTimestampTest:testOpTimestampIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19658, ~: 19920) +LibOpTimestampTest:testOpTimestampRun(uint256) (runs: 2055, μ: 20586, ~: 20364) LibOpUint256ERC20AllowanceTest:testOpERC20AllowanceEvalFourInputs() (gas: 56648) LibOpUint256ERC20AllowanceTest:testOpERC20AllowanceEvalHappy(uint256) (runs: 2055, μ: 70276, ~: 70276) LibOpUint256ERC20AllowanceTest:testOpERC20AllowanceEvalOneInput() (gas: 37942) @@ -395,6 +407,18 @@ LibOpUint256ERC20TotalSupplyTest:testOpERC20TotalSupplyEvalZeroInputs() (gas: 32 LibOpUint256ERC20TotalSupplyTest:testOpERC20TotalSupplyEvalZeroOutputs() (gas: 37804) LibOpUint256ERC20TotalSupplyTest:testOpERC20TotalSupplyIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),bytes32) (runs: 2055, μ: 13793, ~: 13706) LibOpUint256ERC20TotalSupplyTest:testOpERC20TotalSupplyRun(address,uint256,uint16) (runs: 2055, μ: 23332, ~: 23332) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfEvalHappy(address,address,uint256) (runs: 2055, μ: 610932, ~: 104853) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfIntegrity((uint256,uint256,uint256,bytes32[],uint256,bytes),uint8,uint8,uint16) (runs: 2055, μ: 19674, ~: 19908) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFail0() (gas: 31459) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFail1() (gas: 35844) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFail3() (gas: 45183) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfIntegrityFailOperand() (gas: 22186) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfOneInput() (gas: 36374) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfRun(address,address,uint256,uint16) (runs: 2055, μ: 24211, ~: 24211) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfThreeInputs() (gas: 45703) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfTwoOutputs() (gas: 41700) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfZeroInputs() (gas: 31893) +LibOpUint256ERC721BalanceOfTest:testOpERC721BalanceOfZeroOutputs() (gas: 40675) LibParseCommentsTest:testParseCommentAfterSources() (gas: 69689) LibParseCommentsTest:testParseCommentBetweenSources() (gas: 69745) LibParseCommentsTest:testParseCommentInIgnoredLHS() (gas: 46231) @@ -753,19 +777,19 @@ LibParseUnexpectedRightParenTest:testParseUnexpectedRightParen() (gas: 50722) LibParseUnexpectedRightParenTest:testParseUnexpectedRightParenNested() (gas: 56990) LibSubParseSubParserExternTest:testLibSubParseSubParserExtern(address,uint8,uint8,uint8,uint16,uint8) (runs: 2055, μ: 13230, ~: 13163) LibSubParseSubParserExternTest:testLibSubParseSubParserExternConstantsHeightOverflow(address,uint256,uint8,uint8,uint16,uint8) (runs: 2055, μ: 11433, ~: 11167) -RainterpreterExpressionDeployerDeployCheckTest:testRainterpreterExpressionDeployerDeployNoEIP1820() (gas: 7535317) -RainterpreterExpressionDeployerDescribedByMetaV1Test:testRainterpreterExpressionDeployerDescribedByMetaV1Happy() (gas: 7545197) -RainterpreterExpressionDeployerIERC165Test:testRainterpreterExpressionDeployerIERC165(bytes4) (runs: 2055, μ: 7542758, ~: 7542758) +RainterpreterExpressionDeployerDeployCheckTest:testRainterpreterExpressionDeployerDeployNoEIP1820() (gas: 7584813) +RainterpreterExpressionDeployerDescribedByMetaV1Test:testRainterpreterExpressionDeployerDescribedByMetaV1Happy() (gas: 7594781) +RainterpreterExpressionDeployerIERC165Test:testRainterpreterExpressionDeployerIERC165(bytes4) (runs: 2055, μ: 7592254, ~: 7592254) RainterpreterExpressionDeployerMetaTest:testRainterpreterExpressionDeployerExpectedConstructionMetaHash() (gas: 6221) -RainterpreterIERC165Test:testRainterpreterIERC165(bytes4) (runs: 2055, μ: 2463061, ~: 2463061) -RainterpreterParserIERC165Test:testRainterpreterParserIERC165(bytes4) (runs: 2055, μ: 3453367, ~: 3453367) -RainterpreterParserParserPragma:testParsePragmaNoPragma() (gas: 17249288) -RainterpreterParserParserPragma:testParsePragmaSinglePragma() (gas: 10401282) -RainterpreterParserParserPragma:testParsePragmaWithInterstitial() (gas: 10404574) -RainterpreterParserPointersTest:testLiteralParserFunctionPointers() (gas: 3452373) -RainterpreterParserPointersTest:testOperandHandlerFunctionPointers() (gas: 3457073) -RainterpreterParserPointersTest:testParserParseMeta() (gas: 285307) -RainterpreterPointersTest:testOpcodeFunctionPointers() (gas: 2466735) +RainterpreterIERC165Test:testRainterpreterIERC165(bytes4) (runs: 2055, μ: 2502966, ~: 2502966) +RainterpreterParserIERC165Test:testRainterpreterParserIERC165(bytes4) (runs: 2055, μ: 3458983, ~: 3458983) +RainterpreterParserParserPragma:testParsePragmaNoPragma() (gas: 17277348) +RainterpreterParserParserPragma:testParsePragmaSinglePragma() (gas: 10418120) +RainterpreterParserParserPragma:testParsePragmaWithInterstitial() (gas: 10421412) +RainterpreterParserPointersTest:testLiteralParserFunctionPointers() (gas: 3457989) +RainterpreterParserPointersTest:testOperandHandlerFunctionPointers() (gas: 3462914) +RainterpreterParserPointersTest:testParserParseMeta() (gas: 428003) +RainterpreterPointersTest:testOpcodeFunctionPointers() (gas: 2506868) RainterpreterReferenceExternContextRainlenTest:testRainterpreterReferenceExterNPE2ContextRainlenHappy() (gas: 2160048) RainterpreterReferenceExternContextSenderTest:testRainterpreterReferenceExterNPE2ContextContractHappy() (gas: 2159634) RainterpreterReferenceExternContextSenderTest:testRainterpreterReferenceExterNPE2ContextSenderHappy() (gas: 2158330) @@ -774,8 +798,8 @@ RainterpreterReferenceExternIERC165Test:testRainterpreterReferenceExternIERC165( RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncHappySugared() (gas: 2183789) RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncHappyUnsugared() (gas: 2178028) RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncIntegrity(bytes32,uint256,uint256) (runs: 107, μ: 3597, ~: 3597) -RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncRun(bytes32,bytes32[]) (runs: 107, μ: 756186, ~: 762999) -RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncSubParseKnownWord(uint16,bytes1) (runs: 107, μ: 2095499, ~: 2095759) +RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncRun(bytes32,bytes32[]) (runs: 107, μ: 756204, ~: 760591) +RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncSubParseKnownWord(uint16,bytes1) (runs: 107, μ: 2095481, ~: 2095759) RainterpreterReferenceExternIntIncTest:testRainterpreterReferenceExternIntIncSubParseUnknownWord(uint16,bytes1,bytes) (runs: 100, μ: 2091863, ~: 2091662) RainterpreterReferenceExternPointersTest:testIntegrityFunctionPointers() (gas: 2081736) RainterpreterReferenceExternPointersTest:testOpcodeFunctionPointers() (gas: 2081779) @@ -784,7 +808,7 @@ RainterpreterReferenceExternPointersTest:testSubParserLiteralParsers() (gas: 208 RainterpreterReferenceExternPointersTest:testSubParserOperandParsers() (gas: 2082229) RainterpreterReferenceExternPointersTest:testSubParserParseMeta() (gas: 22017) RainterpreterReferenceExternRepeatTest:testRainterpreterReferenceExternRepeatHappy() (gas: 2212950) -RainterpreterReferenceExternStackOperandTest:testRainterpreterReferenceExternStackOperandSingle(uint256) (runs: 2055, μ: 2167482, ~: 2167581) +RainterpreterReferenceExternStackOperandTest:testRainterpreterReferenceExternStackOperandSingle(uint256) (runs: 2055, μ: 2167477, ~: 2167581) RainterpreterReferenceExternUnknownWordTest:testRainterpreterReferenceExternUnknownWord() (gas: 2128684) RainterpreterStateOverlayTest:testStateOverlayGet() (gas: 52336) RainterpreterStateOverlayTest:testStateOverlaySet() (gas: 83065) diff --git a/lib/rain.interpreter.interface b/lib/rain.interpreter.interface index b98af98b0..70d9fae47 160000 --- a/lib/rain.interpreter.interface +++ b/lib/rain.interpreter.interface @@ -1 +1 @@ -Subproject commit b98af98b04ba70bc81fc7157a0172655627860bd +Subproject commit 70d9fae479072d0dad154ba203fd9b6c17d553b2 diff --git a/src/generated/Rainterpreter.pointers.sol b/src/generated/Rainterpreter.pointers.sol index 2492f07ba..9be5cdf6c 100644 --- a/src/generated/Rainterpreter.pointers.sol +++ b/src/generated/Rainterpreter.pointers.sol @@ -10,11 +10,11 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0xa6b8194695aec2caaf40b73cd4e492ee12c82b68f6cb09e771bcd016eb1c1830); +bytes32 constant BYTECODE_HASH = bytes32(0x3e43bbd0c5fff7815d2f91ece0d52af18b1865c85e77585b4a45ae85d5f76e5a); /// @dev The function pointers known to the interpreter for dynamic dispatch. /// By setting these as a constant they can be inlined into the interpreter /// and loaded at eval time for very low gas (~100) due to the compiler /// optimising it to a single `codecopy` to build the in memory bytes array. bytes constant OPCODE_FUNCTION_POINTERS = - hex"075b078d07b1093d0a060a180a2a0a430a670a9b0aac0abd0b5f0b7e0c3c0cec0d700eb20fe510de118011f81209121a121a122b12b812d112e512fe1317132a138c13da1428145914a714f51543162a"; + hex"076c079e07c2094e0a170a290a3b0a540a780aac0abd0ace0b700b8f0c4d0cfd0d810ec30ff60c4d10ef11a1124312bb12cc12dd12dd12ee137b139413a813c113da13ed144f149d14eb151c156a15b8160616ed"; diff --git a/src/generated/RainterpreterExpressionDeployer.pointers.sol b/src/generated/RainterpreterExpressionDeployer.pointers.sol index 9ff5290d7..7d058bda2 100644 --- a/src/generated/RainterpreterExpressionDeployer.pointers.sol +++ b/src/generated/RainterpreterExpressionDeployer.pointers.sol @@ -10,11 +10,11 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0x8129e7266bfb3b783324f17acce944c8eceb52114fdc1e752e1e619af4b996a7); +bytes32 constant BYTECODE_HASH = bytes32(0x9a395815b697bd41925cbb3d0d4b7b4767fcb94df4859ced57b949802e98834f); /// @dev The hash of the meta that describes the contract. -bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xa584ea21441427aadd44a19078a8f80abb0563d43e8da2bb0aab9f02a1205398); +bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xae18cb9cc13a8d1432bc47b0b1ec18bf14e54373e0b974a0f0234ba0477e3f05); /// @dev The function pointers for the integrity check fns. bytes constant INTEGRITY_FUNCTION_POINTERS = - hex"0df80e760eda1054105e105e10681071108c11321132118e12061213105e10681213105e1068105e10681054105410541054121d105e105e105e105e10541227124f122710541227124f124f1068121d"; + hex"0e080e860eea1064106e106e10781081109c11421142119e12161223106e10781223106e1078106e106e106e10781064106410641064122d106e106e106e106e10641237125f123710641237125f125f1078122d"; diff --git a/src/generated/RainterpreterParser.pointers.sol b/src/generated/RainterpreterParser.pointers.sol index 2ef0aa842..741c4a4d9 100644 --- a/src/generated/RainterpreterParser.pointers.sol +++ b/src/generated/RainterpreterParser.pointers.sol @@ -10,7 +10,7 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0x6f543e4dfa04d86b7bb9adbd4f2daf59cafd956a3d1f4d295cb680b8c286ac04); +bytes32 constant BYTECODE_HASH = bytes32(0x0d1bd1e36b938abb7312784026140ed159a9a59520f9d315c8836bcf14931c55); /// @dev The parse meta that is used to lookup word definitions. /// The structure of the parse meta is: @@ -29,7 +29,7 @@ bytes32 constant BYTECODE_HASH = bytes32(0x6f543e4dfa04d86b7bb9adbd4f2daf59cafd9 /// bit count of the previous bloom filter. If we reach the end of the bloom /// filters then we have a miss. bytes constant PARSE_META = - hex"010e000088000004102c00000c8880800d24a0148109008880010000140554a010000d1dbb6302525f2211999fd50f6c01da1871b5110a2139801a69a80f00a4ed3f27ba92e12348361e2628c11e089ebd5e07e235981bb5fc9e24d9ace210e92356163994150b7dfb1509bb6451066c83bf215797780c4960e303fa47a905e82f0c1d4efea02224d7751fbfd64115d6a860135832fd1cb8491f20be2c7c01d81c842562708d0efdd5d8142466661747b9490477ee181251471f19e0ddd31e3436fb"; + hex"0119204182060c080006c6c1800000012200200282040029000100680901208400200d1e98a71dd6ea18118eba9713065d302481e5d904ac72c00e7ff5a229ae0c8706fb9c2528c7bc2312fec72818d295ed23d9a6c50063d58d012ba0980c6cbb42216d6b2403ae6396082c4e962041d78a16172ab51a5b8f1d15f871180f48502f1fb9d38d0be7f2e71cf1ff4d19d140c2271a1e3510abcc6405b702d7020f038b07ee624a1e4143471482e75b1b60aa350a3d21ff174c80cb22cc4a6a26023c0409a046dc259b3887"; /// @dev The build depth of the parser meta. @@ -39,11 +39,11 @@ uint8 constant PARSE_META_BUILD_DEPTH = 2; /// These positional indexes all map to the same indexes looked up in the parse /// meta. bytes constant OPERAND_HANDLER_FUNCTION_POINTERS = - hex"19db19db19db1ab01bc71bc71bc71ab01ab019db19db19db1bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc71bc719db1bc71bc7"; + hex"19eb19eb19eb1ac01bd71bd71bd71ac01ac019eb19eb19eb1bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd71bd719eb1bd71bd7"; /// @dev Every two bytes is a function pointer for a literal parser. /// Literal dispatches are determined by the first byte(s) of the literal /// rather than a full word lookup, and are done with simple conditional /// jumps as the possibilities are limited compared to the number of words we /// have. -bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"1523175517981836"; +bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"1533176517a81846"; diff --git a/src/lib/op/LibAllStandardOps.sol b/src/lib/op/LibAllStandardOps.sol index a4ffa77dd..c98076689 100644 --- a/src/lib/op/LibAllStandardOps.sol +++ b/src/lib/op/LibAllStandardOps.sol @@ -37,6 +37,7 @@ import {LibOpERC20BalanceOf} from "./erc20/LibOpERC20BalanceOf.sol"; import {LibOpERC20TotalSupply} from "./erc20/LibOpERC20TotalSupply.sol"; import {LibOpUint256ERC721BalanceOf} from "./erc721/uint256/LibOpUint256ERC721BalanceOf.sol"; +import {LibOpERC721BalanceOf} from "./erc721/LibOpERC721BalanceOf.sol"; import {LibOpERC721OwnerOf} from "./erc721/LibOpERC721OwnerOf.sol"; import {LibOpERC5313OwnerNP} from "./erc5313/LibOpERC5313OwnerNP.sol"; @@ -105,7 +106,7 @@ import {LibParseLiteralHex} from "../parse/literal/LibParseLiteralHex.sol"; import {LibParseLiteralSubParseable} from "../parse/literal/LibParseLiteralSubParseable.sol"; /// @dev Number of ops currently provided by `AllStandardOps`. -uint256 constant ALL_STANDARD_OPS_LENGTH = 40; +uint256 constant ALL_STANDARD_OPS_LENGTH = 42; /// @title LibAllStandardOps /// @notice Every opcode available from the core repository laid out as a single @@ -183,10 +184,14 @@ library LibAllStandardOps { AuthoringMetaV2( "erc20-total-supply", "Gets the total supply of an erc20 token. The input is the token address." ), - // AuthoringMetaV2( - // "uint256-erc721-balance-of", - // "Gets the balance of an erc721 token for an account as a uint256 value. The first input is the token address and the second is the account address." - // ), + AuthoringMetaV2( + "uint256-erc721-balance-of", + "Gets the balance of an erc721 token for an account as a uint256 value. The first input is the token address and the second is the account address. Returns a uint256 rather than a float." + ), + AuthoringMetaV2( + "erc721-balance-of", + "Gets the balance of an erc721 token for an account. The first input is the token address and the second is the account address." + ), AuthoringMetaV2( "erc721-owner-of", "Gets the owner of an erc721 token. The first input is the token address and the second is the token id." @@ -397,8 +402,10 @@ library LibAllStandardOps { LibParseOperand.handleOperandDisallowed, // erc20-total-supply LibParseOperand.handleOperandDisallowed, - // // uint256-erc721-balance-of - // LibParseOperand.handleOperandDisallowed, + // uint256-erc721-balance-of + LibParseOperand.handleOperandDisallowed, + // erc721-balance-of + LibParseOperand.handleOperandDisallowed, // erc721-owner-of LibParseOperand.handleOperandDisallowed, // erc5313-owner @@ -560,7 +567,8 @@ library LibAllStandardOps { LibOpERC20Allowance.integrity, LibOpERC20BalanceOf.integrity, LibOpERC20TotalSupply.integrity, - // LibOpUint256ERC721BalanceOf.integrity, + LibOpUint256ERC721BalanceOf.integrity, + LibOpERC721BalanceOf.integrity, LibOpERC721OwnerOf.integrity, LibOpERC5313OwnerNP.integrity, LibOpBlockNumber.integrity, @@ -672,7 +680,8 @@ library LibAllStandardOps { LibOpERC20Allowance.run, LibOpERC20BalanceOf.run, LibOpERC20TotalSupply.run, - // LibOpUint256ERC721BalanceOf.run, + LibOpUint256ERC721BalanceOf.run, + LibOpERC721BalanceOf.run, LibOpERC721OwnerOf.run, LibOpERC5313OwnerNP.run, LibOpBlockNumber.run, diff --git a/src/lib/op/erc721/LibOpERC721BalanceOf.sol b/src/lib/op/erc721/LibOpERC721BalanceOf.sol new file mode 100644 index 000000000..39a435e49 --- /dev/null +++ b/src/lib/op/erc721/LibOpERC721BalanceOf.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: CAL +pragma solidity ^0.8.18; + +import {InterpreterState} from "../../state/LibInterpreterState.sol"; +import {OperandV2} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; +import {Pointer} from "rain.solmem/lib/LibPointer.sol"; +import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; +import {LibDecimalFloat, Float} from "rain.math.float/lib/LibDecimalFloat.sol"; +import {StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; +import {IntegrityCheckState} from "../../integrity/LibIntegrityCheck.sol"; + +/// @title LibOpERC721BalanceOf +/// @notice Opcode for getting the current ERC721 balance of an account. +library LibOpERC721BalanceOf { + function integrity(IntegrityCheckState memory, OperandV2) internal pure returns (uint256, uint256) { + // Always 2 inputs, the token and the account. + // Always 1 output, the balance. + return (2, 1); + } + + function run(InterpreterState memory, OperandV2, Pointer stackTop) internal view returns (Pointer) { + uint256 token; + uint256 account; + assembly ("memory-safe") { + token := mload(stackTop) + stackTop := add(stackTop, 0x20) + account := mload(stackTop) + } + uint256 tokenBalance = IERC721(address(uint160(token))).balanceOf(address(uint160(account))); + + Float tokenBalanceFloat = LibDecimalFloat.fromFixedDecimalLosslessPacked(tokenBalance, 0); + + assembly ("memory-safe") { + mstore(stackTop, tokenBalanceFloat) + } + return stackTop; + } + + function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory inputs) + internal + view + returns (StackItem[] memory) + { + address token = address(uint160(uint256(StackItem.unwrap(inputs[0])))); + address account = address(uint160(uint256(StackItem.unwrap(inputs[1])))); + uint256 tokenBalance = IERC721(token).balanceOf(account); + + Float tokenBalanceFloat = LibDecimalFloat.fromFixedDecimalLosslessPacked(tokenBalance, 0); + + StackItem[] memory outputs = new StackItem[](1); + outputs[0] = StackItem.wrap(Float.unwrap(tokenBalanceFloat)); + return outputs; + } +} diff --git a/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.sol b/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.sol index 7bca9b659..0528f595a 100644 --- a/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.sol +++ b/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.sol @@ -6,6 +6,7 @@ import {Pointer} from "rain.solmem/lib/LibPointer.sol"; import {IntegrityCheckState} from "../../../integrity/LibIntegrityCheck.sol"; import {OperandV2} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; import {InterpreterState} from "../../../state/LibInterpreterState.sol"; +import {StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; /// @title OpUint256ERC721BalanceOf /// @notice Opcode for getting the current erc721 balance of an account. @@ -31,16 +32,16 @@ library LibOpUint256ERC721BalanceOf { return stackTop; } - function referenceFn(InterpreterState memory, OperandV2, uint256[] memory inputs) + function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory inputs) internal view - returns (uint256[] memory) + returns (StackItem[] memory) { - uint256 token = inputs[0]; - uint256 account = inputs[1]; - uint256 tokenBalance = IERC721(address(uint160(token))).balanceOf(address(uint160(account))); - uint256[] memory outputs = new uint256[](1); - outputs[0] = tokenBalance; + address token = address(uint160(uint256(StackItem.unwrap(inputs[0])))); + address account = address(uint160(uint256(StackItem.unwrap(inputs[1])))); + uint256 tokenBalance = IERC721(token).balanceOf(account); + StackItem[] memory outputs = new StackItem[](1); + outputs[0] = StackItem.wrap(bytes32(tokenBalance)); return outputs; } } diff --git a/test/src/lib/op/erc721/LibOpUint256ERC721BalanceOf.t.sol b/test/src/lib/op/erc721/LibOpUint256ERC721BalanceOf.t.sol new file mode 100644 index 000000000..126a9316f --- /dev/null +++ b/test/src/lib/op/erc721/LibOpUint256ERC721BalanceOf.t.sol @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: CAL +pragma solidity =0.8.25; + +import {OpTest} from "test/abstract/OpTest.sol"; +import {IntegrityCheckState, BadOpInputsLength} from "src/lib/integrity/LibIntegrityCheck.sol"; +import {LibOpERC721BalanceOf} from "src/lib/op/erc721/LibOpERC721BalanceOf.sol"; +import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; +import { + IInterpreterV4, + FullyQualifiedNamespace, + OperandV2, + SourceIndexV2, + EvalV4 +} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; +import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; +import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol"; +import {UnexpectedOperand} from "src/error/ErrParse.sol"; +import {LibOperand} from "test/lib/operand/LibOperand.sol"; +import {StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; +import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; +import {LibDecimalFloat, Float, LossyConversionToFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; + +/// @title LibOpERC721BalanceOfTest +/// @notice Test the opcode for getting the balance of an erc721 token. +contract LibOpERC721BalanceOfTest is OpTest { + function testOpERC721BalanceOfIntegrity( + IntegrityCheckState memory state, + uint8 inputs, + uint8 outputs, + uint16 operandData + ) external pure { + inputs = uint8(bound(inputs, 0, 0x0F)); + outputs = uint8(bound(outputs, 0, 0x0F)); + (uint256 calcInputs, uint256 calcOutputs) = + LibOpERC721BalanceOf.integrity(state, LibOperand.build(inputs, outputs, operandData)); + + assertEq(calcInputs, 2); + assertEq(calcOutputs, 1); + } + + function testOpERC721BalanceOfRun(address token, address account, uint256 balance, uint16 operandData) external { + assumeEtchable(token); + vm.etch(token, hex"fe"); + + (, bool lossless) = LibDecimalFloat.fromFixedDecimalLossyPacked(balance, 0); + vm.assume(lossless); + + StackItem[] memory inputs = new StackItem[](2); + inputs[0] = StackItem.wrap(bytes32(uint256(uint160(token)))); + inputs[1] = StackItem.wrap(bytes32(uint256(uint160(account)))); + OperandV2 operand = LibOperand.build(2, 1, operandData); + + // invalid token + vm.mockCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), abi.encode(balance)); + // called once for reference, once for run + vm.expectCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), 2); + + opReferenceCheck( + opTestDefaultInterpreterState(), + operand, + LibOpERC721BalanceOf.referenceFn, + LibOpERC721BalanceOf.integrity, + LibOpERC721BalanceOf.run, + inputs + ); + } + + function testOpERC721BalanceOfEvalHappy(address token, address account, uint256 balance) public { + bytes memory bytecode = iDeployer.parse2( + bytes( + string.concat( + "_: erc721-balance-of(", Strings.toHexString(token), " ", Strings.toHexString(account), ");" + ) + ) + ); + + (, bool lossless) = LibDecimalFloat.fromFixedDecimalLossyPacked(balance, 0); + vm.assume(lossless); + + assumeEtchable(token); + vm.etch(token, hex"fe"); + vm.mockCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), abi.encode(balance)); + vm.expectCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), 1); + + (StackItem[] memory stack, bytes32[] memory kvs) = iInterpreter.eval4( + EvalV4({ + store: iStore, + namespace: FullyQualifiedNamespace.wrap(0), + bytecode: bytecode, + sourceIndex: SourceIndexV2.wrap(0), + context: LibContext.build(new bytes32[][](0), new SignedContextV1[](0)), + inputs: new StackItem[](0), + stateOverlay: new bytes32[](0) + }) + ); + assertEq(stack.length, 1); + assertEq(StackItem.unwrap(stack[0]), bytes32(balance)); + assertEq(kvs.length, 0); + } + + /// Test that balance of without inputs fails integrity check. + function testOpERC721BalanceOfIntegrityFail0() external { + vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 0, 2, 0)); + bytes memory bytecode = iDeployer.parse2("_: erc721-balance-of();"); + (bytecode); + } + + /// Test that balance of with one input fails integrity check. + function testOpERC721BalanceOfIntegrityFail1() external { + vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 1, 2, 1)); + bytes memory bytecode = iDeployer.parse2("_: erc721-balance-of(0x00);"); + (bytecode); + } + + /// Test that balance of with three inputs fails integrity check. + function testOpERC721BalanceOfIntegrityFail3() external { + vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 3, 2, 3)); + bytes memory bytecode = iDeployer.parse2("_: erc721-balance-of(0x00 0x01 0x02);"); + (bytecode); + } + + /// Test that operand fails integrity check. + function testOpERC721BalanceOfIntegrityFailOperand() external { + vm.expectRevert(abi.encodeWithSelector(UnexpectedOperand.selector)); + bytes memory bytecode = iDeployer.parse2("_: erc721-balance-of<0>(0x00 0x01);"); + (bytecode); + } + + function testOpERC721BalanceOfZeroInputs() external { + checkBadInputs("_: erc721-balance-of();", 0, 2, 0); + } + + function testOpERC721BalanceOfOneInput() external { + checkBadInputs("_: erc721-balance-of(0x00);", 1, 2, 1); + } + + function testOpERC721BalanceOfThreeInputs() external { + checkBadInputs("_: erc721-balance-of(0x00 0x01 0x02);", 3, 2, 3); + } + + function testOpERC721BalanceOfZeroOutputs() external { + checkBadOutputs(": erc721-balance-of(0x00 0x01);", 2, 1, 0); + } + + function testOpERC721BalanceOfTwoOutputs() external { + checkBadOutputs("_ _: erc721-balance-of(0x00 0x01);", 2, 1, 2); + } +} diff --git a/test/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.t.sol b/test/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.t.sol index a82bb5be9..9c2c7dc0f 100644 --- a/test/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.t.sol +++ b/test/src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.t.sol @@ -1,142 +1,141 @@ // SPDX-License-Identifier: CAL pragma solidity =0.8.25; -// // import {OpTest} from "test/abstract/OpTest.sol"; -// // import {IntegrityCheckState, BadOpInputsLength} from "src/lib/integrity/LibIntegrityCheck.sol"; -// // import {LibOpUint256ERC721BalanceOf} from "src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.sol"; -// // import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; -// // import { -// // IInterpreterV4, -// // FullyQualifiedNamespace, -// // Operand, -// // SourceIndexV2, -// // EvalV4 -// // } from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; -// // import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; -// // import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; -// // import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol"; -// // import {UnexpectedOperand} from "src/error/ErrParse.sol"; -// // import {LibOperand} from "test/lib/operand/LibOperand.sol"; - -// // import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; - -// /// @title LibOpUint256ERC721BalanceOfTest -// /// @notice Test the opcode for getting the balance of an erc721 token. -// contract LibOpUint256ERC721BalanceOfTest is OpTest { -// function testOpERC721BalanceOfIntegrity( -// IntegrityCheckState memory state, -// uint8 inputs, -// uint8 outputs, -// uint16 operandData -// ) external pure { -// inputs = uint8(bound(inputs, 0, 0x0F)); -// outputs = uint8(bound(outputs, 0, 0x0F)); -// (uint256 calcInputs, uint256 calcOutputs) = -// LibOpUint256ERC721BalanceOf.integrity(state, LibOperand.build(inputs, outputs, operandData)); - -// // assertEq(calcInputs, 2); -// // assertEq(calcOutputs, 1); -// // } - -// // function testOpERC721BalanceOfRun(address token, address account, uint256 balance, uint16 operandData) external { -// // assumeEtchable(token); -// // vm.etch(token, hex"fe"); - -// // uint256[] memory inputs = new uint256[](2); -// // inputs[0] = uint256(uint160(token)); -// // inputs[1] = uint256(uint160(account)); -// // Operand operand = LibOperand.build(2, 1, operandData); - -// // // invalid token -// // vm.mockCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), abi.encode(balance)); -// // // called once for reference, once for run -// // vm.expectCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), 2); - -// // opReferenceCheck( -// // opTestDefaultInterpreterState(), -// // operand, -// // LibOpUint256ERC721BalanceOf.referenceFn, -// // LibOpUint256ERC721BalanceOf.integrity, -// // LibOpUint256ERC721BalanceOf.run, -// // inputs -// // ); -// // } - -// // function testOpERC721BalanceOfEvalHappy(address token, address account, uint256 balance) public { -// // bytes memory bytecode = iDeployer.parse2( -// // bytes( -// // string.concat( -// // "_: uint256-erc721-balance-of(", Strings.toHexString(token), " ", Strings.toHexString(account), ");" -// // ) -// // ) -// // ); - -// // assumeEtchable(token); -// // vm.etch(token, hex"fe"); -// // vm.mockCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), abi.encode(balance)); -// // vm.expectCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), 1); - -// // (uint256[] memory stack, uint256[] memory kvs) = iInterpreter.eval4( -// // EvalV4({ -// // store: iStore, -// // namespace: FullyQualifiedNamespace.wrap(0), -// // bytecode: bytecode, -// // sourceIndex: SourceIndexV2.wrap(0), -// // context: LibContext.build(new uint256[][](0), new SignedContextV1[](0)), -// // inputs: new uint256[](0), -// // stateOverlay: new uint256[](0) -// // }) -// // ); -// // assertEq(stack.length, 1); -// // assertEq(stack[0], balance); -// // assertEq(kvs.length, 0); -// // } - -// // /// Test that balance of without inputs fails integrity check. -// // function testOpERC721BalanceOfIntegrityFail0() external { -// // vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 0, 2, 0)); -// // bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of();"); -// // (bytecode); -// // } - -// // /// Test that balance of with one input fails integrity check. -// // function testOpERC721BalanceOfIntegrityFail1() external { -// // vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 1, 2, 1)); -// // bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of(0x00);"); -// // (bytecode); -// // } - -// // /// Test that balance of with three inputs fails integrity check. -// // function testOpERC721BalanceOfIntegrityFail3() external { -// // vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 3, 2, 3)); -// // bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of(0x00 0x01 0x02);"); -// // (bytecode); -// // } - -// // /// Test that operand fails integrity check. -// // function testOpERC721BalanceOfIntegrityFailOperand() external { -// // vm.expectRevert(abi.encodeWithSelector(UnexpectedOperand.selector)); -// // bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of<0>(0x00 0x01);"); -// // (bytecode); -// // } - -// // function testOpERC721BalanceOfZeroInputs() external { -// // checkBadInputs("_: uint256-erc721-balance-of();", 0, 2, 0); -// // } - -// // function testOpERC721BalanceOfOneInput() external { -// // checkBadInputs("_: uint256-erc721-balance-of(0x00);", 1, 2, 1); -// // } - -// // function testOpERC721BalanceOfThreeInputs() external { -// // checkBadInputs("_: uint256-erc721-balance-of(0x00 0x01 0x02);", 3, 2, 3); -// // } - -// // function testOpERC721BalanceOfZeroOutputs() external { -// // checkBadOutputs(": uint256-erc721-balance-of(0x00 0x01);", 2, 1, 0); -// // } - -// // function testOpERC721BalanceOfTwoOutputs() external { -// // checkBadOutputs("_ _: uint256-erc721-balance-of(0x00 0x01);", 2, 1, 2); -// // } -// // } +import {OpTest} from "test/abstract/OpTest.sol"; +import {IntegrityCheckState, BadOpInputsLength} from "src/lib/integrity/LibIntegrityCheck.sol"; +import {LibOpUint256ERC721BalanceOf} from "src/lib/op/erc721/uint256/LibOpUint256ERC721BalanceOf.sol"; +import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; +import { + IInterpreterV4, + FullyQualifiedNamespace, + OperandV2, + SourceIndexV2, + EvalV4 +} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; +import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; +import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol"; +import {UnexpectedOperand} from "src/error/ErrParse.sol"; +import {LibOperand} from "test/lib/operand/LibOperand.sol"; +import {StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; +import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol"; + +/// @title LibOpUint256ERC721BalanceOfTest +/// @notice Test the opcode for getting the balance of an erc721 token. +contract LibOpUint256ERC721BalanceOfTest is OpTest { + function testOpERC721BalanceOfIntegrity( + IntegrityCheckState memory state, + uint8 inputs, + uint8 outputs, + uint16 operandData + ) external pure { + inputs = uint8(bound(inputs, 0, 0x0F)); + outputs = uint8(bound(outputs, 0, 0x0F)); + (uint256 calcInputs, uint256 calcOutputs) = + LibOpUint256ERC721BalanceOf.integrity(state, LibOperand.build(inputs, outputs, operandData)); + + assertEq(calcInputs, 2); + assertEq(calcOutputs, 1); + } + + function testOpERC721BalanceOfRun(address token, address account, uint256 balance, uint16 operandData) external { + assumeEtchable(token); + vm.etch(token, hex"fe"); + + StackItem[] memory inputs = new StackItem[](2); + inputs[0] = StackItem.wrap(bytes32(uint256(uint160(token)))); + inputs[1] = StackItem.wrap(bytes32(uint256(uint160(account)))); + OperandV2 operand = LibOperand.build(2, 1, operandData); + + // invalid token + vm.mockCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), abi.encode(balance)); + // called once for reference, once for run + vm.expectCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), 2); + + opReferenceCheck( + opTestDefaultInterpreterState(), + operand, + LibOpUint256ERC721BalanceOf.referenceFn, + LibOpUint256ERC721BalanceOf.integrity, + LibOpUint256ERC721BalanceOf.run, + inputs + ); + } + + function testOpERC721BalanceOfEvalHappy(address token, address account, uint256 balance) public { + bytes memory bytecode = iDeployer.parse2( + bytes( + string.concat( + "_: uint256-erc721-balance-of(", Strings.toHexString(token), " ", Strings.toHexString(account), ");" + ) + ) + ); + + assumeEtchable(token); + vm.etch(token, hex"fe"); + vm.mockCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), abi.encode(balance)); + vm.expectCall(token, abi.encodeWithSelector(IERC721.balanceOf.selector, account), 1); + + (StackItem[] memory stack, bytes32[] memory kvs) = iInterpreter.eval4( + EvalV4({ + store: iStore, + namespace: FullyQualifiedNamespace.wrap(0), + bytecode: bytecode, + sourceIndex: SourceIndexV2.wrap(0), + context: LibContext.build(new bytes32[][](0), new SignedContextV1[](0)), + inputs: new StackItem[](0), + stateOverlay: new bytes32[](0) + }) + ); + assertEq(stack.length, 1); + assertEq(StackItem.unwrap(stack[0]), bytes32(balance)); + assertEq(kvs.length, 0); + } + + /// Test that balance of without inputs fails integrity check. + function testOpERC721BalanceOfIntegrityFail0() external { + vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 0, 2, 0)); + bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of();"); + (bytecode); + } + + /// Test that balance of with one input fails integrity check. + function testOpERC721BalanceOfIntegrityFail1() external { + vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 1, 2, 1)); + bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of(0x00);"); + (bytecode); + } + + /// Test that balance of with three inputs fails integrity check. + function testOpERC721BalanceOfIntegrityFail3() external { + vm.expectRevert(abi.encodeWithSelector(BadOpInputsLength.selector, 3, 2, 3)); + bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of(0x00 0x01 0x02);"); + (bytecode); + } + + /// Test that operand fails integrity check. + function testOpERC721BalanceOfIntegrityFailOperand() external { + vm.expectRevert(abi.encodeWithSelector(UnexpectedOperand.selector)); + bytes memory bytecode = iDeployer.parse2("_: uint256-erc721-balance-of<0>(0x00 0x01);"); + (bytecode); + } + + function testOpERC721BalanceOfZeroInputs() external { + checkBadInputs("_: uint256-erc721-balance-of();", 0, 2, 0); + } + + function testOpERC721BalanceOfOneInput() external { + checkBadInputs("_: uint256-erc721-balance-of(0x00);", 1, 2, 1); + } + + function testOpERC721BalanceOfThreeInputs() external { + checkBadInputs("_: uint256-erc721-balance-of(0x00 0x01 0x02);", 3, 2, 3); + } + + function testOpERC721BalanceOfZeroOutputs() external { + checkBadOutputs(": uint256-erc721-balance-of(0x00 0x01);", 2, 1, 0); + } + + function testOpERC721BalanceOfTwoOutputs() external { + checkBadOutputs("_ _: uint256-erc721-balance-of(0x00 0x01);", 2, 1, 2); + } +}