Skip to content

Commit

Permalink
refactor(world): use _getSystem when fetching system addresses [N-11] (
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaaa authored Jan 4, 2024
1 parent 6780dd9 commit c207d35
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-emus-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/world": patch
---

Optimised `StoreRegistrationSystem` and `WorldRegistrationSystem` by fetching individual fields instead of entire records where possible.
16 changes: 8 additions & 8 deletions packages/world-modules/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/world/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c207d35

Please sign in to comment.