diff --git a/.changeset/spotty-balloons-itch.md b/.changeset/spotty-balloons-itch.md new file mode 100644 index 0000000000..bc704d667c --- /dev/null +++ b/.changeset/spotty-balloons-itch.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store": patch +--- + +Refactored some Store functions to use a right bit mask instead of left. diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 121b08e68d..d887efdfcf 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -15,19 +15,19 @@ "file": "test/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: set field", - "gasUsed": 56265 + "gasUsed": 56262 }, { "file": "test/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2836 + "gasUsed": 2833 }, { "file": "test/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: push 1 element", - "gasUsed": 32524 + "gasUsed": 32521 }, { "file": "test/FieldLayout.t.sol", @@ -141,7 +141,7 @@ "file": "test/Gas.t.sol", "test": "testCompareAbiEncodeVsCustom", "name": "custom decode", - "gasUsed": 1957 + "gasUsed": 1954 }, { "file": "test/Gas.t.sol", @@ -237,7 +237,7 @@ "file": "test/GasStorageLoad.t.sol", "test": "testCompareStorageLoadMUD", "name": "MUD storage load (cold, 1 word, partial)", - "gasUsed": 2484 + "gasUsed": 2481 }, { "file": "test/GasStorageLoad.t.sol", @@ -261,7 +261,7 @@ "file": "test/GasStorageLoad.t.sol", "test": "testCompareStorageLoadMUD", "name": "MUD storage load (warm, 1 word, partial)", - "gasUsed": 484 + "gasUsed": 481 }, { "file": "test/GasStorageLoad.t.sol", @@ -321,7 +321,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 727524 + "gasUsed": 727521 }, { "file": "test/Mixed.t.sol", @@ -333,49 +333,49 @@ "file": "test/Mixed.t.sol", "test": "testDeleteExternalCold", "name": "delete record from Mixed (external, cold)", - "gasUsed": 24366 + "gasUsed": 24363 }, { "file": "test/Mixed.t.sol", "test": "testDeleteInternalCold", "name": "delete record from Mixed (internal, cold)", - "gasUsed": 19162 + "gasUsed": 19159 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "set record in Mixed (external, cold)", - "gasUsed": 108522 + "gasUsed": 108513 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "get record from Mixed (external, warm)", - "gasUsed": 6989 + "gasUsed": 6977 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "delete record from Mixed (external, warm)", - "gasUsed": 8682 + "gasUsed": 8679 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "set record in Mixed (internal, cold)", - "gasUsed": 103276 + "gasUsed": 103267 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "get record from Mixed (internal, warm)", - "gasUsed": 6675 + "gasUsed": 6663 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "delete record from Mixed (internal, warm)", - "gasUsed": 7475 + "gasUsed": 7472 }, { "file": "test/PackedCounter.t.sol", @@ -519,7 +519,7 @@ "file": "test/Slice.t.sol", "test": "testToBytes", "name": "Slice (2 bytes) to bytes memory", - "gasUsed": 534 + "gasUsed": 531 }, { "file": "test/Slice.t.sol", @@ -531,7 +531,7 @@ "file": "test/Slice.t.sol", "test": "testToBytes", "name": "Slice (34 bytes) to bytes memory", - "gasUsed": 750 + "gasUsed": 747 }, { "file": "test/Slice.t.sol", @@ -561,37 +561,37 @@ "file": "test/Storage.t.sol", "test": "testStoreLoad", "name": "store 34 bytes over 3 storage slots (with offset and safeTrail))", - "gasUsed": 23028 + "gasUsed": 23025 }, { "file": "test/Storage.t.sol", "test": "testStoreLoad", "name": "load 34 bytes over 3 storage slots (with offset and safeTrail))", - "gasUsed": 874 + "gasUsed": 871 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetDynamicFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 5569 + "gasUsed": 5566 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetDynamicFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 1671 + "gasUsed": 1668 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetDynamicFieldSlice", "name": "get field slice (semi-cold, 1 slot)", - "gasUsed": 3664 + "gasUsed": 3661 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetDynamicFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 3891 + "gasUsed": 3885 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -645,13 +645,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access non-existing record", - "gasUsed": 7077 + "gasUsed": 7074 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access static field of non-existing record", - "gasUsed": 1333 + "gasUsed": 1330 }, { "file": "test/StoreCoreGas.t.sol", @@ -669,7 +669,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 8009 + "gasUsed": 8006 }, { "file": "test/StoreCoreGas.t.sol", @@ -705,49 +705,49 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 57948 + "gasUsed": 57945 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 72373 + "gasUsed": 72364 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 19825 + "gasUsed": 19816 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18583 + "gasUsed": 18574 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 57948 + "gasUsed": 57945 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 165513 + "gasUsed": 165498 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 24434 + "gasUsed": 24425 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 20249 + "gasUsed": 20240 }, { "file": "test/StoreCoreGas.t.sol", @@ -759,13 +759,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (2 slots, 10 uint32 items)", - "gasUsed": 32144 + "gasUsed": 32141 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 651188 + "gasUsed": 651185 }, { "file": "test/StoreCoreGas.t.sol", @@ -789,13 +789,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 102507 + "gasUsed": 102498 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "get complex record with dynamic data (4 slots)", - "gasUsed": 4244 + "gasUsed": 4235 }, { "file": "test/StoreCoreGas.t.sol", @@ -831,73 +831,73 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (1 slot)", - "gasUsed": 31246 + "gasUsed": 31243 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 1333 + "gasUsed": 1330 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 29902 + "gasUsed": 29899 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (overlap 2 slot)", - "gasUsed": 1889 + "gasUsed": 1883 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53955 + "gasUsed": 53952 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, first dynamic field)", - "gasUsed": 2230 + "gasUsed": 2227 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, second dynamic field)", - "gasUsed": 32180 + "gasUsed": 32177 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2233 + "gasUsed": 2230 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 32776 + "gasUsed": 32773 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "get static record (1 slot)", - "gasUsed": 1555 + "gasUsed": 1552 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55283 + "gasUsed": 55280 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "get static record (2 slots)", - "gasUsed": 1740 + "gasUsed": 1737 }, { "file": "test/StoreCoreGas.t.sol", @@ -915,7 +915,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "push to field (2 slots, 6 uint64 items)", - "gasUsed": 9276 + "gasUsed": 9273 }, { "file": "test/StoreHook.t.sol", @@ -945,25 +945,25 @@ "file": "test/StoreHooks.t.sol", "test": "testOneSlot", "name": "StoreHooks: set field with one elements (cold)", - "gasUsed": 58269 + "gasUsed": 58266 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (cold)", - "gasUsed": 58269 + "gasUsed": 58266 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: get field (warm)", - "gasUsed": 2838 + "gasUsed": 2835 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (cold)", - "gasUsed": 12620 + "gasUsed": 12617 }, { "file": "test/StoreHooks.t.sol", @@ -975,13 +975,13 @@ "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (warm)", - "gasUsed": 10640 + "gasUsed": 10637 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: update 1 element (warm)", - "gasUsed": 29880 + "gasUsed": 29877 }, { "file": "test/StoreHooks.t.sol", @@ -993,19 +993,19 @@ "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 30421 + "gasUsed": 30418 }, { "file": "test/StoreHooks.t.sol", "test": "testThreeSlots", "name": "StoreHooks: set field with three elements (cold)", - "gasUsed": 80960 + "gasUsed": 80957 }, { "file": "test/StoreHooks.t.sol", "test": "testTwoSlots", "name": "StoreHooks: set field with two elements (cold)", - "gasUsed": 80872 + "gasUsed": 80869 }, { "file": "test/StoreHooksColdLoad.t.sol", @@ -1017,13 +1017,13 @@ "file": "test/StoreHooksColdLoad.t.sol", "test": "testGet", "name": "StoreHooks: get field (cold)", - "gasUsed": 8835 + "gasUsed": 8832 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testGetItem", "name": "StoreHooks: get 1 element (cold)", - "gasUsed": 8446 + "gasUsed": 8443 }, { "file": "test/StoreHooksColdLoad.t.sol", @@ -1041,7 +1041,7 @@ "file": "test/StoreHooksColdLoad.t.sol", "test": "testUpdate", "name": "StoreHooks: update 1 element (cold)", - "gasUsed": 20327 + "gasUsed": 20324 }, { "file": "test/StoreSwitch.t.sol", @@ -1107,18 +1107,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 451184 + "gasUsed": 451181 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 33678 + "gasUsed": 33675 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2539 + "gasUsed": 2536 } ] diff --git a/packages/store/src/Memory.sol b/packages/store/src/Memory.sol index 4789e9cfbf..9dda2a562a 100644 --- a/packages/store/src/Memory.sol +++ b/packages/store/src/Memory.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.21; -import { leftMask } from "./leftMask.sol"; +import { rightMask } from "./rightMask.sol"; /** * @title Memory Operations @@ -47,16 +47,16 @@ library Memory { if (length == 0) return; // Copy the 0-31 length tail - uint256 mask = leftMask(length); + uint256 mask = rightMask(length); /// @solidity memory-safe-assembly assembly { mstore( toPointer, or( // store the left part - and(mload(fromPointer), mask), + and(mload(fromPointer), not(mask)), // preserve the right part - and(mload(toPointer), not(mask)) + and(mload(toPointer), mask) ) ) } diff --git a/packages/store/src/Storage.sol b/packages/store/src/Storage.sol index 34aac44291..c96fc9fcc8 100644 --- a/packages/store/src/Storage.sol +++ b/packages/store/src/Storage.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.21; -import { leftMask } from "./leftMask.sol"; +import { rightMask } from "./rightMask.sol"; import { Memory } from "./Memory.sol"; import { BYTE_TO_BITS } from "./constants.sol"; @@ -57,7 +57,7 @@ library Storage { wordRemainder = 32 - offset; } - uint256 mask = leftMask(length); + uint256 mask = ~rightMask(length); /// @solidity memory-safe-assembly assembly { // Load data from memory and offset it to match storage @@ -103,16 +103,16 @@ library Storage { // For the last partial word, apply a mask to the end if (length > 0) { - uint256 mask = leftMask(length); + uint256 mask = rightMask(length); /// @solidity memory-safe-assembly assembly { sstore( storagePointer, or( // store the left part - and(mload(memoryPointer), mask), + and(mload(memoryPointer), not(mask)), // preserve the right part - and(sload(storagePointer), not(mask)) + and(sload(storagePointer), mask) ) ) } @@ -202,9 +202,9 @@ library Storage { uint256 mask; if (length < wordRemainder) { - mask = leftMask(length); + mask = rightMask(length); } else { - mask = leftMask(wordRemainder); + mask = rightMask(wordRemainder); } /// @solidity memory-safe-assembly assembly { @@ -215,9 +215,9 @@ library Storage { memoryPointer, or( // store the left part - and(offsetData, mask), + and(offsetData, not(mask)), // preserve the right parts - and(mload(memoryPointer), not(mask)) + and(mload(memoryPointer), mask) ) ) } @@ -249,16 +249,16 @@ library Storage { // For the last partial word, apply a mask to the end if (length > 0) { - uint256 mask = leftMask(length); + uint256 mask = rightMask(length); /// @solidity memory-safe-assembly assembly { mstore( memoryPointer, or( // store the left part - and(sload(storagePointer), mask), + and(sload(storagePointer), not(mask)), // preserve the right part - and(mload(memoryPointer), not(mask)) + and(mload(memoryPointer), mask) ) ) } diff --git a/packages/store/src/leftMask.sol b/packages/store/src/leftMask.sol deleted file mode 100644 index 9343cfc5a8..0000000000 --- a/packages/store/src/leftMask.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.21; - -import { BYTE_TO_BITS } from "./constants.sol"; - -/** - * @title Byte Mask Utility - * @notice Utility functions to manage bytes in memory. - * @dev Adapted from https://github.com/dk1a/solidity-stringutils/blob/main/src/utils/mem.sol#L149-L167 - */ - -/** - * @notice Computes a left-aligned byte mask based on the provided byte length. - * @dev The mask is used to extract a specified number of leftmost bytes. - * For byte lengths greater than or equal to 32, it returns the max value of type(uint256). - * Examples: - * length 0: 0x000000...000000 - * length 1: 0xff0000...000000 - * length 2: 0xffff00...000000 - * ... - * length 30: 0xffffff...ff0000 - * length 31: 0xffffff...ffff00 - * length 32+: 0xffffff...ffffff - * @param byteLength The number of leftmost bytes to be masked. - * @return mask A left-aligned byte mask corresponding to the specified byte length. - */ -function leftMask(uint256 byteLength) pure returns (uint256 mask) { - unchecked { - return ~(type(uint256).max >> (byteLength * BYTE_TO_BITS)); - } -} diff --git a/packages/store/src/rightMask.sol b/packages/store/src/rightMask.sol new file mode 100644 index 0000000000..932b031dc9 --- /dev/null +++ b/packages/store/src/rightMask.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.21; + +import { BYTE_TO_BITS } from "./constants.sol"; + +/** + * @title Byte Mask Utility + * @notice Utility functions to manage bytes in memory. + * @dev Adapted from https://github.com/dk1a/solidity-stringutils/blob/main/src/utils/mem.sol#L149-L167 + */ + +/** + * @notice Computes a right-aligned byte mask based on the provided byte length. + * @dev The mask is used to extract a specified number of rightmost bytes. + + * @param byteLength The number of rightmost bytes to be masked. + * @return mask A right-aligned byte mask corresponding to the specified byte length. + */ +function rightMask(uint256 byteLength) pure returns (uint256 mask) { + unchecked { + return type(uint256).max >> (byteLength * BYTE_TO_BITS); + } +} diff --git a/packages/store/test/leftMask.t.sol b/packages/store/test/leftMask.t.sol deleted file mode 100644 index 2b8c5c4e9a..0000000000 --- a/packages/store/test/leftMask.t.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.21; - -import { Test } from "forge-std/Test.sol"; -import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; -import { leftMask } from "../src/leftMask.sol"; - -contract LeftMaskTest is Test, GasReporter { - function testLeftMask() public { - bytes32 mask; - assertEq(leftMask(0), uint256(mask)); - bytes32 highByte = hex"ff"; - for (uint256 i = 1; i <= 32; i++) { - mask |= highByte; - highByte >>= 8; - assertEq(leftMask(i), uint256(mask)); - } - } - - function testFuzzLeftMaskOver32(uint256 byteLength) public { - // for values >32 the mask must always be type(uint256).max - vm.assume(byteLength > 32); - assertEq(leftMask(byteLength), type(uint256).max); - } - - function testLeftMaskOver32() public { - // manually test for overflow issues - for (uint256 i; i < 100; i++) { - assertEq(leftMask(type(uint256).max - i), type(uint256).max); - } - for (uint256 i; i < 100; i++) { - assertEq(leftMask((type(uint256).max >> 8) + 50 - i), type(uint256).max); - } - } -} diff --git a/packages/store/test/rightMask.t.sol b/packages/store/test/rightMask.t.sol new file mode 100644 index 0000000000..d0c2b48ac7 --- /dev/null +++ b/packages/store/test/rightMask.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.21; + +import { Test } from "forge-std/Test.sol"; +import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; +import { rightMask } from "../src/rightMask.sol"; + +contract RightMaskTest is Test, GasReporter { + function testRightMask() public { + bytes32 mask; + assertEq(rightMask(0), type(uint256).max); + bytes32 highByte = hex"ff"; + for (uint256 i = 1; i <= 32; i++) { + mask |= highByte; + highByte >>= 8; + assertEq(rightMask(i), type(uint256).max - uint256(mask)); + } + } + + function testFuzzRightMaskOver32(uint256 byteLength) public { + // for values >32 the mask must always be 0 + vm.assume(byteLength > 32); + assertEq(rightMask(byteLength), 0); + } + + function testRightMaskOver32() public { + // manually test for underflow issues + for (uint256 i; i < 100; i++) { + assertEq(rightMask(type(uint256).max - i), 0); + } + for (uint256 i; i < 100; i++) { + assertEq(rightMask((type(uint256).max >> 8) + 50 - i), 0); + } + } +} diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index aac5b28f3d..45708d4062 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -3,139 +3,139 @@ "file": "test/ERC20.t.sol", "test": "testApprove", "name": "approve", - "gasUsed": 114357 + "gasUsed": 114348 }, { "file": "test/ERC20.t.sol", "test": "testBurn", "name": "burn", - "gasUsed": 75919 + "gasUsed": 75910 }, { "file": "test/ERC20.t.sol", "test": "testMint", "name": "mint", - "gasUsed": 161758 + "gasUsed": 161749 }, { "file": "test/ERC20.t.sol", "test": "testTransfer", "name": "transfer", - "gasUsed": 93004 + "gasUsed": 92995 }, { "file": "test/ERC20.t.sol", "test": "testTransferFrom", "name": "transferFrom", - "gasUsed": 130343 + "gasUsed": 130331 }, { "file": "test/ERC721.t.sol", "test": "testApproveAllGas", "name": "setApprovalForAll", - "gasUsed": 113984 + "gasUsed": 113972 }, { "file": "test/ERC721.t.sol", "test": "testApproveGas", "name": "approve", - "gasUsed": 87993 + "gasUsed": 87981 }, { "file": "test/ERC721.t.sol", "test": "testBurnGas", "name": "burn", - "gasUsed": 101925 + "gasUsed": 101910 }, { "file": "test/ERC721.t.sol", "test": "testMintGas", "name": "mint", - "gasUsed": 169492 + "gasUsed": 169480 }, { "file": "test/ERC721.t.sol", "test": "testSafeMintToEOAGas", "name": "safeMint", - "gasUsed": 169763 + "gasUsed": 169751 }, { "file": "test/ERC721.t.sol", "test": "testSafeTransferFromToEOAGas", "name": "safeTransferFrom", - "gasUsed": 143759 + "gasUsed": 143744 }, { "file": "test/ERC721.t.sol", "test": "testTransferFromGas", "name": "transferFrom", - "gasUsed": 136916 + "gasUsed": 136901 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1435337 + "gasUsed": 1435289 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1435337 + "gasUsed": 1435289 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 158836 + "gasUsed": 158830 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1435337 + "gasUsed": 1435289 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1435337 + "gasUsed": 1435289 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22486 + "gasUsed": 22483 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 155947 + "gasUsed": 155938 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1435337 + "gasUsed": 1435289 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 21208 + "gasUsed": 21205 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 85169 + "gasUsed": 85160 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 681658 + "gasUsed": 681613 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,49 +153,49 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 681658 + "gasUsed": 681613 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 135413 + "gasUsed": 135410 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 681658 + "gasUsed": 681613 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 103816 + "gasUsed": 103813 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36471 + "gasUsed": 36468 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 681658 + "gasUsed": 681613 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 146648 + "gasUsed": 146645 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 111407 + "gasUsed": 111404 }, { "file": "test/query.t.sol", @@ -267,60 +267,60 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 118114 + "gasUsed": 118105 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36685 + "gasUsed": 36679 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromSystemDelegation", "name": "register a systembound delegation", - "gasUsed": 115667 + "gasUsed": 115658 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromSystemDelegation", "name": "call a system via a systembound delegation", - "gasUsed": 33857 + "gasUsed": 33851 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 112590 + "gasUsed": 112581 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26803 + "gasUsed": 26797 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 702662 + "gasUsed": 702605 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51033 + "gasUsed": 51027 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 671694 + "gasUsed": 671649 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51033 + "gasUsed": 51027 } ] diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index e3da94e612..ee91a3c228 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -45,109 +45,109 @@ "file": "test/BatchCall.t.sol", "test": "testBatchCallFromReturnData", "name": "call systems with batchCallFrom", - "gasUsed": 52571 + "gasUsed": 52559 }, { "file": "test/BatchCall.t.sol", "test": "testBatchCallReturnData", "name": "call systems with batchCall", - "gasUsed": 51417 + "gasUsed": 51405 }, { "file": "test/Factories.t.sol", "test": "testCreate2Factory", "name": "deploy contract via Create2", - "gasUsed": 4660544 + "gasUsed": 4659744 }, { "file": "test/Factories.t.sol", "test": "testWorldFactory", "name": "deploy world via WorldFactory", - "gasUsed": 12513229 + "gasUsed": 12512246 }, { "file": "test/World.t.sol", "test": "testCall", "name": "call a system via the World", - "gasUsed": 12364 + "gasUsed": 12361 }, { "file": "test/World.t.sol", "test": "testCallFromNamespaceDelegation", "name": "call a system via a namespace fallback delegation", - "gasUsed": 26137 + "gasUsed": 26131 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 47520 + "gasUsed": 47514 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "call a system via an unlimited delegation", - "gasUsed": 12800 + "gasUsed": 12797 }, { "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9840 + "gasUsed": 9837 }, { "file": "test/World.t.sol", "test": "testPushToDynamicField", "name": "Push data to the table", - "gasUsed": 85836 + "gasUsed": 85833 }, { "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 83111 + "gasUsed": 83102 }, { "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 120894 + "gasUsed": 120879 }, { "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 80412 + "gasUsed": 80403 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 164318 + "gasUsed": 164303 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 537042 + "gasUsed": 537033 }, { "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 36906 + "gasUsed": 36903 }, { "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 39050 + "gasUsed": 39047 }, { "file": "test/World.t.sol", "test": "testUnregisterUnlimitedDelegation", "name": "unregister an unlimited delegation", - "gasUsed": 26179 + "gasUsed": 26173 }, { "file": "test/WorldDynamicUpdate.t.sol", @@ -165,13 +165,13 @@ "file": "test/WorldDynamicUpdate.t.sol", "test": "testSpliceDynamicData", "name": "update in field 1 item (cold)", - "gasUsed": 25984 + "gasUsed": 25981 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testSpliceDynamicData", "name": "update in field 1 item (warm)", - "gasUsed": 13185 + "gasUsed": 13182 }, { "file": "test/WorldResourceId.t.sol",