diff --git a/.changeset/five-emus-battle.md b/.changeset/five-emus-battle.md new file mode 100644 index 0000000000..809894564e --- /dev/null +++ b/.changeset/five-emus-battle.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/world": patch +--- + +Optimised `StoreRegistrationSystem` and `WorldRegistrationSystem` by fetching individual fields instead of entire records where possible. diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index 7faafd63a2..ebd53a7704 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -135,7 +135,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 654271 + "gasUsed": 653351 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,7 +153,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 654271 + "gasUsed": 653351 }, { "file": "test/KeysWithValueModule.t.sol", @@ -165,7 +165,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 654271 + "gasUsed": 653351 }, { "file": "test/KeysWithValueModule.t.sol", @@ -183,7 +183,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 654271 + "gasUsed": 653351 }, { "file": "test/KeysWithValueModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 119215 + "gasUsed": 118295 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -279,7 +279,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromSystemDelegation", "name": "register a systembound delegation", - "gasUsed": 116771 + "gasUsed": 115851 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -291,7 +291,7 @@ "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 113709 + "gasUsed": 112789 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -303,7 +303,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 682567 + "gasUsed": 681647 }, { "file": "test/UniqueEntityModule.t.sol", diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 5dd330ca54..caf93441b1 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -117,7 +117,7 @@ "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 637367 + "gasUsed": 636447 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol index 35687225f2..1df3ca8a96 100644 --- a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol @@ -56,7 +56,7 @@ contract StoreRegistrationSystem is System, IWorldErrors { if (!ResourceIds._getExists(namespaceId)) { // Since this is a root system, we're in the context of the World contract already, // so we can use delegatecall to register the namespace - (address coreSystemAddress, ) = Systems._get(CORE_SYSTEM_ID); + address coreSystemAddress = Systems._getSystem(CORE_SYSTEM_ID); (bool success, bytes memory data) = coreSystemAddress.delegatecall( abi.encodeCall(WorldRegistrationSystem.registerNamespace, (namespaceId)) ); diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index a721841a1f..21025a33c5 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -249,7 +249,7 @@ contract WorldRegistrationSystem is System, IWorldErrors { // If the delegation is limited... if (Delegation.isLimited(delegationControlId) && initCallData.length > 0) { // Require the delegationControl contract to implement the IDelegationControl interface - (address delegationControl, ) = Systems._get(delegationControlId); + address delegationControl = Systems._getSystem(delegationControlId); requireInterface(delegationControl, DELEGATION_CONTROL_INTERFACE_ID); // Call the delegation control contract's init function @@ -288,7 +288,7 @@ contract WorldRegistrationSystem is System, IWorldErrors { AccessControl.requireOwner(namespaceId, _msgSender()); // Require the delegationControl contract to implement the IDelegationControl interface - (address delegationControl, ) = Systems._get(delegationControlId); + address delegationControl = Systems._getSystem(delegationControlId); requireInterface(delegationControl, DELEGATION_CONTROL_INTERFACE_ID); // Register the delegation control