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

feat(store): indexed tableId in store events #1520

Merged
merged 8 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/stale-worms-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store": major
---

Store events now use an `indexed` `tableId`. This adds ~100 gas per write, but means we our sync stack can filter events by table.
2 changes: 0 additions & 2 deletions .changeset/thin-terms-lay.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This saves gas for use cases where the functionality to dynamically determine wh
We decided to continue to always generate a set of functions that dynamically decide which `Store` to use, so that the generated table libraries can still be imported by non-root systems.

```solidity

library Counter {
// Dynamically determine which store to write to based on the context
function set(uint32 value) internal;
Expand All @@ -21,5 +20,4 @@ library Counter {

// ... equivalent functions for all other Store methods
}

```
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# suppress diffs for codegen in PRs
**/codegen/**/*.sol linguist-generated=true
**/test-data/**/*.json linguist-generated=true
8 changes: 4 additions & 4 deletions packages/store-sync/src/postgres/postgresStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("postgresStorage", async () => {
{
"chainId": 31337,
"lastError": null,
"lastUpdatedBlockNumber": 6n,
"lastUpdatedBlockNumber": 5n,
"schemaVersion": 1,
},
]
Expand All @@ -74,7 +74,7 @@ describe("postgresStorage", async () => {
"key": "0x5FbDB2315678afecb367f032d93F642f64180aa3::NumberList",
"keySchema": {},
"lastError": null,
"lastUpdatedBlockNumber": 6n,
"lastUpdatedBlockNumber": 5n,
"name": "NumberList",
"namespace": "",
"schemaVersion": 1,
Expand All @@ -92,7 +92,7 @@ describe("postgresStorage", async () => {
{
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"keySchema": {},
"lastUpdatedBlockNumber": 6n,
"lastUpdatedBlockNumber": 5n,
"name": "NumberList",
"namespace": "",
"tableId": "0x000000000000000000000000000000004e756d6265724c697374000000000000",
Expand All @@ -111,7 +111,7 @@ describe("postgresStorage", async () => {
"__encodedLengths": "0x0000000000000000000000000000000000000000000000000800000000000008",
"__isDeleted": false,
"__key": "0x",
"__lastUpdatedBlockNumber": 6n,
"__lastUpdatedBlockNumber": 5n,
"__staticData": null,
"value": [
420,
Expand Down
8 changes: 4 additions & 4 deletions packages/store-sync/src/sqlite/sqliteStorage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("sqliteStorage", async () => {
{
"chainId": 31337,
"lastError": null,
"lastUpdatedBlockNumber": 6n,
"lastUpdatedBlockNumber": 5n,
"schemaVersion": 1,
},
]
Expand All @@ -77,7 +77,7 @@ describe("sqliteStorage", async () => {
"id": "0x5FbDB2315678afecb367f032d93F642f64180aa3____NumberList",
"keySchema": {},
"lastError": null,
"lastUpdatedBlockNumber": 6n,
"lastUpdatedBlockNumber": 5n,
"name": "NumberList",
"namespace": "",
"schemaVersion": 1,
Expand All @@ -96,7 +96,7 @@ describe("sqliteStorage", async () => {
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"id": "0x5FbDB2315678afecb367f032d93F642f64180aa3____NumberList",
"keySchema": {},
"lastUpdatedBlockNumber": 6n,
"lastUpdatedBlockNumber": 5n,
"name": "NumberList",
"namespace": "",
"tableId": "0x000000000000000000000000000000004e756d6265724c697374000000000000",
Expand All @@ -115,7 +115,7 @@ describe("sqliteStorage", async () => {
"__encodedLengths": "0x0000000000000000000000000000000000000000000000000800000000000008",
"__isDeleted": false,
"__key": "0x",
"__lastUpdatedBlockNumber": 6n,
"__lastUpdatedBlockNumber": 5n,
"__staticData": null,
"value": [
420,
Expand Down
Loading