Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(store): emit event after calling beforeSetRecord hook [L-02] #2017

Merged
merged 24 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3b3541d
fix(store): emit event after calling beforeSetRecord hook
yonadaa Dec 5, 2023
54317e4
fix: move splice events
yonadaa Dec 5, 2023
93d3b99
chore: docs, gas
yonadaa Dec 5, 2023
ab426ef
fix: rearrange _spliceDynamicData
yonadaa Dec 5, 2023
5edfb74
Merge remote-tracking branch 'origin/main' into yonadaaa/emit-event-a…
yonadaa Jan 5, 2024
15c2f5d
chore: do not change docs
yonadaa Jan 5, 2024
0d5ee29
fix: emit delete record event after hook
yonadaa Jan 5, 2024
e26a209
chore: changeset
yonadaa Jan 5, 2024
8526b26
fix: do not change encoded lengths
yonadaa Jan 5, 2024
90dd47d
fix: update correct lengths
yonadaa Jan 5, 2024
5a79dd2
Merge remote-tracking branch 'origin/main' into yonadaaa/emit-event-a…
yonadaa Jan 11, 2024
9cb4a3c
fix: proper early return for offchain tables
yonadaa Jan 12, 2024
2a84f6a
test: ensure that events are emitted for offchain table sets
yonadaa Jan 12, 2024
d05b85e
test: check for deleted offchain tables
yonadaa Jan 12, 2024
3d50fb3
feat: disable before hooks for offchain tables
yonadaa Jan 12, 2024
568aaf0
chore: gas tests
yonadaa Jan 12, 2024
2cbc51a
refactor: use boolean
yonadaa Jan 12, 2024
b4c2a40
perf: remove offchain check for before hooks
yonadaa Jan 12, 2024
5535e9f
refactor: early return with offchain tables immediately
yonadaa Jan 12, 2024
cb82d13
chore: move comments
yonadaa Jan 12, 2024
af2f79d
chore: comment
yonadaa Jan 12, 2024
03bd4b8
chore: root gas report
yonadaa Jan 12, 2024
38e6351
Merge remote-tracking branch 'origin/main' into yonadaaa/emit-event-a…
yonadaa Jan 12, 2024
ea87f34
Update .changeset/beige-ads-melt.md
holic Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-ads-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store": patch
---

Fixes the functions in `StoreCore` to emit a storage event after calling the `beforeSetRecord` hook, ensuring that storage events are emitted in the same order that values are set on-chain.
holic marked this conversation as resolved.
Show resolved Hide resolved
76 changes: 38 additions & 38 deletions packages/store/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"file": "test/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: set field",
"gasUsed": 56241
"gasUsed": 56256
},
{
"file": "test/Callbacks.t.sol",
Expand All @@ -75,7 +75,7 @@
"file": "test/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: push 1 element",
"gasUsed": 32499
"gasUsed": 32515
},
{
"file": "test/FieldLayout.t.sol",
Expand Down Expand Up @@ -369,7 +369,7 @@
"file": "test/KeyEncoding.t.sol",
"test": "testRegisterAndGetFieldLayout",
"name": "register KeyEncoding table",
"gasUsed": 719017
"gasUsed": 719047
},
{
"file": "test/Mixed.t.sol",
Expand All @@ -393,7 +393,7 @@
"file": "test/Mixed.t.sol",
"test": "testSetGetDeleteExternal",
"name": "set record in Mixed (external, cold)",
"gasUsed": 108527
"gasUsed": 108528
},
{
"file": "test/Mixed.t.sol",
Expand All @@ -411,7 +411,7 @@
"file": "test/Mixed.t.sol",
"test": "testSetGetDeleteInternal",
"name": "set record in Mixed (internal, cold)",
"gasUsed": 103281
"gasUsed": 103282
},
{
"file": "test/Mixed.t.sol",
Expand Down Expand Up @@ -669,25 +669,25 @@
"file": "test/StoreCoreDynamic.t.sol",
"test": "testPopFromSecondField",
"name": "pop from field (cold, 1 slot, 1 uint32 item)",
"gasUsed": 18017
"gasUsed": 18026
},
{
"file": "test/StoreCoreDynamic.t.sol",
"test": "testPopFromSecondField",
"name": "pop from field (warm, 1 slot, 1 uint32 item)",
"gasUsed": 12024
"gasUsed": 12034
},
{
"file": "test/StoreCoreDynamic.t.sol",
"test": "testPopFromThirdField",
"name": "pop from field (cold, 2 slots, 10 uint32 items)",
"gasUsed": 15785
"gasUsed": 15795
},
{
"file": "test/StoreCoreDynamic.t.sol",
"test": "testPopFromThirdField",
"name": "pop from field (warm, 2 slots, 10 uint32 items)",
"gasUsed": 11792
"gasUsed": 11803
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down Expand Up @@ -753,13 +753,13 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "set record on table with subscriber",
"gasUsed": 72296
"gasUsed": 72320
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooks",
"name": "set static field on table with subscriber",
"gasUsed": 19761
"gasUsed": 19785
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -777,13 +777,13 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "set (dynamic) record on table with subscriber",
"gasUsed": 165451
"gasUsed": 165460
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testHooksDynamicData",
"name": "set (dynamic) field on table with subscriber",
"gasUsed": 24439
"gasUsed": 24461
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -795,19 +795,19 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testPushToDynamicField",
"name": "push to field (1 slot, 1 uint32 item)",
"gasUsed": 9444
"gasUsed": 9460
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testPushToDynamicField",
"name": "push to field (2 slots, 10 uint32 items)",
"gasUsed": 32114
"gasUsed": 32135
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testRegisterAndGetFieldLayout",
"name": "StoreCore: register table",
"gasUsed": 640899
"gasUsed": 640929
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -831,7 +831,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetDynamicData",
"name": "set complex record with dynamic data (4 slots)",
"gasUsed": 102512
"gasUsed": 102513
},
{
"file": "test/StoreCoreGas.t.sol",
Expand Down Expand Up @@ -873,7 +873,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetField",
"name": "set static field (1 slot)",
"gasUsed": 31209
"gasUsed": 31237
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -885,7 +885,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetField",
"name": "set static field (overlap 2 slot)",
"gasUsed": 29862
"gasUsed": 29893
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -897,7 +897,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetField",
"name": "set dynamic field (1 slot, first dynamic field)",
"gasUsed": 53930
"gasUsed": 53946
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -909,7 +909,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetField",
"name": "set dynamic field (1 slot, second dynamic field)",
"gasUsed": 32153
"gasUsed": 32171
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -921,7 +921,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetStaticData",
"name": "set static record (1 slot)",
"gasUsed": 32756
"gasUsed": 32782
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -933,7 +933,7 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testSetAndGetStaticDataSpanningWords",
"name": "set static record (2 slots)",
"gasUsed": 55260
"gasUsed": 55289
},
{
"file": "test/StoreCoreGas.t.sol",
Expand All @@ -945,13 +945,13 @@
"file": "test/StoreCoreGas.t.sol",
"test": "testUpdateInDynamicField",
"name": "update in field (1 slot, 1 uint32 item)",
"gasUsed": 8792
"gasUsed": 8820
},
{
"file": "test/StoreCoreGas.t.sol",
"test": "testUpdateInDynamicField",
"name": "push to field (2 slots, 6 uint64 items)",
"gasUsed": 9238
"gasUsed": 9267
},
{
"file": "test/StoreHook.t.sol",
Expand Down Expand Up @@ -981,13 +981,13 @@
"file": "test/StoreHooks.t.sol",
"test": "testOneSlot",
"name": "StoreHooks: set field with one elements (cold)",
"gasUsed": 58247
"gasUsed": 58260
},
{
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: set field (cold)",
"gasUsed": 58247
"gasUsed": 58260
},
{
"file": "test/StoreHooks.t.sol",
Expand All @@ -999,25 +999,25 @@
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: push 1 element (cold)",
"gasUsed": 12597
"gasUsed": 12611
},
{
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: pop 1 element (warm)",
"gasUsed": 9931
"gasUsed": 9943
},
{
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: push 1 element (warm)",
"gasUsed": 10614
"gasUsed": 10631
},
{
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: update 1 element (warm)",
"gasUsed": 29840
"gasUsed": 29871
},
{
"file": "test/StoreHooks.t.sol",
Expand All @@ -1029,19 +1029,19 @@
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: set field (warm)",
"gasUsed": 30392
"gasUsed": 30412
},
{
"file": "test/StoreHooks.t.sol",
"test": "testThreeSlots",
"name": "StoreHooks: set field with three elements (cold)",
"gasUsed": 80935
"gasUsed": 80951
},
{
"file": "test/StoreHooks.t.sol",
"test": "testTwoSlots",
"name": "StoreHooks: set field with two elements (cold)",
"gasUsed": 80847
"gasUsed": 80863
},
{
"file": "test/StoreHooksColdLoad.t.sol",
Expand Down Expand Up @@ -1071,13 +1071,13 @@
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testPop",
"name": "StoreHooks: pop 1 element (cold)",
"gasUsed": 18366
"gasUsed": 18375
},
{
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testUpdate",
"name": "StoreHooks: update 1 element (cold)",
"gasUsed": 20295
"gasUsed": 20318
},
{
"file": "test/StoreSwitch.t.sol",
Expand Down Expand Up @@ -1143,13 +1143,13 @@
"file": "test/Vector2.t.sol",
"test": "testRegisterAndGetFieldLayout",
"name": "register Vector2 field layout",
"gasUsed": 442403
"gasUsed": 442432
},
{
"file": "test/Vector2.t.sol",
"test": "testSetAndGet",
"name": "set Vector2 record",
"gasUsed": 33658
"gasUsed": 33684
},
{
"file": "test/Vector2.t.sol",
Expand Down
Loading
Loading