-
Notifications
You must be signed in to change notification settings - Fork 196
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-indexer, store-sync): improve query performance and enable compression, add new api #2026
feat(store-indexer, store-sync): improve query performance and enable compression, add new api #2026
Changes from all commits
6f11afe
b8b54e8
d890c5b
058e5b7
0fbb1a3
943d2a5
d725663
95eafdc
3707e62
5f94e78
8c97999
9453ccc
3e39fa8
1878b99
3488924
0ec053b
be55ff8
b9832da
743fc11
b1c1702
fed6f10
c66ad9e
ad46585
244c42e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@latticexyz/common": minor | ||
--- | ||
|
||
- Added a `Result<Ok, Err>` type for more explicit and typesafe error handling ([inspired by Rust](https://doc.rust-lang.org/std/result/)). | ||
|
||
- Added a `includes` util as typesafe alternative to [`Array.prototype.includes()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
"@latticexyz/store-indexer": minor | ||
"@latticexyz/store-sync": minor | ||
--- | ||
|
||
- Improved query performance by 10x by moving from drizzle ORM to handcrafted SQL. | ||
- Moved away from `trpc` for more granular control over the transport layer. | ||
Added an `/api/logs` endpoint using the new query and gzip compression for 40x less data transferred over the wire. | ||
Deprecated the `/trpc/getLogs` and `/trpc/findAll` endpoints. | ||
- Added a `createIndexerClient` client for the new `/api` indexer API exported from `@latticexyz/store-sync/indexer-client`. | ||
The `createIndexerClient` export from `@latticexyz/store-sync/trpc-indexer` is deprecated. | ||
|
||
```diff | ||
- import { createIndexerClient } from "@latticexyz/store-sync/trpc-indexer"; | ||
+ import { createIndexerClient } from "@latticexyz/store-sync/indexer-client"; | ||
|
||
- const indexer = createIndexerClient({ url: "https://indexer.holesky.redstone.xyz/trpc" }); | ||
+ const indexer = createIndexerClient({ url: "https://indexer.holesky.redstone.xyz" }); | ||
|
||
- const snapshot = indexer.getLogs.query(options); | ||
+ const snapshot = indexer.getLogs(options); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"31337": { | ||
"address": "0x6e9474e9c83676b9a71133ff96db43e7aa0a4342" | ||
"address": "0x2ea123a56f2e986c9844bf4dc13050c4df200b29" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Inspired by https://doc.rust-lang.org/std/result/ | ||
export type Result<Ok, Err = unknown> = { ok: Ok } | { error: Err }; | ||
|
||
export function isOk<Ok, Err>(result: Result<Ok, Err>): result is { ok: Ok } { | ||
return "ok" in result; | ||
} | ||
|
||
export function isError<Ok, Err>(result: Result<Ok, Err>): result is { error: Err } { | ||
return "error" in result; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function includes<item>(items: item[], value: any): value is item { | ||
return items.includes(value); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ const database = drizzle(postgres(env.DATABASE_URL)); | |
|
||
if (await shouldCleanDatabase(database, chainId)) { | ||
console.log("outdated database detected, clearing data to start fresh"); | ||
cleanDatabase(database); | ||
await cleanDatabase(database); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oooof, wonder if we should enable a linter for this feels like we have fewer instances of calling an async function and not awaiting right away and can add a lint ignore for the line we use that approach explicitly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noted here: #2040 |
||
} | ||
|
||
const { storageAdapter, tables } = await createStorageAdapter({ database, publicClient }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀