From e5666fdaf5b7671812cc765c05240e1acb07c249 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 22:43:05 +0100 Subject: [PATCH 01/38] add overload for static data location with a single key --- packages/store/gas-report.json | 20 ++++++++++++++++---- packages/store/src/StoreCore.sol | 24 +++++++++++++++++++++--- packages/store/test/StoreCore.t.sol | 13 +++++++++++++ packages/store/test/StoreCoreGas.t.sol | 15 +++++++++++++++ 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 808cfb2080..32ca92653c 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -677,6 +677,18 @@ "name": "delete record (complex data, 3 slots)", "gasUsed": 6778 }, + { + "file": "test/StoreCoreGas.t.sol", + "test": "testGetStaticDataLocation", + "name": "get static data location (single key)", + "gasUsed": 217 + }, + { + "file": "test/StoreCoreGas.t.sol", + "test": "testGetStaticDataLocation", + "name": "get static data location (single key tuple)", + "gasUsed": 387 + }, { "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", @@ -699,7 +711,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 71248 + "gasUsed": 71270 }, { "file": "test/StoreCoreGas.t.sol", @@ -711,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 16870 + "gasUsed": 16892 }, { "file": "test/StoreCoreGas.t.sol", @@ -723,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 164402 + "gasUsed": 164424 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +747,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 17855 + "gasUsed": 17877 }, { "file": "test/StoreCoreGas.t.sol", diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index d2db8940e0..54f0590c5e 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -9,7 +9,7 @@ import { FieldLayout, FieldLayoutLib } from "./FieldLayout.sol"; import { Schema, SchemaLib } from "./Schema.sol"; import { PackedCounter } from "./PackedCounter.sol"; import { Slice, SliceLib } from "./Slice.sol"; -import { StoreHooks, Tables, ResourceIds, StoreHooksTableId } from "./codegen/index.sol"; +import { StoreHooks, Tables, TablesTableId, ResourceIds, StoreHooksTableId } from "./codegen/index.sol"; import { IStoreErrors } from "./IStoreErrors.sol"; import { IStoreHook } from "./IStoreHook.sol"; import { StoreSwitch } from "./StoreSwitch.sol"; @@ -83,7 +83,7 @@ library StoreCore { ************************************************************************/ /** - * Get the field layout for the given tableId + * Get the field layout for the given tableId. */ function getFieldLayout(ResourceId tableId) internal view returns (FieldLayout fieldLayout) { fieldLayout = FieldLayout.wrap(Tables._getFieldLayout(ResourceId.unwrap(tableId))); @@ -92,6 +92,17 @@ library StoreCore { } } + // /** + // * Get FieldLayout for a table with the given table ID + // */ + // function getFiedLayout(ResourceId tableId) internal returns (FieldLayout) { + // Storage.loadField({ + // storagePointer: StoreCoreInternal._getStaticDataLocation(ResourceId.unwrap(TableTableId), keyTuple), + // length: fieldLayout.atIndex(fieldIndex), + // offset: StoreCoreInternal._getStaticDataOffset(fieldLayout, fieldIndex) + // }); + // } + /** * Get the key schema for the given tableId */ @@ -906,12 +917,19 @@ library StoreCoreInternal { ///////////////////////////////////////////////////////////////////////// /** - * Compute the storage location based on tableId id and index tuple + * Compute the storage location based on tableId id and key tuple */ function _getStaticDataLocation(ResourceId tableId, bytes32[] memory keyTuple) internal pure returns (uint256) { return uint256(SLOT ^ keccak256(abi.encodePacked(tableId, keyTuple))); } + /** + * Compute the storage location based on tableId id and key (equivalent to keyTuple = [key]) + */ + function _getStaticDataLocation(ResourceId tableId, bytes32 key) internal pure returns (uint256) { + return uint256(SLOT ^ keccak256(abi.encodePacked(tableId, key))); + } + /** * Get storage offset for the given value field layout and (static length) index */ diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 02f3ce9ac2..4125340232 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -45,6 +45,19 @@ contract StoreCoreTest is Test, StoreMock { ResourceId _tableId = ResourceIdLib.encode({ typeId: RESOURCE_TABLE, name: "some table" }); ResourceId _tableId2 = ResourceIdLib.encode({ typeId: RESOURCE_TABLE, name: "some other table" }); + function testGetStaticDataLocation() public { + ResourceId tableId = _tableId; + bytes32 key = "some key"; + bytes32[] memory keyTuple = new bytes32[](1); + keyTuple[0] = key; + + // Expect the two methods to return the same value + assertEq( + StoreCoreInternal._getStaticDataLocation(tableId, keyTuple), + StoreCoreInternal._getStaticDataLocation(tableId, key) + ); + } + function testRegisterTable() public { ResourceId tableId = _tableId; diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 50990bad79..282a34f97d 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -38,6 +38,21 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { ResourceId _tableId = ResourceIdLib.encode({ typeId: RESOURCE_TABLE, name: "some table" }); ResourceId _tableId2 = ResourceIdLib.encode({ typeId: RESOURCE_TABLE, name: "some other table" }); + function testGetStaticDataLocation() public { + ResourceId tableId = _tableId; + bytes32 key = "some key"; + bytes32[] memory keyTuple = new bytes32[](1); + keyTuple[0] = key; + + startGasReport("get static data location (single key)"); + StoreCoreInternal._getStaticDataLocation(tableId, key); + endGasReport(); + + startGasReport("get static data location (single key tuple)"); + StoreCoreInternal._getStaticDataLocation(tableId, keyTuple); + endGasReport(); + } + function testRegisterAndGetFieldLayout() public { ResourceId tableId = _tableId; From 2b913f4514cffac5b3beeefe1fe946af7a8a1ed7 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 22:51:14 +0100 Subject: [PATCH 02/38] optimize get field layout --- packages/store/gas-report.json | 16 ++++++++-------- packages/store/src/StoreCore.sol | 27 ++++++++++----------------- packages/store/test/StoreCore.t.sol | 15 ++++----------- 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 32ca92653c..90a6891458 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -363,7 +363,7 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582081 + "gasUsed": 582065 }, { "file": "test/Mixed.t.sol", @@ -579,7 +579,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 2383 + "gasUsed": 2382 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -603,13 +603,13 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetSecondFieldLength", "name": "get field length (warm, 1 slot)", - "gasUsed": 1749 + "gasUsed": 1748 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetThirdFieldLength", "name": "get field length (warm due to , 2 slots)", - "gasUsed": 7753 + "gasUsed": 7754 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -633,7 +633,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 17247 + "gasUsed": 17248 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -771,13 +771,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get field layout (warm)", - "gasUsed": 1287 + "gasUsed": 697 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get value schema (warm)", - "gasUsed": 1808 + "gasUsed": 1807 }, { "file": "test/StoreCoreGas.t.sol", @@ -1119,7 +1119,7 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443558 + "gasUsed": 443574 }, { "file": "test/Vector2.t.sol", diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 54f0590c5e..15e6dc4311 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -83,26 +83,19 @@ library StoreCore { ************************************************************************/ /** - * Get the field layout for the given tableId. + * Get the field layout for the given table ID. */ - function getFieldLayout(ResourceId tableId) internal view returns (FieldLayout fieldLayout) { - fieldLayout = FieldLayout.wrap(Tables._getFieldLayout(ResourceId.unwrap(tableId))); - if (fieldLayout.isEmpty()) { - revert IStoreErrors.Store_TableNotFound(tableId, string(abi.encodePacked(tableId))); - } + function getFieldLayout(ResourceId tableId) internal view returns (FieldLayout) { + return + FieldLayout.wrap( + Storage.loadField({ + storagePointer: StoreCoreInternal._getStaticDataLocation(TablesTableId, ResourceId.unwrap(tableId)), + length: 32, + offset: 0 + }) + ); } - // /** - // * Get FieldLayout for a table with the given table ID - // */ - // function getFiedLayout(ResourceId tableId) internal returns (FieldLayout) { - // Storage.loadField({ - // storagePointer: StoreCoreInternal._getStaticDataLocation(ResourceId.unwrap(TableTableId), keyTuple), - // length: fieldLayout.atIndex(fieldIndex), - // offset: StoreCoreInternal._getStaticDataOffset(fieldLayout, fieldIndex) - // }); - // } - /** * Get the key schema for the given tableId */ diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 4125340232..ace9963324 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -189,18 +189,11 @@ contract StoreCoreTest is Test, StoreMock { assertTrue(ResourceIds._getExists(ResourceId.unwrap(tableId))); assertFalse(ResourceIds._getExists(ResourceId.unwrap(tableId2))); - IStore(this).getFieldLayout(tableId); - IStore(this).getValueSchema(tableId); - IStore(this).getKeySchema(tableId); + assertEq(FieldLayout.unwrap(IStore(this).getFieldLayout(tableId)), FieldLayout.unwrap(fieldLayout)); + assertEq(Schema.unwrap(IStore(this).getValueSchema(tableId)), Schema.unwrap(valueSchema)); + assertEq(Schema.unwrap(IStore(this).getKeySchema(tableId)), Schema.unwrap(defaultKeySchema)); - vm.expectRevert( - abi.encodeWithSelector( - IStoreErrors.Store_TableNotFound.selector, - tableId2, - string(abi.encodePacked(ResourceId.unwrap(tableId2))) - ) - ); - IStore(this).getFieldLayout(tableId2); + assertTrue(IStore(this).getFieldLayout(tableId2).isEmpty()); vm.expectRevert( abi.encodeWithSelector(IStoreErrors.Store_TableNotFound.selector, tableId2, string(abi.encodePacked(tableId2))) From def3f89b3f684cb2cd303a4f6ec6016a0ec5ea56 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 23:10:48 +0100 Subject: [PATCH 03/38] load field layout from storage --- packages/store/gas-report.json | 74 ++++++++++++++++---------------- packages/store/src/StoreCore.sol | 13 +++++- 2 files changed, 48 insertions(+), 39 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 90a6891458..23ba930834 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720205 + "gasUsed": 720486 }, { "file": "test/Mixed.t.sol", @@ -363,19 +363,19 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582065 + "gasUsed": 582346 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "set record in Mixed", - "gasUsed": 103978 + "gasUsed": 104924 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "get record from Mixed", - "gasUsed": 7091 + "gasUsed": 7093 }, { "file": "test/PackedCounter.t.sol", @@ -579,7 +579,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 2382 + "gasUsed": 2383 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -603,13 +603,13 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetSecondFieldLength", "name": "get field length (warm, 1 slot)", - "gasUsed": 1748 + "gasUsed": 1749 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetThirdFieldLength", "name": "get field length (warm due to , 2 slots)", - "gasUsed": 7754 + "gasUsed": 7753 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -633,7 +633,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 17248 + "gasUsed": 17247 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -657,7 +657,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 2059 + "gasUsed": 2058 }, { "file": "test/StoreCoreGas.t.sol", @@ -675,7 +675,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 6778 + "gasUsed": 7712 }, { "file": "test/StoreCoreGas.t.sol", @@ -699,7 +699,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", "name": "check for existence of table (non-existent)", - "gasUsed": 3249 + "gasUsed": 3250 }, { "file": "test/StoreCoreGas.t.sol", @@ -711,7 +711,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 71270 + "gasUsed": 73107 }, { "file": "test/StoreCoreGas.t.sol", @@ -723,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 16892 + "gasUsed": 18727 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 164424 + "gasUsed": 166262 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,13 +747,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 17877 + "gasUsed": 19713 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 10275 + "gasUsed": 10276 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,13 +765,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642079 + "gasUsed": 642360 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get field layout (warm)", - "gasUsed": 697 + "gasUsed": 923 }, { "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": 101934 + "gasUsed": 102868 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "get complex record with dynamic data (4 slots)", - "gasUsed": 4243 + "gasUsed": 4244 }, { "file": "test/StoreCoreGas.t.sol", @@ -819,13 +819,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "set dynamic length of dynamic index 1", - "gasUsed": 968 + "gasUsed": 967 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "reduce dynamic length of dynamic index 0", - "gasUsed": 958 + "gasUsed": 957 }, { "file": "test/StoreCoreGas.t.sol", @@ -837,13 +837,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 1333 + "gasUsed": 1334 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 30260 + "gasUsed": 30261 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +855,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53974 + "gasUsed": 53973 }, { "file": "test/StoreCoreGas.t.sol", @@ -873,13 +873,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2229 + "gasUsed": 2228 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 32179 + "gasUsed": 33112 }, { "file": "test/StoreCoreGas.t.sol", @@ -891,19 +891,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 54684 + "gasUsed": 55616 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "get static record (2 slots)", - "gasUsed": 1741 + "gasUsed": 1740 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 9627 + "gasUsed": 9628 }, { "file": "test/StoreCoreGas.t.sol", @@ -957,7 +957,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2915 + "gasUsed": 2916 }, { "file": "test/tables/Callbacks.t.sol", @@ -1011,13 +1011,13 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 7210 + "gasUsed": 10160 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 31219 + "gasUsed": 31220 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1035,7 +1035,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 16078 + "gasUsed": 19018 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1119,18 +1119,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443574 + "gasUsed": 443855 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 33096 + "gasUsed": 34040 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2540 + "gasUsed": 2541 } ] diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 15e6dc4311..0add5436fe 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -10,6 +10,7 @@ import { Schema, SchemaLib } from "./Schema.sol"; import { PackedCounter } from "./PackedCounter.sol"; import { Slice, SliceLib } from "./Slice.sol"; import { StoreHooks, Tables, TablesTableId, ResourceIds, StoreHooksTableId } from "./codegen/index.sol"; +import { _fieldLayout as TablesTableFieldLayout } from "./codegen/tables/Tables.sol"; import { IStoreErrors } from "./IStoreErrors.sol"; import { IStoreHook } from "./IStoreHook.sol"; import { StoreSwitch } from "./StoreSwitch.sol"; @@ -86,6 +87,10 @@ library StoreCore { * Get the field layout for the given table ID. */ function getFieldLayout(ResourceId tableId) internal view returns (FieldLayout) { + // Explicit check for the tables table to solve the bootstraping issue + if (ResourceId.unwrap(tableId) == ResourceId.unwrap(TablesTableId)) { + return TablesTableFieldLayout; + } return FieldLayout.wrap( Storage.loadField({ @@ -214,8 +219,10 @@ library StoreCore { bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData, - FieldLayout fieldLayout + FieldLayout ) internal { + FieldLayout fieldLayout = getFieldLayout(tableId); + // verify the value has the correct length for the tableId (based on the tableId's field layout) // to prevent invalid data from being stored @@ -432,7 +439,9 @@ library StoreCore { /** * Delete a record for the given tableId, key tuple and value field layout */ - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) internal { + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout) internal { + FieldLayout fieldLayout = getFieldLayout(tableId); + // Emit event to notify indexers emit Store_DeleteRecord(tableId, keyTuple); From 31fe7468d011986d3c093564a47f52479162494e Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 23:19:28 +0100 Subject: [PATCH 04/38] try emitting event instead of loading from storage for comparison --- packages/store/gas-report.json | 68 ++++++++++++++--------------- packages/store/src/IStore.sol | 2 +- packages/store/src/StoreCore.sol | 12 ++--- packages/store/test/StoreCore.t.sol | 2 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 23ba930834..c72582531e 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720486 + "gasUsed": 720205 }, { "file": "test/Mixed.t.sol", @@ -363,19 +363,19 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582346 + "gasUsed": 582081 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "set record in Mixed", - "gasUsed": 104924 + "gasUsed": 103978 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "get record from Mixed", - "gasUsed": 7093 + "gasUsed": 7091 }, { "file": "test/PackedCounter.t.sol", @@ -657,7 +657,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 2058 + "gasUsed": 2059 }, { "file": "test/StoreCoreGas.t.sol", @@ -675,7 +675,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 7712 + "gasUsed": 7060 }, { "file": "test/StoreCoreGas.t.sol", @@ -699,7 +699,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", "name": "check for existence of table (non-existent)", - "gasUsed": 3250 + "gasUsed": 3249 }, { "file": "test/StoreCoreGas.t.sol", @@ -711,7 +711,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 73107 + "gasUsed": 71270 }, { "file": "test/StoreCoreGas.t.sol", @@ -723,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18727 + "gasUsed": 17456 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 166262 + "gasUsed": 164424 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,13 +747,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 19713 + "gasUsed": 18441 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 10276 + "gasUsed": 10275 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,19 +765,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642360 + "gasUsed": 642079 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get field layout (warm)", - "gasUsed": 923 + "gasUsed": 922 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get value schema (warm)", - "gasUsed": 1807 + "gasUsed": 1808 }, { "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": 102868 + "gasUsed": 101934 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "get complex record with dynamic data (4 slots)", - "gasUsed": 4244 + "gasUsed": 4243 }, { "file": "test/StoreCoreGas.t.sol", @@ -819,13 +819,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "set dynamic length of dynamic index 1", - "gasUsed": 967 + "gasUsed": 968 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "reduce dynamic length of dynamic index 0", - "gasUsed": 957 + "gasUsed": 958 }, { "file": "test/StoreCoreGas.t.sol", @@ -837,13 +837,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 1334 + "gasUsed": 1333 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 30261 + "gasUsed": 30260 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +855,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53973 + "gasUsed": 53974 }, { "file": "test/StoreCoreGas.t.sol", @@ -873,13 +873,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2228 + "gasUsed": 2229 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 33112 + "gasUsed": 32179 }, { "file": "test/StoreCoreGas.t.sol", @@ -891,19 +891,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55616 + "gasUsed": 54684 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "get static record (2 slots)", - "gasUsed": 1740 + "gasUsed": 1741 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 9628 + "gasUsed": 9627 }, { "file": "test/StoreCoreGas.t.sol", @@ -957,7 +957,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2916 + "gasUsed": 2915 }, { "file": "test/tables/Callbacks.t.sol", @@ -1011,13 +1011,13 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 10160 + "gasUsed": 7492 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 31220 + "gasUsed": 31219 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1035,7 +1035,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 19018 + "gasUsed": 16360 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1119,18 +1119,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443855 + "gasUsed": 443574 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 34040 + "gasUsed": 33096 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2541 + "gasUsed": 2540 } ] diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 344b37ff88..03c2817607 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -107,7 +107,7 @@ interface IStoreWrite { bytes data, bytes32 encodedLengths ); - event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple); + event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple, FieldLayout fieldLayout); // Set full record (including full dynamic data) function setRecord( diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 0add5436fe..a4e88cd2ab 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -50,7 +50,7 @@ library StoreCore { bytes data, bytes32 encodedLengths ); - event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple); + event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple, FieldLayout fieldLayout); /** * Intialize the store address to use in StoreSwitch. @@ -219,9 +219,9 @@ library StoreCore { bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData, - FieldLayout + FieldLayout fieldLayout ) internal { - FieldLayout fieldLayout = getFieldLayout(tableId); + // FieldLayout fieldLayout = getFieldLayout(tableId); // verify the value has the correct length for the tableId (based on the tableId's field layout) // to prevent invalid data from being stored @@ -439,11 +439,11 @@ library StoreCore { /** * Delete a record for the given tableId, key tuple and value field layout */ - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout) internal { - FieldLayout fieldLayout = getFieldLayout(tableId); + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) internal { + // FieldLayout fieldLayout = getFieldLayout(tableId); // Emit event to notify indexers - emit Store_DeleteRecord(tableId, keyTuple); + emit Store_DeleteRecord(tableId, keyTuple, fieldLayout); // Early return if the table is an offchain table if (tableId.getType() != RESOURCE_TABLE) { diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index ace9963324..edf8d2c548 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -744,7 +744,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a Store_DeleteRecord event to be emitted vm.expectEmit(true, true, true, true); - emit Store_DeleteRecord(tableId, keyTuple); + emit Store_DeleteRecord(tableId, keyTuple, fieldLayout); // Delete data IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); From a86497d636b711907ffb6ea808ec7b336daabc70 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 23:19:45 +0100 Subject: [PATCH 05/38] Revert "try emitting event instead of loading from storage for comparison" This reverts commit 31fe7468d011986d3c093564a47f52479162494e. --- packages/store/gas-report.json | 68 ++++++++++++++--------------- packages/store/src/IStore.sol | 2 +- packages/store/src/StoreCore.sol | 12 ++--- packages/store/test/StoreCore.t.sol | 2 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index c72582531e..23ba930834 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720205 + "gasUsed": 720486 }, { "file": "test/Mixed.t.sol", @@ -363,19 +363,19 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582081 + "gasUsed": 582346 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "set record in Mixed", - "gasUsed": 103978 + "gasUsed": 104924 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "get record from Mixed", - "gasUsed": 7091 + "gasUsed": 7093 }, { "file": "test/PackedCounter.t.sol", @@ -657,7 +657,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 2059 + "gasUsed": 2058 }, { "file": "test/StoreCoreGas.t.sol", @@ -675,7 +675,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 7060 + "gasUsed": 7712 }, { "file": "test/StoreCoreGas.t.sol", @@ -699,7 +699,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", "name": "check for existence of table (non-existent)", - "gasUsed": 3249 + "gasUsed": 3250 }, { "file": "test/StoreCoreGas.t.sol", @@ -711,7 +711,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 71270 + "gasUsed": 73107 }, { "file": "test/StoreCoreGas.t.sol", @@ -723,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 17456 + "gasUsed": 18727 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 164424 + "gasUsed": 166262 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,13 +747,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 18441 + "gasUsed": 19713 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 10275 + "gasUsed": 10276 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,19 +765,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642079 + "gasUsed": 642360 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get field layout (warm)", - "gasUsed": 922 + "gasUsed": 923 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get value schema (warm)", - "gasUsed": 1808 + "gasUsed": 1807 }, { "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": 101934 + "gasUsed": 102868 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "get complex record with dynamic data (4 slots)", - "gasUsed": 4243 + "gasUsed": 4244 }, { "file": "test/StoreCoreGas.t.sol", @@ -819,13 +819,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "set dynamic length of dynamic index 1", - "gasUsed": 968 + "gasUsed": 967 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "reduce dynamic length of dynamic index 0", - "gasUsed": 958 + "gasUsed": 957 }, { "file": "test/StoreCoreGas.t.sol", @@ -837,13 +837,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 1333 + "gasUsed": 1334 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 30260 + "gasUsed": 30261 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +855,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53974 + "gasUsed": 53973 }, { "file": "test/StoreCoreGas.t.sol", @@ -873,13 +873,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2229 + "gasUsed": 2228 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 32179 + "gasUsed": 33112 }, { "file": "test/StoreCoreGas.t.sol", @@ -891,19 +891,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 54684 + "gasUsed": 55616 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "get static record (2 slots)", - "gasUsed": 1741 + "gasUsed": 1740 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 9627 + "gasUsed": 9628 }, { "file": "test/StoreCoreGas.t.sol", @@ -957,7 +957,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2915 + "gasUsed": 2916 }, { "file": "test/tables/Callbacks.t.sol", @@ -1011,13 +1011,13 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 7492 + "gasUsed": 10160 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 31219 + "gasUsed": 31220 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1035,7 +1035,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 16360 + "gasUsed": 19018 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1119,18 +1119,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443574 + "gasUsed": 443855 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 33096 + "gasUsed": 34040 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2540 + "gasUsed": 2541 } ] diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 03c2817607..344b37ff88 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -107,7 +107,7 @@ interface IStoreWrite { bytes data, bytes32 encodedLengths ); - event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple, FieldLayout fieldLayout); + event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple); // Set full record (including full dynamic data) function setRecord( diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index a4e88cd2ab..0add5436fe 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -50,7 +50,7 @@ library StoreCore { bytes data, bytes32 encodedLengths ); - event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple, FieldLayout fieldLayout); + event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple); /** * Intialize the store address to use in StoreSwitch. @@ -219,9 +219,9 @@ library StoreCore { bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData, - FieldLayout fieldLayout + FieldLayout ) internal { - // FieldLayout fieldLayout = getFieldLayout(tableId); + FieldLayout fieldLayout = getFieldLayout(tableId); // verify the value has the correct length for the tableId (based on the tableId's field layout) // to prevent invalid data from being stored @@ -439,11 +439,11 @@ library StoreCore { /** * Delete a record for the given tableId, key tuple and value field layout */ - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) internal { - // FieldLayout fieldLayout = getFieldLayout(tableId); + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout) internal { + FieldLayout fieldLayout = getFieldLayout(tableId); // Emit event to notify indexers - emit Store_DeleteRecord(tableId, keyTuple, fieldLayout); + emit Store_DeleteRecord(tableId, keyTuple); // Early return if the table is an offchain table if (tableId.getType() != RESOURCE_TABLE) { diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index edf8d2c548..ace9963324 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -744,7 +744,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a Store_DeleteRecord event to be emitted vm.expectEmit(true, true, true, true); - emit Store_DeleteRecord(tableId, keyTuple, fieldLayout); + emit Store_DeleteRecord(tableId, keyTuple); // Delete data IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); From b09468d4ddc15c794e444a72a43a07b3622afb63 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 23:28:58 +0100 Subject: [PATCH 06/38] remove field layout from deleteRecord signature --- .../contracts/src/codegen/tables/Multi.sol | 6 +++--- .../contracts/src/codegen/tables/Number.sol | 6 +++--- .../contracts/src/codegen/tables/NumberList.sol | 6 +++--- .../contracts/src/codegen/tables/Vector.sol | 6 +++--- .../contracts/src/codegen/tables/CounterTable.sol | 6 +++--- .../contracts/src/codegen/tables/Inventory.sol | 6 +++--- .../contracts/src/codegen/tables/MessageTable.sol | 6 +++--- .../cli/contracts/src/codegen/tables/Dynamics1.sol | 6 +++--- .../cli/contracts/src/codegen/tables/Dynamics2.sol | 6 +++--- .../cli/contracts/src/codegen/tables/Offchain.sol | 6 +++--- .../cli/contracts/src/codegen/tables/Singleton.sol | 6 +++--- .../cli/contracts/src/codegen/tables/Statics.sol | 6 +++--- packages/store/gas-report.json | 10 +++++----- packages/store/src/IStore.sol | 2 +- packages/store/src/StoreCore.sol | 2 +- packages/store/src/StoreSwitch.sol | 6 +++--- packages/store/src/codegen/tables/Callbacks.sol | 6 +++--- packages/store/src/codegen/tables/Hooks.sol | 6 +++--- packages/store/src/codegen/tables/KeyEncoding.sol | 6 +++--- packages/store/src/codegen/tables/Mixed.sol | 6 +++--- packages/store/src/codegen/tables/ResourceIds.sol | 6 +++--- packages/store/src/codegen/tables/StoreHooks.sol | 6 +++--- packages/store/src/codegen/tables/Tables.sol | 6 +++--- packages/store/src/codegen/tables/Vector2.sol | 6 +++--- packages/store/test/MirrorSubscriber.sol | 2 +- packages/store/test/StoreCore.t.sol | 10 +++++----- packages/store/test/StoreCoreGas.t.sol | 6 +++--- packages/store/test/StoreMock.sol | 4 ++-- packages/store/ts/codegen/record.ts | 2 +- packages/world/src/World.sol | 2 +- .../world/src/modules/core/tables/Balances.sol | 6 +++--- .../src/modules/core/tables/FunctionSelectors.sol | 6 +++--- .../src/modules/core/tables/FunctionSignatures.sol | 6 +++--- .../world/src/modules/core/tables/SystemHooks.sol | 6 +++--- .../src/modules/core/tables/SystemRegistry.sol | 6 +++--- packages/world/src/modules/core/tables/Systems.sol | 6 +++--- .../src/modules/keysintable/tables/KeysInTable.sol | 6 +++--- .../modules/keysintable/tables/UsedKeysIndex.sol | 6 +++--- .../modules/keyswithvalue/tables/KeysWithValue.sol | 6 +++--- .../tables/CallboundDelegations.sol | 6 +++--- .../tables/TimeboundDelegations.sol | 6 +++--- .../modules/uniqueentity/tables/UniqueEntity.sol | 6 +++--- packages/world/src/tables/Delegations.sol | 6 +++--- packages/world/src/tables/InstalledModules.sol | 6 +++--- packages/world/src/tables/NamespaceOwner.sol | 6 +++--- packages/world/src/tables/ResourceAccess.sol | 6 +++--- packages/world/test/World.t.sol | 14 +++++++------- packages/world/test/tables/AddressArray.sol | 6 +++--- packages/world/test/tables/Bool.sol | 6 +++--- packages/world/test/tables/TwoFields.sol | 6 +++--- .../contracts/src/codegen/tables/Counter.sol | 6 +++--- .../contracts/src/codegen/tables/Counter.sol | 6 +++--- .../contracts/src/codegen/tables/Position.sol | 6 +++--- .../contracts/src/codegen/tables/Counter.sol | 6 +++--- 54 files changed, 159 insertions(+), 159 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index bc2f7c4e6e..12a1ca9b0e 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -403,7 +403,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -414,7 +414,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -425,7 +425,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index 339abd0feb..17f796a50a 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -185,7 +185,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -193,7 +193,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -201,7 +201,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index abfad96a35..0a5eacfed0 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -478,21 +478,21 @@ library NumberList { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 30513851e3..22cf65a3af 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -331,7 +331,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -339,7 +339,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -347,7 +347,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol index 9aa6a37376..30dcd3729b 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol @@ -170,21 +170,21 @@ library CounterTable { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol index 49f685a0b1..6a724eddad 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol @@ -220,7 +220,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -230,7 +230,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -240,7 +240,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index ae3ce987db..10d7550099 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -141,21 +141,21 @@ library MessageTable { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index d71529b3dc..96ff5fb548 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -1478,7 +1478,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -1486,7 +1486,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -1494,7 +1494,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index 8347277c43..ca76f89d5c 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -904,7 +904,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -912,7 +912,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -920,7 +920,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/cli/contracts/src/codegen/tables/Offchain.sol b/packages/cli/contracts/src/codegen/tables/Offchain.sol index 9400c79ef6..f2551b612f 100644 --- a/packages/cli/contracts/src/codegen/tables/Offchain.sol +++ b/packages/cli/contracts/src/codegen/tables/Offchain.sol @@ -162,7 +162,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -170,7 +170,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -178,7 +178,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 1e87e6d89c..70ff5cb033 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -852,21 +852,21 @@ library Singleton { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index 0c6d986b4f..ee398e465b 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -919,7 +919,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -932,7 +932,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -945,7 +945,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 23ba930834..71010a7722 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -675,7 +675,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 7712 + "gasUsed": 7707 }, { "file": "test/StoreCoreGas.t.sol", @@ -723,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18727 + "gasUsed": 18639 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,7 +747,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 19713 + "gasUsed": 19625 }, { "file": "test/StoreCoreGas.t.sol", @@ -1011,7 +1011,7 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 10160 + "gasUsed": 10132 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1035,7 +1035,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 19018 + "gasUsed": 18990 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 344b37ff88..628294f273 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -176,7 +176,7 @@ interface IStoreWrite { ) external; // Set full record (including full dynamic data) - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) external; + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) external; } /** diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 0add5436fe..1fdea9ab8d 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -439,7 +439,7 @@ library StoreCore { /** * Delete a record for the given tableId, key tuple and value field layout */ - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout) internal { + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) internal { FieldLayout fieldLayout = getFieldLayout(tableId); // Emit event to notify indexers diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 2c540fec70..e2c8d902e9 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -225,12 +225,12 @@ library StoreSwitch { } } - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) internal { + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.deleteRecord(tableId, keyTuple, fieldLayout); + StoreCore.deleteRecord(tableId, keyTuple); } else { - IStore(_storeAddress).deleteRecord(tableId, keyTuple, fieldLayout); + IStore(_storeAddress).deleteRecord(tableId, keyTuple); } } diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index 23315c30a9..d9707a9709 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -537,7 +537,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -545,7 +545,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -553,7 +553,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index e836bd9352..88f7f74088 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -537,7 +537,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -545,7 +545,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -553,7 +553,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 2351d5ee75..3fc24707c4 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -325,7 +325,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -338,7 +338,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -351,7 +351,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 2aca3ce5d4..58bb6e4dfb 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -801,7 +801,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -809,7 +809,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -817,7 +817,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/store/src/codegen/tables/ResourceIds.sol b/packages/store/src/codegen/tables/ResourceIds.sol index 9414ce5464..df9eb45e94 100644 --- a/packages/store/src/codegen/tables/ResourceIds.sol +++ b/packages/store/src/codegen/tables/ResourceIds.sol @@ -185,7 +185,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -193,7 +193,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -201,7 +201,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index 63f987692c..825b7359c9 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -537,7 +537,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -545,7 +545,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -553,7 +553,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index ffdd1b208a..2a1e92427f 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -895,7 +895,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -903,7 +903,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -911,7 +911,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index 69a48138d5..a214afcdd8 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -331,7 +331,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -339,7 +339,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -347,7 +347,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/store/test/MirrorSubscriber.sol b/packages/store/test/MirrorSubscriber.sol index 2a355201df..9c9096f521 100644 --- a/packages/store/test/MirrorSubscriber.sol +++ b/packages/store/test/MirrorSubscriber.sol @@ -84,6 +84,6 @@ contract MirrorSubscriber is StoreHook { FieldLayout fieldLayout ) public override { if (ResourceId.unwrap(tableId) != _tableId) revert("invalid tableId"); - StoreSwitch.deleteRecord(indexerTableId, keyTuple, fieldLayout); + StoreSwitch.deleteRecord(indexerTableId, keyTuple); } } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index ace9963324..c6126d50ab 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -747,7 +747,7 @@ contract StoreCoreTest is Test, StoreMock { emit Store_DeleteRecord(tableId, keyTuple); // Delete data - IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); + IStore(this).deleteRecord(tableId, keyTuple); // Verify data is deleted (loadedStaticData, loadedEncodedLengths, loadedDynamicData) = IStore(this).getRecord( @@ -1127,7 +1127,7 @@ contract StoreCoreTest is Test, StoreMock { (indexedData, , ) = IStore(this).getRecord(indexerTableId, keyTuple, fieldLayout); assertEq(keccak256(staticData), keccak256(indexedData)); - IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); + IStore(this).deleteRecord(tableId, keyTuple); // Get data from indexed table - the indexer should have mirrored the data there (indexedData, , ) = IStore(this).getRecord(indexerTableId, keyTuple, fieldLayout); @@ -1172,7 +1172,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a revert when the RevertSubscriber's onBeforeDeleteRecord hook is called vm.expectRevert(bytes("onBeforeDeleteRecord")); - IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); + IStore(this).deleteRecord(tableId, keyTuple); // Unregister the RevertSubscriber IStore(this).unregisterStoreHook(tableId, revertSubscriber); @@ -1241,7 +1241,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectEmit(true, true, true, true); emit HookCalled(abi.encodeCall(IStoreHook.onAfterDeleteRecord, (tableId, keyTuple, fieldLayout))); - IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); + IStore(this).deleteRecord(tableId, keyTuple); } struct RecordData { @@ -1319,7 +1319,7 @@ contract StoreCoreTest is Test, StoreMock { assertEq(loadedData.encodedLengths.unwrap(), recordData.encodedLengths.unwrap()); assertEq(loadedData.dynamicData, recordData.dynamicData); - IStore(this).deleteRecord(tableId, keyTuple, fieldLayout); + IStore(this).deleteRecord(tableId, keyTuple); // Get data from indexed table - the indexer should have mirrored the data there (loadedData.staticData, loadedData.encodedLengths, loadedData.dynamicData) = IStore(this).getRecord( diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 282a34f97d..70a9a336ba 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -417,7 +417,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Delete data startGasReport("delete record (complex data, 3 slots)"); - StoreCore.deleteRecord(tableId, keyTuple, fieldLayout); + StoreCore.deleteRecord(tableId, keyTuple); endGasReport(); } @@ -656,7 +656,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { endGasReport(); startGasReport("delete record on table with subscriber"); - StoreCore.deleteRecord(tableId, keyTuple, fieldLayout); + StoreCore.deleteRecord(tableId, keyTuple); endGasReport(); } @@ -708,7 +708,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { endGasReport(); startGasReport("delete (dynamic) record on table with subscriber"); - StoreCore.deleteRecord(tableId, keyTuple, fieldLayout); + StoreCore.deleteRecord(tableId, keyTuple); endGasReport(); } } diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index 7028b83418..bec595d56c 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -99,8 +99,8 @@ contract StoreMock is IStore, StoreRead { } // Set full record (including full dynamic data) - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) public virtual { - StoreCore.deleteRecord(tableId, keyTuple, fieldLayout); + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) public virtual { + StoreCore.deleteRecord(tableId, keyTuple); } function registerTable( diff --git a/packages/store/ts/codegen/record.ts b/packages/store/ts/codegen/record.ts index 8824a08e63..0353559a6c 100644 --- a/packages/store/ts/codegen/record.ts +++ b/packages/store/ts/codegen/record.ts @@ -127,7 +127,7 @@ export function renderDeleteRecordMethods(options: RenderTableOptions) { _typedKeyArgs, ])}) internal { ${_keyTupleDefinition} - ${_store}.deleteRecord(_tableId, _keyTuple, _fieldLayout); + ${_store}.deleteRecord(_tableId, _keyTuple); } ` ); diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 91e35b256b..5a16e72fe0 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -242,7 +242,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { AccessControl.requireAccess(tableId, msg.sender); // Delete the record - StoreCore.deleteRecord(tableId, keyTuple, fieldLayout); + StoreCore.deleteRecord(tableId, keyTuple); } /************************************************************************ diff --git a/packages/world/src/modules/core/tables/Balances.sol b/packages/world/src/modules/core/tables/Balances.sol index a5c091c2fc..3b73d65437 100644 --- a/packages/world/src/modules/core/tables/Balances.sol +++ b/packages/world/src/modules/core/tables/Balances.sol @@ -185,7 +185,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -193,7 +193,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -201,7 +201,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index 5bea8fed05..8bcc58d0ff 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -293,7 +293,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -301,7 +301,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -309,7 +309,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/core/tables/FunctionSignatures.sol b/packages/world/src/modules/core/tables/FunctionSignatures.sol index 263809abaa..d328eeb55f 100644 --- a/packages/world/src/modules/core/tables/FunctionSignatures.sol +++ b/packages/world/src/modules/core/tables/FunctionSignatures.sol @@ -147,7 +147,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -155,7 +155,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -163,7 +163,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 2f04ecde7d..168ed63f57 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -537,7 +537,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -545,7 +545,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -553,7 +553,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/modules/core/tables/SystemRegistry.sol index 4160e95bce..8528cf6de7 100644 --- a/packages/world/src/modules/core/tables/SystemRegistry.sol +++ b/packages/world/src/modules/core/tables/SystemRegistry.sol @@ -185,7 +185,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -193,7 +193,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -201,7 +201,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index 934122ca26..05a1e7d472 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -287,7 +287,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -295,7 +295,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -303,7 +303,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 1939a1ffdb..89ceb23794 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -1432,7 +1432,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -1440,7 +1440,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -1448,7 +1448,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index 9cd905b612..51d122933e 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -308,7 +308,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -317,7 +317,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -326,7 +326,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 7621b94d5f..fe7f897ca8 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -575,7 +575,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -583,7 +583,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -591,7 +591,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol index 1cbdff95f9..eb091d0714 100644 --- a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol @@ -300,7 +300,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -311,7 +311,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -328,7 +328,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol index a8393b5e2f..509bb58689 100644 --- a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol @@ -204,7 +204,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -213,7 +213,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -222,7 +222,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol index 0d1b5db6d8..286024f80a 100644 --- a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -165,21 +165,21 @@ library UniqueEntity { function deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store, ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/tables/Delegations.sol b/packages/world/src/tables/Delegations.sol index 1b241f93e0..5d11b8dc67 100644 --- a/packages/world/src/tables/Delegations.sol +++ b/packages/world/src/tables/Delegations.sol @@ -219,7 +219,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -228,7 +228,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -237,7 +237,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/tables/InstalledModules.sol index 5b80739eff..63ff32ca70 100644 --- a/packages/world/src/tables/InstalledModules.sol +++ b/packages/world/src/tables/InstalledModules.sol @@ -204,7 +204,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -213,7 +213,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -222,7 +222,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/tables/NamespaceOwner.sol index 62832ecd4b..ffb39a62f1 100644 --- a/packages/world/src/tables/NamespaceOwner.sol +++ b/packages/world/src/tables/NamespaceOwner.sol @@ -185,7 +185,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -193,7 +193,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -201,7 +201,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/tables/ResourceAccess.sol index 57ee1ea25e..add7c5658d 100644 --- a/packages/world/src/tables/ResourceAccess.sol +++ b/packages/world/src/tables/ResourceAccess.sol @@ -200,7 +200,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -209,7 +209,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -218,7 +218,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 50abcff526..13253902fb 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -824,7 +824,7 @@ contract WorldTest is Test, GasReporter { assertEq(AddressArray.get(world, tableId, key), dataToPush); // Delete the data - world.deleteRecord(tableId, keyTuple, fieldLayout); + world.deleteRecord(tableId, keyTuple); // Push data to the table via direct access world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); @@ -864,7 +864,7 @@ contract WorldTest is Test, GasReporter { assertTrue(Bool.get(world, tableId)); startGasReport("Delete record"); - world.deleteRecord(tableId, singletonKey, fieldLayout); + world.deleteRecord(tableId, singletonKey); endGasReport(); // expect it to be deleted @@ -884,14 +884,14 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to delete from an address that doesn't have access _expectAccessDenied(address(0x02), namespace, name, RESOURCE_TABLE); - world.deleteRecord(tableId, singletonKey, fieldLayout); + world.deleteRecord(tableId, singletonKey); // Expect the World to not have access vm.prank(address(world)); vm.expectRevert( abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.deleteRecord.selector) ); - world.deleteRecord(tableId, singletonKey, fieldLayout); + world.deleteRecord(tableId, singletonKey); } function testCall() public { @@ -1121,7 +1121,7 @@ contract WorldTest is Test, GasReporter { vm.expectEmit(true, true, true, true); emit HookCalled(abi.encodeCall(IStoreHook.onAfterDeleteRecord, (tableId, singletonKey, fieldLayout))); - world.deleteRecord(tableId, singletonKey, fieldLayout); + world.deleteRecord(tableId, singletonKey); // Expect an error when trying to register an address that doesn't implement the IStoreHook interface vm.expectRevert( @@ -1162,7 +1162,7 @@ contract WorldTest is Test, GasReporter { // Expect a revert when the RevertSubscriber's onBeforeDeleteRecord hook is called vm.expectRevert(bytes("onBeforeDeleteRecord")); - world.deleteRecord(tableId, singletonKey, fieldLayout); + world.deleteRecord(tableId, singletonKey); // Unregister the RevertSubscriber world.unregisterStoreHook(tableId, revertSubscriber); @@ -1212,7 +1212,7 @@ contract WorldTest is Test, GasReporter { vm.expectEmit(true, true, true, true); emit HookCalled(abi.encodeCall(IStoreHook.onAfterDeleteRecord, (tableId, singletonKey, fieldLayout))); - world.deleteRecord(tableId, singletonKey, fieldLayout); + world.deleteRecord(tableId, singletonKey); } function testRegisterSystemHook() public { diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 26a7d7775b..12b88aec69 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -537,7 +537,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -545,7 +545,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -553,7 +553,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack dynamic data using this table's schema */ diff --git a/packages/world/test/tables/Bool.sol b/packages/world/test/tables/Bool.sol index 425534d339..c7de244193 100644 --- a/packages/world/test/tables/Bool.sol +++ b/packages/world/test/tables/Bool.sol @@ -165,21 +165,21 @@ library Bool { function deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store, ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/packages/world/test/tables/TwoFields.sol b/packages/world/test/tables/TwoFields.sol index a85c9eed17..781d359f1f 100644 --- a/packages/world/test/tables/TwoFields.sol +++ b/packages/world/test/tables/TwoFields.sol @@ -302,21 +302,21 @@ library TwoFields { function deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store, ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol index 26d56e1b79..37c25bf200 100644 --- a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol @@ -170,21 +170,21 @@ library Counter { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/templates/react/packages/contracts/src/codegen/tables/Counter.sol b/templates/react/packages/contracts/src/codegen/tables/Counter.sol index 26d56e1b79..37c25bf200 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Counter.sol @@ -170,21 +170,21 @@ library Counter { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index bb7632f63a..e58e3d1e50 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -387,7 +387,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ @@ -395,7 +395,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ @@ -403,7 +403,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ diff --git a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol index 26d56e1b79..37c25bf200 100644 --- a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol @@ -170,21 +170,21 @@ library Counter { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreSwitch.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys */ function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + StoreCore.deleteRecord(_tableId, _keyTuple); } /** Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple, _fieldLayout); + _store.deleteRecord(_tableId, _keyTuple); } /** Tightly pack static data using this table's schema */ From 34f8d290e6418ba1ab58513960ceef398a9acb27 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 22 Sep 2023 23:37:36 +0100 Subject: [PATCH 07/38] remove field layout from setRecord --- .../contracts/src/codegen/tables/Multi.sol | 12 +++---- .../contracts/src/codegen/tables/Vector.sol | 12 +++---- .../src/codegen/tables/MessageTable.sol | 6 ++-- .../src/codegen/tables/Dynamics1.sol | 12 +++---- .../src/codegen/tables/Dynamics2.sol | 12 +++---- .../contracts/src/codegen/tables/Offchain.sol | 6 ++-- .../src/codegen/tables/Singleton.sol | 6 ++-- .../contracts/src/codegen/tables/Statics.sol | 12 +++---- packages/store/gas-report.json | 32 +++++++++---------- packages/store/src/IStore.sol | 3 +- packages/store/src/StoreCore.sol | 3 +- packages/store/src/StoreSwitch.sol | 7 ++-- packages/store/src/codegen/tables/Mixed.sol | 12 +++---- packages/store/src/codegen/tables/Tables.sol | 12 +++---- packages/store/src/codegen/tables/Vector2.sol | 12 +++---- packages/store/test/MirrorSubscriber.sol | 2 +- packages/store/test/StoreCore.t.sol | 25 ++++++--------- packages/store/test/StoreCoreGas.t.sol | 12 +++---- packages/store/test/StoreMock.sol | 5 ++- packages/store/ts/codegen/record.ts | 4 +-- packages/world/src/World.sol | 2 +- .../modules/core/tables/FunctionSelectors.sol | 6 ++-- .../core/tables/FunctionSignatures.sol | 6 ++-- .../world/src/modules/core/tables/Systems.sol | 6 ++-- .../keysintable/tables/KeysInTable.sol | 12 +++---- .../keysintable/tables/UsedKeysIndex.sol | 6 ++-- packages/world/test/World.t.sol | 6 ++-- packages/world/test/tables/TwoFields.sol | 12 +++---- .../contracts/src/codegen/tables/Position.sol | 12 +++---- 29 files changed, 132 insertions(+), 143 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index 12a1ca9b0e..6ff755b012 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -290,7 +290,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -306,7 +306,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -322,7 +322,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -338,7 +338,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -354,7 +354,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -370,7 +370,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 22cf65a3af..228798bc56 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -236,7 +236,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -249,7 +249,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -262,7 +262,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -275,7 +275,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -288,7 +288,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -301,7 +301,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index 10d7550099..ae113bf28d 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -84,7 +84,7 @@ library MessageTable { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -95,7 +95,7 @@ library MessageTable { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -106,7 +106,7 @@ library MessageTable { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 96ff5fb548..758acbd8ef 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -1294,7 +1294,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -1313,7 +1313,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -1333,7 +1333,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -1357,7 +1357,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -1381,7 +1381,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -1405,7 +1405,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index ca76f89d5c..2d8ffc072e 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -796,7 +796,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -808,7 +808,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -820,7 +820,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -832,7 +832,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -844,7 +844,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -856,7 +856,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/cli/contracts/src/codegen/tables/Offchain.sol b/packages/cli/contracts/src/codegen/tables/Offchain.sol index f2551b612f..248597a576 100644 --- a/packages/cli/contracts/src/codegen/tables/Offchain.sol +++ b/packages/cli/contracts/src/codegen/tables/Offchain.sol @@ -112,7 +112,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -125,7 +125,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -138,7 +138,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 70ff5cb033..689d93060a 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -771,7 +771,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -783,7 +783,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -795,7 +795,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index ee398e465b..d23ccb2b21 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -748,7 +748,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -779,7 +779,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -811,7 +811,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -829,7 +829,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -847,7 +847,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -874,7 +874,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 71010a7722..0a76dcf6ef 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720486 + "gasUsed": 720481 }, { "file": "test/Mixed.t.sol", @@ -363,19 +363,19 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582346 + "gasUsed": 582351 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "set record in Mixed", - "gasUsed": 104924 + "gasUsed": 104908 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "get record from Mixed", - "gasUsed": 7093 + "gasUsed": 7087 }, { "file": "test/PackedCounter.t.sol", @@ -573,7 +573,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 8311 + "gasUsed": 8315 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -591,7 +591,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4608 + "gasUsed": 4612 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -711,7 +711,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 73107 + "gasUsed": 73020 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 166262 + "gasUsed": 166175 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,7 +765,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642360 + "gasUsed": 642355 }, { "file": "test/StoreCoreGas.t.sol", @@ -789,7 +789,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 102868 + "gasUsed": 102863 }, { "file": "test/StoreCoreGas.t.sol", @@ -879,7 +879,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 33112 + "gasUsed": 33107 }, { "file": "test/StoreCoreGas.t.sol", @@ -891,7 +891,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55616 + "gasUsed": 55611 }, { "file": "test/StoreCoreGas.t.sol", @@ -957,7 +957,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2916 + "gasUsed": 2920 }, { "file": "test/tables/Callbacks.t.sol", @@ -1119,18 +1119,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443855 + "gasUsed": 443844 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 34040 + "gasUsed": 34024 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2541 + "gasUsed": 2539 } ] diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 628294f273..8c003e006d 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -115,8 +115,7 @@ interface IStoreWrite { bytes32[] calldata keyTuple, bytes calldata staticData, PackedCounter encodedLengths, - bytes calldata dynamicData, - FieldLayout fieldLayout + bytes calldata dynamicData ) external; // Splice data in the static part of the record diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 1fdea9ab8d..6837a214bd 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -218,8 +218,7 @@ library StoreCore { bytes32[] memory keyTuple, bytes memory staticData, PackedCounter encodedLengths, - bytes memory dynamicData, - FieldLayout + bytes memory dynamicData ) internal { FieldLayout fieldLayout = getFieldLayout(tableId); diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index e2c8d902e9..bd0dc4efdc 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -115,14 +115,13 @@ library StoreSwitch { bytes32[] memory keyTuple, bytes memory staticData, PackedCounter encodedLengths, - bytes memory dynamicData, - FieldLayout fieldLayout + bytes memory dynamicData ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData); } else { - IStore(_storeAddress).setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + IStore(_storeAddress).setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData); } } diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 58bb6e4dfb..92c8df8db3 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -682,7 +682,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -695,7 +695,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -708,7 +708,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -721,7 +721,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -734,7 +734,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -747,7 +747,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index 2a1e92427f..a4f1f8d8f2 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -757,7 +757,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -777,7 +777,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -798,7 +798,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -811,7 +811,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -824,7 +824,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -837,7 +837,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index a214afcdd8..d3e6506e4d 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -236,7 +236,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -249,7 +249,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -262,7 +262,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -275,7 +275,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -288,7 +288,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -301,7 +301,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/store/test/MirrorSubscriber.sol b/packages/store/test/MirrorSubscriber.sol index 9c9096f521..83a7c36fee 100644 --- a/packages/store/test/MirrorSubscriber.sol +++ b/packages/store/test/MirrorSubscriber.sol @@ -38,7 +38,7 @@ contract MirrorSubscriber is StoreHook { FieldLayout fieldLayout ) public override { if (ResourceId.unwrap(tableId) != _tableId) revert("invalid table"); - StoreSwitch.setRecord(indexerTableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + StoreSwitch.setRecord(indexerTableId, keyTuple, staticData, encodedLengths, dynamicData); } function onBeforeSpliceStaticData( diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index c6126d50ab..21666acfe5 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -297,7 +297,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectEmit(true, true, true, true); emit Store_SetRecord(tableId, keyTuple, staticData, bytes32(0), new bytes(0)); - IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get data (bytes memory loadedStaticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = IStore(this).getRecord( @@ -332,7 +332,7 @@ contract StoreCoreTest is Test, StoreMock { // This should fail because the data is not 6 bytes long vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_InvalidStaticDataLength.selector, 6, 4)); - IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); } function testSetAndGetStaticDataSpanningWords() public { @@ -358,7 +358,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectEmit(true, true, true, true); emit Store_SetRecord(tableId, keyTuple, staticData, bytes32(0), new bytes(0)); - IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get data (bytes memory loadedStaticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = IStore(this).getRecord( @@ -423,7 +423,7 @@ contract StoreCoreTest is Test, StoreMock { emit Store_SetRecord(tableId, keyTuple, staticData, encodedDynamicLength.unwrap(), dynamicData); // Set data - IStore(this).setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData, fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData); // Get data (bytes memory loadedStaticData, PackedCounter loadedEncodedLengths, bytes memory loadedDynamicData) = IStore(this) @@ -734,7 +734,7 @@ contract StoreCoreTest is Test, StoreMock { keyTuple[0] = bytes32("some key"); // Set data - IStore(this).setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData, fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData); // Get data (bytes memory loadedStaticData, PackedCounter loadedEncodedLengths, bytes memory loadedDynamicData) = IStore(this) @@ -1113,7 +1113,7 @@ contract StoreCoreTest is Test, StoreMock { bytes memory staticData = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); - IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get data from indexed table - the indexer should have mirrored the data there (bytes memory indexedData, , ) = IStore(this).getRecord(indexerTableId, keyTuple, fieldLayout); @@ -1160,7 +1160,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a revert when the RevertSubscriber's onBeforeSetRecord hook is called vm.expectRevert(bytes("onBeforeSetRecord")); - IStore(this).setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData); // Expect a revert when the RevertSubscriber's onBeforeSpliceStaticData hook is called vm.expectRevert(bytes("onBeforeSpliceStaticData")); @@ -1195,7 +1195,7 @@ contract StoreCoreTest is Test, StoreMock { ) ); - IStore(this).setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + IStore(this).setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData); // Expect a HookCalled event to be emitted when the EchoSubscriber's onBeforeSpliceStaticData hook is called vm.expectEmit(true, true, true, true); @@ -1282,14 +1282,7 @@ contract StoreCoreTest is Test, StoreMock { dynamicData: arrayDataBytes }); - IStore(this).setRecord( - tableId, - keyTuple, - recordData.staticData, - recordData.encodedLengths, - recordData.dynamicData, - fieldLayout - ); + IStore(this).setRecord(tableId, keyTuple, recordData.staticData, recordData.encodedLengths, recordData.dynamicData); // Get data from indexed table - the indexer should have mirrored the data there RecordData memory loadedData; diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 70a9a336ba..8d1457527d 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -169,7 +169,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { keyTuple[0] = keccak256("some.key"); startGasReport("set static record (1 slot)"); - StoreCore.setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), dynamicData); endGasReport(); // Get data @@ -197,7 +197,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { keyTuple[0] = "some key"; startGasReport("set static record (2 slots)"); - StoreCore.setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), dynamicData); endGasReport(); // Get data @@ -252,7 +252,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set data startGasReport("set complex record with dynamic data (4 slots)"); - StoreCore.setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData); endGasReport(); // Get data @@ -413,7 +413,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { keyTuple[0] = "some key"; // Set data - StoreCore.setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, encodedDynamicLength, dynamicData); // Delete data startGasReport("delete record (complex data, 3 slots)"); @@ -646,7 +646,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory dynamicData = new bytes(0); startGasReport("set record on table with subscriber"); - StoreCore.setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), dynamicData); endGasReport(); staticData = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20)); @@ -694,7 +694,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory data = abi.encodePacked(staticData, encodedArrayDataLength, dynamicData); startGasReport("set (dynamic) record on table with subscriber"); - StoreCore.setRecord(tableId, keyTuple, staticData, encodedArrayDataLength, dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, encodedArrayDataLength, dynamicData); endGasReport(); // Update dynamic data diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index bec595d56c..224baa5e59 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -24,10 +24,9 @@ contract StoreMock is IStore, StoreRead { bytes32[] calldata keyTuple, bytes calldata staticData, PackedCounter encodedLengths, - bytes calldata dynamicData, - FieldLayout fieldLayout + bytes calldata dynamicData ) public { - StoreCore.setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData); } // Splice data in the static part of the record diff --git a/packages/store/ts/codegen/record.ts b/packages/store/ts/codegen/record.ts index 0353559a6c..520023d79c 100644 --- a/packages/store/ts/codegen/record.ts +++ b/packages/store/ts/codegen/record.ts @@ -51,7 +51,7 @@ export function renderRecordMethods(options: RenderTableOptions) { ${_keyTupleDefinition} - ${_store}.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + ${_store}.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } ` ); @@ -71,7 +71,7 @@ export function renderRecordMethods(options: RenderTableOptions) { ${_keyTupleDefinition} - ${_store}.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + ${_store}.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } ` ); diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 5a16e72fe0..5b62c8edf5 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -124,7 +124,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { AccessControl.requireAccess(tableId, msg.sender); // Set the record - StoreCore.setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout); + StoreCore.setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData); } function spliceStaticData( diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index 8bcc58d0ff..9356bd1bce 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -237,7 +237,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -250,7 +250,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -263,7 +263,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/world/src/modules/core/tables/FunctionSignatures.sol b/packages/world/src/modules/core/tables/FunctionSignatures.sol index d328eeb55f..b33ac55bbf 100644 --- a/packages/world/src/modules/core/tables/FunctionSignatures.sol +++ b/packages/world/src/modules/core/tables/FunctionSignatures.sol @@ -87,7 +87,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -99,7 +99,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -111,7 +111,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index 05a1e7d472..e3dfd8b2aa 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -231,7 +231,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -244,7 +244,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -257,7 +257,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 89ceb23794..4df91f77eb 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -1284,7 +1284,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -1303,7 +1303,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -1323,7 +1323,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -1335,7 +1335,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -1347,7 +1347,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -1359,7 +1359,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index 51d122933e..428e1b3069 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -249,7 +249,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -263,7 +263,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -277,7 +277,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 13253902fb..ad5ca64ac5 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -1093,7 +1093,7 @@ contract WorldTest is Test, GasReporter { ) ); - world.setRecord(tableId, singletonKey, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + world.setRecord(tableId, singletonKey, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); // Expect the hook to be notified when a static field is written (once before and once after the field is written) vm.expectEmit(true, true, true, true); @@ -1154,7 +1154,7 @@ contract WorldTest is Test, GasReporter { // Expect a revert when the RevertSubscriber's onBeforeSetRecord hook is called vm.expectRevert(bytes("onBeforeSetRecord")); - world.setRecord(tableId, singletonKey, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + world.setRecord(tableId, singletonKey, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); // Expect a revert when the RevertSubscriber's onBeforeSpliceStaticData hook is called vm.expectRevert(bytes("onBeforeSpliceStaticData")); @@ -1184,7 +1184,7 @@ contract WorldTest is Test, GasReporter { ) ); - world.setRecord(tableId, singletonKey, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); + world.setRecord(tableId, singletonKey, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); // Expect the hook to be notified when a static field is written (once before and once after the field is written) vm.expectEmit(true, true, true, true); diff --git a/packages/world/test/tables/TwoFields.sol b/packages/world/test/tables/TwoFields.sol index 781d359f1f..8b598c768d 100644 --- a/packages/world/test/tables/TwoFields.sol +++ b/packages/world/test/tables/TwoFields.sol @@ -213,7 +213,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -225,7 +225,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -237,7 +237,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -249,7 +249,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -261,7 +261,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -273,7 +273,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index e58e3d1e50..d35690e95f 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -290,7 +290,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values */ @@ -303,7 +303,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using individual values (using the specified store) */ @@ -316,7 +316,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -329,7 +329,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct */ @@ -342,7 +342,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** Set the full data using the data struct (using the specified store) */ @@ -355,7 +355,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } /** From 51692ad787dfaa9359243ec19050177f91a7583f Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 13:56:34 +0100 Subject: [PATCH 08/38] fix world methods --- packages/world/src/World.sol | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 5b62c8edf5..9516754df0 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -117,8 +117,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes32[] calldata keyTuple, bytes calldata staticData, PackedCounter encodedLengths, - bytes calldata dynamicData, - FieldLayout fieldLayout + bytes calldata dynamicData ) public virtual requireNoCallback { // Require access to the namespace or name AccessControl.requireAccess(tableId, msg.sender); @@ -233,11 +232,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { * Delete a record in the table at the given tableId. * Requires the caller to have access to the namespace or name. */ - function deleteRecord( - ResourceId tableId, - bytes32[] calldata keyTuple, - FieldLayout fieldLayout - ) public virtual requireNoCallback { + function deleteRecord(ResourceId tableId, bytes32[] calldata keyTuple) public virtual requireNoCallback { // Require access to namespace or name AccessControl.requireAccess(tableId, msg.sender); From be383d6e38053991f1feb9b7a5df9de33f72379d Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 14:13:30 +0100 Subject: [PATCH 09/38] fix modules and gas report --- packages/world/gas-report.json | 106 +++++++------- packages/world/test/KeysInTableModule.t.sol | 134 +++--------------- packages/world/test/KeysWithValueModule.t.sol | 56 +------- packages/world/test/World.t.sol | 30 +--- packages/world/test/query.t.sol | 112 +++++++-------- 5 files changed, 140 insertions(+), 298 deletions(-) diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 8318a79df6..0c32709a73 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -33,79 +33,79 @@ "file": "test/CallBatch.t.sol", "test": "testCallBatchReturnData", "name": "call systems with callBatch", - "gasUsed": 45264 + "gasUsed": 45158 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1413281 + "gasUsed": 1413837 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1413281 + "gasUsed": 1413837 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 157774 + "gasUsed": 159445 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1413281 + "gasUsed": 1413837 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1413281 + "gasUsed": 1413837 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22092 + "gasUsed": 22844 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 159243 + "gasUsed": 160882 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1413281 + "gasUsed": 1413837 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 20814 + "gasUsed": 21566 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 84959 + "gasUsed": 86642 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 654858 + "gasUsed": 655143 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "Get list of keys with a given value", - "gasUsed": 5709 + "gasUsed": 5712 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,79 +117,79 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 654858 + "gasUsed": 655143 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 134702 + "gasUsed": 136407 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 654858 + "gasUsed": 655143 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 105043 + "gasUsed": 105890 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 34626 + "gasUsed": 36296 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 654858 + "gasUsed": 655143 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 146968 + "gasUsed": 147816 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 111727 + "gasUsed": 112575 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 103211 + "gasUsed": 103295 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 52945 + "gasUsed": 52973 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 128343 + "gasUsed": 128483 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 81556 + "gasUsed": 81668 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 83218 + "gasUsed": 83302 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18116 + "gasUsed": 18144 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5938615 + "gasUsed": 5938643 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 554009 + "gasUsed": 554037 }, { "file": "test/query.t.sol", @@ -225,79 +225,79 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 46541 + "gasUsed": 46569 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 114534 + "gasUsed": 114520 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 33774 + "gasUsed": 36682 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 109029 + "gasUsed": 109015 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26779 + "gasUsed": 26793 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 682963 + "gasUsed": 692018 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51919 + "gasUsed": 51888 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 650259 + "gasUsed": 659365 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51919 + "gasUsed": 51888 }, { "file": "test/World.t.sol", "test": "testCall", "name": "call a system via the World", - "gasUsed": 12409 + "gasUsed": 12360 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 50539 + "gasUsed": 50525 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "call a system via an unlimited delegation", - "gasUsed": 12796 + "gasUsed": 12814 }, { "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9024 + "gasUsed": 9907 }, { "file": "test/World.t.sol", @@ -309,67 +309,67 @@ "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 83885 + "gasUsed": 89760 }, { "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 123163 + "gasUsed": 123155 }, { "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 81147 + "gasUsed": 87023 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 165280 + "gasUsed": 168205 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 640821 + "gasUsed": 641133 }, { "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 37214 + "gasUsed": 37236 }, { "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 36340 + "gasUsed": 37248 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromField", "name": "pop 1 address (cold)", - "gasUsed": 24499 + "gasUsed": 24521 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromField", "name": "pop 1 address (warm)", - "gasUsed": 13645 + "gasUsed": 13667 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testUpdateInField", "name": "updateInField 1 item (cold)", - "gasUsed": 25063 + "gasUsed": 25019 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testUpdateInField", "name": "updateInField 1 item (warm)", - "gasUsed": 14268 + "gasUsed": 14224 }, { "file": "test/WorldResourceId.t.sol", diff --git a/packages/world/test/KeysInTableModule.t.sol b/packages/world/test/KeysInTableModule.t.sol index 00072be318..80cbd901b7 100644 --- a/packages/world/test/KeysInTableModule.t.sol +++ b/packages/world/test/KeysInTableModule.t.sol @@ -108,14 +108,7 @@ contract KeysInTableModuleTest is Test, GasReporter { bytes32[] memory keyTuple = new bytes32[](0); - world.setRecord( - singletonTableId, - keyTuple, - abi.encodePacked(val1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(singletonTableId, keyTuple, abi.encodePacked(val1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of keys in this target table bytes32[][] memory keysInTable = getKeysInTable(world, singletonTableId); @@ -132,14 +125,7 @@ contract KeysInTableModuleTest is Test, GasReporter { keyTuple[1] = "two"; keyTuple[2] = "three"; - world.setRecord( - compositeTableId, - keyTuple, - abi.encodePacked(val1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(compositeTableId, keyTuple, abi.encodePacked(val1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of keys in this target table bytes32[][] memory keysInTable = getKeysInTable(world, compositeTableId); @@ -164,14 +150,7 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Set a value in the source table startGasReport("set a record on a table with keysInTableModule installed"); - world.setRecord( - tableId, - keyTuple1, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple1, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); endGasReport(); // Get the list of keys in this target table @@ -190,14 +169,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Set a value in the source table startGasReport("set a record on a table with keysInTableModule installed (first)"); - world.setRecord( - tableId, - keyTuple, - abi.encodePacked(value1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), new bytes(0)); endGasReport(); // Get the list of keys in the first target table @@ -229,14 +201,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Set a value in the source table startGasReport("set a record on a table with keysInTableModule installed (second)"); - world.setRecord( - sourceTableId2, - keyTuple, - abi.encodePacked(value2), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(sourceTableId2, keyTuple, abi.encodePacked(value2), PackedCounter.wrap(bytes32(0)), new bytes(0)); endGasReport(); // Get the list of keys in the second target table @@ -256,14 +221,7 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Set a value in the source table - world.setRecord( - tableId, - keyTuple1, - abi.encodePacked(value1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple1, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of keys in the target table bytes32[][] memory keysInTable = getKeysInTable(world, tableId); @@ -273,14 +231,7 @@ contract KeysInTableModuleTest is Test, GasReporter { assertEq(keysInTable[0][0], key1, "2"); // Set another key with the same value - world.setRecord( - tableId, - keyTuple2, - abi.encodePacked(value1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple2, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of keys in the target table keysInTable = getKeysInTable(world, tableId); @@ -292,14 +243,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Change the value of the first key startGasReport("change a record on a table with keysInTableModule installed"); - world.setRecord( - tableId, - keyTuple1, - abi.encodePacked(value2), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple1, abi.encodePacked(value2), PackedCounter.wrap(bytes32(0)), new bytes(0)); endGasReport(); // Get the list of keys in the target table @@ -312,7 +256,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Delete the first key startGasReport("delete a record on a table with keysInTableModule installed"); - world.deleteRecord(tableId, keyTuple1, tableFieldLayout); + world.deleteRecord(tableId, keyTuple1); endGasReport(); // Get the list of keys in the target table @@ -347,8 +291,7 @@ contract KeysInTableModuleTest is Test, GasReporter { keyTupleA, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout + new bytes(0) ); // Get the list of keys in the target table @@ -366,8 +309,7 @@ contract KeysInTableModuleTest is Test, GasReporter { keyTupleB, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout + new bytes(0) ); // Get the list of keys in the target table @@ -389,8 +331,7 @@ contract KeysInTableModuleTest is Test, GasReporter { keyTupleA, abi.encodePacked(value2), PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout + new bytes(0) ); endGasReport(); @@ -408,7 +349,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Delete the first key startGasReport("delete a composite record on a table with keysInTableModule installed"); - world.deleteRecord(compositeTableId, keyTupleA, tableFieldLayout); + world.deleteRecord(compositeTableId, keyTupleA); endGasReport(); // Get the list of keys in the target table @@ -453,14 +394,7 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Set a value in the source table - world.setRecord( - tableId, - keyTuple1, - abi.encodePacked(value1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple1, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), new bytes(0)); startGasReport("Get list of keys in a given table"); bytes32[][] memory keysInTable = getKeysInTable(world, tableId); @@ -471,14 +405,7 @@ contract KeysInTableModuleTest is Test, GasReporter { assertEq(keysInTable[0][0], key1); // Set another key with a different value - world.setRecord( - tableId, - keyTuple2, - abi.encodePacked(value2), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple2, abi.encodePacked(value2), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of keys in the target table keysInTable = getKeysInTable(world, tableId); @@ -493,35 +420,14 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Add 3 values - world.setRecord( - tableId, - keyTuple1, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); - world.setRecord( - tableId, - keyTuple2, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); - world.setRecord( - tableId, - keyTuple3, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - tableFieldLayout - ); + world.setRecord(tableId, keyTuple1, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(tableId, keyTuple2, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(tableId, keyTuple3, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Remove 2, starting from the middle // This tests that KeysInTable correctly tracks swaps indexes - world.deleteRecord(tableId, keyTuple2, tableFieldLayout); - world.deleteRecord(tableId, keyTuple3, tableFieldLayout); + world.deleteRecord(tableId, keyTuple2); + world.deleteRecord(tableId, keyTuple3); // Get the list of keys in the target table bytes32[][] memory keysInTable = getKeysInTable(world, tableId); diff --git a/packages/world/test/KeysWithValueModule.t.sol b/packages/world/test/KeysWithValueModule.t.sol index ab05c20aaa..8be0d88fe4 100644 --- a/packages/world/test/KeysWithValueModule.t.sol +++ b/packages/world/test/KeysWithValueModule.t.sol @@ -89,14 +89,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { uint256 value = 1; startGasReport("set a record on a table with KeysWithValueModule installed"); - world.setRecord( - sourceTableId, - keyTuple1, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - sourceTableFieldLayout - ); + world.setRecord(sourceTableId, keyTuple1, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); endGasReport(); // Get the list of entities with this value from the target table @@ -113,14 +106,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { // Set a value in the source table uint256 value1 = 1; - world.setRecord( - sourceTableId, - keyTuple1, - abi.encodePacked(value1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - sourceTableFieldLayout - ); + world.setRecord(sourceTableId, keyTuple1, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of entities with value1 from the target table bytes32[] memory keysWithValue = KeysWithValue.get(world, targetTableId, keccak256(abi.encodePacked(value1))); @@ -130,14 +116,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { assertEq(keysWithValue[0], key1, "2"); // Set a another key with the same value - world.setRecord( - sourceTableId, - keyTuple2, - abi.encodePacked(value1), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - sourceTableFieldLayout - ); + world.setRecord(sourceTableId, keyTuple2, abi.encodePacked(value1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of entities with value2 from the target table keysWithValue = KeysWithValue.get(world, targetTableId, keccak256(abi.encodePacked(value1))); @@ -151,14 +130,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { uint256 value2 = 2; startGasReport("change a record on a table with KeysWithValueModule installed"); - world.setRecord( - sourceTableId, - keyTuple1, - abi.encodePacked(value2), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - sourceTableFieldLayout - ); + world.setRecord(sourceTableId, keyTuple1, abi.encodePacked(value2), PackedCounter.wrap(bytes32(0)), new bytes(0)); endGasReport(); // Get the list of entities with value1 from the target table @@ -177,7 +149,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { // Delete the first key startGasReport("delete a record on a table with KeysWithValueModule installed"); - world.deleteRecord(sourceTableId, keyTuple1, sourceTableFieldLayout); + world.deleteRecord(sourceTableId, keyTuple1); endGasReport(); // Get the list of entities with value2 from the target table @@ -260,14 +232,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { _installKeysWithValueModule(); // Set a value in the source table - world.setRecord( - sourceTableId, - keyTuple1, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - sourceTableFieldLayout - ); + world.setRecord(sourceTableId, keyTuple1, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); startGasReport("Get list of keys with a given value"); bytes32[] memory keysWithValue = getKeysWithValue( @@ -284,14 +249,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { assertEq(keysWithValue[0], key1); // Set a another key with the same value - world.setRecord( - sourceTableId, - keyTuple2, - abi.encodePacked(value), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - sourceTableFieldLayout - ); + world.setRecord(sourceTableId, keyTuple2, abi.encodePacked(value), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Get the list of keys with value from the target table keysWithValue = getKeysWithValue( diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index ad5ca64ac5..c19d28b251 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -98,22 +98,14 @@ contract WorldTestSystem is System { FieldLayout fieldLayout = StoreSwitch.getFieldLayout(tableId); if (StoreSwitch.getStoreAddress() == address(this)) { - StoreCore.setRecord( - tableId, - keyTuple, - abi.encodePacked(data), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - fieldLayout - ); + StoreCore.setRecord(tableId, keyTuple, abi.encodePacked(data), PackedCounter.wrap(bytes32(0)), new bytes(0)); } else { IBaseWorld(msg.sender).setRecord( tableId, keyTuple, abi.encodePacked(data), PackedCounter.wrap(bytes32(0)), - new bytes(0), - fieldLayout + new bytes(0) ); } } @@ -853,14 +845,7 @@ contract WorldTest is Test, GasReporter { world.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); // Write data to the table and expect it to be written - world.setRecord( - tableId, - singletonKey, - abi.encodePacked(true), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - fieldLayout - ); + world.setRecord(tableId, singletonKey, abi.encodePacked(true), PackedCounter.wrap(bytes32(0)), new bytes(0)); assertTrue(Bool.get(world, tableId)); startGasReport("Delete record"); @@ -871,14 +856,7 @@ contract WorldTest is Test, GasReporter { assertFalse(Bool.get(world, tableId)); // Write data to the table and expect it to be written - world.setRecord( - tableId, - singletonKey, - abi.encodePacked(true), - PackedCounter.wrap(bytes32(0)), - new bytes(0), - fieldLayout - ); + world.setRecord(tableId, singletonKey, abi.encodePacked(true), PackedCounter.wrap(bytes32(0)), new bytes(0)); assertTrue(Bool.get(world, tableId)); assertTrue(Bool.get(world, tableId)); diff --git a/packages/world/test/query.t.sol b/packages/world/test/query.t.sol index 3b0cb7155e..87d3d0e64b 100644 --- a/packages/world/test/query.t.sol +++ b/packages/world/test/query.t.sol @@ -92,9 +92,9 @@ contract QueryTest is Test, GasReporter { function testHasQuery() public { _installKeysInTableModule(); - world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key1, abi.encode(0), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key1, abi.encode(0), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all keys in table1 QueryFragment[] memory fragments = new QueryFragment[](1); @@ -113,9 +113,9 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(table1, key1, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all keys in table1 with value 1 QueryFragment[] memory fragments = new QueryFragment[](1); fragments[0] = QueryFragment(QueryType.HasValue, table1, abi.encode(1)); @@ -131,12 +131,12 @@ contract QueryTest is Test, GasReporter { function testCombinedHasQuery() public { _installKeysInTableModule(); - world.setRecord(table1, key1, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table3, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table3, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -155,12 +155,12 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(table1, key1, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table3, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table3, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -178,13 +178,13 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key3, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key4, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key3, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key4, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -202,13 +202,13 @@ contract QueryTest is Test, GasReporter { function testCombinedHasNotQuery() public { _installKeysInTableModule(); - world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key3, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key4, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key3, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key4, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -226,13 +226,13 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key4, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key4, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -250,16 +250,16 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table2, key4, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table3, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table3, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table3, key4, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key1, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key2, abi.encode(2), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table2, key4, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table3, key2, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table3, key3, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table3, key4, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities that have table2 and not table1 QueryFragment[] memory fragments = new QueryFragment[](3); @@ -278,9 +278,9 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(table1, key1, abi.encode(4), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key2, abi.encode(5), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); - world.setRecord(table1, key3, abi.encode(6), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, key1, abi.encode(4), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key2, abi.encode(5), PackedCounter.wrap(bytes32(0)), new bytes(0)); + world.setRecord(table1, key3, abi.encode(6), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all entities with table1 except value 6 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -301,9 +301,9 @@ contract QueryTest is Test, GasReporter { for (uint256 i; i < 100; i++) { bytes32[] memory keyTuple = new bytes32[](1); keyTuple[0] = bytes32(i); - world.setRecord(table1, keyTuple, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, keyTuple, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); } - world.setRecord(table2, key1, abi.encode(0), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table2, key1, abi.encode(0), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all keys in table1 QueryFragment[] memory fragments = new QueryFragment[](1); @@ -322,9 +322,9 @@ contract QueryTest is Test, GasReporter { for (uint256 i; i < 1000; i++) { bytes32[] memory keyTuple = new bytes32[](1); keyTuple[0] = bytes32(i); - world.setRecord(table1, keyTuple, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table1, keyTuple, abi.encode(1), PackedCounter.wrap(bytes32(0)), new bytes(0)); } - world.setRecord(table2, key1, abi.encode(0), PackedCounter.wrap(bytes32(0)), new bytes(0), tableFieldLayout); + world.setRecord(table2, key1, abi.encode(0), PackedCounter.wrap(bytes32(0)), new bytes(0)); // Query should return all keys in table1 QueryFragment[] memory fragments = new QueryFragment[](1); From 2282499f8282a6af1a926273e2e413f10774a778 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 14:25:27 +0100 Subject: [PATCH 10/38] add internal StoreCore methods that allow passing fieldLayout in --- packages/store/gas-report.json | 40 +++++++++++------------ packages/store/src/StoreCore.sol | 29 ++++++++++++++--- packages/world/gas-report.json | 56 ++++++++++++++++---------------- 3 files changed, 73 insertions(+), 52 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 0a76dcf6ef..6f37fcfed4 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720481 + "gasUsed": 720521 }, { "file": "test/Mixed.t.sol", @@ -363,13 +363,13 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582351 + "gasUsed": 582391 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "set record in Mixed", - "gasUsed": 104908 + "gasUsed": 104948 }, { "file": "test/Mixed.t.sol", @@ -573,7 +573,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 8315 + "gasUsed": 8311 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -591,7 +591,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4612 + "gasUsed": 4608 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -675,7 +675,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 7707 + "gasUsed": 7733 }, { "file": "test/StoreCoreGas.t.sol", @@ -711,7 +711,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 73020 + "gasUsed": 73100 }, { "file": "test/StoreCoreGas.t.sol", @@ -723,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18639 + "gasUsed": 18691 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 166175 + "gasUsed": 166255 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,7 +747,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 19625 + "gasUsed": 19677 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,7 +765,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642355 + "gasUsed": 642395 }, { "file": "test/StoreCoreGas.t.sol", @@ -789,7 +789,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 102863 + "gasUsed": 102903 }, { "file": "test/StoreCoreGas.t.sol", @@ -879,7 +879,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 33107 + "gasUsed": 33147 }, { "file": "test/StoreCoreGas.t.sol", @@ -891,7 +891,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55611 + "gasUsed": 55651 }, { "file": "test/StoreCoreGas.t.sol", @@ -957,7 +957,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2920 + "gasUsed": 2916 }, { "file": "test/tables/Callbacks.t.sol", @@ -1011,7 +1011,7 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 10132 + "gasUsed": 10158 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1035,7 +1035,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 18990 + "gasUsed": 19016 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1119,18 +1119,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443844 + "gasUsed": 443884 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 34024 + "gasUsed": 34064 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2539 + "gasUsed": 2535 } ] diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 6837a214bd..c4af07eee0 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -211,7 +211,8 @@ library StoreCore { ************************************************************************/ /** - * Set full data record for the given table ID and key tuple and field layout + * Set full data record for the given table ID and key tuple and field layout. + * This overload loads the field layout from storage and is exposed externally on `IStore`. */ function setRecord( ResourceId tableId, @@ -220,8 +221,21 @@ library StoreCore { PackedCounter encodedLengths, bytes memory dynamicData ) internal { - FieldLayout fieldLayout = getFieldLayout(tableId); + setRecord(tableId, keyTuple, staticData, encodedLengths, dynamicData, getFieldLayout(tableId)); + } + /** + * Set full data record for the given table ID and key tuple and field layout. + * This overload allows passing in a FieldLayout and is not exposed externally on `IStore`. + */ + function setRecord( + ResourceId tableId, + bytes32[] memory keyTuple, + bytes memory staticData, + PackedCounter encodedLengths, + bytes memory dynamicData, + FieldLayout fieldLayout + ) internal { // verify the value has the correct length for the tableId (based on the tableId's field layout) // to prevent invalid data from being stored @@ -436,11 +450,18 @@ library StoreCore { } /** - * Delete a record for the given tableId, key tuple and value field layout + * Delete a record for the given tableId, key tuple and value field layout. + * This overload loads the field layout from storage and is exposed externally on `IStore`. */ function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) internal { - FieldLayout fieldLayout = getFieldLayout(tableId); + deleteRecord(tableId, keyTuple, getFieldLayout(tableId)); + } + /** + * Delete a record for the given tableId, key tuple and value field layout. + * This overload allows passing in a FieldLayout and is not exposed externally on `IStore`. + */ + function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) internal { // Emit event to notify indexers emit Store_DeleteRecord(tableId, keyTuple); diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 0c32709a73..bb2081d3ea 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,67 +39,67 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1413837 + "gasUsed": 1413917 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1413837 + "gasUsed": 1413917 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 159445 + "gasUsed": 159525 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1413837 + "gasUsed": 1413917 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1413837 + "gasUsed": 1413917 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22844 + "gasUsed": 22884 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 160882 + "gasUsed": 160934 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1413837 + "gasUsed": 1413917 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 21566 + "gasUsed": 21606 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 86642 + "gasUsed": 86694 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 655143 + "gasUsed": 655183 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,49 +117,49 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 655143 + "gasUsed": 655183 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 136407 + "gasUsed": 136473 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 655143 + "gasUsed": 655183 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 105890 + "gasUsed": 105930 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36296 + "gasUsed": 36348 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 655143 + "gasUsed": 655183 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 147816 + "gasUsed": 147842 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 112575 + "gasUsed": 112601 }, { "file": "test/query.t.sol", @@ -237,7 +237,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36682 + "gasUsed": 36708 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -255,7 +255,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 692018 + "gasUsed": 692169 }, { "file": "test/UniqueEntityModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 659365 + "gasUsed": 659516 }, { "file": "test/UniqueEntityModule.t.sol", @@ -297,7 +297,7 @@ "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9907 + "gasUsed": 9933 }, { "file": "test/World.t.sol", @@ -309,7 +309,7 @@ "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 89760 + "gasUsed": 89831 }, { "file": "test/World.t.sol", @@ -321,19 +321,19 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 87023 + "gasUsed": 87094 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 168205 + "gasUsed": 168245 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 641133 + "gasUsed": 641173 }, { "file": "test/World.t.sol", @@ -345,7 +345,7 @@ "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 37248 + "gasUsed": 37288 }, { "file": "test/WorldDynamicUpdate.t.sol", From 4f7831ce26e5a2b8a8ad1081ad19a0d3a0850e5a Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 15:15:10 +0100 Subject: [PATCH 11/38] use internal StoreCore methods in tablegen's internal methods --- .../src/codegen/tables/Dynamics1.sol | 6 +- .../src/codegen/tables/Dynamics2.sol | 6 +- .../contracts/src/codegen/tables/Offchain.sol | 4 +- .../src/codegen/tables/Singleton.sol | 4 +- .../contracts/src/codegen/tables/Statics.sol | 6 +- .../src/codegen/render-solidity/common.ts | 5 +- packages/store/gas-report.json | 72 ++++++++++------ .../store/src/codegen/tables/Callbacks.sol | 2 +- packages/store/src/codegen/tables/Hooks.sol | 2 +- .../store/src/codegen/tables/KeyEncoding.sol | 2 +- packages/store/src/codegen/tables/Mixed.sol | 6 +- .../store/src/codegen/tables/ResourceIds.sol | 2 +- .../store/src/codegen/tables/StoreHooks.sol | 2 +- packages/store/src/codegen/tables/Tables.sol | 6 +- packages/store/src/codegen/tables/Vector2.sol | 6 +- packages/store/test/Mixed.t.sol | 38 ++++++++- packages/store/ts/codegen/record.ts | 83 +++++++++++-------- packages/world/gas-report.json | 36 ++++---- .../src/modules/core/tables/Balances.sol | 2 +- .../modules/core/tables/FunctionSelectors.sol | 4 +- .../core/tables/FunctionSignatures.sol | 4 +- .../src/modules/core/tables/SystemHooks.sol | 2 +- .../modules/core/tables/SystemRegistry.sol | 2 +- .../world/src/modules/core/tables/Systems.sol | 4 +- .../keysintable/tables/KeysInTable.sol | 6 +- .../keysintable/tables/UsedKeysIndex.sol | 4 +- .../keyswithvalue/tables/KeysWithValue.sol | 2 +- .../tables/CallboundDelegations.sol | 2 +- .../tables/TimeboundDelegations.sol | 2 +- .../uniqueentity/tables/UniqueEntity.sol | 2 +- packages/world/src/tables/Delegations.sol | 2 +- .../world/src/tables/InstalledModules.sol | 2 +- packages/world/src/tables/NamespaceOwner.sol | 2 +- packages/world/src/tables/ResourceAccess.sol | 2 +- packages/world/test/tables/AddressArray.sol | 2 +- packages/world/test/tables/Bool.sol | 2 +- packages/world/test/tables/TwoFields.sol | 6 +- 37 files changed, 207 insertions(+), 135 deletions(-) diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 758acbd8ef..1c8f016054 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -1313,7 +1313,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -1381,7 +1381,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -1486,7 +1486,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index 2d8ffc072e..0d4a987dbd 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -808,7 +808,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -844,7 +844,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -912,7 +912,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/cli/contracts/src/codegen/tables/Offchain.sol b/packages/cli/contracts/src/codegen/tables/Offchain.sol index 248597a576..5061275dc5 100644 --- a/packages/cli/contracts/src/codegen/tables/Offchain.sol +++ b/packages/cli/contracts/src/codegen/tables/Offchain.sol @@ -125,7 +125,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -170,7 +170,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 689d93060a..921439e0d4 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -783,7 +783,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -859,7 +859,7 @@ library Singleton { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index d23ccb2b21..4c3efebf84 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -779,7 +779,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -847,7 +847,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -932,7 +932,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/common/src/codegen/render-solidity/common.ts b/packages/common/src/codegen/render-solidity/common.ts index 14e668c3d2..9ce0ec120e 100644 --- a/packages/common/src/codegen/render-solidity/common.ts +++ b/packages/common/src/codegen/render-solidity/common.ts @@ -132,12 +132,13 @@ export function renderWithStore( _store: string, _commentSuffix: string, _untypedStore: string | undefined, - _methodPrefix: string + _methodPrefix: string, + _internal?: boolean ) => string ): string { let result = ""; result += callback(undefined, "StoreSwitch", "", undefined, ""); - result += callback(undefined, "StoreCore", "", undefined, "_"); + result += callback(undefined, "StoreCore", "", undefined, "_", true); if (storeArgument) { result += "\n" + callback("IStore _store", "_store", " (using the specified store)", "_store", ""); diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 6f37fcfed4..ebf7126c7a 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720521 + "gasUsed": 720205 }, { "file": "test/Mixed.t.sol", @@ -363,19 +363,43 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582391 + "gasUsed": 582081 }, { "file": "test/Mixed.t.sol", - "test": "testSetAndGet", - "name": "set record in Mixed", - "gasUsed": 104948 + "test": "testSetGetDeleteExternal", + "name": "set record in Mixed (external)", + "gasUsed": 104951 }, { "file": "test/Mixed.t.sol", - "test": "testSetAndGet", - "name": "get record from Mixed", - "gasUsed": 7087 + "test": "testSetGetDeleteExternal", + "name": "get record from Mixed (external)", + "gasUsed": 7089 + }, + { + "file": "test/Mixed.t.sol", + "test": "testSetGetDeleteExternal", + "name": "delete record from Mixed (external)", + "gasUsed": 8435 + }, + { + "file": "test/Mixed.t.sol", + "test": "testSetGetDeleteInternal", + "name": "set record in Mixed (internal)", + "gasUsed": 103691 + }, + { + "file": "test/Mixed.t.sol", + "test": "testSetGetDeleteInternal", + "name": "get record from Mixed (internal)", + "gasUsed": 6776 + }, + { + "file": "test/Mixed.t.sol", + "test": "testSetGetDeleteInternal", + "name": "delete record from Mixed (internal)", + "gasUsed": 7213 }, { "file": "test/PackedCounter.t.sol", @@ -657,7 +681,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 2058 + "gasUsed": 2059 }, { "file": "test/StoreCoreGas.t.sol", @@ -699,7 +723,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", "name": "check for existence of table (non-existent)", - "gasUsed": 3250 + "gasUsed": 3249 }, { "file": "test/StoreCoreGas.t.sol", @@ -753,7 +777,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testPushToField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 10276 + "gasUsed": 10275 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,19 +789,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642395 + "gasUsed": 642079 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get field layout (warm)", - "gasUsed": 923 + "gasUsed": 922 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get value schema (warm)", - "gasUsed": 1807 + "gasUsed": 1808 }, { "file": "test/StoreCoreGas.t.sol", @@ -819,13 +843,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "set dynamic length of dynamic index 1", - "gasUsed": 967 + "gasUsed": 968 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "reduce dynamic length of dynamic index 0", - "gasUsed": 957 + "gasUsed": 958 }, { "file": "test/StoreCoreGas.t.sol", @@ -837,13 +861,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 1334 + "gasUsed": 1333 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 30261 + "gasUsed": 30260 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +879,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53973 + "gasUsed": 53974 }, { "file": "test/StoreCoreGas.t.sol", @@ -873,7 +897,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2228 + "gasUsed": 2229 }, { "file": "test/StoreCoreGas.t.sol", @@ -885,7 +909,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "get static record (1 slot)", - "gasUsed": 1554 + "gasUsed": 1555 }, { "file": "test/StoreCoreGas.t.sol", @@ -903,7 +927,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 9628 + "gasUsed": 9627 }, { "file": "test/StoreCoreGas.t.sol", @@ -957,7 +981,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2916 + "gasUsed": 2915 }, { "file": "test/tables/Callbacks.t.sol", @@ -1119,7 +1143,7 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443884 + "gasUsed": 443568 }, { "file": "test/Vector2.t.sol", diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index d9707a9709..137f701bf6 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -545,7 +545,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 88f7f74088..e47703481e 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -545,7 +545,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 3fc24707c4..5f3b44f8fe 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -338,7 +338,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 92c8df8db3..184d4ff285 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -695,7 +695,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -734,7 +734,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -809,7 +809,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/ResourceIds.sol b/packages/store/src/codegen/tables/ResourceIds.sol index df9eb45e94..b19c927b4f 100644 --- a/packages/store/src/codegen/tables/ResourceIds.sol +++ b/packages/store/src/codegen/tables/ResourceIds.sol @@ -193,7 +193,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index 825b7359c9..0a2074ff3c 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -545,7 +545,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index a4f1f8d8f2..d6ab0879a0 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -777,7 +777,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -824,7 +824,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -903,7 +903,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index d3e6506e4d..5d2d4d38dd 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -249,7 +249,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -288,7 +288,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -339,7 +339,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index 00d8217ee6..e9f92fb149 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -33,7 +33,7 @@ contract MixedTest is Test, GasReporter, StoreMock { assertEq(keccak256(abi.encode(registeredSchema)), keccak256(abi.encode(declaredSchema))); } - function testSetAndGet() public { + function testSetGetDeleteExternal() public { Mixed.register(); bytes32 key = keccak256("somekey"); @@ -42,11 +42,11 @@ contract MixedTest is Test, GasReporter, StoreMock { a32[1] = 4; string memory s = "some string"; - startGasReport("set record in Mixed"); + startGasReport("set record in Mixed (external)"); Mixed.set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); endGasReport(); - startGasReport("get record from Mixed"); + startGasReport("get record from Mixed (external)"); MixedData memory mixed = Mixed.get(key); endGasReport(); @@ -55,6 +55,38 @@ contract MixedTest is Test, GasReporter, StoreMock { assertEq(mixed.a32[0], 3); assertEq(mixed.a32[1], 4); assertEq(mixed.s, s); + + startGasReport("delete record from Mixed (external)"); + Mixed.deleteRecord(key); + endGasReport(); + } + + function testSetGetDeleteInternal() public { + Mixed._register(); + bytes32 key = keccak256("somekey"); + + uint32[] memory a32 = new uint32[](2); + a32[0] = 3; + a32[1] = 4; + string memory s = "some string"; + + startGasReport("set record in Mixed (internal)"); + Mixed._set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); + endGasReport(); + + startGasReport("get record from Mixed (internal)"); + MixedData memory mixed = Mixed._get(key); + endGasReport(); + + assertEq(mixed.u32, 1); + assertEq(mixed.u128, 2); + assertEq(mixed.a32[0], 3); + assertEq(mixed.a32[1], 4); + assertEq(mixed.s, s); + + startGasReport("delete record from Mixed (internal)"); + Mixed._deleteRecord(key); + endGasReport(); } function testCompareSolidity() public { diff --git a/packages/store/ts/codegen/record.ts b/packages/store/ts/codegen/record.ts index 520023d79c..fa90d96992 100644 --- a/packages/store/ts/codegen/record.ts +++ b/packages/store/ts/codegen/record.ts @@ -39,41 +39,55 @@ export function renderRecordMethods(options: RenderTableOptions) { result += renderWithStore( storeArgument, - (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => ` - /** Set the full data using individual values${_commentSuffix} */ - function ${_methodNamePrefix}set(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`)), - ])}) internal { - ${renderRecordData(options)} + (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix, _internal) => { + const externalArguments = renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`)), + ]); - ${_keyTupleDefinition} + const internalArguments = + "_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData" + (_internal ? ", _fieldLayout" : ""); - ${_store}.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - ` + return ` + /** Set the full data using individual values${_commentSuffix} */ + function ${_methodNamePrefix}set(${externalArguments}) internal { + ${renderRecordData(options)} + + ${_keyTupleDefinition} + + ${_store}.setRecord(${internalArguments}); + } + `; + } ); if (structName !== undefined) { result += renderWithStore( storeArgument, - (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => ` - /** Set the full data using the data struct${_commentSuffix} */ - function ${_methodNamePrefix}set(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - `${structName} memory _table`, - ])}) internal { - ${renderRecordData(options, "_table.")} + (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix, _internal) => { + const externalArguments = renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + `${structName} memory _table`, + ]); - ${_keyTupleDefinition} + const internalArguments = + "_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData" + (_internal ? ", _fieldLayout" : ""); - ${_store}.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); - } - ` + return ` + /** Set the full data using the data struct${_commentSuffix} */ + function ${_methodNamePrefix}set(${externalArguments}) internal { + ${renderRecordData(options, "_table.")} + + ${_keyTupleDefinition} + + ${_store}.setRecord(${internalArguments}); + } + `; + } ); } @@ -119,17 +133,18 @@ export function renderDeleteRecordMethods(options: RenderTableOptions) { return renderWithStore( storeArgument, - (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => ` + (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix, _internal) => { + const externalArguments = renderArguments([_typedStore, _typedTableId, _typedKeyArgs]); + const internalArguments = "_tableId, _keyTuple" + (_internal ? ", _fieldLayout" : ""); + + return ` /** Delete all data for given keys${_commentSuffix} */ - function ${_methodNamePrefix}deleteRecord(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal { + function ${_methodNamePrefix}deleteRecord(${externalArguments}) internal { ${_keyTupleDefinition} - ${_store}.deleteRecord(_tableId, _keyTuple); + ${_store}.deleteRecord(${internalArguments}); } - ` + `; + } ); } diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index bb2081d3ea..4feaebf758 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,13 +39,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1413917 + "gasUsed": 1413261 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1413917 + "gasUsed": 1413261 }, { "file": "test/KeysInTableModule.t.sol", @@ -57,13 +57,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1413917 + "gasUsed": 1413261 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1413917 + "gasUsed": 1413261 }, { "file": "test/KeysInTableModule.t.sol", @@ -81,7 +81,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1413917 + "gasUsed": 1413261 }, { "file": "test/KeysInTableModule.t.sol", @@ -99,7 +99,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 655183 + "gasUsed": 654855 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,7 +117,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 655183 + "gasUsed": 654855 }, { "file": "test/KeysWithValueModule.t.sol", @@ -129,7 +129,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 655183 + "gasUsed": 654855 }, { "file": "test/KeysWithValueModule.t.sol", @@ -147,7 +147,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 655183 + "gasUsed": 654855 }, { "file": "test/KeysWithValueModule.t.sol", @@ -231,7 +231,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 114520 + "gasUsed": 114526 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -243,7 +243,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 109015 + "gasUsed": 109021 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -255,7 +255,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 692169 + "gasUsed": 682930 }, { "file": "test/UniqueEntityModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 659516 + "gasUsed": 650265 }, { "file": "test/UniqueEntityModule.t.sol", @@ -285,7 +285,7 @@ "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 50525 + "gasUsed": 50531 }, { "file": "test/World.t.sol", @@ -309,7 +309,7 @@ "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 89831 + "gasUsed": 83877 }, { "file": "test/World.t.sol", @@ -321,19 +321,19 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 87094 + "gasUsed": 81139 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 168245 + "gasUsed": 165272 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 641173 + "gasUsed": 640845 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/modules/core/tables/Balances.sol b/packages/world/src/modules/core/tables/Balances.sol index 3b73d65437..14927eae86 100644 --- a/packages/world/src/modules/core/tables/Balances.sol +++ b/packages/world/src/modules/core/tables/Balances.sol @@ -193,7 +193,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index 9356bd1bce..cab6323d44 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -250,7 +250,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -301,7 +301,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/core/tables/FunctionSignatures.sol b/packages/world/src/modules/core/tables/FunctionSignatures.sol index b33ac55bbf..72bfcef307 100644 --- a/packages/world/src/modules/core/tables/FunctionSignatures.sol +++ b/packages/world/src/modules/core/tables/FunctionSignatures.sol @@ -99,7 +99,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -155,7 +155,7 @@ library FunctionSignatures { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 168ed63f57..51b0a2ecef 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -545,7 +545,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/modules/core/tables/SystemRegistry.sol index 8528cf6de7..f1f5134903 100644 --- a/packages/world/src/modules/core/tables/SystemRegistry.sol +++ b/packages/world/src/modules/core/tables/SystemRegistry.sol @@ -193,7 +193,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index e3dfd8b2aa..227450dbd4 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -244,7 +244,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -295,7 +295,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 4df91f77eb..045b5e8709 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -1303,7 +1303,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -1347,7 +1347,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -1440,7 +1440,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index 428e1b3069..f4e9e04f03 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -263,7 +263,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -317,7 +317,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index fe7f897ca8..fc1cfc2991 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -583,7 +583,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol index eb091d0714..210dd539c0 100644 --- a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol @@ -311,7 +311,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol index 509bb58689..7e0bda7ba1 100644 --- a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol @@ -213,7 +213,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol index 286024f80a..ab30bdd69a 100644 --- a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -172,7 +172,7 @@ library UniqueEntity { function _deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/tables/Delegations.sol b/packages/world/src/tables/Delegations.sol index 5d11b8dc67..d12fcbca72 100644 --- a/packages/world/src/tables/Delegations.sol +++ b/packages/world/src/tables/Delegations.sol @@ -228,7 +228,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/tables/InstalledModules.sol index 63ff32ca70..8a0005ee43 100644 --- a/packages/world/src/tables/InstalledModules.sol +++ b/packages/world/src/tables/InstalledModules.sol @@ -213,7 +213,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/tables/NamespaceOwner.sol index ffb39a62f1..cea312d83f 100644 --- a/packages/world/src/tables/NamespaceOwner.sol +++ b/packages/world/src/tables/NamespaceOwner.sol @@ -193,7 +193,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/tables/ResourceAccess.sol index add7c5658d..9ae2048d93 100644 --- a/packages/world/src/tables/ResourceAccess.sol +++ b/packages/world/src/tables/ResourceAccess.sol @@ -209,7 +209,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 12b88aec69..48ac1f26f4 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -545,7 +545,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/test/tables/Bool.sol b/packages/world/test/tables/Bool.sol index c7de244193..f3393ea938 100644 --- a/packages/world/test/tables/Bool.sol +++ b/packages/world/test/tables/Bool.sol @@ -172,7 +172,7 @@ library Bool { function _deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/world/test/tables/TwoFields.sol b/packages/world/test/tables/TwoFields.sol index 8b598c768d..0aaac3b8bd 100644 --- a/packages/world/test/tables/TwoFields.sol +++ b/packages/world/test/tables/TwoFields.sol @@ -225,7 +225,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -261,7 +261,7 @@ library TwoFields { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -309,7 +309,7 @@ library TwoFields { function _deleteRecord(ResourceId _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ From 1cf018f9b23c1217d8fc2572cfdb89970a0e8946 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 16:02:58 +0100 Subject: [PATCH 12/38] remove unnecessary validation --- packages/store/gas-report.json | 24 ++++++++--------- packages/store/src/IStoreErrors.sol | 2 -- packages/store/src/StoreCore.sol | 24 ----------------- packages/store/test/StoreCore.t.sol | 24 ----------------- packages/world/gas-report.json | 42 ++++++++++++++--------------- 5 files changed, 33 insertions(+), 83 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index ebf7126c7a..6b74e49eac 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 720205 + "gasUsed": 719887 }, { "file": "test/Mixed.t.sol", @@ -363,13 +363,13 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 582081 + "gasUsed": 581763 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "set record in Mixed (external)", - "gasUsed": 104951 + "gasUsed": 104633 }, { "file": "test/Mixed.t.sol", @@ -387,7 +387,7 @@ "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "set record in Mixed (internal)", - "gasUsed": 103691 + "gasUsed": 103373 }, { "file": "test/Mixed.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 73100 + "gasUsed": 72464 }, { "file": "test/StoreCoreGas.t.sol", @@ -759,7 +759,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 166255 + "gasUsed": 165619 }, { "file": "test/StoreCoreGas.t.sol", @@ -789,7 +789,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 642079 + "gasUsed": 641761 }, { "file": "test/StoreCoreGas.t.sol", @@ -813,7 +813,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 102903 + "gasUsed": 102585 }, { "file": "test/StoreCoreGas.t.sol", @@ -903,7 +903,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 33147 + "gasUsed": 32829 }, { "file": "test/StoreCoreGas.t.sol", @@ -915,7 +915,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55651 + "gasUsed": 55333 }, { "file": "test/StoreCoreGas.t.sol", @@ -1143,13 +1143,13 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443568 + "gasUsed": 443250 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 34064 + "gasUsed": 33746 }, { "file": "test/Vector2.t.sol", diff --git a/packages/store/src/IStoreErrors.sol b/packages/store/src/IStoreErrors.sol index e75591d41f..6bb184c188 100644 --- a/packages/store/src/IStoreErrors.sol +++ b/packages/store/src/IStoreErrors.sol @@ -10,8 +10,6 @@ interface IStoreErrors { error Store_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); error Store_NotDynamicField(); - error Store_InvalidStaticDataLength(uint256 expected, uint256 received); - error Store_InvalidDynamicDataLength(uint256 expected, uint256 received); error Store_InvalidKeyNamesLength(uint256 expected, uint256 received); error Store_InvalidFieldNamesLength(uint256 expected, uint256 received); error Store_InvalidValueSchemaLength(uint256 expected, uint256 received); diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index c4af07eee0..6439d14d5d 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -236,12 +236,6 @@ library StoreCore { bytes memory dynamicData, FieldLayout fieldLayout ) internal { - // verify the value has the correct length for the tableId (based on the tableId's field layout) - // to prevent invalid data from being stored - - // Verify static data length + dynamic data length matches the given data - StoreCoreInternal._validateDataLength(fieldLayout, staticData, encodedLengths, dynamicData); - // Emit event to notify indexers emit Store_SetRecord(tableId, keyTuple, staticData, encodedLengths.unwrap(), dynamicData); @@ -916,24 +910,6 @@ library StoreCoreInternal { * ************************************************************************/ - /** - * Verify static data length + dynamic data length matches the given data - * Returns the static and dynamic lengths - */ - function _validateDataLength( - FieldLayout fieldLayout, - bytes memory staticData, - PackedCounter encodedLengths, - bytes memory dynamicData - ) internal pure { - if (fieldLayout.staticDataLength() != staticData.length) { - revert IStoreErrors.Store_InvalidStaticDataLength(fieldLayout.staticDataLength(), staticData.length); - } - if (encodedLengths.total() != dynamicData.length) { - revert IStoreErrors.Store_InvalidDynamicDataLength(encodedLengths.total(), dynamicData.length); - } - } - ///////////////////////////////////////////////////////////////////////// // STATIC DATA ///////////////////////////////////////////////////////////////////////// diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 21666acfe5..18510ae2cc 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -311,30 +311,6 @@ contract StoreCoreTest is Test, StoreMock { assertEq(_dynamicData, ""); } - function testRevertSetAndGetStaticData() public { - ResourceId tableId = _tableId; - - // Register table - FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); - Schema valueSchema = SchemaEncodeHelper.encode( - SchemaType.UINT8, - SchemaType.UINT16, - SchemaType.UINT8, - SchemaType.UINT16 - ); - IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); - - // Set data - bytes memory staticData = abi.encodePacked(bytes1(0x01), bytes2(0x0203), bytes1(0x04)); - - bytes32[] memory keyTuple = new bytes32[](1); - keyTuple[0] = "some key"; - - // This should fail because the data is not 6 bytes long - vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_InvalidStaticDataLength.selector, 6, 4)); - IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0)); - } - function testSetAndGetStaticDataSpanningWords() public { ResourceId tableId = _tableId; diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 4feaebf758..94fe988d6f 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,37 +39,37 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1413261 + "gasUsed": 1412625 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1413261 + "gasUsed": 1412625 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 159525 + "gasUsed": 158889 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1413261 + "gasUsed": 1412625 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1413261 + "gasUsed": 1412625 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22884 + "gasUsed": 22566 }, { "file": "test/KeysInTableModule.t.sol", @@ -81,13 +81,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1413261 + "gasUsed": 1412625 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 21606 + "gasUsed": 21288 }, { "file": "test/KeysInTableModule.t.sol", @@ -99,7 +99,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 654855 + "gasUsed": 654537 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,25 +117,25 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 654855 + "gasUsed": 654537 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 136473 + "gasUsed": 136155 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 654855 + "gasUsed": 654537 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 105930 + "gasUsed": 105612 }, { "file": "test/KeysWithValueModule.t.sol", @@ -147,7 +147,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 654855 + "gasUsed": 654537 }, { "file": "test/KeysWithValueModule.t.sol", @@ -255,7 +255,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 682930 + "gasUsed": 681658 }, { "file": "test/UniqueEntityModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 650265 + "gasUsed": 648993 }, { "file": "test/UniqueEntityModule.t.sol", @@ -309,7 +309,7 @@ "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 83877 + "gasUsed": 83241 }, { "file": "test/World.t.sol", @@ -321,19 +321,19 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 81139 + "gasUsed": 80503 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 165272 + "gasUsed": 164954 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 640845 + "gasUsed": 640527 }, { "file": "test/World.t.sol", @@ -345,7 +345,7 @@ "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 37288 + "gasUsed": 36970 }, { "file": "test/WorldDynamicUpdate.t.sol", From 6046fb05477b97f4179a24654a87f69aec072f8e Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 16:22:25 +0100 Subject: [PATCH 13/38] remove deleteCount from SpliceStaticData --- docs/pages/store/spec.mdx | 2 +- packages/block-logs-stream/README.md | 2 +- packages/store/gas-report.json | 44 +++---- packages/store/src/IStore.sol | 9 +- packages/store/src/IStoreHook.sol | 2 - packages/store/src/StoreCore.sol | 27 +---- packages/store/src/StoreHook.sol | 4 +- packages/store/src/StoreSwitch.sol | 12 +- packages/store/test/EchoSubscriber.sol | 6 +- packages/store/test/MirrorSubscriber.sol | 16 +-- packages/store/test/RevertSubscriber.sol | 4 +- packages/store/test/StoreCore.t.sol | 26 +--- packages/store/test/StoreMock.sol | 3 +- packages/store/ts/storeEvents.ts | 2 +- packages/world/gas-report.json | 112 +++++++++--------- packages/world/src/World.sol | 3 +- .../modules/keysintable/KeysInTableHook.sol | 1 - .../keyswithvalue/KeysWithValueHook.sol | 2 - packages/world/test/World.t.sol | 28 +---- 19 files changed, 106 insertions(+), 199 deletions(-) diff --git a/docs/pages/store/spec.mdx b/docs/pages/store/spec.mdx index 6c05722c38..e1b9123b8b 100644 --- a/docs/pages/store/spec.mdx +++ b/docs/pages/store/spec.mdx @@ -8,7 +8,7 @@ When a record or a single field is edited, or when a record is deleted, Store em ```solidity event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData), -event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes data), +event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data), event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes data, bytes32 encodedLengths), event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple), ``` diff --git a/packages/block-logs-stream/README.md b/packages/block-logs-stream/README.md index 97a77e5a99..f56e552c13 100644 --- a/packages/block-logs-stream/README.md +++ b/packages/block-logs-stream/README.md @@ -27,7 +27,7 @@ latestBlockNumber$ address, events: parseAbi([ "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", - "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes data)", + "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)", "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes data, bytes32 encodedLengths)", "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)", ]), diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 6b74e49eac..c46032c970 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 719887 + "gasUsed": 719562 }, { "file": "test/Mixed.t.sol", @@ -363,13 +363,13 @@ "file": "test/Mixed.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Mixed table", - "gasUsed": 581763 + "gasUsed": 581438 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "set record in Mixed (external)", - "gasUsed": 104633 + "gasUsed": 104622 }, { "file": "test/Mixed.t.sol", @@ -381,7 +381,7 @@ "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "delete record from Mixed (external)", - "gasUsed": 8435 + "gasUsed": 8424 }, { "file": "test/Mixed.t.sol", @@ -597,7 +597,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 8311 + "gasUsed": 8315 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -615,7 +615,7 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4608 + "gasUsed": 4612 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -735,19 +735,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 72464 + "gasUsed": 72420 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 20732 + "gasUsed": 19864 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18691 + "gasUsed": 18733 }, { "file": "test/StoreCoreGas.t.sol", @@ -759,19 +759,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 165619 + "gasUsed": 165575 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 24526 + "gasUsed": 24504 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 19677 + "gasUsed": 19719 }, { "file": "test/StoreCoreGas.t.sol", @@ -789,7 +789,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 641761 + "gasUsed": 641436 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +855,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (1 slot)", - "gasUsed": 31607 + "gasUsed": 31282 }, { "file": "test/StoreCoreGas.t.sol", @@ -867,7 +867,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 30260 + "gasUsed": 29935 }, { "file": "test/StoreCoreGas.t.sol", @@ -939,7 +939,7 @@ "file": "test/StoreHook.t.sol", "test": "testCallHook", "name": "call an enabled hook", - "gasUsed": 15032 + "gasUsed": 15010 }, { "file": "test/StoreHook.t.sol", @@ -981,7 +981,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2915 + "gasUsed": 2919 }, { "file": "test/tables/Callbacks.t.sol", @@ -1035,7 +1035,7 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 10158 + "gasUsed": 10147 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1059,7 +1059,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 19016 + "gasUsed": 19005 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1143,18 +1143,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 443250 + "gasUsed": 442925 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 33746 + "gasUsed": 33735 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2535 + "gasUsed": 2539 } ] diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 8c003e006d..72fdedb9d2 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -92,13 +92,7 @@ interface IStoreWrite { bytes32 encodedLengths, bytes dynamicData ); - event Store_SpliceStaticData( - ResourceId indexed tableId, - bytes32[] keyTuple, - uint48 start, - uint40 deleteCount, - bytes data - ); + event Store_SpliceStaticData(ResourceId indexed tableId, bytes32[] keyTuple, uint48 start, bytes data); event Store_SpliceDynamicData( ResourceId indexed tableId, bytes32[] keyTuple, @@ -123,7 +117,6 @@ interface IStoreWrite { ResourceId tableId, bytes32[] calldata keyTuple, uint48 start, - uint40 deleteCount, bytes calldata data ) external; diff --git a/packages/store/src/IStoreHook.sol b/packages/store/src/IStoreHook.sol index b8a1b70947..2e4b6e1d28 100644 --- a/packages/store/src/IStoreHook.sol +++ b/packages/store/src/IStoreHook.sol @@ -42,7 +42,6 @@ interface IStoreHook is IERC165 { ResourceId tableId, bytes32[] memory keyTuple, uint48 start, - uint40 deleteCount, bytes memory data ) external; @@ -50,7 +49,6 @@ interface IStoreHook is IERC165 { ResourceId tableId, bytes32[] memory keyTuple, uint48 start, - uint40 deleteCount, bytes memory data ) external; diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 6439d14d5d..52ea2484a0 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -35,13 +35,7 @@ library StoreCore { bytes32 encodedLengths, bytes dynamicData ); - event Store_SpliceStaticData( - ResourceId indexed tableId, - bytes32[] keyTuple, - uint48 start, - uint40 deleteCount, - bytes data - ); + event Store_SpliceStaticData(ResourceId indexed tableId, bytes32[] keyTuple, uint48 start, bytes data); event Store_SpliceDynamicData( ResourceId indexed tableId, bytes32[] keyTuple, @@ -314,23 +308,11 @@ library StoreCore { } } - function spliceStaticData( - ResourceId tableId, - bytes32[] memory keyTuple, - uint48 start, - uint40 deleteCount, - bytes memory data - ) internal { + function spliceStaticData(ResourceId tableId, bytes32[] memory keyTuple, uint48 start, bytes memory data) internal { uint256 location = StoreCoreInternal._getStaticDataLocation(tableId, keyTuple); // Emit event to notify offchain indexers - emit StoreCore.Store_SpliceStaticData({ - tableId: tableId, - keyTuple: keyTuple, - start: start, - deleteCount: deleteCount, - data: data - }); + emit StoreCore.Store_SpliceStaticData({ tableId: tableId, keyTuple: keyTuple, start: start, data: data }); // Early return if the table is an offchain table if (tableId.getType() != RESOURCE_TABLE) { @@ -346,7 +328,6 @@ library StoreCore { tableId: tableId, keyTuple: keyTuple, start: start, - deleteCount: deleteCount, data: data }); } @@ -363,7 +344,6 @@ library StoreCore { tableId: tableId, keyTuple: keyTuple, start: start, - deleteCount: deleteCount, data: data }); } @@ -417,7 +397,6 @@ library StoreCore { tableId: tableId, keyTuple: keyTuple, start: uint48(StoreCoreInternal._getStaticDataOffset(fieldLayout, fieldIndex)), - deleteCount: uint40(fieldLayout.atIndex(fieldIndex)), data: data }); } diff --git a/packages/store/src/StoreHook.sol b/packages/store/src/StoreHook.sol index fae57d9cec..6b5faabb10 100644 --- a/packages/store/src/StoreHook.sol +++ b/packages/store/src/StoreHook.sol @@ -35,11 +35,11 @@ abstract contract StoreHook is IStoreHook { revert StoreHook_NotImplemented(); } - function onBeforeSpliceStaticData(ResourceId, bytes32[] memory, uint48, uint40, bytes memory) public virtual { + function onBeforeSpliceStaticData(ResourceId, bytes32[] memory, uint48, bytes memory) public virtual { revert StoreHook_NotImplemented(); } - function onAfterSpliceStaticData(ResourceId, bytes32[] memory, uint48, uint40, bytes memory) public virtual { + function onAfterSpliceStaticData(ResourceId, bytes32[] memory, uint48, bytes memory) public virtual { revert StoreHook_NotImplemented(); } diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index bd0dc4efdc..6a34f72cd3 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -125,18 +125,12 @@ library StoreSwitch { } } - function spliceStaticData( - ResourceId tableId, - bytes32[] memory keyTuple, - uint48 start, - uint40 deleteCount, - bytes memory data - ) internal { + function spliceStaticData(ResourceId tableId, bytes32[] memory keyTuple, uint48 start, bytes memory data) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.spliceStaticData(tableId, keyTuple, start, deleteCount, data); + StoreCore.spliceStaticData(tableId, keyTuple, start, data); } else { - IStore(_storeAddress).spliceStaticData(tableId, keyTuple, start, deleteCount, data); + IStore(_storeAddress).spliceStaticData(tableId, keyTuple, start, data); } } diff --git a/packages/store/test/EchoSubscriber.sol b/packages/store/test/EchoSubscriber.sol index 6612677719..a0aced4a9d 100644 --- a/packages/store/test/EchoSubscriber.sol +++ b/packages/store/test/EchoSubscriber.sol @@ -39,20 +39,18 @@ contract EchoSubscriber is StoreHook { ResourceId tableId, bytes32[] memory keyTuple, uint48 start, - uint40 deleteCount, bytes memory data ) public override { - emit HookCalled(abi.encodeCall(this.onBeforeSpliceStaticData, (tableId, keyTuple, start, deleteCount, data))); + emit HookCalled(abi.encodeCall(this.onBeforeSpliceStaticData, (tableId, keyTuple, start, data))); } function onAfterSpliceStaticData( ResourceId tableId, bytes32[] memory keyTuple, uint48 start, - uint40 deleteCount, bytes memory data ) public override { - emit HookCalled(abi.encodeCall(this.onAfterSpliceStaticData, (tableId, keyTuple, start, deleteCount, data))); + emit HookCalled(abi.encodeCall(this.onAfterSpliceStaticData, (tableId, keyTuple, start, data))); } function onBeforeSpliceDynamicData( diff --git a/packages/store/test/MirrorSubscriber.sol b/packages/store/test/MirrorSubscriber.sol index 83a7c36fee..137fb36a45 100644 --- a/packages/store/test/MirrorSubscriber.sol +++ b/packages/store/test/MirrorSubscriber.sol @@ -45,11 +45,10 @@ contract MirrorSubscriber is StoreHook { ResourceId tableId, bytes32[] memory keyTuple, uint48 start, - uint40 deleteCount, bytes memory data ) public override { if (ResourceId.unwrap(tableId) != _tableId) revert("invalid tableId"); - StoreSwitch.spliceStaticData(indexerTableId, keyTuple, start, deleteCount, data); + StoreSwitch.spliceStaticData(indexerTableId, keyTuple, start, data); } function onBeforeSpliceDynamicData( @@ -65,19 +64,6 @@ contract MirrorSubscriber is StoreHook { StoreSwitch.spliceDynamicData(indexerTableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data); } - function onAfterSpliceDynamicData( - ResourceId tableId, - bytes32[] memory keyTuple, - uint8 dynamicFieldIndex, - uint40 startWithinField, - uint40 deleteCount, - bytes memory data, - PackedCounter - ) public override { - if (ResourceId.unwrap(tableId) != _tableId) revert("invalid tableId"); - StoreSwitch.spliceDynamicData(indexerTableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data); - } - function onBeforeDeleteRecord( ResourceId tableId, bytes32[] memory keyTuple, diff --git a/packages/store/test/RevertSubscriber.sol b/packages/store/test/RevertSubscriber.sol index f1a7a7d4a1..05f1c6fe55 100644 --- a/packages/store/test/RevertSubscriber.sol +++ b/packages/store/test/RevertSubscriber.sol @@ -29,11 +29,11 @@ contract RevertSubscriber is StoreHook { revert("onAfterSetRecord"); } - function onBeforeSpliceStaticData(ResourceId, bytes32[] memory, uint48, uint40, bytes memory) public pure override { + function onBeforeSpliceStaticData(ResourceId, bytes32[] memory, uint48, bytes memory) public pure override { revert("onBeforeSpliceStaticData"); } - function onAfterSpliceStaticData(ResourceId, bytes32[] memory, uint48, uint40, bytes memory) public pure override { + function onAfterSpliceStaticData(ResourceId, bytes32[] memory, uint48, bytes memory) public pure override { revert("onAfterSpliceStaticData"); } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 18510ae2cc..334f6e26c4 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -473,13 +473,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a Store_SpliceStaticData event to be emitted vm.expectEmit(true, true, true, true); - emit Store_SpliceStaticData( - _data.tableId, - keyTuple, - 0, - uint40(_data.firstDataPacked.length), - _data.firstDataPacked - ); + emit Store_SpliceStaticData(_data.tableId, keyTuple, 0, _data.firstDataPacked); // Set first field IStore(this).setField(_data.tableId, keyTuple, 0, _data.firstDataPacked, _data.fieldLayout); @@ -501,13 +495,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSpliceRecord event to be emitted vm.expectEmit(true, true, true, true); - emit Store_SpliceStaticData( - _data.tableId, - keyTuple, - uint48(_data.firstDataPacked.length), - uint40(_data.secondDataPacked.length), - _data.secondDataPacked - ); + emit Store_SpliceStaticData(_data.tableId, keyTuple, uint48(_data.firstDataPacked.length), _data.secondDataPacked); IStore(this).setField(_data.tableId, keyTuple, 1, _data.secondDataPacked, _data.fieldLayout); @@ -1175,15 +1163,11 @@ contract StoreCoreTest is Test, StoreMock { // Expect a HookCalled event to be emitted when the EchoSubscriber's onBeforeSpliceStaticData hook is called vm.expectEmit(true, true, true, true); - emit HookCalled( - abi.encodeCall(IStoreHook.onBeforeSpliceStaticData, (tableId, keyTuple, 0, uint40(staticData.length), staticData)) - ); + emit HookCalled(abi.encodeCall(IStoreHook.onBeforeSpliceStaticData, (tableId, keyTuple, 0, staticData))); // Expect a HookCalled event to be emitted when the EchoSubscriber's onAfterSpliceStaticData hook is called vm.expectEmit(true, true, true, true); - emit HookCalled( - abi.encodeCall(IStoreHook.onAfterSpliceStaticData, (tableId, keyTuple, 0, uint40(staticData.length), staticData)) - ); + emit HookCalled(abi.encodeCall(IStoreHook.onAfterSpliceStaticData, (tableId, keyTuple, 0, staticData))); IStore(this).setField(tableId, keyTuple, 0, staticData, fieldLayout); @@ -1196,7 +1180,7 @@ contract StoreCoreTest is Test, StoreMock { ) ); - // Expect a HookCalled event to be emitted when the EchoSubscriber's onAfterSpliceStaticData hook is called + // Expect a HookCalled event to be emitted when the EchoSubscriber's onAfterSpliceDynamicData hook is called vm.expectEmit(true, true, true, true); emit HookCalled( abi.encodeCall( diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index 224baa5e59..694087d44f 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -34,10 +34,9 @@ contract StoreMock is IStore, StoreRead { ResourceId tableId, bytes32[] calldata keyTuple, uint48 start, - uint40 deleteCount, bytes calldata data ) public virtual { - StoreCore.spliceStaticData(tableId, keyTuple, start, deleteCount, data); + StoreCore.spliceStaticData(tableId, keyTuple, start, data); } // Splice data in the dynamic part of the record diff --git a/packages/store/ts/storeEvents.ts b/packages/store/ts/storeEvents.ts index 4feeb89db3..84e9f0d8d9 100644 --- a/packages/store/ts/storeEvents.ts +++ b/packages/store/ts/storeEvents.ts @@ -1,6 +1,6 @@ export const storeEvents = [ "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", - "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes data)", + "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)", "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, uint40 deleteCount, bytes data, bytes32 encodedLengths)", "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)", ] as const; diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 94fe988d6f..7df8359bb2 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -33,79 +33,79 @@ "file": "test/CallBatch.t.sol", "test": "testCallBatchReturnData", "name": "call systems with callBatch", - "gasUsed": 45158 + "gasUsed": 45264 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1412625 + "gasUsed": 1411020 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1412625 + "gasUsed": 1411020 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 158889 + "gasUsed": 158894 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1412625 + "gasUsed": 1411020 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1412625 + "gasUsed": 1411020 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22566 + "gasUsed": 22571 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 160934 + "gasUsed": 160569 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1412625 + "gasUsed": 1411020 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 21288 + "gasUsed": 21293 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 86694 + "gasUsed": 86287 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 654537 + "gasUsed": 652590 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "Get list of keys with a given value", - "gasUsed": 5712 + "gasUsed": 5690 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,259 +117,259 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 654537 + "gasUsed": 652590 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 136155 + "gasUsed": 136094 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 654537 + "gasUsed": 652590 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 105612 + "gasUsed": 105551 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36348 + "gasUsed": 36264 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 654537 + "gasUsed": 652590 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 147842 + "gasUsed": 147302 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 112601 + "gasUsed": 112061 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 103295 + "gasUsed": 103163 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 52973 + "gasUsed": 52885 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 128483 + "gasUsed": 128373 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 81668 + "gasUsed": 81580 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 83302 + "gasUsed": 83214 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueQuery", "name": "CombinedHasValueQuery", - "gasUsed": 15705 + "gasUsed": 15661 }, { "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18144 + "gasUsed": 18122 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5938643 + "gasUsed": 5938621 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 554037 + "gasUsed": 554015 }, { "file": "test/query.t.sol", "test": "testHasValueQuery", "name": "HasValueQuery", - "gasUsed": 7521 + "gasUsed": 7499 }, { "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 46569 + "gasUsed": 46481 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 114526 + "gasUsed": 113885 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36708 + "gasUsed": 36694 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 109021 + "gasUsed": 108380 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26793 + "gasUsed": 26779 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 681658 + "gasUsed": 679091 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51888 + "gasUsed": 51594 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 648993 + "gasUsed": 646387 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51888 + "gasUsed": 51594 }, { "file": "test/World.t.sol", "test": "testCall", "name": "call a system via the World", - "gasUsed": 12360 + "gasUsed": 12409 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 50531 + "gasUsed": 50215 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "call a system via an unlimited delegation", - "gasUsed": 12814 + "gasUsed": 12796 }, { "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9933 + "gasUsed": 9911 }, { "file": "test/World.t.sol", "test": "testPushToField", "name": "Push data to the table", - "gasUsed": 86698 + "gasUsed": 86743 }, { "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 83241 + "gasUsed": 83249 }, { "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 123155 + "gasUsed": 122188 }, { "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 80503 + "gasUsed": 80511 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 164954 + "gasUsed": 163987 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 640527 + "gasUsed": 639235 }, { "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 37236 + "gasUsed": 36889 }, { "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 36970 + "gasUsed": 36948 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromField", "name": "pop 1 address (cold)", - "gasUsed": 24521 + "gasUsed": 24499 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromField", "name": "pop 1 address (warm)", - "gasUsed": 13667 + "gasUsed": 13645 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testUpdateInField", "name": "updateInField 1 item (cold)", - "gasUsed": 25019 + "gasUsed": 25063 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testUpdateInField", "name": "updateInField 1 item (warm)", - "gasUsed": 14224 + "gasUsed": 14268 }, { "file": "test/WorldResourceId.t.sol", diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 9516754df0..0641f45412 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -130,14 +130,13 @@ contract World is StoreRead, IStoreData, IWorldKernel { ResourceId tableId, bytes32[] calldata keyTuple, uint48 start, - uint40 deleteCount, bytes calldata data ) public virtual requireNoCallback { // Require access to the namespace or name AccessControl.requireAccess(tableId, msg.sender); // Splice the static data - StoreCore.spliceStaticData(tableId, keyTuple, start, deleteCount, data); + StoreCore.spliceStaticData(tableId, keyTuple, start, data); } function spliceDynamicData( diff --git a/packages/world/src/modules/keysintable/KeysInTableHook.sol b/packages/world/src/modules/keysintable/KeysInTableHook.sol index 3cf09d4638..f3bada4a12 100644 --- a/packages/world/src/modules/keysintable/KeysInTableHook.sol +++ b/packages/world/src/modules/keysintable/KeysInTableHook.sol @@ -57,7 +57,6 @@ contract KeysInTableHook is StoreHook { ResourceId tableId, bytes32[] memory keyTuple, uint48, - uint40, bytes memory ) public override { handleSet(tableId, keyTuple); diff --git a/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol b/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol index 22e25b9d5b..aef1be86c6 100644 --- a/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol +++ b/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol @@ -61,7 +61,6 @@ contract KeysWithValueHook is StoreHook { ResourceId sourceTableId, bytes32[] memory keyTuple, uint48, - uint40, bytes memory ) public override { // Remove the key from the list of keys with the previous value @@ -75,7 +74,6 @@ contract KeysWithValueHook is StoreHook { ResourceId sourceTableId, bytes32[] memory keyTuple, uint48, - uint40, bytes memory ) public override { // Add the key to the list of keys with the new value diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index c19d28b251..43580373a9 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -1075,20 +1075,10 @@ contract WorldTest is Test, GasReporter { // Expect the hook to be notified when a static field is written (once before and once after the field is written) vm.expectEmit(true, true, true, true); - emit HookCalled( - abi.encodeCall( - IStoreHook.onBeforeSpliceStaticData, - (tableId, singletonKey, 0, uint40(staticData.length), staticData) - ) - ); + emit HookCalled(abi.encodeCall(IStoreHook.onBeforeSpliceStaticData, (tableId, singletonKey, 0, staticData))); vm.expectEmit(true, true, true, true); - emit HookCalled( - abi.encodeCall( - IStoreHook.onAfterSpliceStaticData, - (tableId, singletonKey, 0, uint40(staticData.length), staticData) - ) - ); + emit HookCalled(abi.encodeCall(IStoreHook.onAfterSpliceStaticData, (tableId, singletonKey, 0, staticData))); world.setField(tableId, singletonKey, 0, staticData, fieldLayout); @@ -1166,20 +1156,10 @@ contract WorldTest is Test, GasReporter { // Expect the hook to be notified when a static field is written (once before and once after the field is written) vm.expectEmit(true, true, true, true); - emit HookCalled( - abi.encodeCall( - IStoreHook.onBeforeSpliceStaticData, - (tableId, singletonKey, 0, uint40(staticData.length), staticData) - ) - ); + emit HookCalled(abi.encodeCall(IStoreHook.onBeforeSpliceStaticData, (tableId, singletonKey, 0, staticData))); vm.expectEmit(true, true, true, true); - emit HookCalled( - abi.encodeCall( - IStoreHook.onAfterSpliceStaticData, - (tableId, singletonKey, 0, uint40(staticData.length), staticData) - ) - ); + emit HookCalled(abi.encodeCall(IStoreHook.onAfterSpliceStaticData, (tableId, singletonKey, 0, staticData))); world.setField(tableId, singletonKey, 0, staticData, fieldLayout); From 9729f67f9995b07cac487a69d415c42bd29b5756 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 16:26:59 +0100 Subject: [PATCH 14/38] integrate new SpliceStaticData event --- packages/common/src/getByteLength.ts | 6 ++++++ packages/common/src/index.ts | 1 + packages/store-sync/src/postgres/postgresStorage.ts | 9 +++++++-- packages/store-sync/src/recs/recsStorage.ts | 9 +++++++-- packages/store-sync/src/sqlite/sqliteStorage.ts | 9 +++++++-- 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 packages/common/src/getByteLength.ts diff --git a/packages/common/src/getByteLength.ts b/packages/common/src/getByteLength.ts new file mode 100644 index 0000000000..dfbe61e2ce --- /dev/null +++ b/packages/common/src/getByteLength.ts @@ -0,0 +1,6 @@ +import { Hex } from "viem"; + +export function getByteLength(data: Hex): number { + // Remove `0x` prefix, then byte is 2 characters + return (data.length - 2) / 2; +} diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index a15afa9877..c4d9e899ad 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -9,3 +9,4 @@ export * from "./resourceIdToHex"; export * from "./resourceTypes"; export * from "./spliceHex"; export * from "./transportObserver"; +export * from "./getByteLength"; diff --git a/packages/store-sync/src/postgres/postgresStorage.ts b/packages/store-sync/src/postgres/postgresStorage.ts index 961c0b726a..fb61096b6c 100644 --- a/packages/store-sync/src/postgres/postgresStorage.ts +++ b/packages/store-sync/src/postgres/postgresStorage.ts @@ -7,7 +7,7 @@ import { debug } from "./debug"; import { buildInternalTables } from "./buildInternalTables"; import { getTables } from "./getTables"; import { schemaVersion } from "./schemaVersion"; -import { hexToResourceId, spliceHex } from "@latticexyz/common"; +import { getByteLength, hexToResourceId, spliceHex } from "@latticexyz/common"; import { setupTables } from "./setupTables"; import { getTableKey } from "./getTableKey"; import { StorageAdapter, StorageAdapterBlock } from "../common"; @@ -132,7 +132,12 @@ export async function postgresStorage // TODO: verify that this returns what we expect (doesn't error/undefined on no record) const previousValue = (await tx.select().from(sqlTable).where(eq(sqlTable.__key, uniqueKey)).execute())[0]; const previousStaticData = (previousValue?.__staticData as Hex) ?? "0x"; - const newStaticData = spliceHex(previousStaticData, log.args.start, log.args.deleteCount, log.args.data); + const newStaticData = spliceHex( + previousStaticData, + log.args.start, + getByteLength(log.args.data), + log.args.data + ); const newValue = decodeValueArgs(table.valueSchema, { staticData: newStaticData, encodedLengths: (previousValue?.__encodedLengths as Hex) ?? "0x", diff --git a/packages/store-sync/src/recs/recsStorage.ts b/packages/store-sync/src/recs/recsStorage.ts index 27f2dccd89..a9d1e78c33 100644 --- a/packages/store-sync/src/recs/recsStorage.ts +++ b/packages/store-sync/src/recs/recsStorage.ts @@ -3,7 +3,7 @@ import { debug } from "./debug"; import { World as RecsWorld, getComponentValue, hasComponent, removeComponent, setComponent } from "@latticexyz/recs"; import { defineInternalComponents } from "./defineInternalComponents"; import { getTableEntity } from "./getTableEntity"; -import { hexToResourceId, spliceHex } from "@latticexyz/common"; +import { getByteLength, hexToResourceId, spliceHex } from "@latticexyz/common"; import { decodeValueArgs } from "@latticexyz/protocol-parser"; import { Hex } from "viem"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; @@ -98,7 +98,12 @@ export function recsStorage({ // TODO: add tests that this works when no record had been set before const previousValue = getComponentValue(component, entity); const previousStaticData = (previousValue?.__staticData as Hex) ?? "0x"; - const newStaticData = spliceHex(previousStaticData, log.args.start, log.args.deleteCount, log.args.data); + const newStaticData = spliceHex( + previousStaticData, + log.args.start, + getByteLength(log.args.data), + log.args.data + ); const newValue = decodeValueArgs(table.valueSchema, { staticData: newStaticData, encodedLengths: (previousValue?.__encodedLengths as Hex) ?? "0x", diff --git a/packages/store-sync/src/sqlite/sqliteStorage.ts b/packages/store-sync/src/sqlite/sqliteStorage.ts index 7d4590c9f5..4898b1b6a0 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.ts @@ -12,7 +12,7 @@ import { schemaVersion } from "./schemaVersion"; import { StorageAdapter } from "../common"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; import { logToTable } from "../logToTable"; -import { hexToResourceId, spliceHex } from "@latticexyz/common"; +import { getByteLength, hexToResourceId, spliceHex } from "@latticexyz/common"; import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; // TODO: upgrade drizzle and use async sqlite interface for consistency @@ -131,7 +131,12 @@ export async function sqliteStorage({ // TODO: verify that this returns what we expect (doesn't error/undefined on no record) const previousValue = (await tx.select().from(sqlTable).where(eq(sqlTable.__key, uniqueKey)).execute())[0]; const previousStaticData = (previousValue?.__staticData as Hex) ?? "0x"; - const newStaticData = spliceHex(previousStaticData, log.args.start, log.args.deleteCount, log.args.data); + const newStaticData = spliceHex( + previousStaticData, + log.args.start, + getByteLength(log.args.data), + log.args.data + ); const newValue = decodeValueArgs(table.valueSchema, { staticData: newStaticData, encodedLengths: (previousValue?.__encodedLengths as Hex) ?? "0x", From e452215eb9390f9eedbacb53db0b666d27a90295 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 16:39:45 +0100 Subject: [PATCH 15/38] reuse numStaticFields --- packages/store/src/StoreCore.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 52ea2484a0..99c2b85927 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -656,7 +656,7 @@ library StoreCore { uint256 end ) internal view returns (bytes memory) { uint8 numStaticFields = uint8(fieldLayout.numStaticFields()); - if (fieldIndex < fieldLayout.numStaticFields()) { + if (fieldIndex < numStaticFields) { revert IStoreErrors.Store_NotDynamicField(); } From 004fe9ce9ec3012429a498de0a121a32b9639841 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 17:28:04 +0100 Subject: [PATCH 16/38] actually delete data in deleteRecord --- packages/store/gas-report.json | 28 ++++++++++++------------ packages/store/src/IStoreErrors.sol | 1 + packages/store/src/Storage.sol | 12 ++++++++++ packages/store/src/StoreCore.sol | 16 +++++++++++--- packages/world/gas-report.json | 34 ++++++++++++++--------------- 5 files changed, 57 insertions(+), 34 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index c46032c970..616393654d 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -381,7 +381,7 @@ "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "delete record from Mixed (external)", - "gasUsed": 8424 + "gasUsed": 10987 }, { "file": "test/Mixed.t.sol", @@ -399,7 +399,7 @@ "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "delete record from Mixed (internal)", - "gasUsed": 7213 + "gasUsed": 9775 }, { "file": "test/PackedCounter.t.sol", @@ -597,25 +597,25 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 8315 + "gasUsed": 8022 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 2383 + "gasUsed": 2090 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (semi-cold, 1 slot)", - "gasUsed": 4386 + "gasUsed": 4093 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4612 + "gasUsed": 4319 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -693,13 +693,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access slice of dynamic field of non-existing record", - "gasUsed": 1517 + "gasUsed": 1224 }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 7733 + "gasUsed": 10293 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,7 +747,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18733 + "gasUsed": 18747 }, { "file": "test/StoreCoreGas.t.sol", @@ -771,7 +771,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 19719 + "gasUsed": 22772 }, { "file": "test/StoreCoreGas.t.sol", @@ -1035,13 +1035,13 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 10147 + "gasUsed": 11840 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 31220 + "gasUsed": 51121 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1059,7 +1059,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 19005 + "gasUsed": 25337 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1071,7 +1071,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testGetItem", "name": "StoreHooks: get 1 element (cold)", - "gasUsed": 6575 + "gasUsed": 6282 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", diff --git a/packages/store/src/IStoreErrors.sol b/packages/store/src/IStoreErrors.sol index 6bb184c188..46b19f181e 100644 --- a/packages/store/src/IStoreErrors.sol +++ b/packages/store/src/IStoreErrors.sol @@ -10,6 +10,7 @@ interface IStoreErrors { error Store_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); error Store_NotDynamicField(); + error Store_InvalidDynamicDataLength(uint256 expected, uint256 received); error Store_InvalidKeyNamesLength(uint256 expected, uint256 received); error Store_InvalidFieldNamesLength(uint256 expected, uint256 received); error Store_InvalidValueSchemaLength(uint256 expected, uint256 received); diff --git a/packages/store/src/Storage.sol b/packages/store/src/Storage.sol index d8745b3636..e558d23093 100644 --- a/packages/store/src/Storage.sol +++ b/packages/store/src/Storage.sol @@ -99,6 +99,18 @@ library Storage { } } + function zero(uint256 storagePointer, uint256 length) internal { + // Ceil division to round up to the nearest word + uint256 limit = storagePointer + (length + 31) / 32; + while (storagePointer < limit) { + /// @solidity memory-safe-assembly + assembly { + sstore(storagePointer, 0) + storagePointer := add(storagePointer, 1) + } + } + } + function load(uint256 storagePointer) internal view returns (bytes32 word) { assembly { word := sload(storagePointer) diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 99c2b85927..d799e18cbf 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -456,10 +456,20 @@ library StoreCore { uint256 staticDataLocation = StoreCoreInternal._getStaticDataLocation(tableId, keyTuple); Storage.store({ storagePointer: staticDataLocation, offset: 0, data: new bytes(fieldLayout.staticDataLength()) }); - // If there are dynamic fields, delete the dynamic data length - if (fieldLayout.numDynamicFields() > 0) { + // If there are dynamic fields, delete the dynamic data + uint256 numDynamicFields = fieldLayout.numDynamicFields(); + if (numDynamicFields > 0) { uint256 dynamicDataLengthLocation = StoreCoreInternal._getDynamicDataLengthLocation(tableId, keyTuple); - Storage.store({ storagePointer: dynamicDataLengthLocation, data: bytes32(0) }); + PackedCounter dynamicDataLength = PackedCounter.wrap(Storage.load({ storagePointer: dynamicDataLengthLocation })); + + // Delete dynamic data + for (uint256 i; i < numDynamicFields; i++) { + uint256 dynamicDataLocation = StoreCoreInternal._getDynamicDataLocation(tableId, keyTuple, uint8(i)); + Storage.zero({ storagePointer: dynamicDataLocation, length: dynamicDataLength.atIndex(uint8(i)) }); + } + + // Set the dynamic data length to 0 + Storage.zero({ storagePointer: dynamicDataLengthLocation, length: 32 }); } // Call onAfterDeleteRecord hooks diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 7df8359bb2..e4babf0aae 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -75,7 +75,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 160569 + "gasUsed": 159704 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,7 +93,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 86287 + "gasUsed": 86008 }, { "file": "test/KeysWithValueModule.t.sol", @@ -123,7 +123,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 136094 + "gasUsed": 137469 }, { "file": "test/KeysWithValueModule.t.sol", @@ -141,7 +141,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36264 + "gasUsed": 37803 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,43 +153,43 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 147302 + "gasUsed": 148677 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 112061 + "gasUsed": 113593 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 103163 + "gasUsed": 100526 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 52885 + "gasUsed": 52006 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 128373 + "gasUsed": 123685 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 81580 + "gasUsed": 78943 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 83214 + "gasUsed": 80577 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18122 + "gasUsed": 17536 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5938621 + "gasUsed": 5645621 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 554015 + "gasUsed": 524715 }, { "file": "test/query.t.sol", @@ -225,7 +225,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 46481 + "gasUsed": 45602 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -237,7 +237,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36694 + "gasUsed": 36701 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -297,7 +297,7 @@ "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9911 + "gasUsed": 9918 }, { "file": "test/World.t.sol", From e818707c3ea6b4541e8573d77e760d983576809a Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 17:37:54 +0100 Subject: [PATCH 17/38] add more meaningful gas report for deleting on cold slot --- packages/store/gas-report.json | 36 ++++++++++++++----------- packages/store/test/Mixed.t.sol | 47 +++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 616393654d..38c3810b93 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -361,45 +361,51 @@ }, { "file": "test/Mixed.t.sol", - "test": "testRegisterAndGetFieldLayout", - "name": "register Mixed table", - "gasUsed": 581438 + "test": "testDeleteExternalCold", + "name": "delete record from Mixed (external, cold)", + "gasUsed": 36350 + }, + { + "file": "test/Mixed.t.sol", + "test": "testDeleteInternalCold", + "name": "delete record from Mixed (internal, cold)", + "gasUsed": 31146 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", - "name": "set record in Mixed (external)", - "gasUsed": 104622 + "name": "set record in Mixed (external, cold)", + "gasUsed": 108604 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", - "name": "get record from Mixed (external)", - "gasUsed": 7089 + "name": "get record from Mixed (external, warm)", + "gasUsed": 7078 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", - "name": "delete record from Mixed (external)", - "gasUsed": 10987 + "name": "delete record from Mixed (external, warm)", + "gasUsed": 10970 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", - "name": "set record in Mixed (internal)", - "gasUsed": 103373 + "name": "set record in Mixed (internal, cold)", + "gasUsed": 103358 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", - "name": "get record from Mixed (internal)", - "gasUsed": 6776 + "name": "get record from Mixed (internal, warm)", + "gasUsed": 6764 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", - "name": "delete record from Mixed (internal)", - "gasUsed": 9775 + "name": "delete record from Mixed (internal, warm)", + "gasUsed": 9762 }, { "file": "test/PackedCounter.t.sol", diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index e9f92fb149..444ef01adf 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -13,11 +13,18 @@ import { PackedCounter } from "../src/PackedCounter.sol"; contract MixedTest is Test, GasReporter, StoreMock { MixedData private testMixed; - function testRegisterAndGetFieldLayout() public { - startGasReport("register Mixed table"); - Mixed.register(); - endGasReport(); + function setUp() public { + Mixed._register(); + + bytes32 key = keccak256("defaultkey"); + uint32[] memory a32 = new uint32[](2); + a32[0] = 3; + a32[1] = 4; + string memory s = "some string"; + Mixed.set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); + } + function testRegisterAndGetFieldLayout() public { FieldLayout registeredFieldLayout = StoreCore.getFieldLayout(MixedTableId); FieldLayout declaredFieldLayout = Mixed.getFieldLayout(); @@ -25,8 +32,6 @@ contract MixedTest is Test, GasReporter, StoreMock { } function testRegisterAndGetSchema() public { - Mixed.register(); - Schema registeredSchema = StoreCore.getValueSchema(MixedTableId); Schema declaredSchema = Mixed.getValueSchema(); @@ -34,7 +39,6 @@ contract MixedTest is Test, GasReporter, StoreMock { } function testSetGetDeleteExternal() public { - Mixed.register(); bytes32 key = keccak256("somekey"); uint32[] memory a32 = new uint32[](2); @@ -42,11 +46,11 @@ contract MixedTest is Test, GasReporter, StoreMock { a32[1] = 4; string memory s = "some string"; - startGasReport("set record in Mixed (external)"); + startGasReport("set record in Mixed (external, cold)"); Mixed.set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); endGasReport(); - startGasReport("get record from Mixed (external)"); + startGasReport("get record from Mixed (external, warm)"); MixedData memory mixed = Mixed.get(key); endGasReport(); @@ -56,13 +60,12 @@ contract MixedTest is Test, GasReporter, StoreMock { assertEq(mixed.a32[1], 4); assertEq(mixed.s, s); - startGasReport("delete record from Mixed (external)"); + startGasReport("delete record from Mixed (external, warm)"); Mixed.deleteRecord(key); endGasReport(); } function testSetGetDeleteInternal() public { - Mixed._register(); bytes32 key = keccak256("somekey"); uint32[] memory a32 = new uint32[](2); @@ -70,11 +73,11 @@ contract MixedTest is Test, GasReporter, StoreMock { a32[1] = 4; string memory s = "some string"; - startGasReport("set record in Mixed (internal)"); + startGasReport("set record in Mixed (internal, cold)"); Mixed._set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); endGasReport(); - startGasReport("get record from Mixed (internal)"); + startGasReport("get record from Mixed (internal, warm)"); MixedData memory mixed = Mixed._get(key); endGasReport(); @@ -84,7 +87,23 @@ contract MixedTest is Test, GasReporter, StoreMock { assertEq(mixed.a32[1], 4); assertEq(mixed.s, s); - startGasReport("delete record from Mixed (internal)"); + startGasReport("delete record from Mixed (internal, warm)"); + Mixed._deleteRecord(key); + endGasReport(); + } + + function testDeleteExternalCold() public { + bytes32 key = keccak256("defaultkey"); + + startGasReport("delete record from Mixed (external, cold)"); + Mixed.deleteRecord(key); + endGasReport(); + } + + function testDeleteInternalCold() public { + bytes32 key = keccak256("defaultkey"); + + startGasReport("delete record from Mixed (internal, cold)"); Mixed._deleteRecord(key); endGasReport(); } From b70321694b444290cda998af5b3cacae81cae7db Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 17:42:45 +0100 Subject: [PATCH 18/38] add longer dynamic field for test purposes --- packages/store/gas-report.json | 4 ++-- packages/store/test/Mixed.t.sol | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 38c3810b93..f48141c3ef 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -363,13 +363,13 @@ "file": "test/Mixed.t.sol", "test": "testDeleteExternalCold", "name": "delete record from Mixed (external, cold)", - "gasUsed": 36350 + "gasUsed": 112205 }, { "file": "test/Mixed.t.sol", "test": "testDeleteInternalCold", "name": "delete record from Mixed (internal, cold)", - "gasUsed": 31146 + "gasUsed": 107001 }, { "file": "test/Mixed.t.sol", diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index 444ef01adf..5cffb2cc39 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -20,7 +20,8 @@ contract MixedTest is Test, GasReporter, StoreMock { uint32[] memory a32 = new uint32[](2); a32[0] = 3; a32[1] = 4; - string memory s = "some string"; + string + memory s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dapibus velit a ante porta pulvinar. Integer semper quam erat, nec pellentesque nunc feugiat sed. Pellentesque aliquam quam sapien, rutrum egestas sapien vestibulum quis. Suspendisse nisi leo, tincidunt at mauris tincidunt, dapibus luctus dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec eget finibus odio. Maecenas velit diam, fermentum et consectetur at, posuere vitae magna."; Mixed.set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); } From 10fbec7a9586ae726bae66c89372069df134bbb0 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 17:57:32 +0100 Subject: [PATCH 19/38] verify out of bounds in getFieldSlice --- packages/store/gas-report.json | 32 +++++++++++++-------------- packages/store/src/IStoreErrors.sol | 1 + packages/store/src/StoreCore.sol | 27 +++++++++++------------ packages/store/test/Mixed.t.sol | 3 +-- packages/world/gas-report.json | 34 ++++++++++++++--------------- 5 files changed, 48 insertions(+), 49 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index f48141c3ef..a829900896 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -363,13 +363,13 @@ "file": "test/Mixed.t.sol", "test": "testDeleteExternalCold", "name": "delete record from Mixed (external, cold)", - "gasUsed": 112205 + "gasUsed": 24434 }, { "file": "test/Mixed.t.sol", "test": "testDeleteInternalCold", "name": "delete record from Mixed (internal, cold)", - "gasUsed": 107001 + "gasUsed": 19230 }, { "file": "test/Mixed.t.sol", @@ -387,7 +387,7 @@ "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "delete record from Mixed (external, warm)", - "gasUsed": 10970 + "gasUsed": 8750 }, { "file": "test/Mixed.t.sol", @@ -405,7 +405,7 @@ "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "delete record from Mixed (internal, warm)", - "gasUsed": 9762 + "gasUsed": 7543 }, { "file": "test/PackedCounter.t.sol", @@ -603,25 +603,25 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 8022 + "gasUsed": 10692 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 2090 + "gasUsed": 2760 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (semi-cold, 1 slot)", - "gasUsed": 4093 + "gasUsed": 4765 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4319 + "gasUsed": 4991 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -699,13 +699,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access slice of dynamic field of non-existing record", - "gasUsed": 1224 + "gasUsed": 1897 }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 10293 + "gasUsed": 8073 }, { "file": "test/StoreCoreGas.t.sol", @@ -753,7 +753,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18747 + "gasUsed": 18733 }, { "file": "test/StoreCoreGas.t.sol", @@ -777,7 +777,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 22772 + "gasUsed": 20399 }, { "file": "test/StoreCoreGas.t.sol", @@ -1041,13 +1041,13 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 11840 + "gasUsed": 10487 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 51121 + "gasUsed": 31220 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1065,7 +1065,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 25337 + "gasUsed": 19345 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1077,7 +1077,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testGetItem", "name": "StoreHooks: get 1 element (cold)", - "gasUsed": 6282 + "gasUsed": 8952 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", diff --git a/packages/store/src/IStoreErrors.sol b/packages/store/src/IStoreErrors.sol index 46b19f181e..14c8e517b7 100644 --- a/packages/store/src/IStoreErrors.sol +++ b/packages/store/src/IStoreErrors.sol @@ -11,6 +11,7 @@ interface IStoreErrors { error Store_NotDynamicField(); error Store_InvalidDynamicDataLength(uint256 expected, uint256 received); + error Store_OutOfBounds(uint256 length, uint256 accessedIndex); error Store_InvalidKeyNamesLength(uint256 expected, uint256 received); error Store_InvalidFieldNamesLength(uint256 expected, uint256 received); error Store_InvalidValueSchemaLength(uint256 expected, uint256 received); diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index d799e18cbf..51297e3fd7 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -456,19 +456,10 @@ library StoreCore { uint256 staticDataLocation = StoreCoreInternal._getStaticDataLocation(tableId, keyTuple); Storage.store({ storagePointer: staticDataLocation, offset: 0, data: new bytes(fieldLayout.staticDataLength()) }); - // If there are dynamic fields, delete the dynamic data - uint256 numDynamicFields = fieldLayout.numDynamicFields(); - if (numDynamicFields > 0) { + // If there are dynamic fields, set the dynamic data length to 0. + // We don't need to delete the dynamic data because it will be overwritten when a new record is set. + if (fieldLayout.numDynamicFields() > 0) { uint256 dynamicDataLengthLocation = StoreCoreInternal._getDynamicDataLengthLocation(tableId, keyTuple); - PackedCounter dynamicDataLength = PackedCounter.wrap(Storage.load({ storagePointer: dynamicDataLengthLocation })); - - // Delete dynamic data - for (uint256 i; i < numDynamicFields; i++) { - uint256 dynamicDataLocation = StoreCoreInternal._getDynamicDataLocation(tableId, keyTuple, uint8(i)); - Storage.zero({ storagePointer: dynamicDataLocation, length: dynamicDataLength.atIndex(uint8(i)) }); - } - - // Set the dynamic data length to 0 Storage.zero({ storagePointer: dynamicDataLengthLocation, length: 32 }); } @@ -655,7 +646,6 @@ library StoreCore { /** * Get a byte slice (including start, excluding end) of a single dynamic field from the given table ID and key tuple, with the given value field layout. - * The slice is unchecked and will return invalid data if `start`:`end` overflow. */ function getFieldSlice( ResourceId tableId, @@ -669,9 +659,18 @@ library StoreCore { if (fieldIndex < numStaticFields) { revert IStoreErrors.Store_NotDynamicField(); } + uint8 dynamicFieldIndex = fieldIndex - numStaticFields; + + // Verify the accessed data is within the bounds of the dynamic field. + // This is necessary because we don't delete the dynamic data when a record is deleted, + // but only decrease its length. + PackedCounter encodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); + uint256 fieldLength = encodedLengths.atIndex(dynamicFieldIndex); + if (start > fieldLength || end > fieldLength) { + revert IStoreErrors.Store_OutOfBounds(fieldLength, start > end ? start : end); + } // Get the length and storage location of the dynamic field - uint8 dynamicFieldIndex = fieldIndex - numStaticFields; uint256 location = StoreCoreInternal._getDynamicDataLocation(tableId, keyTuple, dynamicFieldIndex); return Storage.load({ storagePointer: location, length: end - start, offset: start }); diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index 5cffb2cc39..c9a0ba7249 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -20,8 +20,7 @@ contract MixedTest is Test, GasReporter, StoreMock { uint32[] memory a32 = new uint32[](2); a32[0] = 3; a32[1] = 4; - string - memory s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas dapibus velit a ante porta pulvinar. Integer semper quam erat, nec pellentesque nunc feugiat sed. Pellentesque aliquam quam sapien, rutrum egestas sapien vestibulum quis. Suspendisse nisi leo, tincidunt at mauris tincidunt, dapibus luctus dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec eget finibus odio. Maecenas velit diam, fermentum et consectetur at, posuere vitae magna."; + string memory s = "Lorem ipsum dolor sit amet"; Mixed.set({ key: key, u32: 1, u128: 2, a32: a32, s: s }); } diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index e4babf0aae..dbb1024bcd 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -75,7 +75,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 159704 + "gasUsed": 161700 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,7 +93,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 86008 + "gasUsed": 86664 }, { "file": "test/KeysWithValueModule.t.sol", @@ -123,7 +123,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 137469 + "gasUsed": 136434 }, { "file": "test/KeysWithValueModule.t.sol", @@ -141,7 +141,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 37803 + "gasUsed": 36604 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,43 +153,43 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 148677 + "gasUsed": 147642 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 113593 + "gasUsed": 112401 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 100526 + "gasUsed": 106556 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 52006 + "gasUsed": 54016 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 123685 + "gasUsed": 134405 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 78943 + "gasUsed": 84973 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 80577 + "gasUsed": 86607 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 17536 + "gasUsed": 18876 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5645621 + "gasUsed": 6315621 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 524715 + "gasUsed": 591715 }, { "file": "test/query.t.sol", @@ -225,7 +225,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 45602 + "gasUsed": 47612 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -237,7 +237,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36701 + "gasUsed": 36694 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -297,7 +297,7 @@ "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9918 + "gasUsed": 9911 }, { "file": "test/World.t.sol", From 74987e1277b15604110f8a12f606f55e913652f0 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 18:18:55 +0100 Subject: [PATCH 20/38] revert if data out of bounds is accessed in dynamic field --- packages/store/src/IStoreErrors.sol | 2 +- packages/store/src/StoreCore.sol | 4 ++-- packages/store/test/StoreCore.t.sol | 1 + packages/store/test/StoreCoreDynamic.t.sol | 10 ++++++++++ packages/store/test/StoreCoreGas.t.sol | 3 +-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/store/src/IStoreErrors.sol b/packages/store/src/IStoreErrors.sol index 14c8e517b7..9c3e704b5a 100644 --- a/packages/store/src/IStoreErrors.sol +++ b/packages/store/src/IStoreErrors.sol @@ -11,7 +11,7 @@ interface IStoreErrors { error Store_NotDynamicField(); error Store_InvalidDynamicDataLength(uint256 expected, uint256 received); - error Store_OutOfBounds(uint256 length, uint256 accessedIndex); + error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex); error Store_InvalidKeyNamesLength(uint256 expected, uint256 received); error Store_InvalidFieldNamesLength(uint256 expected, uint256 received); error Store_InvalidValueSchemaLength(uint256 expected, uint256 received); diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 51297e3fd7..344678d5c8 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -666,8 +666,8 @@ library StoreCore { // but only decrease its length. PackedCounter encodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); uint256 fieldLength = encodedLengths.atIndex(dynamicFieldIndex); - if (start > fieldLength || end > fieldLength) { - revert IStoreErrors.Store_OutOfBounds(fieldLength, start > end ? start : end); + if (start >= fieldLength || end > fieldLength) { + revert IStoreErrors.Store_IndexOutOfBounds(fieldLength, start >= fieldLength ? start : end - 1); } // Get the length and storage location of the dynamic field diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 334f6e26c4..f9a5d5f581 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -1048,6 +1048,7 @@ contract StoreCoreTest is Test, StoreMock { uint256 data3Length = IStore(this).getFieldLength(tableId, keyTuple, 1, fieldLayout); assertEq(data3Length, 0); + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, 0, 0)); bytes memory data3Slice = IStore(this).getFieldSlice(tableId, keyTuple, 1, fieldLayout, 0, 0); assertEq(data3Slice.length, 0); } diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index f596f71419..173dc82a4d 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -12,6 +12,7 @@ import { FieldLayout } from "../src/FieldLayout.sol"; import { Schema } from "../src/Schema.sol"; import { ResourceId, ResourceIdLib } from "../src/ResourceId.sol"; import { RESOURCE_TABLE } from "../src/storeResourceTypes.sol"; +import { IStoreErrors } from "../src/IStoreErrors.sol"; import { StoreMock } from "../test/StoreMock.sol"; import { FieldLayoutEncodeHelper } from "./FieldLayoutEncodeHelper.sol"; import { SchemaEncodeHelper } from "./SchemaEncodeHelper.sol"; @@ -218,5 +219,14 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { thirdFieldSlice = StoreCore.getFieldSlice(_tableId, _keyTuple, 2, fieldLayout, 8, 40); endGasReport(); assertEq(thirdFieldSlice, SliceLib.getSubslice(thirdDataBytes, 8, 40).toBytes()); + + // Expect a revert if the end index is out of bounds + uint256 length = secondDataBytes.length; + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, length, length)); + StoreCore.getFieldSlice(_tableId, _keyTuple, 1, fieldLayout, 0, length + 1); + + // Expect a revert if the start index is out of bounds + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, length, length)); + StoreCore.getFieldSlice(_tableId, _keyTuple, 1, fieldLayout, length, length); } } diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 8d1457527d..5bdd86e637 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -612,9 +612,8 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { StoreCore.getFieldLength(tableId, keyTuple, 1, fieldLayout); endGasReport(); - startGasReport("access slice of dynamic field of non-existing record"); + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, 0, 0)); StoreCore.getFieldSlice(tableId, keyTuple, 1, fieldLayout, 0, 0); - endGasReport(); } function testHooks() public { From 05ac89d464bdedef7d643a829a572458a31cc0be Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 18:54:56 +0100 Subject: [PATCH 21/38] before refacor of all usages --- .../contracts/src/codegen/tables/Multi.sol | 6 +- .../contracts/src/codegen/tables/Number.sol | 2 +- .../src/codegen/tables/NumberList.sol | 2 +- .../contracts/src/codegen/tables/Vector.sol | 6 +- packages/store/gas-report.json | 18 +- packages/store/src/IStoreErrors.sol | 2 - packages/store/src/StoreCore.sol | 166 ++++++------------ .../store/src/codegen/tables/Callbacks.sol | 76 +++----- packages/store/src/codegen/tables/Hooks.sol | 76 +++----- packages/store/src/codegen/tables/Mixed.sol | 62 +++---- .../store/src/codegen/tables/StoreHooks.sol | 76 +++----- packages/store/src/codegen/tables/Tables.sol | 62 +++---- packages/store/test/StoreCore.t.sol | 6 +- packages/store/ts/codegen/field.ts | 17 +- packages/world/gas-report.json | 22 +-- 15 files changed, 214 insertions(+), 385 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index 6ff755b012..fede3f2eb5 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -306,7 +306,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -354,7 +354,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -414,7 +414,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index 17f796a50a..e20c4753a4 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -193,7 +193,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index 0a5eacfed0..63c66c3ebd 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -485,7 +485,7 @@ library NumberList { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 228798bc56..6e9030d916 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -249,7 +249,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -288,7 +288,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -339,7 +339,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index a829900896..4ff3bc9ef7 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -603,25 +603,25 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 10692 + "gasUsed": 10695 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 2760 + "gasUsed": 2763 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (semi-cold, 1 slot)", - "gasUsed": 4765 + "gasUsed": 4768 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4991 + "gasUsed": 4994 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -695,12 +695,6 @@ "name": "access length of dynamic field of non-existing record", "gasUsed": 1118 }, - { - "file": "test/StoreCoreGas.t.sol", - "test": "testAccessEmptyData", - "name": "access slice of dynamic field of non-existing record", - "gasUsed": 1897 - }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", @@ -795,7 +789,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 641436 + "gasUsed": 641486 }, { "file": "test/StoreCoreGas.t.sol", @@ -1077,7 +1071,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testGetItem", "name": "StoreHooks: get 1 element (cold)", - "gasUsed": 8952 + "gasUsed": 8955 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", diff --git a/packages/store/src/IStoreErrors.sol b/packages/store/src/IStoreErrors.sol index 9c3e704b5a..5a957a2f4e 100644 --- a/packages/store/src/IStoreErrors.sol +++ b/packages/store/src/IStoreErrors.sol @@ -9,12 +9,10 @@ interface IStoreErrors { error Store_TableNotFound(ResourceId tableId, string tableIdString); error Store_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); - error Store_NotDynamicField(); error Store_InvalidDynamicDataLength(uint256 expected, uint256 received); error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex); error Store_InvalidKeyNamesLength(uint256 expected, uint256 received); error Store_InvalidFieldNamesLength(uint256 expected, uint256 received); error Store_InvalidValueSchemaLength(uint256 expected, uint256 received); - error Store_DataIndexOverflow(uint256 length, uint256 received); error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength); } diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 344678d5c8..f229306291 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -353,7 +353,7 @@ library StoreCore { function spliceDynamicData( ResourceId tableId, bytes32[] memory keyTuple, - uint8 dynamicFieldIndex, // need this to compute the dynamic data location + uint8 dynamicFieldIndex, uint40 startWithinField, uint40 deleteCount, bytes memory data @@ -473,61 +473,83 @@ library StoreCore { } /** - * Push data to a field in a table with the given tableId, keyTuple tuple and value field layout + * Push data to a field at the dynamic field index in a table with the given table ID and keyTuple tuple */ - function pushToField( + function pushToDynamicField( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - bytes memory dataToPush, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + bytes memory dataToPush ) internal { - if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.Store_NotDynamicField(); - } + // Load the previous length of the field to set from storage to compute where to start to push + PackedCounter previousEncodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); + uint40 previousFieldLength = uint40(previousEncodedLengths.atIndex(dynamicFieldIndex)); - StoreCoreInternal._pushToDynamicField(tableId, keyTuple, fieldLayout, fieldIndex, dataToPush); + // Splice the dynamic data + StoreCoreInternal._spliceDynamicData({ + tableId: tableId, + keyTuple: keyTuple, + dynamicFieldIndex: dynamicFieldIndex, + startWithinField: uint40(previousFieldLength), + deleteCount: 0, + data: dataToPush, + previousEncodedLengths: previousEncodedLengths + }); } /** - * Pop data from a field in a table with the given tableId, key tuple and value field layout + * Pop data from a field at the dynamic field index in a table with the given table ID and key tuple */ - function popFromField( + function popFromDynamicField( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, + uint8 dynamicFieldIndex, uint256 byteLengthToPop, FieldLayout fieldLayout ) internal { - if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.Store_NotDynamicField(); - } + // Load the previous length of the field to set from storage to compute where to start to push + PackedCounter previousEncodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); + uint40 previousFieldLength = uint40(previousEncodedLengths.atIndex(dynamicFieldIndex)); - StoreCoreInternal._popFromDynamicField(tableId, keyTuple, fieldLayout, fieldIndex, byteLengthToPop); + // Splice the dynamic data + StoreCoreInternal._spliceDynamicData({ + tableId: tableId, + keyTuple: keyTuple, + dynamicFieldIndex: dynamicFieldIndex, + startWithinField: uint40(previousFieldLength - byteLengthToPop), + deleteCount: uint40(byteLengthToPop), + data: new bytes(0), + previousEncodedLengths: previousEncodedLengths + }); } /** * Update data in a field in a table with the given tableId, key tuple and value field layout */ - function updateInField( + function updateInDynamicField( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, + uint8 dynamicFieldIndex, uint256 startByteIndex, - bytes memory dataToSet, - FieldLayout fieldLayout + bytes memory dataToSet ) internal { - if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.Store_NotDynamicField(); - } - - // index must be checked because it could be arbitrarily large - // (but dataToSet.length can be unchecked - it won't overflow into another slot due to gas costs and hashed slots) - if (startByteIndex > type(uint40).max) { - revert IStoreErrors.Store_DataIndexOverflow(type(uint40).max, startByteIndex); + // Verify that the index is in bounds of the dynamic field + PackedCounter previousEncodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); + if (startByteIndex + dataToSet.length > previousEncodedLengths.atIndex(dynamicFieldIndex)) { + IStoreErrors.Store_IndexOutOfBounds( + previousEncodedLengths.atIndex(dynamicFieldIndex), + startByteIndex + dataToSet.length - 1 + ); } - StoreCoreInternal._setDynamicFieldItem(tableId, keyTuple, fieldLayout, fieldIndex, startByteIndex, dataToSet); + StoreCoreInternal._spliceDynamicData({ + tableId: tableId, + keyTuple: keyTuple, + startWithinField: uint40(startByteIndex), + deleteCount: uint40(dataToSet.length), + data: dataToSet, + previousEncodedLengths: previousEncodedLengths + }); } /************************************************************************ @@ -647,20 +669,13 @@ library StoreCore { /** * Get a byte slice (including start, excluding end) of a single dynamic field from the given table ID and key tuple, with the given value field layout. */ - function getFieldSlice( + function getDynamicFieldSlice( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - FieldLayout fieldLayout, + uint8 dynamicFieldIndex, uint256 start, uint256 end ) internal view returns (bytes memory) { - uint8 numStaticFields = uint8(fieldLayout.numStaticFields()); - if (fieldIndex < numStaticFields) { - revert IStoreErrors.Store_NotDynamicField(); - } - uint8 dynamicFieldIndex = fieldIndex - numStaticFields; - // Verify the accessed data is within the bounds of the dynamic field. // This is necessary because we don't delete the dynamic data when a record is deleted, // but only decrease its length. @@ -782,75 +797,6 @@ library StoreCoreInternal { } } - function _pushToDynamicField( - ResourceId tableId, - bytes32[] memory keyTuple, - FieldLayout fieldLayout, - uint8 fieldIndex, - bytes memory dataToPush - ) internal { - uint8 dynamicFieldIndex = fieldIndex - uint8(fieldLayout.numStaticFields()); - - // Load the previous length of the field to set from storage to compute where to start to push - PackedCounter previousEncodedLengths = _loadEncodedDynamicDataLength(tableId, keyTuple); - uint40 previousFieldLength = uint40(previousEncodedLengths.atIndex(dynamicFieldIndex)); - - // Splice the dynamic data - _spliceDynamicData({ - tableId: tableId, - keyTuple: keyTuple, - dynamicFieldIndex: dynamicFieldIndex, - startWithinField: uint40(previousFieldLength), - deleteCount: 0, - data: dataToPush, - previousEncodedLengths: previousEncodedLengths - }); - } - - function _popFromDynamicField( - ResourceId tableId, - bytes32[] memory keyTuple, - FieldLayout fieldLayout, - uint8 fieldIndex, - uint256 byteLengthToPop - ) internal { - uint8 dynamicFieldIndex = fieldIndex - uint8(fieldLayout.numStaticFields()); - - // Load the previous length of the field to set from storage to compute where to start to push - PackedCounter previousEncodedLengths = _loadEncodedDynamicDataLength(tableId, keyTuple); - uint40 previousFieldLength = uint40(previousEncodedLengths.atIndex(dynamicFieldIndex)); - - // Splice the dynamic data - _spliceDynamicData({ - tableId: tableId, - keyTuple: keyTuple, - dynamicFieldIndex: dynamicFieldIndex, - startWithinField: uint40(previousFieldLength - byteLengthToPop), - deleteCount: uint40(byteLengthToPop), - data: new bytes(0), - previousEncodedLengths: previousEncodedLengths - }); - } - - function _setDynamicFieldItem( - ResourceId tableId, - bytes32[] memory keyTuple, - FieldLayout fieldLayout, - uint8 fieldIndex, - uint256 startByteIndex, - bytes memory dataToSet - ) internal { - _spliceDynamicData({ - tableId: tableId, - keyTuple: keyTuple, - dynamicFieldIndex: fieldIndex - uint8(fieldLayout.numStaticFields()), - startWithinField: uint40(startByteIndex), - deleteCount: uint40(dataToSet.length), - data: dataToSet, - previousEncodedLengths: _loadEncodedDynamicDataLength(tableId, keyTuple) - }); - } - /************************************************************************ * * GET DATA @@ -937,9 +883,9 @@ library StoreCoreInternal { function _getDynamicDataLocation( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex + uint8 dynamicFieldIndex ) internal pure returns (uint256) { - return uint256(DYNMAIC_DATA_SLOT ^ bytes1(fieldIndex) ^ keccak256(abi.encodePacked(tableId, keyTuple))); + return uint256(DYNMAIC_DATA_SLOT ^ bytes1(dynamicFieldIndex) ^ keccak256(abi.encodePacked(tableId, keyTuple))); } /** diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index 137f701bf6..f62ffec498 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -255,14 +255,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 24, - (_index + 1) * 24 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 24, (_index + 1) * 24); return (bytes24(_blob)); } } @@ -276,14 +269,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 24, - (_index + 1) * 24 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 24, (_index + 1) * 24); return (bytes24(_blob)); } } @@ -297,7 +283,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 24, (_index + 1) * 24); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 24, (_index + 1) * 24); return (bytes24(_blob)); } } @@ -311,14 +297,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 24, - (_index + 1) * 24 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 24, (_index + 1) * 24); return (bytes24(_blob)); } } @@ -332,14 +311,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 24, - (_index + 1) * 24 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 24, (_index + 1) * 24); return (bytes24(_blob)); } } @@ -353,7 +325,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 24, (_index + 1) * 24); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 24, (_index + 1) * 24); return (bytes24(_blob)); } } @@ -363,7 +335,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +343,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +351,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +359,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +367,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +375,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +383,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 24, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 24); } /** Pop an element from value */ @@ -419,7 +391,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 24, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 24); } /** Pop an element from value (using the specified store) */ @@ -427,7 +399,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 24, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 24); } /** Pop an element from value */ @@ -435,7 +407,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 24, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 24); } /** Pop an element from value */ @@ -443,7 +415,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 24, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 24); } /** Pop an element from value (using the specified store) */ @@ -451,7 +423,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 24, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 24); } /** @@ -463,7 +435,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); } } @@ -476,7 +448,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); } } @@ -489,7 +461,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); } } @@ -502,7 +474,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); } } @@ -515,7 +487,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); } } @@ -528,7 +500,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); } } diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index e47703481e..9a0bfe03b8 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -250,14 +250,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -271,14 +264,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -297,7 +283,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 21, (_index + 1) * 21); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -311,14 +297,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -332,14 +311,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -353,7 +325,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 21, (_index + 1) * 21); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -363,7 +335,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +343,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +351,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +359,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +367,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +375,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +383,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -419,7 +391,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value (using the specified store) */ @@ -427,7 +399,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -435,7 +407,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -443,7 +415,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value (using the specified store) */ @@ -451,7 +423,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** @@ -463,7 +435,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -476,7 +448,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -489,7 +461,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -502,7 +474,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -515,7 +487,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -528,7 +500,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 184d4ff285..1872ab959b 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -286,14 +286,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -307,7 +300,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -321,7 +314,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -331,7 +324,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to a32 */ @@ -339,7 +332,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to a32 (using the specified store) */ @@ -347,7 +340,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from a32 */ @@ -355,7 +348,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from a32 */ @@ -363,7 +356,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 2, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from a32 (using the specified store) */ @@ -371,7 +364,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 2, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** @@ -383,7 +376,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -396,7 +389,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -409,7 +402,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -506,14 +499,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 1, - (_index + 1) * 1 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (string(_blob)); } } @@ -527,7 +513,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (string(_blob)); } } @@ -541,7 +527,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (string(_blob)); } } @@ -551,7 +537,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Push a slice to s */ @@ -559,7 +545,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Push a slice to s (using the specified store) */ @@ -567,7 +553,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Pop a slice from s */ @@ -575,7 +561,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 1, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** Pop a slice from s */ @@ -583,7 +569,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 3, 1, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** Pop a slice from s (using the specified store) */ @@ -591,7 +577,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 3, 1, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** @@ -603,7 +589,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -616,7 +602,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -629,7 +615,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index 0a2074ff3c..fda7d18127 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -255,14 +255,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -276,14 +269,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -297,7 +283,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 21, (_index + 1) * 21); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -311,14 +297,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -332,14 +311,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -353,7 +325,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 21, (_index + 1) * 21); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -363,7 +335,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +343,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +351,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +359,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +367,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +375,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +383,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -419,7 +391,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value (using the specified store) */ @@ -427,7 +399,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -435,7 +407,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -443,7 +415,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value (using the specified store) */ @@ -451,7 +423,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** @@ -463,7 +435,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -476,7 +448,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -489,7 +461,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -502,7 +474,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -515,7 +487,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -528,7 +500,7 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index d6ab0879a0..834e6b1618 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -343,14 +343,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 1, - (_index + 1) * 1 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -364,7 +357,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -382,7 +375,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -392,7 +385,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** Push a slice to abiEncodedKeyNames */ @@ -400,7 +393,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** Push a slice to abiEncodedKeyNames (using the specified store) */ @@ -408,7 +401,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } /** Pop a slice from abiEncodedKeyNames */ @@ -416,7 +409,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 1, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** Pop a slice from abiEncodedKeyNames */ @@ -424,7 +417,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.popFromField(_tableId, _keyTuple, 3, 1, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** Pop a slice from abiEncodedKeyNames (using the specified store) */ @@ -432,7 +425,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.popFromField(_tableId, _keyTuple, 3, 1, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 1); } /** @@ -444,7 +437,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); } } @@ -457,7 +450,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); } } @@ -470,7 +463,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); } } @@ -570,14 +563,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 4, - _fieldLayout, - _index * 1, - (_index + 1) * 1 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -591,7 +577,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 4, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -609,7 +595,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 4, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -619,7 +605,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.pushToField(_tableId, _keyTuple, 4, bytes((_slice)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Push a slice to abiEncodedFieldNames */ @@ -627,7 +613,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.pushToField(_tableId, _keyTuple, 4, bytes((_slice)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Push a slice to abiEncodedFieldNames (using the specified store) */ @@ -635,7 +621,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.pushToField(_tableId, _keyTuple, 4, bytes((_slice)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Pop a slice from abiEncodedFieldNames */ @@ -643,7 +629,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.popFromField(_tableId, _keyTuple, 4, 1, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** Pop a slice from abiEncodedFieldNames */ @@ -651,7 +637,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.popFromField(_tableId, _keyTuple, 4, 1, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** Pop a slice from abiEncodedFieldNames (using the specified store) */ @@ -659,7 +645,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.popFromField(_tableId, _keyTuple, 4, 1, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** @@ -671,7 +657,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 1, bytes((_slice)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -684,7 +670,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 4, _index * 1, bytes((_slice)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -697,7 +683,7 @@ library Tables { _keyTuple[0] = tableId; unchecked { - _store.updateInField(_tableId, _keyTuple, 4, _index * 1, bytes((_slice)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index f9a5d5f581..74d44b72a4 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -1019,7 +1019,11 @@ contract StoreCoreTest is Test, StoreMock { // startByteIndex must not overflow vm.expectRevert( - abi.encodeWithSelector(IStoreErrors.Store_DataIndexOverflow.selector, type(uint40).max, type(uint56).max) + abi.encodeWithSelector( + IStoreErrors.Store_IndexOutOfBounds.selector, + data.newThirdDataBytes.length, + type(uint56).max + data.thirdDataForUpdate.length - 1 + ) ); IStore(this).updateInField(data.tableId, data.keyTuple, 2, type(uint56).max, data.thirdDataForUpdate, fieldLayout); } diff --git a/packages/store/ts/codegen/field.ts b/packages/store/ts/codegen/field.ts index 6fad585ca1..895301622e 100644 --- a/packages/store/ts/codegen/field.ts +++ b/packages/store/ts/codegen/field.ts @@ -74,6 +74,7 @@ export function renderFieldMethods(options: RenderTableOptions) { if (field.isDynamic) { const portionData = fieldPortionData(field); + const dynamicSchemaIndex = schemaIndex - options.staticFields.length; if (options.withGetters) { result += renderWithFieldSuffix(options.withSuffixlessFieldMethods, field.name, (_methodNameSuffix) => @@ -112,11 +113,10 @@ export function renderFieldMethods(options: RenderTableOptions) { ])}) internal view returns (${portionData.typeWithLocation}) { ${_keyTupleDefinition} unchecked { - bytes memory _blob = ${_store}.getFieldSlice( + bytes memory _blob = ${_store}.getDynamicFieldSlice( _tableId, _keyTuple, - ${schemaIndex}, - _fieldLayout, + ${dynamicSchemaIndex}, _index * ${portionData.elementLength}, (_index + 1) * ${portionData.elementLength} ); @@ -140,7 +140,7 @@ export function renderFieldMethods(options: RenderTableOptions) { `${portionData.typeWithLocation} ${portionData.name}`, ])}) internal { ${_keyTupleDefinition} - ${_store}.pushToField(_tableId, _keyTuple, ${schemaIndex}, ${portionData.encoded}, _fieldLayout); + ${_store}.pushToDynamicField(_tableId, _keyTuple, ${dynamicSchemaIndex}, ${portionData.encoded}); } ` ) @@ -157,7 +157,7 @@ export function renderFieldMethods(options: RenderTableOptions) { _typedKeyArgs, ])}) internal { ${_keyTupleDefinition} - ${_store}.popFromField(_tableId, _keyTuple, ${schemaIndex}, ${portionData.elementLength}, _fieldLayout); + ${_store}.popFromDynamicField(_tableId, _keyTuple, ${dynamicSchemaIndex}, ${portionData.elementLength}); } ` ) @@ -180,13 +180,12 @@ export function renderFieldMethods(options: RenderTableOptions) { ])}) internal { ${_keyTupleDefinition} unchecked { - ${_store}.updateInField( + ${_store}.updateInDynamicField( _tableId, _keyTuple, - ${schemaIndex}, + ${dynamicSchemaIndex}, _index * ${portionData.elementLength}, - ${portionData.encoded}, - _fieldLayout + ${portionData.encoded} ); } } diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index dbb1024bcd..2833b6680d 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -75,7 +75,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 161700 + "gasUsed": 161709 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,7 +93,7 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 86664 + "gasUsed": 86667 }, { "file": "test/KeysWithValueModule.t.sol", @@ -165,31 +165,31 @@ "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 106556 + "gasUsed": 106583 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 54016 + "gasUsed": 54025 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 134405 + "gasUsed": 134453 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 84973 + "gasUsed": 85000 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 86607 + "gasUsed": 86634 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18876 + "gasUsed": 18882 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 6315621 + "gasUsed": 6318621 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 591715 + "gasUsed": 592015 }, { "file": "test/query.t.sol", @@ -225,7 +225,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 47612 + "gasUsed": 47621 }, { "file": "test/StandardDelegationsModule.t.sol", From 2b84cf6bf2d04d773575388a30e9e3aaeb8f92c0 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 19:12:34 +0100 Subject: [PATCH 22/38] refactor except tests --- packages/store/src/IStore.sol | 26 ++-- packages/store/src/StoreRead.sol | 2 +- packages/store/src/StoreSwitch.sol | 38 +++-- packages/store/test/StoreMock.sol | 27 ++-- packages/world/src/World.sol | 27 ++-- .../src/modules/core/tables/SystemHooks.sol | 52 ++++--- .../keysintable/tables/KeysInTable.sol | 130 +++++++++++------- .../keyswithvalue/tables/KeysWithValue.sol | 52 ++++--- packages/world/test/tables/AddressArray.sol | 52 ++++--- 9 files changed, 229 insertions(+), 177 deletions(-) diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 72fdedb9d2..b8c1836813 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -74,11 +74,10 @@ interface IStoreRead { * Get a byte slice (including start, excluding end) of a single dynamic field from the given tableId and key tuple, with the given value field layout. * The slice is unchecked and will return invalid data if `start`:`end` overflow. */ - function getFieldSlice( + function getDynamicFieldSlice( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - FieldLayout fieldLayout, + uint8 dynamicFieldIndex, uint256 start, uint256 end ) external view returns (bytes memory data); @@ -140,31 +139,28 @@ interface IStoreWrite { ) external; // Push encoded items to the dynamic field at field index - function pushToField( + function pushToDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - bytes calldata dataToPush, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + bytes calldata dataToPush ) external; // Pop byte length from the dynamic field at field index - function popFromField( + function popFromDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - uint256 byteLengthToPop, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + uint256 byteLengthToPop ) external; // Change encoded items within the dynamic field at field index - function updateInField( + function updateInDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, + uint8 dynamicFieldIndex, uint256 startByteIndex, - bytes calldata dataToSet, - FieldLayout fieldLayout + bytes calldata dataToSet ) external; // Set full record (including full dynamic data) diff --git a/packages/store/src/StoreRead.sol b/packages/store/src/StoreRead.sol index 386e3c7f29..fdd8a4ae35 100644 --- a/packages/store/src/StoreRead.sol +++ b/packages/store/src/StoreRead.sol @@ -77,6 +77,6 @@ contract StoreRead is IStoreRead { uint256 start, uint256 end ) public view virtual returns (bytes memory) { - return StoreCore.getFieldSlice(tableId, keyTuple, fieldIndex, fieldLayout, start, end); + return StoreCore.getDynamicFieldSlice(tableId, keyTuple, dynamicFieldIndex, start, end); } } diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 6a34f72cd3..2958f717fb 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -172,49 +172,46 @@ library StoreSwitch { } } - function pushToField( + function pushToDynamicField( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - bytes memory dataToPush, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + bytes memory dataToPush ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.pushToField(tableId, keyTuple, fieldIndex, dataToPush, fieldLayout); + StoreCore.pushToDynamicField(tableId, keyTuple, dynamicFieldIndex, dataToPush); } else { - IStore(_storeAddress).pushToField(tableId, keyTuple, fieldIndex, dataToPush, fieldLayout); + IStore(_storeAddress).pushToDynamicField(tableId, keyTuple, dynamicFieldIndex, dataToPush); } } function popFromField( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - uint256 byteLengthToPop, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + uint256 byteLengthToPop ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.popFromField(tableId, keyTuple, fieldIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } else { - IStore(_storeAddress).popFromField(tableId, keyTuple, fieldIndex, byteLengthToPop, fieldLayout); + IStore(_storeAddress).popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } } function updateInField( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, + uint8 dynamicFieldIndex, uint256 startByteIndex, - bytes memory dataToSet, - FieldLayout fieldLayout + bytes memory dataToSet ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.updateInField(tableId, keyTuple, fieldIndex, startByteIndex, dataToSet, fieldLayout); + StoreCore.updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); } else { - IStore(_storeAddress).updateInField(tableId, keyTuple, fieldIndex, startByteIndex, dataToSet, fieldLayout); + IStore(_storeAddress).updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); } } @@ -295,19 +292,18 @@ library StoreSwitch { } } - function getFieldSlice( + function getDynamicFieldSlice( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - FieldLayout fieldLayout, + uint8 dynamicFieldIndex, uint256 start, uint256 end ) internal view returns (bytes memory) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getFieldSlice(tableId, keyTuple, fieldIndex, fieldLayout, start, end); + return StoreCore.getDynamicFieldSlice(tableId, keyTuple, dynamicFieldIndex, start, end); } else { - return IStore(_storeAddress).getFieldSlice(tableId, keyTuple, fieldIndex, fieldLayout, start, end); + return IStore(_storeAddress).getDynamicFieldSlice(tableId, keyTuple, dynamicFieldIndex, start, end); } } } diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index 694087d44f..0b85bdfbe6 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -63,37 +63,34 @@ contract StoreMock is IStore, StoreRead { } // Push encoded items to the dynamic field at field index - function pushToField( + function pushToDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - bytes calldata dataToPush, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + bytes calldata dataToPush ) public virtual { - StoreCore.pushToField(tableId, keyTuple, fieldIndex, dataToPush, fieldLayout); + StoreCore.pushToDynamicField(tableId, keyTuple, dynamicFieldIndex, dataToPush); } // Pop byte length from the dynamic field at field index - function popFromField( + function popFromDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - uint256 byteLengthToPop, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + uint256 byteLengthToPop ) public virtual { - StoreCore.popFromField(tableId, keyTuple, fieldIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } // Change encoded items within the dynamic field at field index - function updateInField( + function updateInDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, + uint8 dynamicFieldIndex, uint256 startByteIndex, - bytes calldata dataToSet, - FieldLayout fieldLayout + bytes calldata dataToSet ) public virtual { - StoreCore.updateInField(tableId, keyTuple, fieldIndex, startByteIndex, dataToSet, fieldLayout); + StoreCore.updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); } // Set full record (including full dynamic data) diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 0641f45412..873468b205 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -176,55 +176,52 @@ contract World is StoreRead, IStoreData, IWorldKernel { * Push data to the end of a field in the table at the given tableId. * Requires the caller to have access to the table's namespace or name (encoded in the tableId). */ - function pushToField( + function pushToDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - bytes calldata dataToPush, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + bytes calldata dataToPush ) public virtual requireNoCallback { // Require access to namespace or name AccessControl.requireAccess(tableId, msg.sender); // Push to the field - StoreCore.pushToField(tableId, keyTuple, fieldIndex, dataToPush, fieldLayout); + StoreCore.pushToDynamicField(tableId, keyTuple, dynamicFieldIndex, dataToPush); } /** * Pop data from the end of a field in the table at the given tableId. * Requires the caller to have access to the table's namespace or name (encoded in the tableId). */ - function popFromField( + function popFromDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - uint256 byteLengthToPop, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + uint256 byteLengthToPop ) public virtual requireNoCallback { // Require access to namespace or name AccessControl.requireAccess(tableId, msg.sender); // Push to the field - StoreCore.popFromField(tableId, keyTuple, fieldIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } /** * Update data at `startByteIndex` of a field in the table at the given tableId. * Requires the caller to have access to the table's namespace or name (encoded in the tableId). */ - function updateInField( + function updateInDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, + uint8 dynamicFieldIndex, uint256 startByteIndex, - bytes calldata dataToSet, - FieldLayout fieldLayout + bytes calldata dataToSet ) public virtual requireNoCallback { // Require access to namespace or name AccessControl.requireAccess(tableId, msg.sender); // Update data in the field - StoreCore.updateInField(tableId, keyTuple, fieldIndex, startByteIndex, dataToSet, fieldLayout); + StoreCore.updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); } /** diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 51b0a2ecef..10e6be1781 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -297,7 +297,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 21, (_index + 1) * 21); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -353,7 +353,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 21, (_index + 1) * 21); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -363,7 +363,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +371,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +379,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +387,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +395,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +403,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +411,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); } /** Pop an element from value */ @@ -419,7 +419,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); } /** Pop an element from value (using the specified store) */ @@ -427,7 +427,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); } /** Pop an element from value */ @@ -435,7 +435,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); } /** Pop an element from value */ @@ -443,7 +443,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); } /** Pop an element from value (using the specified store) */ @@ -451,7 +451,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.popFromField(_tableId, _keyTuple, 0, 21, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); } /** @@ -463,7 +463,13 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 21, + abi.encodePacked((_element)) + ); } } @@ -476,7 +482,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); } } @@ -489,7 +495,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); } } @@ -502,7 +508,13 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 21, + abi.encodePacked((_element)) + ); } } @@ -515,7 +527,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); } } @@ -528,7 +540,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); } } diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 045b5e8709..2eb468a9ab 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -229,7 +229,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -239,7 +239,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys0 */ @@ -247,7 +247,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys0 (using the specified store) */ @@ -255,7 +255,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from keys0 */ @@ -263,7 +263,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys0 */ @@ -271,7 +271,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys0 (using the specified store) */ @@ -279,7 +279,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** @@ -291,7 +291,13 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -304,7 +310,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -317,7 +323,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -456,7 +462,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -466,7 +472,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys1 */ @@ -474,7 +480,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys1 (using the specified store) */ @@ -482,7 +488,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from keys1 */ @@ -490,7 +496,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys1 */ @@ -498,7 +504,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromField(_tableId, _keyTuple, 1, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys1 (using the specified store) */ @@ -506,7 +512,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 1, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** @@ -518,7 +524,13 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -531,7 +543,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -544,7 +556,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -683,7 +695,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -693,7 +705,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys2 */ @@ -701,7 +713,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys2 (using the specified store) */ @@ -709,7 +721,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from keys2 */ @@ -717,7 +729,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys2 */ @@ -725,7 +737,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromField(_tableId, _keyTuple, 2, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys2 (using the specified store) */ @@ -733,7 +745,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 2, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** @@ -745,7 +757,13 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -758,7 +776,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -771,7 +789,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -910,7 +928,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 3, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -920,7 +938,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys3 */ @@ -928,7 +946,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys3 (using the specified store) */ @@ -936,7 +954,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from keys3 */ @@ -944,7 +962,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys3 */ @@ -952,7 +970,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromField(_tableId, _keyTuple, 3, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys3 (using the specified store) */ @@ -960,7 +978,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 3, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** @@ -972,7 +990,13 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -985,7 +1009,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -998,7 +1022,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -1137,7 +1161,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 4, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 4, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -1147,7 +1171,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys4 */ @@ -1155,7 +1179,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keys4 (using the specified store) */ @@ -1163,7 +1187,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from keys4 */ @@ -1171,7 +1195,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 4, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys4 */ @@ -1179,7 +1203,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromField(_tableId, _keyTuple, 4, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keys4 (using the specified store) */ @@ -1187,7 +1211,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 4, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** @@ -1199,7 +1223,13 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -1212,7 +1242,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -1225,7 +1255,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index fc1cfc2991..d74eaf91df 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -324,7 +324,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -385,7 +385,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -395,7 +395,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keysWithValue */ @@ -403,7 +403,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keysWithValue (using the specified store) */ @@ -411,7 +411,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keysWithValue */ @@ -419,7 +419,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keysWithValue */ @@ -427,7 +427,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to keysWithValue (using the specified store) */ @@ -435,7 +435,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from keysWithValue */ @@ -443,7 +443,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keysWithValue */ @@ -451,7 +451,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keysWithValue (using the specified store) */ @@ -459,7 +459,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keysWithValue */ @@ -467,7 +467,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keysWithValue */ @@ -475,7 +475,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** Pop an element from keysWithValue (using the specified store) */ @@ -483,7 +483,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); } /** @@ -495,7 +495,13 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -508,7 +514,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -527,7 +533,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -540,7 +546,13 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 32, + abi.encodePacked((_element)) + ); } } @@ -553,7 +565,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } @@ -566,7 +578,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); } } diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 48ac1f26f4..a661725c4a 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -297,7 +297,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 20, (_index + 1) * 20); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -353,7 +353,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 20, (_index + 1) * 20); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -363,7 +363,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +371,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +379,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +387,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +395,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +403,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +411,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); } /** Pop an element from value */ @@ -419,7 +419,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 20, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); } /** Pop an element from value (using the specified store) */ @@ -427,7 +427,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 20, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); } /** Pop an element from value */ @@ -435,7 +435,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); } /** Pop an element from value */ @@ -443,7 +443,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 20, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); } /** Pop an element from value (using the specified store) */ @@ -451,7 +451,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 20, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); } /** @@ -463,7 +463,13 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 20, + abi.encodePacked((_element)) + ); } } @@ -476,7 +482,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); } } @@ -489,7 +495,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); } } @@ -502,7 +508,13 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField( + _tableId, + _keyTuple, + dynamicFieldIndex, + _index * 20, + abi.encodePacked((_element)) + ); } } @@ -515,7 +527,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); } } @@ -528,7 +540,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); } } From 5ffbbd771e594749d95dd6f0286b96f22c4f4db1 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 19:36:29 +0100 Subject: [PATCH 23/38] refactor tests and gas-report --- packages/store/gas-report.json | 76 +++---- packages/store/src/StoreCore.sol | 8 +- packages/store/src/StoreRead.sol | 5 +- packages/store/src/StoreSwitch.sol | 4 +- packages/store/test/StoreCore.t.sol | 37 +-- packages/store/test/StoreCoreDynamic.t.sol | 35 ++- packages/store/test/StoreCoreGas.t.sol | 20 +- packages/world/gas-report.json | 100 ++++----- .../src/modules/core/tables/SystemHooks.sol | 84 ++----- .../keysintable/tables/KeysInTable.sol | 210 +++++------------- .../keyswithvalue/tables/KeysWithValue.sol | 84 ++----- packages/world/test/World.t.sol | 14 +- packages/world/test/WorldDynamicUpdate.t.sol | 34 +-- packages/world/test/tables/AddressArray.sol | 84 ++----- 14 files changed, 293 insertions(+), 502 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 4ff3bc9ef7..9cca7531d2 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -601,27 +601,27 @@ }, { "file": "test/StoreCoreDynamic.t.sol", - "test": "testGetFieldSlice", + "test": "testGetDynamicFieldSlice", "name": "get field slice (cold, 1 slot)", - "gasUsed": 10695 + "gasUsed": 10240 }, { "file": "test/StoreCoreDynamic.t.sol", - "test": "testGetFieldSlice", + "test": "testGetDynamicFieldSlice", "name": "get field slice (warm, 1 slot)", - "gasUsed": 2763 + "gasUsed": 2308 }, { "file": "test/StoreCoreDynamic.t.sol", - "test": "testGetFieldSlice", + "test": "testGetDynamicFieldSlice", "name": "get field slice (semi-cold, 1 slot)", - "gasUsed": 4768 + "gasUsed": 4313 }, { "file": "test/StoreCoreDynamic.t.sol", - "test": "testGetFieldSlice", + "test": "testGetDynamicFieldSlice", "name": "get field slice (warm, 2 slots)", - "gasUsed": 4994 + "gasUsed": 4539 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -651,25 +651,25 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (cold, 1 slot, 1 uint32 item)", - "gasUsed": 19479 + "gasUsed": 18692 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (warm, 1 slot, 1 uint32 item)", - "gasUsed": 13487 + "gasUsed": 12700 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 17247 + "gasUsed": 16460 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (warm, 2 slots, 10 uint32 items)", - "gasUsed": 13255 + "gasUsed": 12468 }, { "file": "test/StoreCoreGas.t.sol", @@ -729,7 +729,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 58781 + "gasUsed": 57983 }, { "file": "test/StoreCoreGas.t.sol", @@ -753,7 +753,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 58781 + "gasUsed": 57983 }, { "file": "test/StoreCoreGas.t.sol", @@ -775,21 +775,21 @@ }, { "file": "test/StoreCoreGas.t.sol", - "test": "testPushToField", + "test": "testPushToDynamicField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 10275 + "gasUsed": 9488 }, { "file": "test/StoreCoreGas.t.sol", - "test": "testPushToField", + "test": "testPushToDynamicField", "name": "push to field (2 slots, 10 uint32 items)", - "gasUsed": 32945 + "gasUsed": 32158 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 641486 + "gasUsed": 641436 }, { "file": "test/StoreCoreGas.t.sol", @@ -925,15 +925,15 @@ }, { "file": "test/StoreCoreGas.t.sol", - "test": "testUpdateInField", + "test": "testUpdateInDynamicField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 9627 + "gasUsed": 8986 }, { "file": "test/StoreCoreGas.t.sol", - "test": "testUpdateInField", + "test": "testUpdateInDynamicField", "name": "push to field (2 slots, 6 uint64 items)", - "gasUsed": 10073 + "gasUsed": 9432 }, { "file": "test/StoreHook.t.sol", @@ -975,7 +975,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: set field", - "gasUsed": 57069 + "gasUsed": 57063 }, { "file": "test/tables/Callbacks.t.sol", @@ -987,19 +987,19 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: push 1 element", - "gasUsed": 33351 + "gasUsed": 32547 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testOneSlot", "name": "StoreHooks: set field with one elements (cold)", - "gasUsed": 59075 + "gasUsed": 59069 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (cold)", - "gasUsed": 59075 + "gasUsed": 59069 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1011,25 +1011,25 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (cold)", - "gasUsed": 13449 + "gasUsed": 12645 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: pop 1 element (warm)", - "gasUsed": 10777 + "gasUsed": 9979 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (warm)", - "gasUsed": 11466 + "gasUsed": 10662 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: update 1 element (warm)", - "gasUsed": 30686 + "gasUsed": 30028 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1041,19 +1041,19 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 31220 + "gasUsed": 31214 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testThreeSlots", "name": "StoreHooks: set field with three elements (cold)", - "gasUsed": 81763 + "gasUsed": 81757 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTwoSlots", "name": "StoreHooks: set field with two elements (cold)", - "gasUsed": 81675 + "gasUsed": 81669 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1071,25 +1071,25 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testGetItem", "name": "StoreHooks: get 1 element (cold)", - "gasUsed": 8955 + "gasUsed": 8486 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testLength", "name": "StoreHooks: get length (cold)", - "gasUsed": 5871 + "gasUsed": 5865 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testPop", "name": "StoreHooks: pop 1 element (cold)", - "gasUsed": 19212 + "gasUsed": 18414 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testUpdate", "name": "StoreHooks: update 1 element (cold)", - "gasUsed": 21141 + "gasUsed": 20483 }, { "file": "test/tightcoder/DecodeSlice.t.sol", diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index f229306291..c3c63a5a33 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -504,8 +504,7 @@ library StoreCore { ResourceId tableId, bytes32[] memory keyTuple, uint8 dynamicFieldIndex, - uint256 byteLengthToPop, - FieldLayout fieldLayout + uint256 byteLengthToPop ) internal { // Load the previous length of the field to set from storage to compute where to start to push PackedCounter previousEncodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); @@ -536,7 +535,7 @@ library StoreCore { // Verify that the index is in bounds of the dynamic field PackedCounter previousEncodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); if (startByteIndex + dataToSet.length > previousEncodedLengths.atIndex(dynamicFieldIndex)) { - IStoreErrors.Store_IndexOutOfBounds( + revert IStoreErrors.Store_IndexOutOfBounds( previousEncodedLengths.atIndex(dynamicFieldIndex), startByteIndex + dataToSet.length - 1 ); @@ -545,9 +544,10 @@ library StoreCore { StoreCoreInternal._spliceDynamicData({ tableId: tableId, keyTuple: keyTuple, + dynamicFieldIndex: dynamicFieldIndex, startWithinField: uint40(startByteIndex), - deleteCount: uint40(dataToSet.length), data: dataToSet, + deleteCount: uint40(dataToSet.length), previousEncodedLengths: previousEncodedLengths }); } diff --git a/packages/store/src/StoreRead.sol b/packages/store/src/StoreRead.sol index fdd8a4ae35..cc3630fb69 100644 --- a/packages/store/src/StoreRead.sol +++ b/packages/store/src/StoreRead.sol @@ -69,11 +69,10 @@ contract StoreRead is IStoreRead { return StoreCore.getFieldLength(tableId, keyTuple, fieldIndex, fieldLayout); } - function getFieldSlice( + function getDynamicFieldSlice( ResourceId tableId, bytes32[] memory keyTuple, - uint8 fieldIndex, - FieldLayout fieldLayout, + uint8 dynamicFieldIndex, uint256 start, uint256 end ) public view virtual returns (bytes memory) { diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 2958f717fb..2634478279 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -186,7 +186,7 @@ library StoreSwitch { } } - function popFromField( + function popFromDynamicField( ResourceId tableId, bytes32[] memory keyTuple, uint8 dynamicFieldIndex, @@ -200,7 +200,7 @@ library StoreSwitch { } } - function updateInField( + function updateInDynamicField( ResourceId tableId, bytes32[] memory keyTuple, uint8 dynamicFieldIndex, diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 74d44b72a4..90eca45674 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -724,7 +724,7 @@ contract StoreCoreTest is Test, StoreMock { assertEq(loadedDynamicData, ""); } - struct TestPushToFieldData { + struct TestPushToDynamicFieldData { ResourceId tableId; bytes32[] keyTuple; bytes32 firstDataBytes; @@ -737,10 +737,21 @@ contract StoreCoreTest is Test, StoreMock { bytes newThirdDataBytes; } - function testPushToField() public { + function testPushToDynamicField() public { ResourceId tableId = _tableId; - TestPushToFieldData memory data = TestPushToFieldData(tableId, new bytes32[](0), 0, "", "", "", "", "", "", ""); + TestPushToDynamicFieldData memory data = TestPushToDynamicFieldData( + tableId, + new bytes32[](0), + 0, + "", + "", + "", + "", + "", + "", + "" + ); // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); @@ -783,7 +794,7 @@ contract StoreCoreTest is Test, StoreMock { IStore(this).setField(data.tableId, data.keyTuple, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); IStore(this).setField(data.tableId, data.keyTuple, 1, data.secondDataBytes, fieldLayout); // Initialize a field with push - IStore(this).pushToField(data.tableId, data.keyTuple, 2, data.thirdDataBytes, fieldLayout); + IStore(this).pushToDynamicField(data.tableId, data.keyTuple, 1, data.thirdDataBytes); // Create data to push { @@ -805,7 +816,7 @@ contract StoreCoreTest is Test, StoreMock { ); // Push to second field - IStore(this).pushToField(data.tableId, data.keyTuple, 1, data.secondDataToPush, fieldLayout); + IStore(this).pushToDynamicField(data.tableId, data.keyTuple, 0, data.secondDataToPush); // Get second field data.loadedData = IStore(this).getField(data.tableId, data.keyTuple, 1, fieldLayout); @@ -848,7 +859,7 @@ contract StoreCoreTest is Test, StoreMock { ); // Push to third field - IStore(this).pushToField(data.tableId, data.keyTuple, 2, data.thirdDataToPush, fieldLayout); + IStore(this).pushToDynamicField(data.tableId, data.keyTuple, 1, data.thirdDataToPush); // Get third field data.loadedData = IStore(this).getField(data.tableId, data.keyTuple, 2, fieldLayout); @@ -863,7 +874,7 @@ contract StoreCoreTest is Test, StoreMock { assertEq(IStore(this).getField(data.tableId, data.keyTuple, 1, fieldLayout), data.newSecondDataBytes, "10"); } - struct TestUpdateInFieldData { + struct TestUpdateInDynamicFieldData { ResourceId tableId; bytes32[] keyTuple; bytes32 firstDataBytes; @@ -878,10 +889,10 @@ contract StoreCoreTest is Test, StoreMock { bytes loadedData; } - function testUpdateInField() public { + function testUpdateInDynamicField() public { ResourceId tableId = _tableId; - TestUpdateInFieldData memory data = TestUpdateInFieldData( + TestUpdateInDynamicFieldData memory data = TestUpdateInDynamicFieldData( tableId, new bytes32[](0), 0, @@ -958,7 +969,7 @@ contract StoreCoreTest is Test, StoreMock { ); // Update index 1 in second field (4 = byte length of uint32) - IStore(this).updateInField(data.tableId, data.keyTuple, 1, 4 * 1, data.secondDataForUpdate, fieldLayout); + IStore(this).updateInDynamicField(data.tableId, data.keyTuple, 0, 4 * 1, data.secondDataForUpdate); // Get second field data.loadedData = IStore(this).getField(data.tableId, data.keyTuple, 1, fieldLayout); @@ -1003,7 +1014,7 @@ contract StoreCoreTest is Test, StoreMock { ); // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) - IStore(this).updateInField(data.tableId, data.keyTuple, 2, 8 * 1, data.thirdDataForUpdate, fieldLayout); + IStore(this).updateInDynamicField(data.tableId, data.keyTuple, 1, 8 * 1, data.thirdDataForUpdate); // Get third field data.loadedData = IStore(this).getField(data.tableId, data.keyTuple, 2, fieldLayout); @@ -1025,7 +1036,7 @@ contract StoreCoreTest is Test, StoreMock { type(uint56).max + data.thirdDataForUpdate.length - 1 ) ); - IStore(this).updateInField(data.tableId, data.keyTuple, 2, type(uint56).max, data.thirdDataForUpdate, fieldLayout); + IStore(this).updateInDynamicField(data.tableId, data.keyTuple, 1, type(uint56).max, data.thirdDataForUpdate); } function testAccessEmptyData() public { @@ -1053,7 +1064,7 @@ contract StoreCoreTest is Test, StoreMock { assertEq(data3Length, 0); vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, 0, 0)); - bytes memory data3Slice = IStore(this).getFieldSlice(tableId, keyTuple, 1, fieldLayout, 0, 0); + bytes memory data3Slice = IStore(this).getDynamicFieldSlice(tableId, keyTuple, 0, 0, 0); assertEq(data3Slice.length, 0); } diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index 173dc82a4d..e91eaf498c 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -29,15 +29,14 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { uint32[] internal thirdData; bytes internal thirdDataBytes; - // Expose an external popFromField function for testing purposes of indexers (see testHooks) - function popFromField( + // Expose an external popFromDynamicField function for testing purposes of indexers (see testHooks) + function popFromDynamicField( ResourceId tableId, bytes32[] calldata keyTuple, - uint8 fieldIndex, - uint256 byteLengthToPop, - FieldLayout fieldLayout + uint8 dynamicFieldIndex, + uint256 byteLengthToPop ) public override { - StoreCore.popFromField(tableId, keyTuple, fieldIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } function setUp() public { @@ -80,7 +79,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked(firstDataBytes), fieldLayout); StoreCore.setField(_tableId, _keyTuple, 1, secondDataBytes, fieldLayout); // Initialize a field with push - StoreCore.pushToField(_tableId, _keyTuple, 2, thirdDataBytes, fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, thirdDataBytes); } function testPopFromSecondField() public { @@ -107,7 +106,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Pop from second field startGasReport("pop from field (cold, 1 slot, 1 uint32 item)"); - StoreCore.popFromField(_tableId, _keyTuple, 1, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, byteLengthToPop); endGasReport(); // Get second field bytes memory loadedData = StoreCore.getField(_tableId, _keyTuple, 1, fieldLayout); @@ -117,7 +116,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Reset the second field and pop again (but warm this time) StoreCore.setField(_tableId, _keyTuple, 1, dataBytes, fieldLayout); startGasReport("pop from field (warm, 1 slot, 1 uint32 item)"); - StoreCore.popFromField(_tableId, _keyTuple, 1, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, byteLengthToPop); endGasReport(); // Get second field loadedData = StoreCore.getField(_tableId, _keyTuple, 1, fieldLayout); @@ -153,7 +152,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Pop from the field startGasReport("pop from field (cold, 2 slots, 10 uint32 items)"); - StoreCore.popFromField(_tableId, _keyTuple, 2, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, byteLengthToPop); endGasReport(); // Load and verify the field bytes memory loadedData = StoreCore.getField(_tableId, _keyTuple, 2, fieldLayout); @@ -162,7 +161,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Reset the field and pop again (but warm this time) StoreCore.setField(_tableId, _keyTuple, 2, dataBytes, fieldLayout); startGasReport("pop from field (warm, 2 slots, 10 uint32 items)"); - StoreCore.popFromField(_tableId, _keyTuple, 2, byteLengthToPop, fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, byteLengthToPop); endGasReport(); // Load and verify the field loadedData = StoreCore.getField(_tableId, _keyTuple, 2, fieldLayout); @@ -199,34 +198,34 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { assertEq(length, thirdDataBytes.length); } - function testGetFieldSlice() public { + function testGetDynamicFieldSlice() public { FieldLayout fieldLayout = StoreCore.getFieldLayout(_tableId); startGasReport("get field slice (cold, 1 slot)"); - bytes memory secondFieldSlice = StoreCore.getFieldSlice(_tableId, _keyTuple, 1, fieldLayout, 0, 4); + bytes memory secondFieldSlice = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, 0, 4); endGasReport(); assertEq(secondFieldSlice, SliceLib.getSubslice(secondDataBytes, 0, 4).toBytes()); startGasReport("get field slice (warm, 1 slot)"); - secondFieldSlice = StoreCore.getFieldSlice(_tableId, _keyTuple, 1, fieldLayout, 4, 8); + secondFieldSlice = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, 4, 8); endGasReport(); assertEq(secondFieldSlice, SliceLib.getSubslice(secondDataBytes, 4, 8).toBytes()); startGasReport("get field slice (semi-cold, 1 slot)"); - bytes memory thirdFieldSlice = StoreCore.getFieldSlice(_tableId, _keyTuple, 2, fieldLayout, 4, 32); + bytes memory thirdFieldSlice = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, 4, 32); endGasReport(); assertEq(thirdFieldSlice, SliceLib.getSubslice(thirdDataBytes, 4, 32).toBytes()); startGasReport("get field slice (warm, 2 slots)"); - thirdFieldSlice = StoreCore.getFieldSlice(_tableId, _keyTuple, 2, fieldLayout, 8, 40); + thirdFieldSlice = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, 8, 40); endGasReport(); assertEq(thirdFieldSlice, SliceLib.getSubslice(thirdDataBytes, 8, 40).toBytes()); // Expect a revert if the end index is out of bounds uint256 length = secondDataBytes.length; vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, length, length)); - StoreCore.getFieldSlice(_tableId, _keyTuple, 1, fieldLayout, 0, length + 1); + StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, 0, length + 1); // Expect a revert if the start index is out of bounds vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, length, length)); - StoreCore.getFieldSlice(_tableId, _keyTuple, 1, fieldLayout, length, length); + StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, length, length); } } diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 5bdd86e637..044863552f 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -421,7 +421,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { endGasReport(); } - function testPushToField() public { + function testPushToDynamicField() public { ResourceId tableId = _tableId; // Register table @@ -459,7 +459,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { StoreCore.setField(tableId, keyTuple, 0, abi.encodePacked(firstDataBytes), fieldLayout); StoreCore.setField(tableId, keyTuple, 1, secondDataBytes, fieldLayout); // Initialize a field with push - StoreCore.pushToField(tableId, keyTuple, 2, thirdDataBytes, fieldLayout); + StoreCore.pushToDynamicField(tableId, keyTuple, 1, thirdDataBytes); // Create data to push bytes memory secondDataToPush; @@ -471,7 +471,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Push to second field startGasReport("push to field (1 slot, 1 uint32 item)"); - StoreCore.pushToField(tableId, keyTuple, 1, secondDataToPush, fieldLayout); + StoreCore.pushToDynamicField(tableId, keyTuple, 0, secondDataToPush); endGasReport(); // Create data to push @@ -493,11 +493,11 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Push to third field startGasReport("push to field (2 slots, 10 uint32 items)"); - StoreCore.pushToField(tableId, keyTuple, 2, thirdDataToPush, fieldLayout); + StoreCore.pushToDynamicField(tableId, keyTuple, 1, thirdDataToPush); endGasReport(); } - struct TestUpdateInFieldData { + struct TestUpdateInDynamicFieldData { bytes32 firstDataBytes; bytes secondDataBytes; bytes secondDataForUpdate; @@ -507,10 +507,10 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes newThirdDataBytes; } - function testUpdateInField() public { + function testUpdateInDynamicField() public { ResourceId tableId = _tableId; - TestUpdateInFieldData memory data = TestUpdateInFieldData("", "", "", "", "", "", ""); + TestUpdateInDynamicFieldData memory data = TestUpdateInDynamicFieldData("", "", "", "", "", "", ""); // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( @@ -556,7 +556,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update index 1 in second field (4 = byte length of uint32) startGasReport("update in field (1 slot, 1 uint32 item)"); - StoreCore.updateInField(tableId, keyTuple, 1, 4 * 1, data.secondDataForUpdate, fieldLayout); + StoreCore.updateInDynamicField(tableId, keyTuple, 0, 4 * 1, data.secondDataForUpdate); endGasReport(); // Create data for update @@ -580,7 +580,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) startGasReport("push to field (2 slots, 6 uint64 items)"); - StoreCore.updateInField(tableId, keyTuple, 2, 8 * 1, data.thirdDataForUpdate, fieldLayout); + StoreCore.updateInDynamicField(tableId, keyTuple, 1, 8 * 1, data.thirdDataForUpdate); endGasReport(); } @@ -613,7 +613,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { endGasReport(); vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, 0, 0)); - StoreCore.getFieldSlice(tableId, keyTuple, 1, fieldLayout, 0, 0); + StoreCore.getDynamicFieldSlice(tableId, keyTuple, 0, 0, 0); } function testHooks() public { diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 2833b6680d..e67af478f8 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -33,73 +33,73 @@ "file": "test/CallBatch.t.sol", "test": "testCallBatchReturnData", "name": "call systems with callBatch", - "gasUsed": 45264 + "gasUsed": 45220 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1411020 + "gasUsed": 1410200 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1411020 + "gasUsed": 1410200 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 158894 + "gasUsed": 158056 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1411020 + "gasUsed": 1410200 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1411020 + "gasUsed": 1410200 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22571 + "gasUsed": 22549 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 161709 + "gasUsed": 155582 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1411020 + "gasUsed": 1410200 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 21293 + "gasUsed": 21271 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 86667 + "gasUsed": 84710 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 652590 + "gasUsed": 651770 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,79 +117,79 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 652590 + "gasUsed": 651770 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 136434 + "gasUsed": 135626 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 652590 + "gasUsed": 651770 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 105551 + "gasUsed": 104787 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36604 + "gasUsed": 36649 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 652590 + "gasUsed": 651770 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 147642 + "gasUsed": 146879 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 112401 + "gasUsed": 111638 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 106583 + "gasUsed": 102130 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 54025 + "gasUsed": 52542 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 134453 + "gasUsed": 126519 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 85000 + "gasUsed": 80613 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 86634 + "gasUsed": 82181 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18882 + "gasUsed": 17911 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 6318621 + "gasUsed": 5803614 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 592015 + "gasUsed": 540567 }, { "file": "test/query.t.sol", @@ -225,7 +225,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 47621 + "gasUsed": 46138 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -237,7 +237,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36694 + "gasUsed": 36672 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -249,7 +249,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26779 + "gasUsed": 26757 }, { "file": "test/UniqueEntityModule.t.sol", @@ -261,25 +261,25 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51594 + "gasUsed": 51615 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 646387 + "gasUsed": 646365 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51594 + "gasUsed": 51615 }, { "file": "test/World.t.sol", "test": "testCall", "name": "call a system via the World", - "gasUsed": 12409 + "gasUsed": 12387 }, { "file": "test/World.t.sol", @@ -291,7 +291,7 @@ "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "call a system via an unlimited delegation", - "gasUsed": 12796 + "gasUsed": 12774 }, { "file": "test/World.t.sol", @@ -301,9 +301,9 @@ }, { "file": "test/World.t.sol", - "test": "testPushToField", + "test": "testPushToDynamicField", "name": "Push data to the table", - "gasUsed": 86743 + "gasUsed": 85901 }, { "file": "test/World.t.sol", @@ -321,7 +321,7 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 80511 + "gasUsed": 80510 }, { "file": "test/World.t.sol", @@ -339,7 +339,7 @@ "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 36889 + "gasUsed": 36933 }, { "file": "test/World.t.sol", @@ -349,27 +349,27 @@ }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testPopFromField", + "test": "testPopFromDyanmicField", "name": "pop 1 address (cold)", - "gasUsed": 24499 + "gasUsed": 23647 }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testPopFromField", + "test": "testPopFromDyanmicField", "name": "pop 1 address (warm)", - "gasUsed": 13645 + "gasUsed": 12793 }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testUpdateInField", - "name": "updateInField 1 item (cold)", - "gasUsed": 25063 + "test": "testUpdateInDynamicField", + "name": "update in field 1 item (cold)", + "gasUsed": 24371 }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testUpdateInField", - "name": "updateInField 1 item (warm)", - "gasUsed": 14268 + "test": "testUpdateInDynamicField", + "name": "update in field 1 item (warm)", + "gasUsed": 13570 }, { "file": "test/WorldResourceId.t.sol", diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 10e6be1781..7c2203549e 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -255,14 +255,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -276,14 +269,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -311,14 +297,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -332,14 +311,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 21, - (_index + 1) * 21 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 21, (_index + 1) * 21); return (bytes21(_blob)); } } @@ -363,7 +335,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +343,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +351,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +359,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +367,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +375,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +383,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -419,7 +391,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value (using the specified store) */ @@ -427,7 +399,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -435,7 +407,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value */ @@ -443,7 +415,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** Pop an element from value (using the specified store) */ @@ -451,7 +423,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 21); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 21); } /** @@ -463,13 +435,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 21, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -482,7 +448,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -495,7 +461,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -508,13 +474,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 21, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -527,7 +487,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } @@ -540,7 +500,7 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 21, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); } } diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 2eb468a9ab..264b6a2b15 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -187,14 +187,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -208,14 +201,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -239,7 +225,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keys0 */ @@ -247,7 +233,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keys0 (using the specified store) */ @@ -255,7 +241,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from keys0 */ @@ -263,7 +249,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keys0 */ @@ -271,7 +257,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keys0 (using the specified store) */ @@ -279,7 +265,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** @@ -291,13 +277,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -310,7 +290,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -323,7 +303,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -420,14 +400,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 1, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -441,14 +414,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 1, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -472,7 +438,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Push an element to keys1 */ @@ -480,7 +446,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Push an element to keys1 (using the specified store) */ @@ -488,7 +454,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Pop an element from keys1 */ @@ -496,7 +462,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 32); } /** Pop an element from keys1 */ @@ -504,7 +470,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 32); } /** Pop an element from keys1 (using the specified store) */ @@ -512,7 +478,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 1, 32); } /** @@ -524,13 +490,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); } } @@ -543,7 +503,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); } } @@ -556,7 +516,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); } } @@ -653,14 +613,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -674,14 +627,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -705,7 +651,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Push an element to keys2 */ @@ -713,7 +659,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Push an element to keys2 (using the specified store) */ @@ -721,7 +667,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Pop an element from keys2 */ @@ -729,7 +675,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 2, 32); } /** Pop an element from keys2 */ @@ -737,7 +683,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 2, 32); } /** Pop an element from keys2 (using the specified store) */ @@ -745,7 +691,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 2, 32); } /** @@ -757,13 +703,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); } } @@ -776,7 +716,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); } } @@ -789,7 +729,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); } } @@ -886,14 +826,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 3, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -907,14 +840,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 3, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -938,7 +864,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); } /** Push an element to keys3 */ @@ -946,7 +872,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); } /** Push an element to keys3 (using the specified store) */ @@ -954,7 +880,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); } /** Pop an element from keys3 */ @@ -962,7 +888,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 3, 32); } /** Pop an element from keys3 */ @@ -970,7 +896,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 3, 32); } /** Pop an element from keys3 (using the specified store) */ @@ -978,7 +904,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 3, 32); } /** @@ -990,13 +916,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); } } @@ -1009,7 +929,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); } } @@ -1022,7 +942,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); } } @@ -1119,14 +1039,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 4, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 4, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -1140,14 +1053,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 4, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 4, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -1171,7 +1077,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); } /** Push an element to keys4 */ @@ -1179,7 +1085,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); } /** Push an element to keys4 (using the specified store) */ @@ -1187,7 +1093,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); } /** Pop an element from keys4 */ @@ -1195,7 +1101,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 4, 32); } /** Pop an element from keys4 */ @@ -1203,7 +1109,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 4, 32); } /** Pop an element from keys4 (using the specified store) */ @@ -1211,7 +1117,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 4, 32); } /** @@ -1223,13 +1129,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); } } @@ -1242,7 +1142,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); } } @@ -1255,7 +1155,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); } } diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index d74eaf91df..4a94899466 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -273,14 +273,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -298,14 +291,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -338,14 +324,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -359,14 +338,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -395,7 +367,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keysWithValue */ @@ -403,7 +375,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keysWithValue (using the specified store) */ @@ -411,7 +383,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keysWithValue */ @@ -419,7 +391,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keysWithValue */ @@ -427,7 +399,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to keysWithValue (using the specified store) */ @@ -435,7 +407,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from keysWithValue */ @@ -443,7 +415,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keysWithValue */ @@ -451,7 +423,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keysWithValue (using the specified store) */ @@ -459,7 +431,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keysWithValue */ @@ -467,7 +439,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keysWithValue */ @@ -475,7 +447,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from keysWithValue (using the specified store) */ @@ -483,7 +455,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 32); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** @@ -495,13 +467,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -514,7 +480,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -533,7 +499,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -546,13 +512,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 32, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -565,7 +525,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -578,7 +538,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 32, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 43580373a9..e81fae20bb 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -791,7 +791,7 @@ contract WorldTest is Test, GasReporter { world.setField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); } - function testPushToField() public { + function testPushToDynamicField() public { bytes14 namespace = "testPushField"; bytes16 name = "testTable"; ResourceId tableId = WorldResourceIdLib.encode({ typeId: RESOURCE_TABLE, namespace: namespace, name: name }); @@ -809,7 +809,7 @@ contract WorldTest is Test, GasReporter { bytes memory encodedData = EncodeArray.encode(dataToPush); startGasReport("Push data to the table"); - world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); + world.pushToDynamicField(tableId, keyTuple, 0, encodedData); endGasReport(); // Expect the data to be written @@ -819,19 +819,21 @@ contract WorldTest is Test, GasReporter { world.deleteRecord(tableId, keyTuple); // Push data to the table via direct access - world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); + world.pushToDynamicField(tableId, keyTuple, 0, encodedData); // Expect the data to be written assertEq(AddressArray.get(world, tableId, key), dataToPush); // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), namespace, name, RESOURCE_TABLE); - world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); + world.pushToDynamicField(tableId, keyTuple, 0, encodedData); // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.pushToField.selector)); - world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.pushToDynamicField.selector) + ); + world.pushToDynamicField(tableId, keyTuple, 0, encodedData); } function testDeleteRecord() public { diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index 3d054da1e7..18d130589e 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -26,7 +26,7 @@ import { CoreModule } from "../src/modules/core/CoreModule.sol"; import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol"; -contract UpdateInFieldTest is Test, GasReporter { +contract UpdateInDynamicFieldTest is Test, GasReporter { using WorldResourceIdInstance for ResourceId; event HookCalled(bytes data); @@ -81,7 +81,7 @@ contract UpdateInFieldTest is Test, GasReporter { vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_AccessDenied.selector, _tableId.toString(), _caller)); } - function testPopFromField() public { + function testPopFromDyanmicField() public { FieldLayout fieldLayout = AddressArray.getFieldLayout(); // Expect the data to be written @@ -91,7 +91,7 @@ contract UpdateInFieldTest is Test, GasReporter { uint256 byteLengthToPop = 20; startGasReport("pop 1 address (cold)"); - world.popFromField(tableId, keyTuple, 0, byteLengthToPop, fieldLayout); + world.popFromDynamicField(tableId, keyTuple, 0, byteLengthToPop); endGasReport(); // Expect the data to be updated @@ -105,7 +105,7 @@ contract UpdateInFieldTest is Test, GasReporter { byteLengthToPop = 20; startGasReport("pop 1 address (warm)"); - world.popFromField(tableId, keyTuple, 0, byteLengthToPop, fieldLayout); + world.popFromDynamicField(tableId, keyTuple, 0, byteLengthToPop); endGasReport(); // Expect the data to be updated @@ -119,7 +119,7 @@ contract UpdateInFieldTest is Test, GasReporter { world.setField(tableId, keyTuple, 0, encodedData, fieldLayout); // Pop 2 items via direct access byteLengthToPop = 20 * 2; - world.popFromField(tableId, keyTuple, 0, byteLengthToPop, fieldLayout); + world.popFromDynamicField(tableId, keyTuple, 0, byteLengthToPop); // Expect the data to be updated loadedData = AddressArray.get(world, tableId, key); assertEq(loadedData.length, initData.length - 2); @@ -129,17 +129,17 @@ contract UpdateInFieldTest is Test, GasReporter { // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), tableId); - world.popFromField(tableId, keyTuple, 0, 20, fieldLayout); + world.popFromDynamicField(tableId, keyTuple, 0, 20); // Expect the World to not have access vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.popFromField.selector) + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.popFromDynamicField.selector) ); - world.popFromField(tableId, keyTuple, 0, 20, fieldLayout); + world.popFromDynamicField(tableId, keyTuple, 0, 20); } - function testUpdateInField() public { + function testUpdateInDynamicField() public { FieldLayout fieldLayout = AddressArray.getFieldLayout(); // Expect the data to be written @@ -149,12 +149,12 @@ contract UpdateInFieldTest is Test, GasReporter { address[] memory dataForUpdate = new address[](1); dataForUpdate[0] = address(bytes20(keccak256("address for update"))); - startGasReport("updateInField 1 item (cold)"); - world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); + startGasReport("update in field 1 item (cold)"); + world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); endGasReport(); - startGasReport("updateInField 1 item (warm)"); - world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); + startGasReport("update in field 1 item (warm)"); + world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); endGasReport(); // Expect the data to be updated @@ -162,7 +162,7 @@ contract UpdateInFieldTest is Test, GasReporter { assertEq(AddressArray.get(world, tableId, key), initData); // Update index 1 via direct access - world.updateInField(tableId, keyTuple, 0, 20 * 1, EncodeArray.encode(dataForUpdate), fieldLayout); + world.updateInDynamicField(tableId, keyTuple, 0, 20 * 1, EncodeArray.encode(dataForUpdate)); // Expect the data to be updated initData[1] = dataForUpdate[0]; @@ -170,13 +170,13 @@ contract UpdateInFieldTest is Test, GasReporter { // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), tableId); - world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); + world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); // Expect the World to not have access vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.updateInField.selector) + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.updateInDynamicField.selector) ); - world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); + world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); } } diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index a661725c4a..25ef87db20 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -250,14 +250,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 20, - (_index + 1) * 20 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -271,14 +264,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 20, - (_index + 1) * 20 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -311,14 +297,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 20, - (_index + 1) * 20 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -332,14 +311,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 20, - (_index + 1) * 20 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -363,7 +335,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -371,7 +343,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -379,7 +351,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -387,7 +359,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ @@ -395,7 +367,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ @@ -403,7 +375,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToDynamicField(_tableId, _keyTuple, dynamicFieldIndex, abi.encodePacked((_element))); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from value */ @@ -411,7 +383,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 20); } /** Pop an element from value */ @@ -419,7 +391,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 20); } /** Pop an element from value (using the specified store) */ @@ -427,7 +399,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 20); } /** Pop an element from value */ @@ -435,7 +407,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 20); } /** Pop an element from value */ @@ -443,7 +415,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 20); } /** Pop an element from value (using the specified store) */ @@ -451,7 +423,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromDynamicField(_tableId, _keyTuple, dynamicFieldIndex, 20); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 20); } /** @@ -463,13 +435,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 20, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); } } @@ -482,7 +448,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); } } @@ -495,7 +461,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); } } @@ -508,13 +474,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField( - _tableId, - _keyTuple, - dynamicFieldIndex, - _index * 20, - abi.encodePacked((_element)) - ); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); } } @@ -527,7 +487,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); } } @@ -540,7 +500,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, dynamicFieldIndex, _index * 20, abi.encodePacked((_element))); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); } } From efcec63a66d8bf35d54074cfab5f4b20cd9a9aac Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 19:45:06 +0100 Subject: [PATCH 24/38] expose methods to explicitly set static or dynamic fields --- .../src/codegen/tables/Dynamics1.sol | 176 ++++++------------ .../src/codegen/tables/Dynamics2.sol | 93 ++++----- .../src/codegen/tables/Singleton.sol | 93 ++++----- packages/store/gas-report.json | 4 +- packages/store/src/IStore.sol | 15 ++ packages/store/src/StoreCore.sol | 6 +- packages/store/src/StoreSwitch.sol | 29 +++ packages/store/test/StoreMock.sol | 21 +++ packages/world/gas-report.json | 62 +++--- packages/world/src/World.sol | 35 ++++ 10 files changed, 268 insertions(+), 266 deletions(-) diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 1c8f016054..2316a4a763 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -193,14 +193,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -214,14 +207,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 32, - (_index + 1) * 32 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -235,7 +221,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 32, (_index + 1) * 32); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 32, (_index + 1) * 32); return (bytes32(_blob)); } } @@ -245,7 +231,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to staticB32 */ @@ -253,7 +239,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to staticB32 (using the specified store) */ @@ -261,7 +247,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from staticB32 */ @@ -269,7 +255,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from staticB32 */ @@ -277,7 +263,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** Pop an element from staticB32 (using the specified store) */ @@ -285,7 +271,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 32, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 32); } /** @@ -297,7 +283,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -310,7 +296,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -323,7 +309,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); } } @@ -420,14 +406,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 1, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 4, (_index + 1) * 4); return (int32(uint32(bytes4(_blob)))); } } @@ -441,7 +420,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 4, (_index + 1) * 4); return (int32(uint32(bytes4(_blob)))); } } @@ -455,7 +434,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 4, (_index + 1) * 4); return (int32(uint32(bytes4(_blob)))); } } @@ -465,7 +444,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Push an element to staticI32 */ @@ -473,7 +452,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Push an element to staticI32 (using the specified store) */ @@ -481,7 +460,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Pop an element from staticI32 */ @@ -489,7 +468,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 4); } /** Pop an element from staticI32 */ @@ -497,7 +476,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 1, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 4); } /** Pop an element from staticI32 (using the specified store) */ @@ -505,7 +484,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 1, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 1, 4); } /** @@ -517,7 +496,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); } } @@ -530,7 +509,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); } } @@ -543,7 +522,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); } } @@ -646,14 +625,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 16, - (_index + 1) * 16 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 16, (_index + 1) * 16); return (uint128(bytes16(_blob))); } } @@ -667,14 +639,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 16, - (_index + 1) * 16 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 16, (_index + 1) * 16); return (uint128(bytes16(_blob))); } } @@ -688,7 +653,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 16, (_index + 1) * 16); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 16, (_index + 1) * 16); return (uint128(bytes16(_blob))); } } @@ -698,7 +663,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Push an element to staticU128 */ @@ -706,7 +671,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Push an element to staticU128 (using the specified store) */ @@ -714,7 +679,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Pop an element from staticU128 */ @@ -722,7 +687,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 16, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 2, 16); } /** Pop an element from staticU128 */ @@ -730,7 +695,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 2, 16, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 2, 16); } /** Pop an element from staticU128 (using the specified store) */ @@ -738,7 +703,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 2, 16, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 2, 16); } /** @@ -750,7 +715,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); } } @@ -763,7 +728,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); } } @@ -776,7 +741,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); } } @@ -885,14 +850,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 20, - (_index + 1) * 20 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 3, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -906,14 +864,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 20, - (_index + 1) * 20 - ); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 3, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -927,7 +878,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 20, (_index + 1) * 20); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 3, _index * 20, (_index + 1) * 20); return (address(bytes20(_blob))); } } @@ -937,7 +888,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); } /** Push an element to staticAddrs */ @@ -945,7 +896,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); } /** Push an element to staticAddrs (using the specified store) */ @@ -953,7 +904,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); } /** Pop an element from staticAddrs */ @@ -961,7 +912,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 20, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 3, 20); } /** Pop an element from staticAddrs */ @@ -969,7 +920,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 3, 20, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 3, 20); } /** Pop an element from staticAddrs (using the specified store) */ @@ -977,7 +928,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 3, 20, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 3, 20); } /** @@ -989,7 +940,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); } } @@ -1002,7 +953,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); } } @@ -1015,7 +966,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); } } @@ -1112,14 +1063,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 4, - _fieldLayout, - _index * 1, - (_index + 1) * 1 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 4, _index * 1, (_index + 1) * 1); return (_toBool(uint8(bytes1(_blob)))); } } @@ -1133,7 +1077,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 4, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 4, _index * 1, (_index + 1) * 1); return (_toBool(uint8(bytes1(_blob)))); } } @@ -1147,7 +1091,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 4, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 4, _index * 1, (_index + 1) * 1); return (_toBool(uint8(bytes1(_blob)))); } } @@ -1157,7 +1101,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); } /** Push an element to staticBools */ @@ -1165,7 +1109,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); } /** Push an element to staticBools (using the specified store) */ @@ -1173,7 +1117,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); } /** Pop an element from staticBools */ @@ -1181,7 +1125,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 4, 1, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 4, 1); } /** Pop an element from staticBools */ @@ -1189,7 +1133,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 4, 1, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 4, 1); } /** Pop an element from staticBools (using the specified store) */ @@ -1197,7 +1141,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 4, 1, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 4, 1); } /** @@ -1209,7 +1153,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); } } @@ -1222,7 +1166,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); } } @@ -1235,7 +1179,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); } } diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index 0d4a987dbd..cd1ca1cbae 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -181,14 +181,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 8, - (_index + 1) * 8 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 8, (_index + 1) * 8); return (uint64(bytes8(_blob))); } } @@ -202,7 +195,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 8, (_index + 1) * 8); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 8, (_index + 1) * 8); return (uint64(bytes8(_blob))); } } @@ -216,7 +209,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 8, (_index + 1) * 8); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 8, (_index + 1) * 8); return (uint64(bytes8(_blob))); } } @@ -226,7 +219,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to u64 */ @@ -234,7 +227,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to u64 (using the specified store) */ @@ -242,7 +235,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from u64 */ @@ -250,7 +243,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 8, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 8); } /** Pop an element from u64 */ @@ -258,7 +251,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 0, 8, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 8); } /** Pop an element from u64 (using the specified store) */ @@ -266,7 +259,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 8, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 8); } /** @@ -278,7 +271,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); } } @@ -291,7 +284,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); } } @@ -304,7 +297,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); } } @@ -401,14 +394,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 1, - _fieldLayout, - _index * 1, - (_index + 1) * 1 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (string(_blob)); } } @@ -422,7 +408,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (string(_blob)); } } @@ -436,7 +422,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1); return (string(_blob)); } } @@ -446,7 +432,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Push a slice to str */ @@ -454,7 +440,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Push a slice to str (using the specified store) */ @@ -462,7 +448,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice))); } /** Pop a slice from str */ @@ -470,7 +456,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 1, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** Pop a slice from str */ @@ -478,7 +464,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 1, 1, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** Pop a slice from str (using the specified store) */ @@ -486,7 +472,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 1, 1, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 1, 1); } /** @@ -498,7 +484,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -511,7 +497,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -524,7 +510,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); } } @@ -621,14 +607,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 1, - (_index + 1) * 1 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -642,7 +621,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -656,7 +635,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 1, (_index + 1) * 1); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 1, (_index + 1) * 1); return (bytes(_blob)); } } @@ -666,7 +645,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, bytes((_slice)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 2, bytes((_slice))); } /** Push a slice to b */ @@ -674,7 +653,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.pushToField(_tableId, _keyTuple, 2, bytes((_slice)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 2, bytes((_slice))); } /** Push a slice to b (using the specified store) */ @@ -682,7 +661,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 2, bytes((_slice)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 2, bytes((_slice))); } /** Pop a slice from b */ @@ -690,7 +669,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 1, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 2, 1); } /** Pop a slice from b */ @@ -698,7 +677,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.popFromField(_tableId, _keyTuple, 2, 1, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 2, 1); } /** Pop a slice from b (using the specified store) */ @@ -706,7 +685,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 2, 1, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 2, 1); } /** @@ -718,7 +697,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); } } @@ -731,7 +710,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); } } @@ -744,7 +723,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); } } diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 921439e0d4..438ca797f2 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -210,14 +210,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 1, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -230,7 +223,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -243,7 +236,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 1, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -252,42 +245,42 @@ library Singleton { function pushV2(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to v2 */ function _pushV2(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to v2 (using the specified store) */ function pushV2(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from v2 */ function popV2() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from v2 */ function _popV2() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.popFromField(_tableId, _keyTuple, 1, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from v2 (using the specified store) */ function popV2(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 1, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** @@ -298,7 +291,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -310,7 +303,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -322,7 +315,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -409,14 +402,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 2, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -429,7 +415,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -442,7 +428,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 2, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -451,42 +437,42 @@ library Singleton { function pushV3(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Push an element to v3 */ function _pushV3(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Push an element to v3 (using the specified store) */ function pushV3(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); } /** Pop an element from v3 */ function popV3() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 4); } /** Pop an element from v3 */ function _popV3() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.popFromField(_tableId, _keyTuple, 2, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 4); } /** Pop an element from v3 (using the specified store) */ function popV3(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 2, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 1, 4); } /** @@ -497,7 +483,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); } } @@ -509,7 +495,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); } } @@ -521,7 +507,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); } } @@ -608,14 +594,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 3, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -628,7 +607,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -641,7 +620,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 3, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 2, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -650,42 +629,42 @@ library Singleton { function pushV4(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Push an element to v4 */ function _pushV4(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Push an element to v4 (using the specified store) */ function pushV4(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); } /** Pop an element from v4 */ function popV4() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 2, 4); } /** Pop an element from v4 */ function _popV4() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.popFromField(_tableId, _keyTuple, 3, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 2, 4); } /** Pop an element from v4 (using the specified store) */ function popV4(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 3, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 2, 4); } /** @@ -696,7 +675,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); } } @@ -708,7 +687,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); } } @@ -720,7 +699,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); } } diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 9cca7531d2..7de7ef7730 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -741,7 +741,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 19864 + "gasUsed": 19907 }, { "file": "test/StoreCoreGas.t.sol", @@ -765,7 +765,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 24504 + "gasUsed": 24482 }, { "file": "test/StoreCoreGas.t.sol", diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index b8c1836813..7c71b1afa5 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -138,6 +138,21 @@ interface IStoreWrite { FieldLayout fieldLayout ) external; + function setStaticField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex, + bytes calldata data, + FieldLayout fieldLayout + ) external; + + function setDynamicField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 dynamicFieldIndex, + bytes calldata data + ) external; + // Push encoded items to the dynamic field at field index function pushToDynamicField( ResourceId tableId, diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index c3c63a5a33..04a2eb9c2e 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -380,7 +380,7 @@ library StoreCore { FieldLayout fieldLayout ) internal { if (fieldIndex < fieldLayout.numStaticFields()) { - setStaticField(tableId, keyTuple, fieldLayout, fieldIndex, data); + setStaticField(tableId, keyTuple, fieldIndex, data, fieldLayout); } else { setDynamicField(tableId, keyTuple, fieldIndex - uint8(fieldLayout.numStaticFields()), data); } @@ -389,9 +389,9 @@ library StoreCore { function setStaticField( ResourceId tableId, bytes32[] memory keyTuple, - FieldLayout fieldLayout, uint8 fieldIndex, - bytes memory data + bytes memory data, + FieldLayout fieldLayout ) internal { spliceStaticData({ tableId: tableId, diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 2634478279..93d7d357a0 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -172,6 +172,35 @@ library StoreSwitch { } } + function setStaticField( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex, + bytes memory data, + FieldLayout fieldLayout + ) internal { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + StoreCore.setStaticField(tableId, keyTuple, fieldIndex, data, fieldLayout); + } else { + IStore(_storeAddress).setStaticField(tableId, keyTuple, fieldIndex, data, fieldLayout); + } + } + + function setDynamicField( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 dynamicFieldIndex, + bytes memory data + ) internal { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + StoreCore.setDynamicField(tableId, keyTuple, dynamicFieldIndex, data); + } else { + IStore(_storeAddress).setDynamicField(tableId, keyTuple, dynamicFieldIndex, data); + } + } + function pushToDynamicField( ResourceId tableId, bytes32[] memory keyTuple, diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index 0b85bdfbe6..a6e5e6ad2c 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -62,6 +62,27 @@ contract StoreMock is IStore, StoreRead { StoreCore.setField(tableId, keyTuple, fieldIndex, data, fieldLayout); } + // Set partial data at field index + function setStaticField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex, + bytes calldata data, + FieldLayout fieldLayout + ) public virtual { + StoreCore.setStaticField(tableId, keyTuple, fieldIndex, data, fieldLayout); + } + + // Set partial data at dynamic field index + function setDynamicField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 dynamicFieldIndex, + bytes calldata data + ) public virtual { + StoreCore.setDynamicField(tableId, keyTuple, dynamicFieldIndex, data); + } + // Push encoded items to the dynamic field at field index function pushToDynamicField( ResourceId tableId, diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index e67af478f8..a06eb1e104 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -33,19 +33,19 @@ "file": "test/CallBatch.t.sol", "test": "testCallBatchReturnData", "name": "call systems with callBatch", - "gasUsed": 45220 + "gasUsed": 45264 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1410200 + "gasUsed": 1410222 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1410200 + "gasUsed": 1410222 }, { "file": "test/KeysInTableModule.t.sol", @@ -57,13 +57,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1410200 + "gasUsed": 1410222 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1410200 + "gasUsed": 1410222 }, { "file": "test/KeysInTableModule.t.sol", @@ -75,13 +75,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 155582 + "gasUsed": 155647 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1410200 + "gasUsed": 1410222 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,13 +93,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 84710 + "gasUsed": 84731 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 651770 + "gasUsed": 651792 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,79 +117,79 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 651770 + "gasUsed": 651792 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 135626 + "gasUsed": 135603 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 651770 + "gasUsed": 651792 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 104787 + "gasUsed": 104742 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36649 + "gasUsed": 36648 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 651770 + "gasUsed": 651792 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 146879 + "gasUsed": 146811 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 111638 + "gasUsed": 111570 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 102130 + "gasUsed": 102328 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 52542 + "gasUsed": 52608 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 126519 + "gasUsed": 126871 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 80613 + "gasUsed": 80811 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 82181 + "gasUsed": 82379 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 17911 + "gasUsed": 17955 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5803614 + "gasUsed": 5825614 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 540567 + "gasUsed": 542767 }, { "file": "test/query.t.sol", @@ -225,7 +225,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 46138 + "gasUsed": 46204 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -261,7 +261,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51615 + "gasUsed": 51637 }, { "file": "test/UniqueEntityModule.t.sol", @@ -273,13 +273,13 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51615 + "gasUsed": 51637 }, { "file": "test/World.t.sol", "test": "testCall", "name": "call a system via the World", - "gasUsed": 12387 + "gasUsed": 12409 }, { "file": "test/World.t.sol", @@ -297,7 +297,7 @@ "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9911 + "gasUsed": 9933 }, { "file": "test/World.t.sol", @@ -321,7 +321,7 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 80510 + "gasUsed": 80532 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 873468b205..9ed88cbdd9 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -172,6 +172,41 @@ contract World is StoreRead, IStoreData, IWorldKernel { StoreCore.setField(tableId, keyTuple, fieldIndex, data, fieldLayout); } + /** + * Write a static field in the table at the given tableId. + * Requires the caller to have access to the table's namespace or name (encoded in the tableId). + */ + function setStaticField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex, + bytes calldata data, + FieldLayout fieldLayout + ) public virtual requireNoCallback { + // Require access to namespace or name + AccessControl.requireAccess(tableId, msg.sender); + + // Set the field + StoreCore.setStaticField(tableId, keyTuple, fieldIndex, data, fieldLayout); + } + + /** + * Write a dynamic field in the table at the given tableId. + * Requires the caller to have access to the table's namespace or name (encoded in the tableId). + */ + function setDynamicField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 dynamicFieldIndex, + bytes calldata data + ) public virtual requireNoCallback { + // Require access to namespace or name + AccessControl.requireAccess(tableId, msg.sender); + + // Set the field + StoreCore.setDynamicField(tableId, keyTuple, dynamicFieldIndex, data); + } + /** * Push data to the end of a field in the table at the given tableId. * Requires the caller to have access to the table's namespace or name (encoded in the tableId). From 57b8cd50e72b5dbb96b41ce675e6f9d252558dd0 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 19:54:19 +0100 Subject: [PATCH 25/38] use setStaticField or setDynamicField in tablegen --- .../src/codegen/tables/Dynamics1.sol | 54 ++++++------------- .../src/codegen/tables/Dynamics2.sol | 18 +++---- .../contracts/src/codegen/tables/Offchain.sol | 6 +-- .../src/codegen/tables/Singleton.sol | 24 ++++----- .../contracts/src/codegen/tables/Statics.sol | 36 ++++++------- packages/store/gas-report.json | 18 +++---- .../store/src/codegen/tables/Callbacks.sol | 12 ++--- packages/store/src/codegen/tables/Hooks.sol | 12 ++--- .../store/src/codegen/tables/KeyEncoding.sol | 12 ++--- packages/store/src/codegen/tables/Mixed.sol | 24 ++++----- .../store/src/codegen/tables/ResourceIds.sol | 12 ++--- .../store/src/codegen/tables/StoreHooks.sol | 12 ++--- packages/store/src/codegen/tables/Tables.sol | 30 +++++------ packages/store/src/codegen/tables/Vector2.sol | 12 ++--- packages/store/ts/codegen/field.ts | 25 ++++----- packages/world/gas-report.json | 44 +++++++-------- .../src/modules/core/tables/Balances.sol | 12 ++--- .../modules/core/tables/FunctionSelectors.sol | 12 ++--- .../src/modules/core/tables/SystemHooks.sol | 12 ++--- .../modules/core/tables/SystemRegistry.sol | 12 ++--- .../world/src/modules/core/tables/Systems.sol | 12 ++--- .../keysintable/tables/KeysInTable.sol | 30 +++++------ .../keysintable/tables/UsedKeysIndex.sol | 12 ++--- .../keyswithvalue/tables/KeysWithValue.sol | 12 ++--- .../tables/CallboundDelegations.sol | 12 ++--- .../tables/TimeboundDelegations.sol | 12 ++--- .../uniqueentity/tables/UniqueEntity.sol | 12 ++--- packages/world/src/tables/Delegations.sol | 12 ++--- .../world/src/tables/InstalledModules.sol | 12 ++--- packages/world/src/tables/NamespaceOwner.sol | 12 ++--- packages/world/src/tables/ResourceAccess.sol | 12 ++--- packages/world/test/tables/AddressArray.sol | 12 ++--- packages/world/test/tables/Bool.sol | 12 ++--- packages/world/test/tables/TwoFields.sol | 12 ++--- 34 files changed, 281 insertions(+), 304 deletions(-) diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 2316a4a763..b93e2f6411 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -126,13 +126,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField( - _tableId, - _keyTuple, - 0, - EncodeArray.encode(fromStaticArray_bytes32_1(staticB32)), - _fieldLayout - ); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32))); } /** Set staticB32 */ @@ -140,7 +134,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32))); } /** Set staticB32 (using the specified store) */ @@ -148,7 +142,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32))); } /** Get the length of staticB32 */ @@ -345,7 +339,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32))); } /** Set staticI32 */ @@ -353,7 +347,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32))); } /** Set staticI32 (using the specified store) */ @@ -361,7 +355,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32))); } /** Get the length of staticI32 */ @@ -558,13 +552,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField( - _tableId, - _keyTuple, - 2, - EncodeArray.encode(fromStaticArray_uint128_3(staticU128)), - _fieldLayout - ); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128))); } /** Set staticU128 */ @@ -572,7 +560,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128))); } /** Set staticU128 (using the specified store) */ @@ -580,7 +568,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128))); } /** Get the length of staticU128 */ @@ -777,13 +765,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField( - _tableId, - _keyTuple, - 3, - EncodeArray.encode(fromStaticArray_address_4(staticAddrs)), - _fieldLayout - ); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs))); } /** Set staticAddrs */ @@ -791,13 +773,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField( - _tableId, - _keyTuple, - 3, - EncodeArray.encode(fromStaticArray_address_4(staticAddrs)), - _fieldLayout - ); + StoreCore.setDynamicField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs))); } /** Set staticAddrs (using the specified store) */ @@ -805,7 +781,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs))); } /** Get the length of staticAddrs */ @@ -1002,7 +978,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools))); } /** Set staticBools */ @@ -1010,7 +986,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools))); } /** Set staticBools (using the specified store) */ @@ -1018,7 +994,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools))); } /** Get the length of staticBools */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index cd1ca1cbae..c7af992506 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -120,7 +120,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((u64))); } /** Set u64 */ @@ -128,7 +128,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((u64))); } /** Set u64 (using the specified store) */ @@ -136,7 +136,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((u64))); } /** Get the length of u64 */ @@ -333,7 +333,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, bytes((str)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, bytes((str))); } /** Set str */ @@ -341,7 +341,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 1, bytes((str)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 1, bytes((str))); } /** Set str (using the specified store) */ @@ -349,7 +349,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, bytes((str)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 1, bytes((str))); } /** Get the length of str */ @@ -546,7 +546,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, bytes((b)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 2, bytes((b))); } /** Set b */ @@ -554,7 +554,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 2, bytes((b)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 2, bytes((b))); } /** Set b (using the specified store) */ @@ -562,7 +562,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, bytes((b)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 2, bytes((b))); } /** Get the length of b */ diff --git a/packages/cli/contracts/src/codegen/tables/Offchain.sol b/packages/cli/contracts/src/codegen/tables/Offchain.sol index 5061275dc5..bc428c7f0c 100644 --- a/packages/cli/contracts/src/codegen/tables/Offchain.sol +++ b/packages/cli/contracts/src/codegen/tables/Offchain.sol @@ -83,7 +83,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -91,7 +91,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ @@ -99,7 +99,7 @@ library Offchain { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set the full data using individual values */ diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 438ca797f2..a5aba15c95 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -110,21 +110,21 @@ library Singleton { function setV1(int256 v1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); } /** Set v1 */ function _setV1(int256 v1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); } /** Set v1 (using the specified store) */ function setV1(IStore _store, int256 v1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); } /** Get v2 */ @@ -155,21 +155,21 @@ library Singleton { function setV2(uint32[2] memory v2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_uint32_2(v2))); } /** Set v2 */ function _setV2(uint32[2] memory v2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_uint32_2(v2))); } /** Set v2 (using the specified store) */ function setV2(IStore _store, uint32[2] memory v2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_uint32_2(v2))); } /** Get the length of v2 */ @@ -347,21 +347,21 @@ library Singleton { function setV3(uint32[2] memory v3) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v3))); } /** Set v3 */ function _setV3(uint32[2] memory v3) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v3))); } /** Set v3 (using the specified store) */ function setV3(IStore _store, uint32[2] memory v3) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v3))); } /** Get the length of v3 */ @@ -539,21 +539,21 @@ library Singleton { function setV4(uint32[1] memory v4) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_1(v4))); } /** Set v4 */ function _setV4(uint32[1] memory v4) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_1(v4))); } /** Set v4 (using the specified store) */ function setV4(IStore _store, uint32[1] memory v4) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_1(v4))); } /** Get the length of v4 */ diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index 4c3efebf84..2177a5282a 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -170,7 +170,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); } /** Set v1 */ @@ -183,7 +183,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); } /** Set v1 (using the specified store) */ @@ -196,7 +196,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), _fieldLayout); } /** Get v2 */ @@ -259,7 +259,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), _fieldLayout); } /** Set v2 */ @@ -272,7 +272,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), _fieldLayout); } /** Set v2 (using the specified store) */ @@ -285,7 +285,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), _fieldLayout); } /** Get v3 */ @@ -348,7 +348,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), _fieldLayout); } /** Set v3 */ @@ -361,7 +361,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), _fieldLayout); } /** Set v3 (using the specified store) */ @@ -374,7 +374,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), _fieldLayout); } /** Get v4 */ @@ -437,7 +437,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), _fieldLayout); } /** Set v4 */ @@ -450,7 +450,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), _fieldLayout); } /** Set v4 (using the specified store) */ @@ -463,7 +463,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), _fieldLayout); } /** Get v5 */ @@ -526,7 +526,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), _fieldLayout); } /** Set v5 */ @@ -539,7 +539,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), _fieldLayout); } /** Set v5 (using the specified store) */ @@ -552,7 +552,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), _fieldLayout); } /** Get v6 */ @@ -615,7 +615,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), _fieldLayout); } /** Set v6 */ @@ -628,7 +628,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), _fieldLayout); } /** Set v6 (using the specified store) */ @@ -641,7 +641,7 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), _fieldLayout); } /** Get the full data */ diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 7de7ef7730..1d72adc40f 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -351,7 +351,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 719562 + "gasUsed": 719171 }, { "file": "test/Mixed.t.sol", @@ -789,7 +789,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 641436 + "gasUsed": 641045 }, { "file": "test/StoreCoreGas.t.sol", @@ -975,7 +975,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: set field", - "gasUsed": 57063 + "gasUsed": 56289 }, { "file": "test/tables/Callbacks.t.sol", @@ -993,13 +993,13 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testOneSlot", "name": "StoreHooks: set field with one elements (cold)", - "gasUsed": 59069 + "gasUsed": 58295 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (cold)", - "gasUsed": 59069 + "gasUsed": 58295 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1041,19 +1041,19 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 31214 + "gasUsed": 30440 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testThreeSlots", "name": "StoreHooks: set field with three elements (cold)", - "gasUsed": 81757 + "gasUsed": 80983 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTwoSlots", "name": "StoreHooks: set field with two elements (cold)", - "gasUsed": 81669 + "gasUsed": 80895 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1143,7 +1143,7 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 442925 + "gasUsed": 442534 }, { "file": "test/Vector2.t.sol", diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index f62ffec498..a50463c044 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -137,7 +137,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -145,7 +145,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -153,7 +153,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -161,7 +161,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -169,7 +169,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -177,7 +177,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Get the length of value */ diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 9a0bfe03b8..06b74944e5 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -132,7 +132,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -140,7 +140,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -148,7 +148,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -156,7 +156,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -164,7 +164,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -172,7 +172,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Get the length of value */ diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 5f3b44f8fe..4beef6264b 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -229,7 +229,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -242,7 +242,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ @@ -264,7 +264,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -277,7 +277,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -290,7 +290,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ @@ -312,7 +312,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 1872ab959b..f964008522 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -123,7 +123,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), _fieldLayout); } /** Set u32 */ @@ -131,7 +131,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), _fieldLayout); } /** Set u32 (using the specified store) */ @@ -139,7 +139,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), _fieldLayout); } /** Get u128 */ @@ -174,7 +174,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), _fieldLayout); } /** Set u128 */ @@ -182,7 +182,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), _fieldLayout); } /** Set u128 (using the specified store) */ @@ -190,7 +190,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), _fieldLayout); } /** Get a32 */ @@ -225,7 +225,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((a32))); } /** Set a32 */ @@ -233,7 +233,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((a32))); } /** Set a32 (using the specified store) */ @@ -241,7 +241,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((a32))); } /** Get the length of a32 */ @@ -438,7 +438,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 3, bytes((s)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, bytes((s))); } /** Set s */ @@ -446,7 +446,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 3, bytes((s)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 1, bytes((s))); } /** Set s (using the specified store) */ @@ -454,7 +454,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 3, bytes((s)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 1, bytes((s))); } /** Get the length of s */ diff --git a/packages/store/src/codegen/tables/ResourceIds.sol b/packages/store/src/codegen/tables/ResourceIds.sol index b19c927b4f..742af60ce9 100644 --- a/packages/store/src/codegen/tables/ResourceIds.sol +++ b/packages/store/src/codegen/tables/ResourceIds.sol @@ -137,7 +137,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); } /** Set exists */ @@ -145,7 +145,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); } /** Set exists (using the specified store) */ @@ -153,7 +153,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); } /** Set exists */ @@ -161,7 +161,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); } /** Set exists */ @@ -169,7 +169,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); } /** Set exists (using the specified store) */ @@ -177,7 +177,7 @@ library ResourceIds { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((exists)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index fda7d18127..f783df6eaf 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -137,7 +137,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -145,7 +145,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -153,7 +153,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -161,7 +161,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -169,7 +169,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -177,7 +177,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Get the length of value */ diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index 834e6b1618..eae4edb798 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -126,7 +126,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((fieldLayout)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((fieldLayout)), _fieldLayout); } /** Set fieldLayout */ @@ -134,7 +134,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((fieldLayout)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((fieldLayout)), _fieldLayout); } /** Set fieldLayout (using the specified store) */ @@ -142,7 +142,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((fieldLayout)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((fieldLayout)), _fieldLayout); } /** Get keySchema */ @@ -177,7 +177,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((keySchema)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((keySchema)), _fieldLayout); } /** Set keySchema */ @@ -185,7 +185,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((keySchema)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((keySchema)), _fieldLayout); } /** Set keySchema (using the specified store) */ @@ -193,7 +193,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((keySchema)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((keySchema)), _fieldLayout); } /** Get valueSchema */ @@ -228,7 +228,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((valueSchema)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((valueSchema)), _fieldLayout); } /** Set valueSchema */ @@ -236,7 +236,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setField(_tableId, _keyTuple, 2, abi.encodePacked((valueSchema)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((valueSchema)), _fieldLayout); } /** Set valueSchema (using the specified store) */ @@ -244,7 +244,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((valueSchema)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((valueSchema)), _fieldLayout); } /** Get abiEncodedKeyNames */ @@ -282,7 +282,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 3, bytes((abiEncodedKeyNames)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((abiEncodedKeyNames))); } /** Set abiEncodedKeyNames */ @@ -290,7 +290,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setField(_tableId, _keyTuple, 3, bytes((abiEncodedKeyNames)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((abiEncodedKeyNames))); } /** Set abiEncodedKeyNames (using the specified store) */ @@ -298,7 +298,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 3, bytes((abiEncodedKeyNames)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, bytes((abiEncodedKeyNames))); } /** Get the length of abiEncodedKeyNames */ @@ -502,7 +502,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 4, bytes((abiEncodedFieldNames)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames))); } /** Set abiEncodedFieldNames */ @@ -510,7 +510,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreCore.setField(_tableId, _keyTuple, 4, bytes((abiEncodedFieldNames)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames))); } /** Set abiEncodedFieldNames (using the specified store) */ @@ -518,7 +518,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 4, bytes((abiEncodedFieldNames)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames))); } /** Get the length of abiEncodedFieldNames */ diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index 5d2d4d38dd..2a394dce5d 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -117,7 +117,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Set x */ @@ -125,7 +125,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Set x (using the specified store) */ @@ -133,7 +133,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Get y */ @@ -168,7 +168,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Set y */ @@ -176,7 +176,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Set y (using the specified store) */ @@ -184,7 +184,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Get the full data */ diff --git a/packages/store/ts/codegen/field.ts b/packages/store/ts/codegen/field.ts index 895301622e..54e7d26390 100644 --- a/packages/store/ts/codegen/field.ts +++ b/packages/store/ts/codegen/field.ts @@ -55,21 +55,22 @@ export function renderFieldMethods(options: RenderTableOptions) { } result += renderWithFieldSuffix(options.withSuffixlessFieldMethods, field.name, (_methodNameSuffix) => - renderWithStore( - storeArgument, - (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => ` + renderWithStore(storeArgument, (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => { + const externalArguments = renderArguments([_typedStore, _typedTableId, _typedKeyArgs, _typedFieldName]); + const setFieldMethod = field.isDynamic ? "setDynamicField" : "setStaticField"; + const encodeFieldSingle = renderEncodeFieldSingle(field); + const internalArguments = field.isDynamic + ? `_tableId, _keyTuple, ${schemaIndex - options.staticFields.length}, ${encodeFieldSingle}` + : `_tableId, _keyTuple, ${schemaIndex}, ${encodeFieldSingle}, _fieldLayout`; + + return ` /** Set ${field.name}${_commentSuffix} */ - function ${_methodNamePrefix}set${_methodNameSuffix}(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - _typedFieldName, - ])}) internal { + function ${_methodNamePrefix}set${_methodNameSuffix}(${externalArguments}) internal { ${_keyTupleDefinition} - ${_store}.setField(_tableId, _keyTuple, ${schemaIndex}, ${renderEncodeFieldSingle(field)}, _fieldLayout); + ${_store}.${setFieldMethod}(${internalArguments}); } - ` - ) + `; + }) ); if (field.isDynamic) { diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index a06eb1e104..7bc41a6546 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,13 +39,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1410222 + "gasUsed": 1408267 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1410222 + "gasUsed": 1408267 }, { "file": "test/KeysInTableModule.t.sol", @@ -57,13 +57,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1410222 + "gasUsed": 1408267 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1410222 + "gasUsed": 1408267 }, { "file": "test/KeysInTableModule.t.sol", @@ -75,13 +75,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 155647 + "gasUsed": 155212 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1410222 + "gasUsed": 1408267 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,13 +93,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 84731 + "gasUsed": 84296 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 651792 + "gasUsed": 649446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,7 +117,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 651792 + "gasUsed": 649446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -129,13 +129,13 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 651792 + "gasUsed": 649446 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 104742 + "gasUsed": 103936 }, { "file": "test/KeysWithValueModule.t.sol", @@ -147,7 +147,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 651792 + "gasUsed": 649446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -231,7 +231,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 113885 + "gasUsed": 113103 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -243,7 +243,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 108380 + "gasUsed": 107598 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -255,25 +255,25 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 679091 + "gasUsed": 675963 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51637 + "gasUsed": 51202 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 646365 + "gasUsed": 643237 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51637 + "gasUsed": 51202 }, { "file": "test/World.t.sol", @@ -285,7 +285,7 @@ "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 50215 + "gasUsed": 49824 }, { "file": "test/World.t.sol", @@ -315,7 +315,7 @@ "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 122188 + "gasUsed": 121015 }, { "file": "test/World.t.sol", @@ -327,13 +327,13 @@ "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 163987 + "gasUsed": 162814 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 639235 + "gasUsed": 637671 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/modules/core/tables/Balances.sol b/packages/world/src/modules/core/tables/Balances.sol index 14927eae86..eef3ceabe6 100644 --- a/packages/world/src/modules/core/tables/Balances.sol +++ b/packages/world/src/modules/core/tables/Balances.sol @@ -137,7 +137,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); } /** Set balance */ @@ -145,7 +145,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); } /** Set balance (using the specified store) */ @@ -153,7 +153,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); } /** Set balance */ @@ -161,7 +161,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); } /** Set balance */ @@ -169,7 +169,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); } /** Set balance (using the specified store) */ @@ -177,7 +177,7 @@ library Balances { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((balance)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index cab6323d44..9e8cdb6c2f 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -112,7 +112,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId */ @@ -120,7 +120,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId (using the specified store) */ @@ -128,7 +128,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Get systemFunctionSelector */ @@ -166,7 +166,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((systemFunctionSelector)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((systemFunctionSelector)), _fieldLayout); } /** Set systemFunctionSelector */ @@ -174,7 +174,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((systemFunctionSelector)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((systemFunctionSelector)), _fieldLayout); } /** Set systemFunctionSelector (using the specified store) */ @@ -182,7 +182,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((systemFunctionSelector)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((systemFunctionSelector)), _fieldLayout); } /** Get the full data */ diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 7c2203549e..2724bd790f 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -137,7 +137,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -145,7 +145,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -153,7 +153,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -161,7 +161,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -169,7 +169,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -177,7 +177,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Get the length of value */ diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/modules/core/tables/SystemRegistry.sol index f1f5134903..b68751af45 100644 --- a/packages/world/src/modules/core/tables/SystemRegistry.sol +++ b/packages/world/src/modules/core/tables/SystemRegistry.sol @@ -137,7 +137,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId */ @@ -145,7 +145,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId (using the specified store) */ @@ -153,7 +153,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId */ @@ -161,7 +161,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId */ @@ -169,7 +169,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Set systemId (using the specified store) */ @@ -177,7 +177,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((systemId)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index 227450dbd4..0f3f44acc3 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -112,7 +112,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((system)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((system)), _fieldLayout); } /** Set system */ @@ -120,7 +120,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((system)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((system)), _fieldLayout); } /** Set system (using the specified store) */ @@ -128,7 +128,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((system)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((system)), _fieldLayout); } /** Get publicAccess */ @@ -163,7 +163,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), _fieldLayout); } /** Set publicAccess */ @@ -171,7 +171,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), _fieldLayout); } /** Set publicAccess (using the specified store) */ @@ -179,7 +179,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), _fieldLayout); } /** Get the full data */ diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 264b6a2b15..2a52bc2148 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -126,7 +126,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0))); } /** Set keys0 */ @@ -134,7 +134,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0))); } /** Set keys0 (using the specified store) */ @@ -142,7 +142,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0))); } /** Get the length of keys0 */ @@ -339,7 +339,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1))); } /** Set keys1 */ @@ -347,7 +347,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1))); } /** Set keys1 (using the specified store) */ @@ -355,7 +355,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1))); } /** Get the length of keys1 */ @@ -552,7 +552,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2))); } /** Set keys2 */ @@ -560,7 +560,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2))); } /** Set keys2 (using the specified store) */ @@ -568,7 +568,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2))); } /** Get the length of keys2 */ @@ -765,7 +765,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3))); } /** Set keys3 */ @@ -773,7 +773,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3))); } /** Set keys3 (using the specified store) */ @@ -781,7 +781,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3))); } /** Get the length of keys3 */ @@ -978,7 +978,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4))); } /** Set keys4 */ @@ -986,7 +986,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreCore.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4))); } /** Set keys4 (using the specified store) */ @@ -994,7 +994,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4))); } /** Get the length of keys4 */ diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index f4e9e04f03..5aa4220250 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -118,7 +118,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((has)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((has)), _fieldLayout); } /** Set has */ @@ -127,7 +127,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((has)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((has)), _fieldLayout); } /** Set has (using the specified store) */ @@ -136,7 +136,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((has)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((has)), _fieldLayout); } /** Get index */ @@ -175,7 +175,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((index)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((index)), _fieldLayout); } /** Set index */ @@ -184,7 +184,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((index)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((index)), _fieldLayout); } /** Set index (using the specified store) */ @@ -193,7 +193,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((index)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((index)), _fieldLayout); } /** Get the full data */ diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 4a94899466..61b964f260 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -146,7 +146,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); } /** Set keysWithValue */ @@ -154,7 +154,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); } /** Set keysWithValue (using the specified store) */ @@ -167,7 +167,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); } /** Set keysWithValue */ @@ -175,7 +175,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); } /** Set keysWithValue */ @@ -183,7 +183,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); } /** Set keysWithValue (using the specified store) */ @@ -191,7 +191,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); } /** Get the length of keysWithValue */ diff --git a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol index 210dd539c0..cdf4002f24 100644 --- a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol @@ -202,7 +202,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); } /** Set availableCalls */ @@ -219,7 +219,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); } /** Set availableCalls (using the specified store) */ @@ -237,7 +237,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); } /** Set availableCalls */ @@ -254,7 +254,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); } /** Set availableCalls */ @@ -271,7 +271,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); } /** Set availableCalls (using the specified store) */ @@ -289,7 +289,7 @@ library CallboundDelegations { _keyTuple[2] = systemId; _keyTuple[3] = callDataHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((availableCalls)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol index 7e0bda7ba1..977442857c 100644 --- a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol @@ -150,7 +150,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); } /** Set maxTimestamp */ @@ -159,7 +159,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); } /** Set maxTimestamp (using the specified store) */ @@ -168,7 +168,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); } /** Set maxTimestamp */ @@ -177,7 +177,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); } /** Set maxTimestamp */ @@ -186,7 +186,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); } /** Set maxTimestamp (using the specified store) */ @@ -195,7 +195,7 @@ library TimeboundDelegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((maxTimestamp)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol index ab30bdd69a..a62887d571 100644 --- a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -123,42 +123,42 @@ library UniqueEntity { function setValue(ResourceId _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _setValue(ResourceId _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function setValue(IStore _store, ResourceId _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function set(ResourceId _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _set(ResourceId _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function set(IStore _store, ResourceId _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/tables/Delegations.sol b/packages/world/src/tables/Delegations.sol index d12fcbca72..5e02211c4e 100644 --- a/packages/world/src/tables/Delegations.sol +++ b/packages/world/src/tables/Delegations.sol @@ -160,7 +160,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); } /** Set delegationControlId */ @@ -169,7 +169,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); } /** Set delegationControlId (using the specified store) */ @@ -183,7 +183,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); } /** Set delegationControlId */ @@ -192,7 +192,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); } /** Set delegationControlId */ @@ -201,7 +201,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); } /** Set delegationControlId (using the specified store) */ @@ -210,7 +210,7 @@ library Delegations { _keyTuple[0] = bytes32(uint256(uint160(delegator))); _keyTuple[1] = bytes32(uint256(uint160(delegatee))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((delegationControlId)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/tables/InstalledModules.sol index 8a0005ee43..e030d1fec9 100644 --- a/packages/world/src/tables/InstalledModules.sol +++ b/packages/world/src/tables/InstalledModules.sol @@ -150,7 +150,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); } /** Set moduleAddress */ @@ -159,7 +159,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); } /** Set moduleAddress (using the specified store) */ @@ -168,7 +168,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); } /** Set moduleAddress */ @@ -177,7 +177,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); } /** Set moduleAddress */ @@ -186,7 +186,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); } /** Set moduleAddress (using the specified store) */ @@ -195,7 +195,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/tables/NamespaceOwner.sol index cea312d83f..b47c56e645 100644 --- a/packages/world/src/tables/NamespaceOwner.sol +++ b/packages/world/src/tables/NamespaceOwner.sol @@ -137,7 +137,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); } /** Set owner */ @@ -145,7 +145,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); } /** Set owner (using the specified store) */ @@ -153,7 +153,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); } /** Set owner */ @@ -161,7 +161,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); } /** Set owner */ @@ -169,7 +169,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); } /** Set owner (using the specified store) */ @@ -177,7 +177,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = namespaceId; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/tables/ResourceAccess.sol index 9ae2048d93..37c4d3266b 100644 --- a/packages/world/src/tables/ResourceAccess.sol +++ b/packages/world/src/tables/ResourceAccess.sol @@ -146,7 +146,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); } /** Set access */ @@ -155,7 +155,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); } /** Set access (using the specified store) */ @@ -164,7 +164,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); } /** Set access */ @@ -173,7 +173,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); } /** Set access */ @@ -182,7 +182,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); } /** Set access (using the specified store) */ @@ -191,7 +191,7 @@ library ResourceAccess { _keyTuple[0] = resourceId; _keyTuple[1] = bytes32(uint256(uint160(caller))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((access)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 25ef87db20..41a7a1153d 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -132,7 +132,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -140,7 +140,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -148,7 +148,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -156,7 +156,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ @@ -164,7 +164,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ @@ -172,7 +172,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Get the length of value */ diff --git a/packages/world/test/tables/Bool.sol b/packages/world/test/tables/Bool.sol index f3393ea938..e110386002 100644 --- a/packages/world/test/tables/Bool.sol +++ b/packages/world/test/tables/Bool.sol @@ -123,42 +123,42 @@ library Bool { function setValue(ResourceId _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _setValue(ResourceId _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function setValue(IStore _store, ResourceId _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function set(ResourceId _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _set(ResourceId _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function set(IStore _store, ResourceId _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/packages/world/test/tables/TwoFields.sol b/packages/world/test/tables/TwoFields.sol index 0aaac3b8bd..8685868093 100644 --- a/packages/world/test/tables/TwoFields.sol +++ b/packages/world/test/tables/TwoFields.sol @@ -106,21 +106,21 @@ library TwoFields { function setValue1(ResourceId _tableId, bool value1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); } /** Set value1 */ function _setValue1(ResourceId _tableId, bool value1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); } /** Set value1 (using the specified store) */ function setValue1(IStore _store, ResourceId _tableId, bool value1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); } /** Get value2 */ @@ -151,21 +151,21 @@ library TwoFields { function setValue2(ResourceId _tableId, bool value2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); } /** Set value2 */ function _setValue2(ResourceId _tableId, bool value2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); } /** Set value2 (using the specified store) */ function setValue2(IStore _store, ResourceId _tableId, bool value2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); } /** Get the full data */ From a503e72a99e3069bf650e28122166b6673ece77a Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 20:22:26 +0100 Subject: [PATCH 26/38] add overloads for getRecord, getField, getFieldLength and setField that load fieldLayout from storage and add getDynamicFieldLength --- packages/store/gas-report.json | 68 +++++++++++++++---------------- packages/store/src/IStore.sol | 42 ++++++++++++++++++- packages/store/src/StoreCore.sol | 58 +++++++++++++++++++++++--- packages/store/src/StoreRead.sol | 31 ++++++++++++++ packages/store/test/StoreMock.sol | 10 +++++ packages/world/src/World.sol | 17 ++++++++ packages/world/test/World.t.sol | 6 ++- 7 files changed, 189 insertions(+), 43 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 1d72adc40f..1a55795e5c 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -627,49 +627,49 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetSecondFieldLength", "name": "get field length (cold, 1 slot)", - "gasUsed": 7754 + "gasUsed": 7795 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetSecondFieldLength", "name": "get field length (warm, 1 slot)", - "gasUsed": 1749 + "gasUsed": 1790 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetThirdFieldLength", "name": "get field length (warm due to , 2 slots)", - "gasUsed": 7753 + "gasUsed": 7794 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetThirdFieldLength", "name": "get field length (warm, 2 slots)", - "gasUsed": 1749 + "gasUsed": 1790 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (cold, 1 slot, 1 uint32 item)", - "gasUsed": 18692 + "gasUsed": 18696 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (warm, 1 slot, 1 uint32 item)", - "gasUsed": 12700 + "gasUsed": 12704 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 16460 + "gasUsed": 16464 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (warm, 2 slots, 10 uint32 items)", - "gasUsed": 12468 + "gasUsed": 12472 }, { "file": "test/StoreCoreGas.t.sol", @@ -687,19 +687,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 2059 + "gasUsed": 2063 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access length of dynamic field of non-existing record", - "gasUsed": 1118 + "gasUsed": 1159 }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 8073 + "gasUsed": 8077 }, { "file": "test/StoreCoreGas.t.sol", @@ -729,67 +729,67 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 57983 + "gasUsed": 57987 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 72420 + "gasUsed": 72493 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 19907 + "gasUsed": 19893 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18733 + "gasUsed": 18719 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 57983 + "gasUsed": 57987 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 165575 + "gasUsed": 165648 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 24482 + "gasUsed": 24513 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 20399 + "gasUsed": 20385 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 9488 + "gasUsed": 9492 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (2 slots, 10 uint32 items)", - "gasUsed": 32158 + "gasUsed": 32162 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 641045 + "gasUsed": 641053 }, { "file": "test/StoreCoreGas.t.sol", @@ -813,7 +813,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 102585 + "gasUsed": 102589 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +855,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (1 slot)", - "gasUsed": 31282 + "gasUsed": 31286 }, { "file": "test/StoreCoreGas.t.sol", @@ -867,7 +867,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 29935 + "gasUsed": 29939 }, { "file": "test/StoreCoreGas.t.sol", @@ -879,31 +879,31 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53974 + "gasUsed": 53978 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, first dynamic field)", - "gasUsed": 2226 + "gasUsed": 2230 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, second dynamic field)", - "gasUsed": 32197 + "gasUsed": 32201 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2229 + "gasUsed": 2233 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 32829 + "gasUsed": 32833 }, { "file": "test/StoreCoreGas.t.sol", @@ -915,7 +915,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55333 + "gasUsed": 55337 }, { "file": "test/StoreCoreGas.t.sol", @@ -927,13 +927,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 8986 + "gasUsed": 8990 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "push to field (2 slots, 6 uint64 items)", - "gasUsed": 9432 + "gasUsed": 9436 }, { "file": "test/StoreHook.t.sol", @@ -1077,7 +1077,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testLength", "name": "StoreHooks: get length (cold)", - "gasUsed": 5865 + "gasUsed": 5906 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 7c71b1afa5..ed2c1340a4 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -20,7 +20,15 @@ interface IStoreRead { function getKeySchema(ResourceId tableId) external view returns (Schema keySchema); /** - * Get full record (all fields, static and dynamic data) for the given tableId and key tuple, with the given value field layout + * Get full record (all fields, static and dynamic data) for the given tableId and key tuple, loading the field layout from storage + */ + function getRecord( + ResourceId tableId, + bytes32[] calldata keyTuple + ) external view returns (bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData); + + /** + * Get full record (all fields, static and dynamic data) for the given tableId and key tuple, with the given field layout */ function getRecord( ResourceId tableId, @@ -29,7 +37,16 @@ interface IStoreRead { ) external view returns (bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData); /** - * Get a single field from the given tableId and key tuple, with the given value field layout + * Get a single field from the given tableId and key tuple, loading the field layout from storage + */ + function getField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex + ) external view returns (bytes memory data); + + /** + * Get a single field from the given tableId and key tuple, with the given field layout */ function getField( ResourceId tableId, @@ -60,6 +77,15 @@ interface IStoreRead { uint8 dynamicFieldIndex ) external view returns (bytes memory); + /** + * Get the byte length of a single field from the given tableId and key tuple, loading the field layout from storage + */ + function getFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex + ) external view returns (uint256); + /** * Get the byte length of a single field from the given tableId and key tuple, with the given value field layout */ @@ -70,6 +96,15 @@ interface IStoreRead { FieldLayout fieldLayout ) external view returns (uint256); + /** + * Get the byte length of a single dynamic field from the given tableId and key tuple + */ + function getDynamicFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 dynamicFieldIndex + ) external view returns (uint256); + /** * Get a byte slice (including start, excluding end) of a single dynamic field from the given tableId and key tuple, with the given value field layout. * The slice is unchecked and will return invalid data if `start`:`end` overflow. @@ -129,6 +164,9 @@ interface IStoreWrite { bytes calldata data ) external; + // Set partial data at field index + function setField(ResourceId tableId, bytes32[] calldata keyTuple, uint8 fieldIndex, bytes calldata data) external; + // Set partial data at field index function setField( ResourceId tableId, diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 04a2eb9c2e..55545e8fb6 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -370,7 +370,14 @@ library StoreCore { } /** - * Set data for a field in a table with the given tableId, key tuple and value field layout + * Set data for a field at the given index in a table with the given tableId, key tuple, loading the field layout from storage + */ + function setField(ResourceId tableId, bytes32[] memory keyTuple, uint8 fieldIndex, bytes memory data) internal { + setField(tableId, keyTuple, fieldIndex, data, getFieldLayout(tableId)); + } + + /** + * Set data for a field at the given index in a table with the given tableId, key tuple and value field layout */ function setField( ResourceId tableId, @@ -559,7 +566,17 @@ library StoreCore { ************************************************************************/ /** - * Get full record (all fields, static and dynamic data) for the given table ID and key tuple, with the given value field layout + * Get full record (all fields, static and dynamic data) for the given table ID and key tuple, loading the field layout from storage + */ + function getRecord( + ResourceId tableId, + bytes32[] memory keyTuple + ) internal view returns (bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData) { + return getRecord(tableId, keyTuple, getFieldLayout(tableId)); + } + + /** + * Get full record (all fields, static and dynamic data) for the given table ID and key tuple, with the given field layout */ function getRecord( ResourceId tableId, @@ -592,6 +609,17 @@ library StoreCore { } } + /** + * Get a single field from the given table ID and key tuple, loading the field layout from storage + */ + function getField( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex + ) internal view returns (bytes memory) { + return getField(tableId, keyTuple, fieldIndex, getFieldLayout(tableId)); + } + /** * Get a single field from the given table ID and key tuple, with the given value field layout */ @@ -647,6 +675,17 @@ library StoreCore { }); } + /** + * Get the byte length of a single field from the given table ID and key tuple + */ + function getFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex + ) internal view returns (uint256) { + return getFieldLength(tableId, keyTuple, fieldIndex, getFieldLayout(tableId)); + } + /** * Get the byte length of a single field from the given table ID and key tuple, with the given value field layout */ @@ -660,12 +699,21 @@ library StoreCore { if (fieldIndex < numStaticFields) { return fieldLayout.atIndex(fieldIndex); } else { - // Get the length and storage location of the dynamic field - uint8 dynamicFieldLayoutIndex = fieldIndex - numStaticFields; - return StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple).atIndex(dynamicFieldLayoutIndex); + return getDynamicFieldLength(tableId, keyTuple, fieldIndex - numStaticFields); } } + /** + * Get the byte length of a single dynamic field from the given table ID and key tuple + */ + function getDynamicFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 dynamicFieldIndex + ) internal view returns (uint256) { + return StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple).atIndex(dynamicFieldIndex); + } + /** * Get a byte slice (including start, excluding end) of a single dynamic field from the given table ID and key tuple, with the given value field layout. */ diff --git a/packages/store/src/StoreRead.sol b/packages/store/src/StoreRead.sol index cc3630fb69..a9720b6907 100644 --- a/packages/store/src/StoreRead.sol +++ b/packages/store/src/StoreRead.sol @@ -26,6 +26,13 @@ contract StoreRead is IStoreRead { keySchema = StoreCore.getKeySchema(tableId); } + function getRecord( + ResourceId tableId, + bytes32[] calldata keyTuple + ) public view virtual returns (bytes memory staticData, PackedCounter encodedLengths, bytes memory dynamicData) { + return StoreCore.getRecord(tableId, keyTuple); + } + function getRecord( ResourceId tableId, bytes32[] calldata keyTuple, @@ -34,6 +41,14 @@ contract StoreRead is IStoreRead { return StoreCore.getRecord(tableId, keyTuple, fieldLayout); } + function getField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex + ) public view virtual returns (bytes memory data) { + data = StoreCore.getField(tableId, keyTuple, fieldIndex); + } + function getField( ResourceId tableId, bytes32[] calldata keyTuple, @@ -60,6 +75,14 @@ contract StoreRead is IStoreRead { data = StoreCore.getDynamicField(tableId, keyTuple, dynamicFieldIndex); } + function getFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex + ) public view virtual returns (uint256) { + return StoreCore.getFieldLength(tableId, keyTuple, fieldIndex); + } + function getFieldLength( ResourceId tableId, bytes32[] memory keyTuple, @@ -69,6 +92,14 @@ contract StoreRead is IStoreRead { return StoreCore.getFieldLength(tableId, keyTuple, fieldIndex, fieldLayout); } + function getDynamicFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 dynamicFieldIndex + ) public view virtual returns (uint256) { + return StoreCore.getFieldLength(tableId, keyTuple, dynamicFieldIndex); + } + function getDynamicFieldSlice( ResourceId tableId, bytes32[] memory keyTuple, diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index a6e5e6ad2c..09a8550cf4 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -51,6 +51,16 @@ contract StoreMock is IStore, StoreRead { StoreCore.spliceDynamicData(tableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data); } + // Set partial data at field index + function setField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex, + bytes calldata data + ) public virtual { + StoreCore.setField(tableId, keyTuple, fieldIndex, data); + } + // Set partial data at field index function setField( ResourceId tableId, diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 9ed88cbdd9..8f8ecf65e1 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -154,6 +154,23 @@ contract World is StoreRead, IStoreData, IWorldKernel { StoreCore.spliceDynamicData(tableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data); } + /** + * Write a field in the table at the given tableId. + * Requires the caller to have access to the table's namespace or name (encoded in the tableId). + */ + function setField( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint8 fieldIndex, + bytes calldata data + ) public virtual requireNoCallback { + // Require access to namespace or name + AccessControl.requireAccess(tableId, msg.sender); + + // Set the field + StoreCore.setField(tableId, keyTuple, fieldIndex, data); + } + /** * Write a field in the table at the given tableId. * Requires the caller to have access to the table's namespace or name (encoded in the tableId). diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index e81fae20bb..62f9cd4796 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -787,8 +787,10 @@ contract WorldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.setField.selector)); - world.setField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.setStaticField.selector) + ); + world.setStaticField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); } function testPushToDynamicField() public { From 5df9270b921cc7fefd44662c7a30080d5d7c66b4 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 20:28:53 +0100 Subject: [PATCH 27/38] use getDynamicFieldLength in codegen --- .../src/codegen/tables/Dynamics1.sol | 30 +++--- .../src/codegen/tables/Dynamics2.sol | 18 ++-- .../src/codegen/tables/Singleton.sol | 18 ++-- packages/store/gas-report.json | 2 +- packages/store/src/StoreSwitch.sol | 60 ++++++++++++ .../store/src/codegen/tables/Callbacks.sol | 12 +-- packages/store/src/codegen/tables/Hooks.sol | 12 +-- packages/store/src/codegen/tables/Mixed.sol | 12 +-- .../store/src/codegen/tables/StoreHooks.sol | 12 +-- packages/store/src/codegen/tables/Tables.sol | 12 +-- packages/store/ts/codegen/field.ts | 2 +- packages/world/gas-report.json | 96 +++++++++---------- .../src/modules/core/tables/SystemHooks.sol | 12 +-- .../keysintable/tables/KeysInTable.sol | 30 +++--- .../keyswithvalue/tables/KeysWithValue.sol | 12 +-- packages/world/test/tables/AddressArray.sol | 12 +-- 16 files changed, 206 insertions(+), 146 deletions(-) diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index b93e2f6411..fee35f90d1 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -150,7 +150,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -161,7 +161,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -172,7 +172,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -363,7 +363,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 4; } @@ -374,7 +374,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 4; } @@ -385,7 +385,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 4; } @@ -576,7 +576,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 16; } @@ -587,7 +587,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 16; } @@ -598,7 +598,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 16; } @@ -789,7 +789,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 3); unchecked { return _byteLength / 20; } @@ -800,7 +800,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 3); unchecked { return _byteLength / 20; } @@ -811,7 +811,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 3); unchecked { return _byteLength / 20; } @@ -1002,7 +1002,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 4); unchecked { return _byteLength / 1; } @@ -1013,7 +1013,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 4); unchecked { return _byteLength / 1; } @@ -1024,7 +1024,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 4); unchecked { return _byteLength / 1; } diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index c7af992506..d3767a797c 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -144,7 +144,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 8; } @@ -155,7 +155,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 8; } @@ -166,7 +166,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 8; } @@ -357,7 +357,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -368,7 +368,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -379,7 +379,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -570,7 +570,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 1; } @@ -581,7 +581,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 1; } @@ -592,7 +592,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 1; } diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index a5aba15c95..a7b8171af7 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -176,7 +176,7 @@ library Singleton { function lengthV2() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -186,7 +186,7 @@ library Singleton { function _lengthV2() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -196,7 +196,7 @@ library Singleton { function lengthV2(IStore _store) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -368,7 +368,7 @@ library Singleton { function lengthV3() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 4; } @@ -378,7 +378,7 @@ library Singleton { function _lengthV3() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 4; } @@ -388,7 +388,7 @@ library Singleton { function lengthV3(IStore _store) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 4; } @@ -560,7 +560,7 @@ library Singleton { function lengthV4() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 4; } @@ -570,7 +570,7 @@ library Singleton { function _lengthV4() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 4; } @@ -580,7 +580,7 @@ library Singleton { function lengthV4(IStore _store) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 4; } diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 1a55795e5c..0a89272ae2 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -1077,7 +1077,7 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testLength", "name": "StoreHooks: get length (cold)", - "gasUsed": 5906 + "gasUsed": 5394 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 93d7d357a0..27530c562b 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -157,6 +157,15 @@ library StoreSwitch { } } + function setField(ResourceId tableId, bytes32[] memory keyTuple, uint8 fieldIndex, bytes memory data) internal { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + StoreCore.setField(tableId, keyTuple, fieldIndex, data); + } else { + IStore(_storeAddress).setField(tableId, keyTuple, fieldIndex, data); + } + } + function setField( ResourceId tableId, bytes32[] memory keyTuple, @@ -253,6 +262,18 @@ library StoreSwitch { } } + function getRecord( + ResourceId tableId, + bytes32[] memory keyTuple + ) internal view returns (bytes memory, PackedCounter, bytes memory) { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + return StoreCore.getRecord(tableId, keyTuple); + } else { + return IStore(_storeAddress).getRecord(tableId, keyTuple); + } + } + function getRecord( ResourceId tableId, bytes32[] memory keyTuple, @@ -266,6 +287,19 @@ library StoreSwitch { } } + function getField( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex + ) internal view returns (bytes memory) { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + return StoreCore.getField(tableId, keyTuple, fieldIndex); + } else { + return IStore(_storeAddress).getField(tableId, keyTuple, fieldIndex); + } + } + function getField( ResourceId tableId, bytes32[] memory keyTuple, @@ -307,6 +341,19 @@ library StoreSwitch { } } + function getFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 fieldIndex + ) internal view returns (uint256) { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + return StoreCore.getFieldLength(tableId, keyTuple, fieldIndex); + } else { + return IStore(_storeAddress).getFieldLength(tableId, keyTuple, fieldIndex); + } + } + function getFieldLength( ResourceId tableId, bytes32[] memory keyTuple, @@ -321,6 +368,19 @@ library StoreSwitch { } } + function getDynamicFieldLength( + ResourceId tableId, + bytes32[] memory keyTuple, + uint8 dynamicFieldIndex + ) internal view returns (uint256) { + address _storeAddress = getStoreAddress(); + if (_storeAddress == address(this)) { + return StoreCore.getDynamicFieldLength(tableId, keyTuple, dynamicFieldIndex); + } else { + return IStore(_storeAddress).getDynamicFieldLength(tableId, keyTuple, dynamicFieldIndex); + } + } + function getDynamicFieldSlice( ResourceId tableId, bytes32[] memory keyTuple, diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index a50463c044..415a1c4f66 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -185,7 +185,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 24; } @@ -196,7 +196,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 24; } @@ -207,7 +207,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 24; } @@ -218,7 +218,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 24; } @@ -229,7 +229,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 24; } @@ -240,7 +240,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 24; } diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 06b74944e5..91f9136c05 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -180,7 +180,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -191,7 +191,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -202,7 +202,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -213,7 +213,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -224,7 +224,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -235,7 +235,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index f964008522..452a27f0c9 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -249,7 +249,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -260,7 +260,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -271,7 +271,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -462,7 +462,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -473,7 +473,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -484,7 +484,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index f783df6eaf..2a1153f17f 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -185,7 +185,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -196,7 +196,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -207,7 +207,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -218,7 +218,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -229,7 +229,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -240,7 +240,7 @@ library StoreHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index eae4edb798..39a10fdec1 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -306,7 +306,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } @@ -317,7 +317,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } @@ -328,7 +328,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 1; } @@ -526,7 +526,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -537,7 +537,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } @@ -548,7 +548,7 @@ library Tables { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 1; } diff --git a/packages/store/ts/codegen/field.ts b/packages/store/ts/codegen/field.ts index 54e7d26390..457b2e8c8a 100644 --- a/packages/store/ts/codegen/field.ts +++ b/packages/store/ts/codegen/field.ts @@ -89,7 +89,7 @@ export function renderFieldMethods(options: RenderTableOptions) { _typedKeyArgs, ])}) internal view returns (uint256) { ${_keyTupleDefinition} - uint256 _byteLength = ${_store}.getFieldLength(_tableId, _keyTuple, ${schemaIndex}, _fieldLayout); + uint256 _byteLength = ${_store}.getDynamicFieldLength(_tableId, _keyTuple, ${dynamicSchemaIndex}); unchecked { return _byteLength / ${portionData.elementLength}; } diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 7bc41a6546..a7dc136a89 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,31 +39,31 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1408267 + "gasUsed": 1408378 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1408267 + "gasUsed": 1408378 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 158056 + "gasUsed": 158958 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1408267 + "gasUsed": 1408378 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1408267 + "gasUsed": 1408378 }, { "file": "test/KeysInTableModule.t.sol", @@ -75,13 +75,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 155212 + "gasUsed": 156295 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1408267 + "gasUsed": 1408378 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,19 +93,19 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 84296 + "gasUsed": 85289 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 649446 + "gasUsed": 649535 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "Get list of keys with a given value", - "gasUsed": 5690 + "gasUsed": 5712 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,163 +117,163 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 649446 + "gasUsed": 649535 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 135603 + "gasUsed": 135647 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 649446 + "gasUsed": 649535 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 103936 + "gasUsed": 104002 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36648 + "gasUsed": 36693 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 649446 + "gasUsed": 649535 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 146811 + "gasUsed": 146878 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 111570 + "gasUsed": 111637 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 102328 + "gasUsed": 104977 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 52608 + "gasUsed": 53535 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 126871 + "gasUsed": 131154 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 80811 + "gasUsed": 84321 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 82379 + "gasUsed": 84984 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueQuery", "name": "CombinedHasValueQuery", - "gasUsed": 15661 + "gasUsed": 15705 }, { "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 17955 + "gasUsed": 18838 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5825614 + "gasUsed": 5804541 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 542767 + "gasUsed": 541494 }, { "file": "test/query.t.sol", "test": "testHasValueQuery", "name": "HasValueQuery", - "gasUsed": 7499 + "gasUsed": 7521 }, { "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 46204 + "gasUsed": 47131 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 113103 + "gasUsed": 113124 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36672 + "gasUsed": 36737 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 107598 + "gasUsed": 107619 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26757 + "gasUsed": 26822 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 675963 + "gasUsed": 676029 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 51202 + "gasUsed": 51180 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 643237 + "gasUsed": 643348 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 51202 + "gasUsed": 51180 }, { "file": "test/World.t.sol", @@ -285,37 +285,37 @@ "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 49824 + "gasUsed": 49845 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "call a system via an unlimited delegation", - "gasUsed": 12774 + "gasUsed": 12839 }, { "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9933 + "gasUsed": 9911 }, { "file": "test/World.t.sol", "test": "testPushToDynamicField", "name": "Push data to the table", - "gasUsed": 85901 + "gasUsed": 85856 }, { "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 83249 + "gasUsed": 83271 }, { "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 121015 + "gasUsed": 121037 }, { "file": "test/World.t.sol", @@ -327,7 +327,7 @@ "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 162814 + "gasUsed": 162836 }, { "file": "test/World.t.sol", @@ -339,25 +339,25 @@ "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 36933 + "gasUsed": 36955 }, { "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 36948 + "gasUsed": 36970 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromDyanmicField", "name": "pop 1 address (cold)", - "gasUsed": 23647 + "gasUsed": 23714 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromDyanmicField", "name": "pop 1 address (warm)", - "gasUsed": 12793 + "gasUsed": 12860 }, { "file": "test/WorldDynamicUpdate.t.sol", diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 2724bd790f..d08648b1bf 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -185,7 +185,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -196,7 +196,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -207,7 +207,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -218,7 +218,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -229,7 +229,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } @@ -240,7 +240,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = systemId; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 21; } diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 2a52bc2148..3d62bfffb1 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -150,7 +150,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -161,7 +161,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -172,7 +172,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -363,7 +363,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 32; } @@ -374,7 +374,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 32; } @@ -385,7 +385,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 1, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 1); unchecked { return _byteLength / 32; } @@ -576,7 +576,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 32; } @@ -587,7 +587,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 32; } @@ -598,7 +598,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 2, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 2); unchecked { return _byteLength / 32; } @@ -789,7 +789,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 3); unchecked { return _byteLength / 32; } @@ -800,7 +800,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 3); unchecked { return _byteLength / 32; } @@ -811,7 +811,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 3, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 3); unchecked { return _byteLength / 32; } @@ -1002,7 +1002,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 4); unchecked { return _byteLength / 32; } @@ -1013,7 +1013,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 4); unchecked { return _byteLength / 32; } @@ -1024,7 +1024,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 4, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 4); unchecked { return _byteLength / 32; } diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 61b964f260..2cfba3c42d 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -199,7 +199,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -210,7 +210,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -221,7 +221,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -232,7 +232,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -243,7 +243,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } @@ -254,7 +254,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 32; } diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 41a7a1153d..652b543329 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -180,7 +180,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 20; } @@ -191,7 +191,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 20; } @@ -202,7 +202,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 20; } @@ -213,7 +213,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 20; } @@ -224,7 +224,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 20; } @@ -235,7 +235,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 20; } From 8a0551812ed79ed457d5c0612c0743867342fa02 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 20:36:11 +0100 Subject: [PATCH 28/38] regenerate artifacts --- .../contracts/src/codegen/tables/Multi.sol | 12 +-- .../contracts/src/codegen/tables/Number.sol | 12 +-- .../src/codegen/tables/NumberList.sol | 86 ++++++++----------- .../contracts/src/codegen/tables/Vector.sol | 12 +-- .../src/systems/NumberListSystem.sol | 2 +- e2e/packages/contracts/worlds.json | 2 +- .../src/codegen/tables/CounterTable.sol | 14 +-- .../src/codegen/tables/Inventory.sol | 14 +-- .../src/codegen/tables/MessageTable.sol | 4 +- .../contracts/src/codegen/tables/Counter.sol | 14 +-- .../contracts/src/codegen/tables/Counter.sol | 14 +-- .../contracts/src/codegen/tables/Position.sol | 24 +++--- .../contracts/src/codegen/tables/Counter.sol | 14 +-- 13 files changed, 105 insertions(+), 119 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index fede3f2eb5..d05ca9deea 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -135,7 +135,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((num)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((num)), _fieldLayout); } /** Set num */ @@ -146,7 +146,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((num)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((num)), _fieldLayout); } /** Set num (using the specified store) */ @@ -157,7 +157,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((num)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((num)), _fieldLayout); } /** Get value */ @@ -204,7 +204,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -215,7 +215,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ @@ -226,7 +226,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value)), _fieldLayout); } /** Get the full data */ diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index e20c4753a4..7b59e9b2b0 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -137,7 +137,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -145,7 +145,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ @@ -153,7 +153,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -161,7 +161,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ @@ -169,7 +169,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ @@ -177,7 +177,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index 63c66c3ebd..8a3c4441e3 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -128,49 +128,49 @@ library NumberList { function setValue(uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ function _setValue(uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ function setValue(IStore _store, uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ function set(uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value */ function _set(uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Set value (using the specified store) */ function set(IStore _store, uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), _fieldLayout); + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); } /** Get the length of value */ function lengthValue() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -180,7 +180,7 @@ library NumberList { function _lengthValue() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -190,7 +190,7 @@ library NumberList { function lengthValue(IStore _store) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -200,7 +200,7 @@ library NumberList { function length() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreSwitch.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -210,7 +210,7 @@ library NumberList { function _length() internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = StoreCore.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -220,7 +220,7 @@ library NumberList { function length(IStore _store) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](0); - uint256 _byteLength = _store.getFieldLength(_tableId, _keyTuple, 0, _fieldLayout); + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { return _byteLength / 4; } @@ -234,14 +234,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -254,7 +247,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -267,7 +260,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -280,14 +273,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreSwitch.getFieldSlice( - _tableId, - _keyTuple, - 0, - _fieldLayout, - _index * 4, - (_index + 1) * 4 - ); + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -300,7 +286,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = StoreCore.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -313,7 +299,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - bytes memory _blob = _store.getFieldSlice(_tableId, _keyTuple, 0, _fieldLayout, _index * 4, (_index + 1) * 4); + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 4, (_index + 1) * 4); return (uint32(bytes4(_blob))); } } @@ -322,84 +308,84 @@ library NumberList { function pushValue(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ function _pushValue(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ function pushValue(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ function push(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value */ function _push(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Push an element to value (using the specified store) */ function push(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), _fieldLayout); + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); } /** Pop an element from value */ function popValue() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from value */ function _popValue() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.popFromField(_tableId, _keyTuple, 0, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from value (using the specified store) */ function popValue(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 0, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from value */ function pop() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 4, _fieldLayout); + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from value */ function _pop() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.popFromField(_tableId, _keyTuple, 0, 4, _fieldLayout); + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** Pop an element from value (using the specified store) */ function pop(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 0, 4, _fieldLayout); + _store.popFromDynamicField(_tableId, _keyTuple, 0, 4); } /** @@ -410,7 +396,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -422,7 +408,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -434,7 +420,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -446,7 +432,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -458,7 +444,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), _fieldLayout); + StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } @@ -470,7 +456,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), _fieldLayout); + _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); } } diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 6e9030d916..7726df751c 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -117,7 +117,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Set x */ @@ -125,7 +125,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Set x (using the specified store) */ @@ -133,7 +133,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Get y */ @@ -168,7 +168,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Set y */ @@ -176,7 +176,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Set y (using the specified store) */ @@ -184,7 +184,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Get the full data */ diff --git a/e2e/packages/contracts/src/systems/NumberListSystem.sol b/e2e/packages/contracts/src/systems/NumberListSystem.sol index 9309cf5a0e..0433e1efc5 100644 --- a/e2e/packages/contracts/src/systems/NumberListSystem.sol +++ b/e2e/packages/contracts/src/systems/NumberListSystem.sol @@ -22,7 +22,7 @@ contract NumberListSystem is System { } bytes32[] memory emptyKey; - StoreSwitch.pushToField(NumberListTableId, emptyKey, 0, EncodeArray.encode(list), NumberList.getFieldLayout()); + StoreSwitch.pushToDynamicField(NumberListTableId, emptyKey, 0, EncodeArray.encode(list)); } function pop() public { diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index e00b04bb2d..17fe3e5e71 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0x4C4a2f8c81640e47606d3fd77B353E87Ba015584" + "address": "0x0355B7B8cb128fA5692729Ab3AAa199C1753f726" } } \ No newline at end of file diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol index 30dcd3729b..d7d9be524e 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol @@ -128,42 +128,42 @@ library CounterTable { function setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function setValue(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ @@ -177,7 +177,7 @@ library CounterTable { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol index 6a724eddad..f4ffed0d8c 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol @@ -160,7 +160,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); } /** Set amount */ @@ -170,7 +170,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); } /** Set amount (using the specified store) */ @@ -180,7 +180,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); } /** Set amount */ @@ -190,7 +190,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); } /** Set amount */ @@ -200,7 +200,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); } /** Set amount (using the specified store) */ @@ -210,7 +210,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), _fieldLayout); } /** Delete all data for given keys */ @@ -230,7 +230,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index ae113bf28d..db4763267d 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -95,7 +95,7 @@ library MessageTable { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -148,7 +148,7 @@ library MessageTable { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol index 37c25bf200..f9e4523d88 100644 --- a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol @@ -128,42 +128,42 @@ library Counter { function setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function setValue(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ @@ -177,7 +177,7 @@ library Counter { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/templates/react/packages/contracts/src/codegen/tables/Counter.sol b/templates/react/packages/contracts/src/codegen/tables/Counter.sol index 37c25bf200..f9e4523d88 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Counter.sol @@ -128,42 +128,42 @@ library Counter { function setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function setValue(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ @@ -177,7 +177,7 @@ library Counter { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index d35690e95f..7fe7bc7733 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -120,7 +120,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Set x */ @@ -128,7 +128,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Set x (using the specified store) */ @@ -136,7 +136,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } /** Get y */ @@ -171,7 +171,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Set y */ @@ -179,7 +179,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Set y (using the specified store) */ @@ -187,7 +187,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } /** Get z */ @@ -222,7 +222,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); } /** Set z */ @@ -230,7 +230,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); } /** Set z (using the specified store) */ @@ -238,7 +238,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); } /** Get the full data */ @@ -303,7 +303,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using individual values (using the specified store) */ @@ -342,7 +342,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } /** Set the full data using the data struct (using the specified store) */ @@ -395,7 +395,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ diff --git a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol index 37c25bf200..f9e4523d88 100644 --- a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol @@ -128,42 +128,42 @@ library Counter { function setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _setValue(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function setValue(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value */ function _set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); } /** Delete all data for given keys */ @@ -177,7 +177,7 @@ library Counter { function _deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreCore.deleteRecord(_tableId, _keyTuple); + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } /** Delete all data for given keys (using the specified store) */ From c12617c056e5f1fef4517146b9b7a7579f1b1466 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 20:40:27 +0100 Subject: [PATCH 29/38] fix e2e --- e2e/packages/sync-test/data/setContractData.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/packages/sync-test/data/setContractData.ts b/e2e/packages/sync-test/data/setContractData.ts index be886c0d07..3b8ebc80f4 100644 --- a/e2e/packages/sync-test/data/setContractData.ts +++ b/e2e/packages/sync-test/data/setContractData.ts @@ -19,7 +19,6 @@ export async function setContractData(page: Page, data: Data) { record.staticData, record.encodedLengths, record.dynamicData, - record.fieldLayout, ]); // Wait for transactions to be confirmed From 9b22c740026bd4380af393105a4764023c990764 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 20:42:32 +0100 Subject: [PATCH 30/38] regenerate test data --- .../src/postgres/postgresStorage.test.ts | 8 +- .../src/sqlite/sqliteStorage.test.ts | 8 +- test-data/world-logs.json | 970 ++++++++++++------ 3 files changed, 658 insertions(+), 328 deletions(-) diff --git a/packages/store-sync/src/postgres/postgresStorage.test.ts b/packages/store-sync/src/postgres/postgresStorage.test.ts index 5708b84656..f717c07ea8 100644 --- a/packages/store-sync/src/postgres/postgresStorage.test.ts +++ b/packages/store-sync/src/postgres/postgresStorage.test.ts @@ -56,7 +56,7 @@ describe("postgresStorage", async () => { { "chainId": 31337, "lastError": null, - "lastUpdatedBlockNumber": 6n, + "lastUpdatedBlockNumber": 5n, "schemaVersion": 1, }, ] @@ -74,7 +74,7 @@ describe("postgresStorage", async () => { "key": "0x5FbDB2315678afecb367f032d93F642f64180aa3::NumberList", "keySchema": {}, "lastError": null, - "lastUpdatedBlockNumber": 6n, + "lastUpdatedBlockNumber": 5n, "name": "NumberList", "namespace": "", "schemaVersion": 1, @@ -94,7 +94,7 @@ describe("postgresStorage", async () => { "key": "0x5FbDB2315678afecb367f032d93F642f64180aa3::NumberList", "keySchema": {}, "lastError": null, - "lastUpdatedBlockNumber": 6n, + "lastUpdatedBlockNumber": 5n, "name": "NumberList", "namespace": "", "schemaVersion": 1, @@ -114,7 +114,7 @@ describe("postgresStorage", async () => { "__encodedLengths": "0x0000000000000000000000000000000000000000000000000800000000000008", "__isDeleted": false, "__key": "0x", - "__lastUpdatedBlockNumber": 6n, + "__lastUpdatedBlockNumber": 5n, "__staticData": null, "value": [ 420, diff --git a/packages/store-sync/src/sqlite/sqliteStorage.test.ts b/packages/store-sync/src/sqlite/sqliteStorage.test.ts index 4df6c97446..06b01ce31e 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.test.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.test.ts @@ -64,7 +64,7 @@ describe("sqliteStorage", async () => { { "chainId": 31337, "lastError": null, - "lastUpdatedBlockNumber": 6n, + "lastUpdatedBlockNumber": 5n, "schemaVersion": 1, }, ] @@ -77,7 +77,7 @@ describe("sqliteStorage", async () => { "id": "0x5FbDB2315678afecb367f032d93F642f64180aa3____NumberList", "keySchema": {}, "lastError": null, - "lastUpdatedBlockNumber": 6n, + "lastUpdatedBlockNumber": 5n, "name": "NumberList", "namespace": "", "schemaVersion": 1, @@ -97,7 +97,7 @@ describe("sqliteStorage", async () => { "id": "0x5FbDB2315678afecb367f032d93F642f64180aa3____NumberList", "keySchema": {}, "lastError": null, - "lastUpdatedBlockNumber": 6n, + "lastUpdatedBlockNumber": 5n, "name": "NumberList", "namespace": "", "schemaVersion": 1, @@ -117,7 +117,7 @@ describe("sqliteStorage", async () => { "__encodedLengths": "0x0000000000000000000000000000000000000000000000000800000000000008", "__isDeleted": false, "__key": "0x", - "__lastUpdatedBlockNumber": 6n, + "__lastUpdatedBlockNumber": 5n, "__staticData": null, "value": [ 420, diff --git a/test-data/world-logs.json b/test-data/world-logs.json index 326f3e06e7..27eeab7fc6 100644 --- a/test-data/world-logs.json +++ b/test-data/world-logs.json @@ -6,9 +6,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000022000000000a0000000000002c00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000174626d756473746f72650000000000005461626c65730000000000000000000000000000000000000000000000000000000000000000000000000000000000600060030220202000000000000000000000000000000000000000000000000000002001005f000000000000000000000000000000000000000000000000000000006003025f5f5fc4c4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000077461626c654964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000b6669656c644c61796f757400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096b6579536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b76616c7565536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012616269456e636f6465644b65794e616d657300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014616269456e636f6465644669656c644e616d6573000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x0", "transactionLogIndex": "0x0", @@ -17,13 +17,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000174626d756473746f72650000000000005461626c65730000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000174626d756473746f72650000000000005461626c65730000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1", "transactionLogIndex": "0x1", @@ -36,9 +36,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a0000000000001400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000174626d756473746f726500000000000053746f7265486f6f6b7300000000000000000000000000000000000000000000000000000000000000000000000000600000000100000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000001b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b65790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2", "transactionLogIndex": "0x2", @@ -47,13 +47,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000174626d756473746f726500000000000053746f7265486f6f6b7300000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000174626d756473746f726500000000000053746f7265486f6f6b7300000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x3", "transactionLogIndex": "0x3", @@ -66,9 +66,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a0000000000001400000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000174626d756473746f72650000000000005265736f75726365496473000000000000000000000000000000000000000000000000000000000000000000000000600001010001000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000010100600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a7265736f7572636549640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000066578697374730000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x4", "transactionLogIndex": "0x4", @@ -77,13 +77,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000174626d756473746f72650000000000005265736f75726365496473000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000174626d756473746f72650000000000005265736f75726365496473000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x5", "transactionLogIndex": "0x5", @@ -96,9 +96,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e616d6573706163654f776e6572000000000000000000000000000000000000000000000000000000000000000000600014010014000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000140100610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b6e616d657370616365496400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056f776e6572000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x6", "transactionLogIndex": "0x6", @@ -107,13 +107,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e616d6573706163654f776e6572000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e616d6573706163654f776e6572000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x7", "transactionLogIndex": "0x7", @@ -126,9 +126,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a000000000000140000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000042616c616e636573000000000000000000000000000000000000000000000000000000000000000000000000000000600020010020000000000000000000000000000000000000000000000000000000002001005f000000000000000000000000000000000000000000000000000000002001001f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000b6e616d6573706163654964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000762616c616e636500000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x8", "transactionLogIndex": "0x8", @@ -137,13 +137,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000042616c616e636573000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000042616c616e636573000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x9", "transactionLogIndex": "0x9", @@ -156,9 +156,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a00000000100000000000001a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000174620000000000000000000000000000496e7374616c6c65644d6f64756c657300000000000000000000000000000000000000000000000000000000000000600014010014000000000000000000000000000000000000000000000000000000003002004f5f0000000000000000000000000000000000000000000000000000001401006100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a6d6f64756c654e616d6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d617267756d656e74734861736800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d6d6f64756c654164647265737300000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0xa", "transactionLogIndex": "0xa", @@ -167,13 +167,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000174620000000000000000000000000000496e7374616c6c65644d6f64756c657300000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000174620000000000000000000000000000496e7374616c6c65644d6f64756c657300000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0xb", "transactionLogIndex": "0xb", @@ -186,9 +186,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a00000000100000000000001a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000044656c65676174696f6e730000000000000000000000000000000000000000000000000000000000000000000000006000200100200000000000000000000000000000000000000000000000000000000028020061610000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000964656c656761746f720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000964656c6567617465650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001364656c65676174696f6e436f6e74726f6c496400000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0xc", "transactionLogIndex": "0xc", @@ -197,13 +197,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000044656c65676174696f6e73000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000044656c65676174696f6e73000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0xd", "transactionLogIndex": "0xd", @@ -216,9 +216,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a00000000100000000000001a000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000005265736f75726365416363657373000000000000000000000000000000000000000000000000000000000000000000600001010001000000000000000000000000000000000000000000000000000000003402005f610000000000000000000000000000000000000000000000000000000101006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a7265736f75726365496400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000663616c6c6572000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000066163636573730000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0xe", "transactionLogIndex": "0xe", @@ -227,13 +227,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000005265736f75726365416363657373000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000005265736f75726365416363657373000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0xf", "transactionLogIndex": "0xf", @@ -246,9 +246,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000010000000000a0000000000001a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d7300000000000000000000000000000000000000000000000000000000000000000000000000000000600015020014010000000000000000000000000000000000000000000000000000002001005f000000000000000000000000000000000000000000000000000000001502006160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000873797374656d49640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000673797374656d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c7075626c69634163636573730000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x10", "transactionLogIndex": "0x10", @@ -257,13 +257,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d7300000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d7300000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x11", "transactionLogIndex": "0x11", @@ -276,9 +276,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000010000000000a0000000000001a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000240200200400000000000000000000000000000000000000000000000000000004010043000000000000000000000000000000000000000000000000000000002402005f43000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001066756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000873797374656d4964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001673797374656d46756e6374696f6e53656c6563746f7200000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x12", "transactionLogIndex": "0x12", @@ -287,13 +287,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000046756e6374696f6e53656c6563746f7200000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000046756e6374696f6e53656c6563746f7200000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x13", "transactionLogIndex": "0x13", @@ -306,9 +306,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a000000000000140000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d486f6f6b73000000000000000000000000000000000000000000000000000000000000000000000000600000000100000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000001b60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000873797374656d4964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x14", "transactionLogIndex": "0x14", @@ -317,13 +317,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d486f6f6b73000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d486f6f6b73000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x15", "transactionLogIndex": "0x15", @@ -336,9 +336,9 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a000000000000140000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d52656769737472790000000000000000000000000000000000000000000000000000000000000000006000200100200000000000000000000000000000000000000000000000000000000014010061000000000000000000000000000000000000000000000000000000002001005f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000673797374656d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000873797374656d4964000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x16", "transactionLogIndex": "0x16", @@ -347,13 +347,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d5265676973747279000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000017462000000000000000000000000000053797374656d5265676973747279000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x17", "transactionLogIndex": "0x17", @@ -362,13 +362,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000016e7300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000016e7300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x18", "transactionLogIndex": "0x18", @@ -377,13 +377,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x746200000000000000000000000000004e616d6573706163654f776e65720000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000016e730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000016e730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x19", "transactionLogIndex": "0x19", @@ -392,13 +392,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x746200000000000000000000000000005265736f757263654163636573730000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000026e73000000000000000000000000000000000000000000000000000000000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000026e73000000000000000000000000000000000000000000000000000000000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1a", "transactionLogIndex": "0x1a", @@ -407,13 +407,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000173790000000000000000000000000000636f726500000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000173790000000000000000000000000000636f726500000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1b", "transactionLogIndex": "0x1b", @@ -426,9 +426,9 @@ "0x7462000000000000000000000000000053797374656d73000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000173790000000000000000000000000000636f72650000000000000000000000000000000000000000000000000000000000000000000000000000000000000015cafac3dd18ac6c6e92c921884f9e4176737c052c0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1c", "transactionLogIndex": "0x1c", @@ -437,13 +437,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x7462000000000000000000000000000053797374656d52656769737472790000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cafac3dd18ac6c6e92c921884f9e4176737c052c000000000000000000000000000000000000000000000000000000000000002073790000000000000000000000000000636f7265000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cafac3dd18ac6c6e92c921884f9e4176737c052c000000000000000000000000000000000000000000000000000000000000002073790000000000000000000000000000636f7265000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1d", "transactionLogIndex": "0x1d", @@ -452,13 +452,13 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x746200000000000000000000000000005265736f757263654163636573730000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000026e73000000000000000000000000000000000000000000000000000000000000000000000000000000000000cafac3dd18ac6c6e92c921884f9e4176737c052c00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000026e73000000000000000000000000000000000000000000000000000000000000000000000000000000000000cafac3dd18ac6c6e92c921884f9e4176737c052c00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1e", "transactionLogIndex": "0x1e", @@ -471,9 +471,9 @@ "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000140554c3a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f726500000000000000000000000040554c3a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x1f", "transactionLogIndex": "0x1f", @@ -483,12 +483,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000018d53b20800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000008d53b208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000001c0000000000001c00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000140554c3a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c6772616e7441636365737328627974657333322c616464726573732900000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x20", "transactionLogIndex": "0x20", @@ -500,10 +500,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001ef5d6bbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000ef5d6bbb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000018d53b20800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000008d53b208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x21", "transactionLogIndex": "0x21", @@ -513,12 +513,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001c9c85a6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000c9c85a60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000001d0000000000001d00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000018d53b208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001d7265766f6b6541636365737328627974657333322c6164647265737329000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x22", "transactionLogIndex": "0x22", @@ -530,10 +530,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000145afd19900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f726500000000000000000000000045afd199000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001ef5d6bbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000ef5d6bbb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x23", "transactionLogIndex": "0x23", @@ -543,12 +543,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010ca8997800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000000ca89978000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000220000000000002200000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001ef5d6bbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000227472616e736665724f776e65727368697028627974657333322c6164647265737329000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x24", "transactionLogIndex": "0x24", @@ -560,10 +560,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000018da798da00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000008da798da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001c9c85a6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000c9c85a60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x25", "transactionLogIndex": "0x25", @@ -573,12 +573,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010ba51f4900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000000ba51f49000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000330000000000003300000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001c9c85a6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000337472616e7366657242616c616e6365546f4e616d65737061636528627974657333322c627974657333322c75696e743235362900000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x26", "transactionLogIndex": "0x26", @@ -590,10 +590,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001530f4b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000530f4b60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000145afd19900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f726500000000000000000000000045afd199000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x27", "transactionLogIndex": "0x27", @@ -603,12 +603,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010560912900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f726500000000000000000000000005609129000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000310000000000003100000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000145afd19900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000317472616e7366657242616c616e6365546f4164647265737328627974657333322c616464726573732c75696e7432353629000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x28", "transactionLogIndex": "0x28", @@ -620,10 +620,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001b29e408900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000b29e4089000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010ca8997800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000000ca89978000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x29", "transactionLogIndex": "0x29", @@ -633,12 +633,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001d5f8337f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000d5f8337f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000001c0000000000001c00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010ca89978000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c63616c6c42617463682828627974657333322c6279746573295b5d2900000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2a", "transactionLogIndex": "0x2a", @@ -650,10 +650,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001a92813ad00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000a92813ad000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000018da798da00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000008da798da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2b", "transactionLogIndex": "0x2b", @@ -663,12 +663,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000013350b6a900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000003350b6a9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000001c0000000000001c00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000018da798da000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c696e7374616c6c4d6f64756c6528616464726573732c62797465732900000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2c", "transactionLogIndex": "0x2c", @@ -680,10 +680,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000013c03a51c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000003c03a51c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010ba51f4900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000000ba51f49000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2d", "transactionLogIndex": "0x2d", @@ -693,12 +693,12 @@ "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", - "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001b7a3c75600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000b7a3c756000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000400000000000004000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000010ba51f49000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004072656769737465725461626c6528627974657333322c627974657333322c627974657333322c627974657333322c737472696e675b5d2c737472696e675b5d29", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2e", "transactionLogIndex": "0x2e", @@ -710,10 +710,10 @@ "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], - "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000011d2257ba00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000001d2257ba000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001530f4b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000530f4b60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x2f", "transactionLogIndex": "0x2f", @@ -722,18 +722,273 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", - "0x74620000000000000000000000000000496e7374616c6c65644d6f64756c6573" + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000002636f726500000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4700000000000000000000000000000000000000000000000000000000000000014e7f1725e7734ce288f8367e1bb143e90bb3f0512000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x0d4155dcc6f97b40f4fe8f4af55fe089b29c5eef9522dc83c66d5b96009210f0", + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000280000000000002800000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001530f4b600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028726567697374657253746f7265486f6f6b28627974657333322c616464726573732c75696e743829000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", "transactionIndex": "0x0", "logIndex": "0x30", "transactionLogIndex": "0x30", "removed": false }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010560912900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f726500000000000000000000000005609129000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x31", + "transactionLogIndex": "0x31", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000240000000000002400000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001056091290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024756e726567697374657253746f7265486f6f6b28627974657333322c616464726573732900000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x32", + "transactionLogIndex": "0x32", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001b29e408900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000b29e4089000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x33", + "transactionLogIndex": "0x33", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000001a0000000000001a00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001b29e4089000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a72656769737465724e616d657370616365286279746573333229000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x34", + "transactionLogIndex": "0x34", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001d5f8337f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000d5f8337f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x35", + "transactionLogIndex": "0x35", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000290000000000002900000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001d5f8337f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029726567697374657253797374656d486f6f6b28627974657333322c616464726573732c75696e7438290000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x36", + "transactionLogIndex": "0x36", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001a92813ad00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000a92813ad000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x37", + "transactionLogIndex": "0x37", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000250000000000002500000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001a92813ad0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025756e726567697374657253797374656d486f6f6b28627974657333322c6164647265737329000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x38", + "transactionLogIndex": "0x38", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000013350b6a900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000003350b6a9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x39", + "transactionLogIndex": "0x39", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000240000000000002400000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000013350b6a90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024726567697374657253797374656d28627974657333322c616464726573732c626f6f6c2900000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x3a", + "transactionLogIndex": "0x3a", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000126d9810200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f726500000000000000000000000026d98102000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x3b", + "transactionLogIndex": "0x3b", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000280000000000002800000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000126d981020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028726567697374657246756e6374696f6e53656c6563746f7228627974657333322c737472696e6729000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x3c", + "transactionLogIndex": "0x3c", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001742d611800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f7265000000000000000000000000742d6118000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x3d", + "transactionLogIndex": "0x3d", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000330000000000003300000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001742d611800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000337265676973746572526f6f7446756e6374696f6e53656c6563746f7228627974657333322c737472696e672c6279746573342900000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x3e", + "transactionLogIndex": "0x3e", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000011d2257ba00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000636f72650000000000000000000000001d2257ba000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x3f", + "transactionLogIndex": "0x3f", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000290000000000002900000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000011d2257ba0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029726567697374657244656c65676174696f6e28616464726573732c627974657333322c6279746573290000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x40", + "transactionLogIndex": "0x40", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", + "0x74620000000000000000000000000000496e7374616c6c65644d6f64756c6573" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002636f726500000000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4700000000000000000000000000000000000000000000000000000000000000014e7f1725e7734ce288f8367e1bb143e90bb3f0512000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5ee42010450b6a9f7d2fca03511de209f9fc8ed04782bd284595a9a76e13d30b", + "transactionIndex": "0x0", + "logIndex": "0x41", + "transactionLogIndex": "0x41", + "removed": false + }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ @@ -741,26 +996,26 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e756d626572000000000000000000000000000000000000000000000000000000000000000000000000000000000060000401000400000000000000000000000000000000000000000000000000000000040100030000000000000000000000000000000000000000000000000000000004010003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b65790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0xf5a82d96f1cc4bb9088cefeb8017b84c43b250bffcb1b32871299f1bd121e7ce", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x94df79dac95a1919e42cba4f58e67b9e024e0e6f21fbbc1aa3f62c0c125ec20d", "transactionIndex": "0x1", - "logIndex": "0x31", + "logIndex": "0x42", "transactionLogIndex": "0x0", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e756d6265720000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0xf5a82d96f1cc4bb9088cefeb8017b84c43b250bffcb1b32871299f1bd121e7ce", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e756d6265720000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x94df79dac95a1919e42cba4f58e67b9e024e0e6f21fbbc1aa3f62c0c125ec20d", "transactionIndex": "0x1", - "logIndex": "0x32", + "logIndex": "0x43", "transactionLogIndex": "0x1", "removed": false }, @@ -771,26 +1026,26 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000010000000000a0000000000001a00000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000174620000000000000000000000000000566563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000006000080200040400000000000000000000000000000000000000000000000000000004010003000000000000000000000000000000000000000000000000000000000802002323000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b6579000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017900000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x3e121030b94cd43e44bfd7d304b22b1300d9495d9bddfa941442d4b99afa3aef", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0xbb5784f997595f2b2eeabe279c852bfe44d265243fa5a92221acb481620b1bce", "transactionIndex": "0x2", - "logIndex": "0x33", + "logIndex": "0x44", "transactionLogIndex": "0x0", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000174620000000000000000000000000000566563746f720000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x3e121030b94cd43e44bfd7d304b22b1300d9495d9bddfa941442d4b99afa3aef", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000174620000000000000000000000000000566563746f720000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0xbb5784f997595f2b2eeabe279c852bfe44d265243fa5a92221acb481620b1bce", "transactionIndex": "0x2", - "logIndex": "0x34", + "logIndex": "0x45", "transactionLogIndex": "0x1", "removed": false }, @@ -801,26 +1056,26 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000a00000000040000000000000e000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e756d6265724c697374000000000000000000000000000000000000000000000000000000000000000000000000006000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x2ee1e32f041555f04407696ce0bf25ca5b23c187259dc638a001a87a1b24df19", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0xda6dd25e11f1ae999036ef7239af3a0a1765ce0f8a774aa45adfb34efdfd84f1", "transactionIndex": "0x3", - "logIndex": "0x35", + "logIndex": "0x46", "transactionLogIndex": "0x0", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e756d6265724c69737400000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x2ee1e32f041555f04407696ce0bf25ca5b23c187259dc638a001a87a1b24df19", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004e756d6265724c69737400000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0xda6dd25e11f1ae999036ef7239af3a0a1765ce0f8a774aa45adfb34efdfd84f1", "transactionIndex": "0x3", - "logIndex": "0x36", + "logIndex": "0x47", "transactionLogIndex": "0x1", "removed": false }, @@ -831,41 +1086,41 @@ "0x74626d756473746f72650000000000005461626c657300000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000010000000001c0000000000002c000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004d756c74690000000000000000000000000000000000000000000000000000000000000000000000000000000000006000210200200100000000000000000000000000000000000000000000000000000034040003601f2e000000000000000000000000000000000000000000000000002102003f60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000016100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000162000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000036e756d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x49135abf8dcc1a3c5232cb964bff59b619d259d5265d84a5034233f37adf5f0d", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x4a758aa6196b84927d3135706bc6914712dd6af007981926b2d771463c7a4f5b", "transactionIndex": "0x4", - "logIndex": "0x37", + "logIndex": "0x48", "transactionLogIndex": "0x0", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004d756c7469000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x49135abf8dcc1a3c5232cb964bff59b619d259d5265d84a5034233f37adf5f0d", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001746200000000000000000000000000004d756c7469000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x4a758aa6196b84927d3135706bc6914712dd6af007981926b2d771463c7a4f5b", "transactionIndex": "0x4", - "logIndex": "0x38", + "logIndex": "0x49", "transactionLogIndex": "0x1", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000173790000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x99e0c1847e48adcee18f0d44815cfc2a043c8ef5f3948f251615c45a8c611437", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000173790000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x6251a49bb9104637ca2884f86be1ae61bdf17552e71b5df926eb770eb4fe9b95", "transactionIndex": "0x5", - "logIndex": "0x39", + "logIndex": "0x4a", "transactionLogIndex": "0x0", "removed": false }, @@ -876,56 +1131,56 @@ "0x7462000000000000000000000000000053797374656d73000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000173790000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000155fc8d32690cc91d4c39d9d3abcbd16989f8757070100000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x99e0c1847e48adcee18f0d44815cfc2a043c8ef5f3948f251615c45a8c611437", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x6251a49bb9104637ca2884f86be1ae61bdf17552e71b5df926eb770eb4fe9b95", "transactionIndex": "0x5", - "logIndex": "0x3a", + "logIndex": "0x4b", "transactionLogIndex": "0x1", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x7462000000000000000000000000000053797374656d52656769737472790000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f875707000000000000000000000000000000000000000000000000000000000000002073790000000000000000000000000000437573746f6d4572726f727353797374", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x99e0c1847e48adcee18f0d44815cfc2a043c8ef5f3948f251615c45a8c611437", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f875707000000000000000000000000000000000000000000000000000000000000002073790000000000000000000000000000437573746f6d4572726f727353797374", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x6251a49bb9104637ca2884f86be1ae61bdf17552e71b5df926eb770eb4fe9b95", "transactionIndex": "0x5", - "logIndex": "0x3b", + "logIndex": "0x4c", "transactionLogIndex": "0x2", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x746200000000000000000000000000005265736f757263654163636573730000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000026e730000000000000000000000000000000000000000000000000000000000000000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f87570700000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x99e0c1847e48adcee18f0d44815cfc2a043c8ef5f3948f251615c45a8c611437", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000026e730000000000000000000000000000000000000000000000000000000000000000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f87570700000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x6251a49bb9104637ca2884f86be1ae61bdf17552e71b5df926eb770eb4fe9b95", "transactionIndex": "0x5", - "logIndex": "0x3c", + "logIndex": "0x4d", "transactionLogIndex": "0x3", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x74626d756473746f72650000000000005265736f757263654964730000000000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001737900000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x38e51a427ad28d8c2c2cc92b65668e0a9056624c610e7849234f3db49f50799e", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001737900000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x921cfb89e243f8f8bcd521023f05f131d42ddaedb5998fc7d13aa4ef12debaf6", "transactionIndex": "0x6", - "logIndex": "0x3d", + "logIndex": "0x4e", "transactionLogIndex": "0x0", "removed": false }, @@ -936,41 +1191,41 @@ "0x7462000000000000000000000000000053797374656d73000000000000000000" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000001737900000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000150165878a594ca255338adfa4d48449f69242eb8f0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x38e51a427ad28d8c2c2cc92b65668e0a9056624c610e7849234f3db49f50799e", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x921cfb89e243f8f8bcd521023f05f131d42ddaedb5998fc7d13aa4ef12debaf6", "transactionIndex": "0x6", - "logIndex": "0x3e", + "logIndex": "0x4f", "transactionLogIndex": "0x1", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x7462000000000000000000000000000053797374656d52656769737472790000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f0000000000000000000000000000000000000000000000000000000000000020737900000000000000000000000000004e756d6265724c69737453797374656d", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x38e51a427ad28d8c2c2cc92b65668e0a9056624c610e7849234f3db49f50799e", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f0000000000000000000000000000000000000000000000000000000000000020737900000000000000000000000000004e756d6265724c69737453797374656d", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x921cfb89e243f8f8bcd521023f05f131d42ddaedb5998fc7d13aa4ef12debaf6", "transactionIndex": "0x6", - "logIndex": "0x3f", + "logIndex": "0x50", "transactionLogIndex": "0x2", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xac9f2b70ab41044b24c3864d8dce7f6ad1fef853dfd4404d42d93445baeb9e3b", + "0x8c0b5119d4cec7b284c6b1b39252a03d1e2f2d7451a5895562524c113bb952be", "0x746200000000000000000000000000005265736f757263654163636573730000" ], - "data": "0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000026e730000000000000000000000000000000000000000000000000000000000000000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x38e51a427ad28d8c2c2cc92b65668e0a9056624c610e7849234f3db49f50799e", + "data": "0x0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000026e730000000000000000000000000000000000000000000000000000000000000000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x921cfb89e243f8f8bcd521023f05f131d42ddaedb5998fc7d13aa4ef12debaf6", "transactionIndex": "0x6", - "logIndex": "0x40", + "logIndex": "0x51", "transactionLogIndex": "0x3", "removed": false }, @@ -981,14 +1236,29 @@ "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000015f644e3c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002473790000000000000000000000000000437573746f6d4572726f7273537973745f644e3c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x7598f1b801a683f2b453285df8011f829e5e9127355f76bd7dd46b3f4c2842d6", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0xb286f0ac33f44e432f794406490c5e613b71edaa4d7b0a775e2c955249752fa9", "transactionIndex": "0x7", - "logIndex": "0x41", + "logIndex": "0x52", "transactionLogIndex": "0x0", "removed": false }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000d0000000000000d00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000015f644e3c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d737475622875696e743235362900000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0xb286f0ac33f44e432f794406490c5e613b71edaa4d7b0a775e2c955249752fa9", + "transactionIndex": "0x7", + "logIndex": "0x53", + "transactionLogIndex": "0x1", + "removed": false + }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ @@ -996,14 +1266,29 @@ "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001a4ece52c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024737900000000000000000000000000004e756d6265724c69737453797374656da4ece52c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0xa2e4b041f401f2d1511ef4e6b524e3605d345249a6574f9ffd39a6e788f1d18b", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5adf0e6893341c02a55c76850baf664ea1591135560bfd49e91568c677cdd21a", "transactionIndex": "0x8", - "logIndex": "0x42", + "logIndex": "0x54", "transactionLogIndex": "0x0", "removed": false }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000050000000000000500000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001a4ece52c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005706f702829000000000000000000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x5adf0e6893341c02a55c76850baf664ea1591135560bfd49e91568c677cdd21a", + "transactionIndex": "0x8", + "logIndex": "0x55", + "transactionLogIndex": "0x1", + "removed": false + }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ @@ -1011,14 +1296,29 @@ "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001f7f0e440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024737900000000000000000000000000004e756d6265724c69737453797374656df7f0e440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x2bd78b932289533ba9d103c573e4e4067a29ee4746e31d8793b055a5fa047264", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x56b5b83be5d90b586081bb35a83f6a3b2e3bf74a776f8ac126aad4cf37b45077", "transactionIndex": "0x9", - "logIndex": "0x43", + "logIndex": "0x56", "transactionLogIndex": "0x0", "removed": false }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000c0000000000000c00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001f7f0e440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c707573682875696e743332290000000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x56b5b83be5d90b586081bb35a83f6a3b2e3bf74a776f8ac126aad4cf37b45077", + "transactionIndex": "0x9", + "logIndex": "0x57", + "transactionLogIndex": "0x1", + "removed": false + }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ @@ -1026,14 +1326,29 @@ "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001306d61a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024737900000000000000000000000000004e756d6265724c69737453797374656d306d61a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x7e432718eed0f9bac0392dff4c56a4806408c6be029d9cc7ae26ea4d38ad6d16", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x217733e1fa8b0d98657f37e45fcaeb3b39f53bf5cb60b4b0f54e25f24f574995", "transactionIndex": "0xa", - "logIndex": "0x44", + "logIndex": "0x58", "transactionLogIndex": "0x0", "removed": false }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000180000000000001800000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001306d61a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000187075736852616e67652875696e7433322c75696e743332290000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x217733e1fa8b0d98657f37e45fcaeb3b39f53bf5cb60b4b0f54e25f24f574995", + "transactionIndex": "0xa", + "logIndex": "0x59", + "transactionLogIndex": "0x1", + "removed": false + }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ @@ -1041,14 +1356,29 @@ "0x7462000000000000000000000000000046756e6374696f6e53656c6563746f72" ], "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001b8a44c7c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024737900000000000000000000000000004e756d6265724c69737453797374656db8a44c7c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x5f2408cb39487c49f722df0cb4f4e2ebc9010e3ad7da802390014ff4fb347aae", - "blockNumber": "0x5", - "transactionHash": "0x8cff8e78888467f20094368dafceae31a8edc24c25db94bfef2e3c45f12012b8", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x35f04bc3c24ada572913090478644ca8a0245269cffdaef1d56b0ecb237090db", "transactionIndex": "0xb", - "logIndex": "0x45", + "logIndex": "0x5a", "transactionLogIndex": "0x0", "removed": false }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0x8dbb3a9672eebfd3773e72dd9c102393436816d832c7ba9e1e1ac8fcadcac7a9", + "0x6f74000000000000000000000000000046756e6374696f6e5369676e61747572" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000d0000000000000d00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000001b8a44c7c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d7365742875696e7433325b5d2900000000000000000000000000000000000000", + "blockHash": "0xeaf8ccb09cd16e6da4d06645533c73bd7ee9db947c3e919fa25a47dcafddbe9c", + "blockNumber": "0x4", + "transactionHash": "0x35f04bc3c24ada572913090478644ca8a0245269cffdaef1d56b0ecb237090db", + "transactionIndex": "0xb", + "logIndex": "0x5b", + "transactionLogIndex": "0x1", + "removed": false + }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ @@ -1056,9 +1386,9 @@ "0x746200000000000000000000000000004e756d6265724c697374000000000000" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000040000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000001a400000000000000000000000000000000000000000000000000000000", - "blockHash": "0x4dae55000be05dbd6c7b3674e060d16b83187b5c0f960ce6c22cfe0ab48acf9d", - "blockNumber": "0x6", - "transactionHash": "0x4410e51b0804e73bbba41fc7012eef28c79f12ee16b608e4c9592ce019a2a962", + "blockHash": "0x25c9b45dfe75ab077cfa6285fda364fdbc33f6a97e418b19ff1925048e066338", + "blockNumber": "0x5", + "transactionHash": "0x07b9968aee56aa4bb2744fecff2adf3f5f62b7a48843413e76482cb0283d4bac", "transactionIndex": "0x0", "logIndex": "0x0", "transactionLogIndex": "0x0", @@ -1071,9 +1401,9 @@ "0x746200000000000000000000000000004e756d6265724c697374000000000000" ], "data": "0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000800000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000004500000000000000000000000000000000000000000000000000000000", - "blockHash": "0x4dae55000be05dbd6c7b3674e060d16b83187b5c0f960ce6c22cfe0ab48acf9d", - "blockNumber": "0x6", - "transactionHash": "0x43dcd8e4dff98e4fcbf533f5acafd42cc91361b4eb7fbbc8c9d302520439219d", + "blockHash": "0x25c9b45dfe75ab077cfa6285fda364fdbc33f6a97e418b19ff1925048e066338", + "blockNumber": "0x5", + "transactionHash": "0x6e54305e15426eb9da2e8b4af55e43c45ee8706dbf9e2163f381ef454a87ac28", "transactionIndex": "0x1", "logIndex": "0x1", "transactionLogIndex": "0x0", From fd361dfe3effc93c7f33d2155ada82baa4b0d232 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 20:45:37 +0100 Subject: [PATCH 31/38] fix type error in dev tools --- packages/dev-tools/src/events/LogsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dev-tools/src/events/LogsTable.tsx b/packages/dev-tools/src/events/LogsTable.tsx index aee82a615a..7e38dec1c4 100644 --- a/packages/dev-tools/src/events/LogsTable.tsx +++ b/packages/dev-tools/src/events/LogsTable.tsx @@ -52,7 +52,7 @@ export function LogsTable({ logs }: Props) { }) : null} {log.eventName === "Store_SpliceStaticData" - ? JSON.stringify({ start: log.args.start, deleteCount: log.args.deleteCount, data: log.args.data }) + ? JSON.stringify({ start: log.args.start, data: log.args.data }) : null} {log.eventName === "Store_SpliceDynamicData" ? JSON.stringify({ From e28b0a09bde408b5b307d0d724e0fe7e722f16c8 Mon Sep 17 00:00:00 2001 From: alvarius Date: Sat, 23 Sep 2023 21:25:09 +0100 Subject: [PATCH 32/38] Create wicked-squids-do.md --- .changeset/wicked-squids-do.md | 131 +++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 .changeset/wicked-squids-do.md diff --git a/.changeset/wicked-squids-do.md b/.changeset/wicked-squids-do.md new file mode 100644 index 0000000000..28200e2527 --- /dev/null +++ b/.changeset/wicked-squids-do.md @@ -0,0 +1,131 @@ +--- +"@latticexyz/block-logs-stream": patch +"@latticexyz/cli": patch +"@latticexyz/common": minor +"@latticexyz/dev-tools": patch +"@latticexyz/store-sync": patch +"@latticexyz/store": major +"@latticexyz/world": major +"create-mud": patch +--- + +- The external `setRecord` and `deleteRecord` methods of `IStore` no longer accept a `FieldLayout` as input, but load it from storage instead. + This is to prevent invalid `FieldLayout` values being passed, which could cause the onchain state to diverge from the indexer state. + However, the internal `StoreCore` library still exposes a `setRecord` and `deleteRecord` method that allows a `FieldLayout` to be passed. + This is because `StoreCore` can only be used internally, so the `FieldLayout` value can be trusted and we can save the gas for accessing storage. + + ```diff + interface IStore { + function setRecord( + ResourceId tableId, + bytes32[] calldata keyTuple, + bytes calldata staticData, + PackedCounter encodedLengths, + bytes calldata dynamicData, + - FieldLayout fieldLayout + ) external; + + function deleteRecord( + ResourceId tableId, + bytes32[] memory keyTuple, + - FieldLayout fieldLayout + ) external; + } + ``` + +- The `spliceStaticData` method and `Store_SpliceStaticData` event of `IStore` and `StoreCore` no longer include `deleteCount` in their signature. + This is because when splicing static data, the data after `start` is always overwritten with `data` instead of being shifted, so `deleteCount` is always the length of the data to be written. + + ```diff + + event Store_SpliceStaticData( + ResourceId indexed tableId, + bytes32[] keyTuple, + uint48 start, + - uint40 deleteCount, + bytes data + ); + + interface IStore { + function spliceStaticData( + ResourceId tableId, + bytes32[] calldata keyTuple, + uint48 start, + - uint40 deleteCount, + bytes calldata data + ) external; + } + + ``` + +- All methods that are only valid for dynamic fields (`pushToField`, `popFromField`, `updateInField`, `getFieldSlice`) + have been renamed to make this more explicit (`pushToDynamicField`, `popFromDynamicField`, `updateInDynamicField`, `getDynamicFieldSlice`). + + Their `fieldIndex` parameter has been replaced by a `dynamicFieldIndex` parameter, which is the index relative to the first dynamic field (i.e. `dynamicFieldIndex` = `fieldIndex` - `numStaticFields`). + The `FieldLayout` parameter has been removed, as it was only used to calculate the `dynamicFieldIndex` in the method. + + ```diff + interface IStore { + - function pushToField( + + function pushToDynamicField( + ResourceId tableId, + bytes32[] calldata keyTuple, + - uint8 fieldIndex, + + uint8 dynamicFieldIndex, + bytes calldata dataToPush, + - FieldLayout fieldLayout + ) external; + + - function popFromField( + + function popFromDynamicField( + ResourceId tableId, + bytes32[] calldata keyTuple, + - uint8 fieldIndex, + + uint8 dynamicFieldIndex, + uint256 byteLengthToPop, + - FieldLayout fieldLayout + ) external; + + - function updateInField( + + function updateInDynamicField( + ResourceId tableId, + bytes32[] calldata keyTuple, + - uint8 fieldIndex, + + uint8 dynamicFieldIndex, + uint256 startByteIndex, + bytes calldata dataToSet, + - FieldLayout fieldLayout + ) external; + + - function getFieldSlice( + + function getDynamicFieldSlice( + ResourceId tableId, + bytes32[] memory keyTuple, + - uint8 fieldIndex, + + uint8 dynamicFieldIndex, + - FieldLayout fieldLayout, + uint256 start, + uint256 end + ) external view returns (bytes memory data); + } + ``` + +- `IStore` has a new `getDynamicFieldLength` length method, which returns the byte length of the given dynamic field and doesn't require the `FieldLayout`. + + ```diff + IStore { + + function getDynamicFieldLength( + + ResourceId tableId, + + bytes32[] memory keyTuple, + + uint8 dynamicFieldIndex + + ) external view returns (uint256); + } + +- `IStore` now has additional overloads for `getRecord`, `getField`, `getFieldLength` and `setField` that don't require a `FieldLength` to be passed, but instead load it from storage. + +- `IStore` now exposes `setStaticField` and `setDynamicField` to save gas by avoiding the dynamic inference of whether the field is static or dynamic. + +- The `getDynamicFieldSlice` method no longer accepts reading outside the bounds of the dynamic field. + This is to avoid returning invalid data, as the data of a dynamic field is not deleted when the record is deleted, but only its length is set to zero. + + From c79eec26d914cd59fd7ef565daaf61abdd89f6e9 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 21:33:28 +0100 Subject: [PATCH 33/38] expect revert when accessing out of bound --- packages/cli/contracts/test/Tablegen.t.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cli/contracts/test/Tablegen.t.sol b/packages/cli/contracts/test/Tablegen.t.sol index 204566a7a1..1d1e611ed2 100644 --- a/packages/cli/contracts/test/Tablegen.t.sol +++ b/packages/cli/contracts/test/Tablegen.t.sol @@ -3,6 +3,7 @@ pragma solidity >=0.8.21; import "forge-std/Test.sol"; import { StoreMock } from "@latticexyz/store/test/StoreMock.sol"; +import { IStoreErrors } from "@latticexyz/store/src/IStoreErrors.sol"; import { Statics, StaticsData, Dynamics1, Dynamics1Data, Dynamics2, Dynamics2Data, Singleton, Offchain } from "../src/codegen/index.sol"; @@ -140,6 +141,7 @@ contract TablegenTest is Test, StoreMock { assertEq(abi.encode(Singleton.getV4()), abi.encode([uint32(5)])); assertEq(Singleton.lengthV4(), 1); assertEq(Singleton.getItemV4(0), 5); + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_IndexOutOfBounds.selector, 4, 4)); assertEq(Singleton.getItemV4(1), 0); } From 5a29de7b901a28431abd84f2e9de38ca2c43bdcb Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 22:25:24 +0100 Subject: [PATCH 34/38] remove updateInField --- .../src/codegen/tables/NumberList.sol | 18 +++-- .../src/codegen/tables/Dynamics1.sol | 45 ++++++++---- .../src/codegen/tables/Dynamics2.sol | 27 +++++--- .../src/codegen/tables/Singleton.sol | 27 +++++--- packages/store/gas-report.json | 64 ++++++++--------- packages/store/src/IStore.sol | 9 --- packages/store/src/StoreCore.sol | 35 ++-------- packages/store/src/StoreSwitch.sol | 15 ---- .../store/src/codegen/tables/Callbacks.sol | 18 +++-- packages/store/src/codegen/tables/Hooks.sol | 18 +++-- packages/store/src/codegen/tables/Mixed.sol | 18 +++-- .../store/src/codegen/tables/StoreHooks.sol | 18 +++-- packages/store/src/codegen/tables/Tables.sol | 18 +++-- packages/store/test/StoreCore.t.sol | 35 ++++++++-- packages/store/test/StoreCoreGas.t.sol | 18 ++++- packages/store/test/StoreMock.sol | 11 --- packages/store/ts/codegen/field.ts | 41 ++++++----- packages/world/gas-report.json | 68 +++++++++---------- packages/world/src/World.sol | 18 ----- .../src/modules/core/tables/SystemHooks.sol | 18 +++-- .../keysintable/tables/KeysInTable.sol | 45 ++++++++---- .../keyswithvalue/tables/KeysWithValue.sol | 18 +++-- packages/world/test/WorldDynamicUpdate.t.sol | 24 ++++--- packages/world/test/tables/AddressArray.sol | 18 +++-- 24 files changed, 358 insertions(+), 286 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index 8a3c4441e3..7f70d3db64 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -396,7 +396,8 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -408,7 +409,8 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -420,7 +422,8 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -432,7 +435,8 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -444,7 +448,8 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -456,7 +461,8 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index fee35f90d1..4957973342 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -277,7 +277,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -290,7 +291,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -303,7 +305,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -490,7 +493,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -503,7 +507,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -516,7 +521,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -703,7 +709,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 16), uint40(_encoded.length), _encoded); } } @@ -716,7 +723,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 16), uint40(_encoded.length), _encoded); } } @@ -729,7 +737,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 16), uint40(_encoded.length), _encoded); } } @@ -916,7 +925,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 3, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -929,7 +939,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 3, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -942,7 +953,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 3, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -1129,7 +1141,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 4, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -1142,7 +1155,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 4, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -1155,7 +1169,8 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 4, uint40(_index * 1), uint40(_encoded.length), _encoded); } } diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index d3767a797c..06603f02f2 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -271,7 +271,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 8), uint40(_encoded.length), _encoded); } } @@ -284,7 +285,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 8), uint40(_encoded.length), _encoded); } } @@ -297,7 +299,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 8), uint40(_encoded.length), _encoded); } } @@ -484,7 +487,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -497,7 +501,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -510,7 +515,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + _store.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -697,7 +703,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -710,7 +717,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -723,7 +731,8 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + _store.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 1), uint40(_encoded.length), _encoded); } } diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index a7b8171af7..ab91f15ecc 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -291,7 +291,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -303,7 +304,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -315,7 +317,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -483,7 +486,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -495,7 +499,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -507,7 +512,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -675,7 +681,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -687,7 +694,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -699,7 +707,8 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 4), uint40(_encoded.length), _encoded); } } diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 0a89272ae2..8d0a243835 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -651,25 +651,25 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (cold, 1 slot, 1 uint32 item)", - "gasUsed": 18696 + "gasUsed": 18728 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (warm, 1 slot, 1 uint32 item)", - "gasUsed": 12704 + "gasUsed": 12736 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 16464 + "gasUsed": 16496 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (warm, 2 slots, 10 uint32 items)", - "gasUsed": 12472 + "gasUsed": 12504 }, { "file": "test/StoreCoreGas.t.sol", @@ -729,61 +729,61 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 57987 + "gasUsed": 58019 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 72493 + "gasUsed": 72428 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 19893 + "gasUsed": 19915 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18719 + "gasUsed": 18741 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 57987 + "gasUsed": 58019 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 165648 + "gasUsed": 165583 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 24513 + "gasUsed": 24599 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 20385 + "gasUsed": 20407 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 9492 + "gasUsed": 9524 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (2 slots, 10 uint32 items)", - "gasUsed": 32162 + "gasUsed": 32194 }, { "file": "test/StoreCoreGas.t.sol", @@ -879,7 +879,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53978 + "gasUsed": 54010 }, { "file": "test/StoreCoreGas.t.sol", @@ -891,7 +891,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, second dynamic field)", - "gasUsed": 32201 + "gasUsed": 32233 }, { "file": "test/StoreCoreGas.t.sol", @@ -927,13 +927,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 8990 + "gasUsed": 8872 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "push to field (2 slots, 6 uint64 items)", - "gasUsed": 9436 + "gasUsed": 9318 }, { "file": "test/StoreHook.t.sol", @@ -975,7 +975,7 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: set field", - "gasUsed": 56289 + "gasUsed": 56321 }, { "file": "test/tables/Callbacks.t.sol", @@ -987,19 +987,19 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: push 1 element", - "gasUsed": 32547 + "gasUsed": 32579 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testOneSlot", "name": "StoreHooks: set field with one elements (cold)", - "gasUsed": 58295 + "gasUsed": 58327 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (cold)", - "gasUsed": 58295 + "gasUsed": 58327 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1011,25 +1011,25 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (cold)", - "gasUsed": 12645 + "gasUsed": 12677 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: pop 1 element (warm)", - "gasUsed": 9979 + "gasUsed": 10011 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (warm)", - "gasUsed": 10662 + "gasUsed": 10694 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: update 1 element (warm)", - "gasUsed": 30028 + "gasUsed": 29920 }, { "file": "test/tables/StoreHooks.t.sol", @@ -1041,19 +1041,19 @@ "file": "test/tables/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 30440 + "gasUsed": 30472 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testThreeSlots", "name": "StoreHooks: set field with three elements (cold)", - "gasUsed": 80983 + "gasUsed": 81015 }, { "file": "test/tables/StoreHooks.t.sol", "test": "testTwoSlots", "name": "StoreHooks: set field with two elements (cold)", - "gasUsed": 80895 + "gasUsed": 80927 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", @@ -1083,13 +1083,13 @@ "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testPop", "name": "StoreHooks: pop 1 element (cold)", - "gasUsed": 18414 + "gasUsed": 18446 }, { "file": "test/tables/StoreHooksColdLoad.t.sol", "test": "testUpdate", "name": "StoreHooks: update 1 element (cold)", - "gasUsed": 20483 + "gasUsed": 20375 }, { "file": "test/tightcoder/DecodeSlice.t.sol", @@ -1143,7 +1143,7 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 442534 + "gasUsed": 442557 }, { "file": "test/Vector2.t.sol", diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index ed2c1340a4..192968fb27 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -207,15 +207,6 @@ interface IStoreWrite { uint256 byteLengthToPop ) external; - // Change encoded items within the dynamic field at field index - function updateInDynamicField( - ResourceId tableId, - bytes32[] calldata keyTuple, - uint8 dynamicFieldIndex, - uint256 startByteIndex, - bytes calldata dataToSet - ) external; - // Set full record (including full dynamic data) function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) external; } diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 55545e8fb6..8679adb77d 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -529,36 +529,6 @@ library StoreCore { }); } - /** - * Update data in a field in a table with the given tableId, key tuple and value field layout - */ - function updateInDynamicField( - ResourceId tableId, - bytes32[] memory keyTuple, - uint8 dynamicFieldIndex, - uint256 startByteIndex, - bytes memory dataToSet - ) internal { - // Verify that the index is in bounds of the dynamic field - PackedCounter previousEncodedLengths = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, keyTuple); - if (startByteIndex + dataToSet.length > previousEncodedLengths.atIndex(dynamicFieldIndex)) { - revert IStoreErrors.Store_IndexOutOfBounds( - previousEncodedLengths.atIndex(dynamicFieldIndex), - startByteIndex + dataToSet.length - 1 - ); - } - - StoreCoreInternal._spliceDynamicData({ - tableId: tableId, - keyTuple: keyTuple, - dynamicFieldIndex: dynamicFieldIndex, - startWithinField: uint40(startByteIndex), - data: dataToSet, - deleteCount: uint40(dataToSet.length), - previousEncodedLengths: previousEncodedLengths - }); - } - /************************************************************************ * * GET DATA @@ -777,6 +747,11 @@ library StoreCoreInternal { revert IStoreErrors.Store_InvalidSplice(startWithinField, deleteCount, uint40(previousFieldLength)); } + // The start index can't be larger than the previous length of the field + if (startWithinField > previousFieldLength) { + revert IStoreErrors.Store_IndexOutOfBounds(previousFieldLength, startWithinField); + } + // Compute start index for the splice uint256 start = startWithinField; unchecked { diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 27530c562b..08af0e37b5 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -238,21 +238,6 @@ library StoreSwitch { } } - function updateInDynamicField( - ResourceId tableId, - bytes32[] memory keyTuple, - uint8 dynamicFieldIndex, - uint256 startByteIndex, - bytes memory dataToSet - ) internal { - address _storeAddress = getStoreAddress(); - if (_storeAddress == address(this)) { - StoreCore.updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); - } else { - IStore(_storeAddress).updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); - } - } - function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index 415a1c4f66..78cf4c6bf3 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -435,7 +435,8 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 24), uint40(_encoded.length), _encoded); } } @@ -448,7 +449,8 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 24), uint40(_encoded.length), _encoded); } } @@ -461,7 +463,8 @@ library Callbacks { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 24), uint40(_encoded.length), _encoded); } } @@ -474,7 +477,8 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 24), uint40(_encoded.length), _encoded); } } @@ -487,7 +491,8 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 24), uint40(_encoded.length), _encoded); } } @@ -500,7 +505,8 @@ library Callbacks { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 24), uint40(_encoded.length), _encoded); } } diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 91f9136c05..3210316a6b 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -435,7 +435,8 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -448,7 +449,8 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -461,7 +463,8 @@ library Hooks { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -474,7 +477,8 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -487,7 +491,8 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -500,7 +505,8 @@ library Hooks { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 452a27f0c9..603baed3bd 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -376,7 +376,8 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -389,7 +390,8 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -402,7 +404,8 @@ library Mixed { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 4), uint40(_encoded.length), _encoded); } } @@ -589,7 +592,8 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -602,7 +606,8 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -615,7 +620,8 @@ library Mixed { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + _store.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index 2a1153f17f..964bf84104 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -435,7 +435,8 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -448,7 +449,8 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -461,7 +463,8 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -474,7 +477,8 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -487,7 +491,8 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -500,7 +505,8 @@ library StoreHooks { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index 39a10fdec1..36a03a5a66 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -437,7 +437,8 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -450,7 +451,8 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -463,7 +465,8 @@ library Tables { _keyTuple[0] = tableId; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -657,7 +660,8 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -670,7 +674,8 @@ library Tables { _keyTuple[0] = tableId; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } @@ -683,7 +688,8 @@ library Tables { _keyTuple[0] = tableId; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + bytes memory _encoded = bytes((_slice)); + _store.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded); } } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 90eca45674..61dc2cddcd 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -874,7 +874,7 @@ contract StoreCoreTest is Test, StoreMock { assertEq(IStore(this).getField(data.tableId, data.keyTuple, 1, fieldLayout), data.newSecondDataBytes, "10"); } - struct TestUpdateInDynamicFieldData { + struct TestSpliceDynamicDataData { ResourceId tableId; bytes32[] keyTuple; bytes32 firstDataBytes; @@ -889,10 +889,10 @@ contract StoreCoreTest is Test, StoreMock { bytes loadedData; } - function testUpdateInDynamicField() public { + function testSpliceDynamicData() public { ResourceId tableId = _tableId; - TestUpdateInDynamicFieldData memory data = TestUpdateInDynamicFieldData( + TestSpliceDynamicDataData memory data = TestSpliceDynamicDataData( tableId, new bytes32[](0), 0, @@ -969,7 +969,14 @@ contract StoreCoreTest is Test, StoreMock { ); // Update index 1 in second field (4 = byte length of uint32) - IStore(this).updateInDynamicField(data.tableId, data.keyTuple, 0, 4 * 1, data.secondDataForUpdate); + IStore(this).spliceDynamicData( + data.tableId, + data.keyTuple, + 0, + uint40(4 * 1), + uint40(data.secondDataForUpdate.length), + data.secondDataForUpdate + ); // Get second field data.loadedData = IStore(this).getField(data.tableId, data.keyTuple, 1, fieldLayout); @@ -1014,7 +1021,14 @@ contract StoreCoreTest is Test, StoreMock { ); // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) - IStore(this).updateInDynamicField(data.tableId, data.keyTuple, 1, 8 * 1, data.thirdDataForUpdate); + IStore(this).spliceDynamicData( + data.tableId, + data.keyTuple, + 1, + uint40(8 * 1), + uint40(data.thirdDataForUpdate.length), + data.thirdDataForUpdate + ); // Get third field data.loadedData = IStore(this).getField(data.tableId, data.keyTuple, 2, fieldLayout); @@ -1033,10 +1047,17 @@ contract StoreCoreTest is Test, StoreMock { abi.encodeWithSelector( IStoreErrors.Store_IndexOutOfBounds.selector, data.newThirdDataBytes.length, - type(uint56).max + data.thirdDataForUpdate.length - 1 + uint40(type(uint56).max) ) ); - IStore(this).updateInDynamicField(data.tableId, data.keyTuple, 1, type(uint56).max, data.thirdDataForUpdate); + IStore(this).spliceDynamicData( + data.tableId, + data.keyTuple, + 1, + uint40(type(uint56).max), + uint40(data.thirdDataForUpdate.length), + data.thirdDataForUpdate + ); } function testAccessEmptyData() public { diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 044863552f..dfe4f86597 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -556,7 +556,14 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update index 1 in second field (4 = byte length of uint32) startGasReport("update in field (1 slot, 1 uint32 item)"); - StoreCore.updateInDynamicField(tableId, keyTuple, 0, 4 * 1, data.secondDataForUpdate); + StoreCore.spliceDynamicData( + tableId, + keyTuple, + 0, + uint40(4 * 1), + uint40(data.secondDataForUpdate.length), + data.secondDataForUpdate + ); endGasReport(); // Create data for update @@ -580,7 +587,14 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) startGasReport("push to field (2 slots, 6 uint64 items)"); - StoreCore.updateInDynamicField(tableId, keyTuple, 1, 8 * 1, data.thirdDataForUpdate); + StoreCore.spliceDynamicData( + tableId, + keyTuple, + 1, + uint40(8 * 1), + uint40(data.thirdDataForUpdate.length), + data.thirdDataForUpdate + ); endGasReport(); } diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index 09a8550cf4..590a53f033 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -113,17 +113,6 @@ contract StoreMock is IStore, StoreRead { StoreCore.popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } - // Change encoded items within the dynamic field at field index - function updateInDynamicField( - ResourceId tableId, - bytes32[] calldata keyTuple, - uint8 dynamicFieldIndex, - uint256 startByteIndex, - bytes calldata dataToSet - ) public virtual { - StoreCore.updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); - } - // Set full record (including full dynamic data) function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) public virtual { StoreCore.deleteRecord(tableId, keyTuple); diff --git a/packages/store/ts/codegen/field.ts b/packages/store/ts/codegen/field.ts index 457b2e8c8a..30b0beeebe 100644 --- a/packages/store/ts/codegen/field.ts +++ b/packages/store/ts/codegen/field.ts @@ -165,33 +165,38 @@ export function renderFieldMethods(options: RenderTableOptions) { ); result += renderWithFieldSuffix(options.withSuffixlessFieldMethods, field.name, (_methodNameSuffix) => - renderWithStore( - storeArgument, - (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => ` - /** - * Update ${portionData.title} of ${field.name}${_commentSuffix} at \`_index\` - * (checked only to prevent modifying other tables; can corrupt own data if index overflows) - */ - function ${_methodNamePrefix}update${_methodNameSuffix}(${renderArguments([ + renderWithStore(storeArgument, (_typedStore, _store, _commentSuffix, _untypedStore, _methodNamePrefix) => { + const externalArguments = renderArguments([ _typedStore, _typedTableId, _typedKeyArgs, "uint256 _index", `${portionData.typeWithLocation} ${portionData.name}`, - ])}) internal { + ]); + + const internalArguments = ` + _tableId, + _keyTuple, + ${dynamicSchemaIndex}, + uint40(_index * ${portionData.elementLength}), + uint40(_encoded.length), + _encoded + `; + + return ` + /** + * Update ${portionData.title} of ${field.name}${_commentSuffix} at \`_index\` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function ${_methodNamePrefix}update${_methodNameSuffix}(${externalArguments}) internal { ${_keyTupleDefinition} unchecked { - ${_store}.updateInDynamicField( - _tableId, - _keyTuple, - ${dynamicSchemaIndex}, - _index * ${portionData.elementLength}, - ${portionData.encoded} - ); + bytes memory _encoded = ${portionData.encoded}; + ${_store}.spliceDynamicData(${internalArguments}); } } - ` - ) + `; + }) ); } } diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index a7dc136a89..b83ce1fac5 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -39,31 +39,31 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1408378 + "gasUsed": 1408343 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1408378 + "gasUsed": 1408343 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 158958 + "gasUsed": 159011 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1408378 + "gasUsed": 1408343 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1408378 + "gasUsed": 1408343 }, { "file": "test/KeysInTableModule.t.sol", @@ -75,13 +75,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 156295 + "gasUsed": 156389 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1408378 + "gasUsed": 1408343 }, { "file": "test/KeysInTableModule.t.sol", @@ -93,13 +93,13 @@ "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 85289 + "gasUsed": 85335 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 649535 + "gasUsed": 649500 }, { "file": "test/KeysWithValueModule.t.sol", @@ -117,25 +117,25 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 649535 + "gasUsed": 649500 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 135647 + "gasUsed": 135679 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 649535 + "gasUsed": 649500 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 104002 + "gasUsed": 104066 }, { "file": "test/KeysWithValueModule.t.sol", @@ -147,49 +147,49 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 649535 + "gasUsed": 649500 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 146878 + "gasUsed": 146910 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 111637 + "gasUsed": 111669 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 104977 + "gasUsed": 105109 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 53535 + "gasUsed": 53579 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 131154 + "gasUsed": 131374 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 84321 + "gasUsed": 84497 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 84984 + "gasUsed": 85116 }, { "file": "test/query.t.sol", @@ -201,19 +201,19 @@ "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18838 + "gasUsed": 18882 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5804541 + "gasUsed": 5804585 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 541494 + "gasUsed": 541538 }, { "file": "test/query.t.sol", @@ -225,7 +225,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 47131 + "gasUsed": 47175 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -255,7 +255,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 676029 + "gasUsed": 676007 }, { "file": "test/UniqueEntityModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 643348 + "gasUsed": 643281 }, { "file": "test/UniqueEntityModule.t.sol", @@ -303,7 +303,7 @@ "file": "test/World.t.sol", "test": "testPushToDynamicField", "name": "Push data to the table", - "gasUsed": 85856 + "gasUsed": 85888 }, { "file": "test/World.t.sol", @@ -351,25 +351,25 @@ "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromDyanmicField", "name": "pop 1 address (cold)", - "gasUsed": 23714 + "gasUsed": 23679 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromDyanmicField", "name": "pop 1 address (warm)", - "gasUsed": 12860 + "gasUsed": 12825 }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testUpdateInDynamicField", + "test": "testSpliceDynamicData", "name": "update in field 1 item (cold)", - "gasUsed": 24371 + "gasUsed": 24030 }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testUpdateInDynamicField", + "test": "testSpliceDynamicData", "name": "update in field 1 item (warm)", - "gasUsed": 13570 + "gasUsed": 13231 }, { "file": "test/WorldResourceId.t.sol", diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 8f8ecf65e1..5cead664e8 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -258,24 +258,6 @@ contract World is StoreRead, IStoreData, IWorldKernel { StoreCore.popFromDynamicField(tableId, keyTuple, dynamicFieldIndex, byteLengthToPop); } - /** - * Update data at `startByteIndex` of a field in the table at the given tableId. - * Requires the caller to have access to the table's namespace or name (encoded in the tableId). - */ - function updateInDynamicField( - ResourceId tableId, - bytes32[] calldata keyTuple, - uint8 dynamicFieldIndex, - uint256 startByteIndex, - bytes calldata dataToSet - ) public virtual requireNoCallback { - // Require access to namespace or name - AccessControl.requireAccess(tableId, msg.sender); - - // Update data in the field - StoreCore.updateInDynamicField(tableId, keyTuple, dynamicFieldIndex, startByteIndex, dataToSet); - } - /** * Delete a record in the table at the given tableId. * Requires the caller to have access to the namespace or name. diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index d08648b1bf..28ca84f61c 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -435,7 +435,8 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -448,7 +449,8 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -461,7 +463,8 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -474,7 +477,8 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -487,7 +491,8 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } @@ -500,7 +505,8 @@ library SystemHooks { _keyTuple[0] = systemId; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 21, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 21), uint40(_encoded.length), _encoded); } } diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 3d62bfffb1..5c049370a7 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -277,7 +277,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -290,7 +291,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -303,7 +305,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -490,7 +493,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -503,7 +507,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -516,7 +521,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -703,7 +709,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -716,7 +723,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -729,7 +737,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 2, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -916,7 +925,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 3, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -929,7 +939,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 3, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -942,7 +953,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 3, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -1129,7 +1141,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 4, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -1142,7 +1155,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 4, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -1155,7 +1169,8 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 4, uint40(_index * 32), uint40(_encoded.length), _encoded); } } diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 2cfba3c42d..eb6625f4dd 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -467,7 +467,8 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -480,7 +481,8 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -499,7 +501,8 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -512,7 +515,8 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -525,7 +529,8 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } @@ -538,7 +543,8 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 32), uint40(_encoded.length), _encoded); } } diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index 18d130589e..493e120065 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -81,7 +81,7 @@ contract UpdateInDynamicFieldTest is Test, GasReporter { vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_AccessDenied.selector, _tableId.toString(), _caller)); } - function testPopFromDyanmicField() public { + function testPopFromDynamicField() public { FieldLayout fieldLayout = AddressArray.getFieldLayout(); // Expect the data to be written @@ -139,7 +139,7 @@ contract UpdateInDynamicFieldTest is Test, GasReporter { world.popFromDynamicField(tableId, keyTuple, 0, 20); } - function testUpdateInDynamicField() public { + function testSpliceDynamicData() public { FieldLayout fieldLayout = AddressArray.getFieldLayout(); // Expect the data to be written @@ -148,13 +148,14 @@ contract UpdateInDynamicFieldTest is Test, GasReporter { // Update index 0 address[] memory dataForUpdate = new address[](1); dataForUpdate[0] = address(bytes20(keccak256("address for update"))); + bytes memory encodedDataForUpdate = EncodeArray.encode(dataForUpdate); startGasReport("update in field 1 item (cold)"); - world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.spliceDynamicData(tableId, keyTuple, 0, uint40(0), uint40(encodedDataForUpdate.length), encodedDataForUpdate); endGasReport(); startGasReport("update in field 1 item (warm)"); - world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.spliceDynamicData(tableId, keyTuple, 0, uint40(0), uint40(encodedDataForUpdate.length), encodedDataForUpdate); endGasReport(); // Expect the data to be updated @@ -162,7 +163,14 @@ contract UpdateInDynamicFieldTest is Test, GasReporter { assertEq(AddressArray.get(world, tableId, key), initData); // Update index 1 via direct access - world.updateInDynamicField(tableId, keyTuple, 0, 20 * 1, EncodeArray.encode(dataForUpdate)); + world.spliceDynamicData( + tableId, + keyTuple, + 0, + uint40(20 * 1), + uint40(encodedDataForUpdate.length), + encodedDataForUpdate + ); // Expect the data to be updated initData[1] = dataForUpdate[0]; @@ -170,13 +178,13 @@ contract UpdateInDynamicFieldTest is Test, GasReporter { // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), tableId); - world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.spliceDynamicData(tableId, keyTuple, 0, uint40(0), uint40(encodedDataForUpdate.length), encodedDataForUpdate); // Expect the World to not have access vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.updateInDynamicField.selector) + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.spliceDynamicData.selector) ); - world.updateInDynamicField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.spliceDynamicData(tableId, keyTuple, 0, uint40(0), uint40(encodedDataForUpdate.length), encodedDataForUpdate); } } diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 652b543329..b9e4230eef 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -435,7 +435,8 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -448,7 +449,8 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -461,7 +463,8 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -474,7 +477,8 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -487,7 +491,8 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreCore.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); } } @@ -500,7 +505,8 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInDynamicField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); } } From d9fdbf9091380c9fcba8c31e3be0d8d9a4633b36 Mon Sep 17 00:00:00 2001 From: alvarius Date: Sat, 23 Sep 2023 22:31:34 +0100 Subject: [PATCH 35/38] Update wicked-squids-do.md --- .changeset/wicked-squids-do.md | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.changeset/wicked-squids-do.md b/.changeset/wicked-squids-do.md index 28200e2527..287e6c643b 100644 --- a/.changeset/wicked-squids-do.md +++ b/.changeset/wicked-squids-do.md @@ -55,11 +55,19 @@ bytes calldata data ) external; } + ``` +- The `updateInField` method has been removed from `IStore`, as it's almost identical to the more general `spliceDynamicData`. + If you're manually calling `updateInField`, here is how to upgrade to `spliceDynamicData`: + + ```diff + - store.updateInField(tableId, keyTuple, fieldIndex, startByteIndex, dataToSet, fieldLayout); + + uint8 dynamicFieldIndex = fieldIndex - fieldLayout.numStaticFields(); + + store.spliceDynamicData(tableId, keyTuple, dynamicFieldIndex, uint40(startByteIndex), uint40(dataToSet.length), dataToSet); ``` -- All methods that are only valid for dynamic fields (`pushToField`, `popFromField`, `updateInField`, `getFieldSlice`) - have been renamed to make this more explicit (`pushToDynamicField`, `popFromDynamicField`, `updateInDynamicField`, `getDynamicFieldSlice`). +- All other methods that are only valid for dynamic fields (`pushToField`, `popFromField`, `getFieldSlice`) + have been renamed to make this more explicit (`pushToDynamicField`, `popFromDynamicField`, `getDynamicFieldSlice`). Their `fieldIndex` parameter has been replaced by a `dynamicFieldIndex` parameter, which is the index relative to the first dynamic field (i.e. `dynamicFieldIndex` = `fieldIndex` - `numStaticFields`). The `FieldLayout` parameter has been removed, as it was only used to calculate the `dynamicFieldIndex` in the method. @@ -86,17 +94,6 @@ - FieldLayout fieldLayout ) external; - - function updateInField( - + function updateInDynamicField( - ResourceId tableId, - bytes32[] calldata keyTuple, - - uint8 fieldIndex, - + uint8 dynamicFieldIndex, - uint256 startByteIndex, - bytes calldata dataToSet, - - FieldLayout fieldLayout - ) external; - - function getFieldSlice( + function getDynamicFieldSlice( ResourceId tableId, From 05eb31bec31e2aff4dc882d183dfb5c2878c1af4 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 22:32:35 +0100 Subject: [PATCH 36/38] update gas report --- packages/world/gas-report.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index b83ce1fac5..ca76f2c34a 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -349,13 +349,13 @@ }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testPopFromDyanmicField", + "test": "testPopFromDynamicField", "name": "pop 1 address (cold)", "gasUsed": 23679 }, { "file": "test/WorldDynamicUpdate.t.sol", - "test": "testPopFromDyanmicField", + "test": "testPopFromDynamicField", "name": "pop 1 address (warm)", "gasUsed": 12825 }, From 1d3adb8897ec9ea7e767cfab4df58f76fcbd63e0 Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 22:34:17 +0100 Subject: [PATCH 37/38] prettier --- .changeset/wicked-squids-do.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.changeset/wicked-squids-do.md b/.changeset/wicked-squids-do.md index 287e6c643b..039fb58cb8 100644 --- a/.changeset/wicked-squids-do.md +++ b/.changeset/wicked-squids-do.md @@ -59,7 +59,7 @@ - The `updateInField` method has been removed from `IStore`, as it's almost identical to the more general `spliceDynamicData`. If you're manually calling `updateInField`, here is how to upgrade to `spliceDynamicData`: - + ```diff - store.updateInField(tableId, keyTuple, fieldIndex, startByteIndex, dataToSet, fieldLayout); + uint8 dynamicFieldIndex = fieldIndex - fieldLayout.numStaticFields(); @@ -108,7 +108,7 @@ ``` - `IStore` has a new `getDynamicFieldLength` length method, which returns the byte length of the given dynamic field and doesn't require the `FieldLayout`. - + ```diff IStore { + function getDynamicFieldLength( @@ -118,11 +118,11 @@ + ) external view returns (uint256); } + ``` + - `IStore` now has additional overloads for `getRecord`, `getField`, `getFieldLength` and `setField` that don't require a `FieldLength` to be passed, but instead load it from storage. - `IStore` now exposes `setStaticField` and `setDynamicField` to save gas by avoiding the dynamic inference of whether the field is static or dynamic. - The `getDynamicFieldSlice` method no longer accepts reading outside the bounds of the dynamic field. This is to avoid returning invalid data, as the data of a dynamic field is not deleted when the record is deleted, but only its length is set to zero. - - From 7893115b341ec155369e7db69207fd057211aabc Mon Sep 17 00:00:00 2001 From: alvrs Date: Sat, 23 Sep 2023 22:37:00 +0100 Subject: [PATCH 38/38] replace custom function with size --- packages/common/src/getByteLength.ts | 6 ------ packages/common/src/index.ts | 1 - packages/store-sync/src/postgres/postgresStorage.ts | 11 +++-------- packages/store-sync/src/recs/recsStorage.ts | 11 +++-------- packages/store-sync/src/sqlite/sqliteStorage.ts | 11 +++-------- 5 files changed, 9 insertions(+), 31 deletions(-) delete mode 100644 packages/common/src/getByteLength.ts diff --git a/packages/common/src/getByteLength.ts b/packages/common/src/getByteLength.ts deleted file mode 100644 index dfbe61e2ce..0000000000 --- a/packages/common/src/getByteLength.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Hex } from "viem"; - -export function getByteLength(data: Hex): number { - // Remove `0x` prefix, then byte is 2 characters - return (data.length - 2) / 2; -} diff --git a/packages/common/src/index.ts b/packages/common/src/index.ts index c4d9e899ad..a15afa9877 100644 --- a/packages/common/src/index.ts +++ b/packages/common/src/index.ts @@ -9,4 +9,3 @@ export * from "./resourceIdToHex"; export * from "./resourceTypes"; export * from "./spliceHex"; export * from "./transportObserver"; -export * from "./getByteLength"; diff --git a/packages/store-sync/src/postgres/postgresStorage.ts b/packages/store-sync/src/postgres/postgresStorage.ts index fb61096b6c..127889a855 100644 --- a/packages/store-sync/src/postgres/postgresStorage.ts +++ b/packages/store-sync/src/postgres/postgresStorage.ts @@ -1,4 +1,4 @@ -import { Hex, PublicClient, concatHex } from "viem"; +import { Hex, PublicClient, concatHex, size } from "viem"; import { PgDatabase, QueryResultHKT } from "drizzle-orm/pg-core"; import { eq, inArray } from "drizzle-orm"; import { buildTable } from "./buildTable"; @@ -7,7 +7,7 @@ import { debug } from "./debug"; import { buildInternalTables } from "./buildInternalTables"; import { getTables } from "./getTables"; import { schemaVersion } from "./schemaVersion"; -import { getByteLength, hexToResourceId, spliceHex } from "@latticexyz/common"; +import { hexToResourceId, spliceHex } from "@latticexyz/common"; import { setupTables } from "./setupTables"; import { getTableKey } from "./getTableKey"; import { StorageAdapter, StorageAdapterBlock } from "../common"; @@ -132,12 +132,7 @@ export async function postgresStorage // TODO: verify that this returns what we expect (doesn't error/undefined on no record) const previousValue = (await tx.select().from(sqlTable).where(eq(sqlTable.__key, uniqueKey)).execute())[0]; const previousStaticData = (previousValue?.__staticData as Hex) ?? "0x"; - const newStaticData = spliceHex( - previousStaticData, - log.args.start, - getByteLength(log.args.data), - log.args.data - ); + const newStaticData = spliceHex(previousStaticData, log.args.start, size(log.args.data), log.args.data); const newValue = decodeValueArgs(table.valueSchema, { staticData: newStaticData, encodedLengths: (previousValue?.__encodedLengths as Hex) ?? "0x", diff --git a/packages/store-sync/src/recs/recsStorage.ts b/packages/store-sync/src/recs/recsStorage.ts index a9d1e78c33..f4c3672d2a 100644 --- a/packages/store-sync/src/recs/recsStorage.ts +++ b/packages/store-sync/src/recs/recsStorage.ts @@ -3,9 +3,9 @@ import { debug } from "./debug"; import { World as RecsWorld, getComponentValue, hasComponent, removeComponent, setComponent } from "@latticexyz/recs"; import { defineInternalComponents } from "./defineInternalComponents"; import { getTableEntity } from "./getTableEntity"; -import { getByteLength, hexToResourceId, spliceHex } from "@latticexyz/common"; +import { hexToResourceId, spliceHex } from "@latticexyz/common"; import { decodeValueArgs } from "@latticexyz/protocol-parser"; -import { Hex } from "viem"; +import { Hex, size } from "viem"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; import { logToTable } from "../logToTable"; import { hexKeyTupleToEntity } from "./hexKeyTupleToEntity"; @@ -98,12 +98,7 @@ export function recsStorage({ // TODO: add tests that this works when no record had been set before const previousValue = getComponentValue(component, entity); const previousStaticData = (previousValue?.__staticData as Hex) ?? "0x"; - const newStaticData = spliceHex( - previousStaticData, - log.args.start, - getByteLength(log.args.data), - log.args.data - ); + const newStaticData = spliceHex(previousStaticData, log.args.start, size(log.args.data), log.args.data); const newValue = decodeValueArgs(table.valueSchema, { staticData: newStaticData, encodedLengths: (previousValue?.__encodedLengths as Hex) ?? "0x", diff --git a/packages/store-sync/src/sqlite/sqliteStorage.ts b/packages/store-sync/src/sqlite/sqliteStorage.ts index 4898b1b6a0..c010d8c8d7 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.ts @@ -1,4 +1,4 @@ -import { Hex, PublicClient, concatHex, getAddress } from "viem"; +import { Hex, PublicClient, concatHex, getAddress, size } from "viem"; import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core"; import { and, eq, sql } from "drizzle-orm"; import { sqliteTableToSql } from "./sqliteTableToSql"; @@ -12,7 +12,7 @@ import { schemaVersion } from "./schemaVersion"; import { StorageAdapter } from "../common"; import { isTableRegistrationLog } from "../isTableRegistrationLog"; import { logToTable } from "../logToTable"; -import { getByteLength, hexToResourceId, spliceHex } from "@latticexyz/common"; +import { hexToResourceId, spliceHex } from "@latticexyz/common"; import { decodeKey, decodeValueArgs } from "@latticexyz/protocol-parser"; // TODO: upgrade drizzle and use async sqlite interface for consistency @@ -131,12 +131,7 @@ export async function sqliteStorage({ // TODO: verify that this returns what we expect (doesn't error/undefined on no record) const previousValue = (await tx.select().from(sqlTable).where(eq(sqlTable.__key, uniqueKey)).execute())[0]; const previousStaticData = (previousValue?.__staticData as Hex) ?? "0x"; - const newStaticData = spliceHex( - previousStaticData, - log.args.start, - getByteLength(log.args.data), - log.args.data - ); + const newStaticData = spliceHex(previousStaticData, log.args.start, size(log.args.data), log.args.data); const newValue = decodeValueArgs(table.valueSchema, { staticData: newStaticData, encodedLengths: (previousValue?.__encodedLengths as Hex) ?? "0x",