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(network): fix cache #41

Merged
merged 1 commit into from
Jun 29, 2022
Merged

fix(network): fix cache #41

merged 1 commit into from
Jun 29, 2022

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Jun 29, 2022

  • Cache component schema locally
  • Flushes cache to indexdb periodically (every 10s) because saving on every new event takes too long
  • Only increases block number when all events from this block have been added to the cache to avoid incomplete cache

@alvrs alvrs requested a review from Kooshaba June 29, 2022 14:33
@alvrs alvrs merged commit 71217bc into nyc-sprint-1 Jun 29, 2022
alvrs added a commit that referenced this pull request Jul 2, 2022
* Nyc david components (#17)

* feat(std-contracts): add basic components to std lib

* feat(solecs): add componentID getter to component.sol

* refactor(ri-contracts): use new base components from stdlib

* feat(ri-contracts): add new components and contract functions

* feat(ri-client): adding components and action system

* feat(network): make decoder error when key not passed in

* feat(recs): expose getEntitiesWithValue function

* fix(ri-client): replace get component value with query

* feat(vscode): add std-contract mapping to vscode

* refactor(ri-client): remove spawncreaturesystem and old logs

* fix(std-contracts): fix solidity compiler and export settings

* feat(network,recs,ri): correctly handle component removal events (#20)

* Persona / Launcher Integration (#18)

* refactor(ri/client): fix up the interface for action creators

* feat(ri): hook ri up to launcher and persona

* fix(ri): use 31337 as local chain id everywhere

* feat: integrate persona and player entity when spawning

* feat: join game with persona integrated

* fix(solecs,ri): fix remappings

* fix(ri/client): add lodash to ri client

* feat(contract): check entity owner when moving

* fix(ri/contracts): fix Diamond upgrade hardhat task and make it faster

* fix(ri/contract): remove garbage function

Co-authored-by: ludens <ludens@lattice.xyz>

* fix: make ecs-browser compatible with recs v2

* feat(ri): update ri to support recs v2

* feat(ri): create stamina system with a global turn timer (#25)

* chore: update constants for lattice chain (#26)

* Ability to select and move multiple units (#27)

* feat(ri): remove area selection

* feat: spawn multiple units when joining game
- can select a specific unit and move it

* feat(ri-contracts): add spawn point and mineable components (#28)

* feat: add persona-js package, add simple ri launcher (#29)

* feat(persona-js): add boilerplate for ts library

* feat(ri-launcher): add boilerplate for ri launcher

* fix(ri-client): use new world disposer in boot.tsx

* feat(ri-launcher): add auto mint of persona

* feat(persona-js): add persona types and utils

* feat(ri-launcher): add simple boot screen

* build: yarn install

* chore(ri-launcher): rename game address config

* feat(ri-launcher): make config configurable

* fix(ri-launcher): remove logs

* feat(ri-client): change tile size from 24 to 16 and update art to latest ember-art tileset and atlas (#30)

* beginnings of a UI (#31)

* feat(ri): make a UI system for registering components in an area of the screen
- beginnings of a real UI

* feat: paint persona colors on entities owned by that persona

* feat: LOD (#33)

* feat(ri): silly cluster lod + remove component browser

* feat(ri): add tactical view

* fix: properly hue hero sprite (#32)

* fix: can highlight coord 0 (#34)

* fix: some fixes (#35)

* fix: manually edit auto generated snapshot ts file (#36)

* feat(client): performance improvements (#37)

* feat(network): optimize local cache

* fix(ri-launcher): fix passing checkpoint service

* feat(client): cache checkpoint, fix maps

* fix(network): await cache promise

* feat(ri/client): modify outline shader to accept color input (#39)

* feat(ri/client): modify outline shader to accept color input

* fix(ri/client): pipeline hack is no longer needed

* chore(phaserx): remove log

* feat(phaserx): support any number of map chunks at once

* chore(recs): remove v1

* chore(client): remove check for entities with pos in joinGame

* chore(client): remove outdated log

* chore(client): clean up moveEntity api function

* chore(client): remove unnecessary gas limits

* chore(phaserx): set game object origin to 0,0

* chore(client): remove teleportation

* chore(contracts): remove duplicate contract

* chore(client): rename Window to Cell

* docs(std-contracts): add info about exports.txt to Readme.md

* feat(contracts): add param for amount of stamina to reduce to reduceStamina

* chore(network): fix typo

* chore(network): update persona.js

* chore(persona-js): add overrides as optional param

* fix: a couple review fixes

* fix: more review changes

* Opaque Entity Types (#40)

* feat: add opaque types for EntityID and EntityIndex (formerly just string and number types)

* fix(recs): translate entity indices to IDs when using Proxy fragments

* Update packages/ecs-browser/src/EntityEditor.tsx

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* fix(recs): remove mistaken EntityID in component type

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* fix: more review fixes

* fix(network): fix cache worker memory leak

* fix(client): remove unperformant pixel map

* fix(network): fix cache (#41)

* docs(client): update comment about throttling application of ecs events

* fix(client): remove previous path in createDrawPotentialPathSystem

* chore: add optional update to sync system and simplify sync of CurrentStamina/LocalCurrentStamina

* fix(client): align tile highlight with tile grid

* fix(contract): remove onlyOwner, fix build

* fix(ri/client): remove manual gasLimit on moveEntity

* fix(ri/client): fix PotentialPath render position

* refactor(ri/client): refactor(ri/client): no longer support area select

i removed area selection because it doesn't make sense for the current prototype. the previous
implementation would go through every Selectable entity, assuming anything could potentially be in
the area. that was no longer necessary.

* fix(ri/client): fix selection test to not expect area selection

* fix(ri/client): properly update local stamina inside move action

* feat(ri): add a concept of DEV_MODE (#42)

* feat(ri): add DEV_MODE

* fix(ri/client): feed DEV_MODE param through to contract setup

* Update packages/ri/client/src/layers/Network/createNetworkLayer.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* refactor(ri): stamina as one component

* fix(client): more efficient memory handling in cache and sync worker (#43)

* fix: fix cache once more (actually no more memory leako)

* chore: remove unused logs

* fix: await storing values before storing block number

* chore(contracts): pull out logic from EmberFacet to separate facets and libs (#44)

* feat(ri/contracts): make LibStamina

* feat(ri/contracts): make Move and PlayerJoin facets

* chore: update require message

* chore: update require message

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* fix: fix turn timer and hardhat block time (#45)

* fix: make sure hardhat block time is in sync with local time

* fix(ri): make the UI render every second without component updates

* fix(ri/client): fix DevHighlight rendering

* fix: hot module replacement (#46)

* fix: add empty dependency array to useEffect in ComponentRenderer

* fix: hot module replacement

* fix: self-revie

* newTurn$ stream (#48)

* feat(ri): create newTurn$ stream

* refactor: i understand rxjs now?

* refactor(ri): refactor CurrentStaminaSystem to use a combined Stamina update and newTurn stream

* chore: remove unused import

* refactor(ri/client): refactor turn$ to be more rxjs-y

* fix: woops

* fix: fix rendering of maps and add chunk config per map (#49)

* fix(phaserx): set tile size to map tileSize instead of tileset tileSize

* feat(phaserx): add padding around viewport to avoid black areas while panning

* feat(launcher): make rpc configurable via get params

* feat(phaserx): allow configuration of chunks per map

* fix: self review

* fix: self review

* feat: improve react UI engine, refactor component browser (#50)

* fix(ecs-browser): fix ComponentBrowser by hooking into Component update streams

* fix(ecs-browser): load current values for component values when expanding entities

- before, the ComponentEditor components were waiting for an update to display anything

* feat(ecs-browser): sort components by id in the query filter shortcuts

* refactor(ecs-browser): create useComponentValueStream hook and use it in ecs-browser

* chore: align std-client version number to mud

* fix: review fixes

* chore: review

* fix(contracts): undo stamina component id change

* feat(ecs-browser): allow queries to be written without q and c prefix

Co-authored-by: alvrs <alvarius@lattice.xyz>

Co-authored-by: Big Nuge <davidkolop@gmail.com>
Co-authored-by: ludens <ludens@lattice.xyz>
Co-authored-by: andrii dobroshynski <24281657+andriidski@users.noreply.github.com>
Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>
Co-authored-by: alvrs <alvarius@lattice.xyz>
@alvrs alvrs deleted the alvrs/fix-cache branch July 19, 2022 19:49
LPSCRYPT pushed a commit to LPSCRYPT/esp that referenced this pull request Jan 23, 2023
* Nyc david components (latticexyz#17)

* feat(std-contracts): add basic components to std lib

* feat(solecs): add componentID getter to component.sol

* refactor(ri-contracts): use new base components from stdlib

* feat(ri-contracts): add new components and contract functions

* feat(ri-client): adding components and action system

* feat(network): make decoder error when key not passed in

* feat(recs): expose getEntitiesWithValue function

* fix(ri-client): replace get component value with query

* feat(vscode): add std-contract mapping to vscode

* refactor(ri-client): remove spawncreaturesystem and old logs

* fix(std-contracts): fix solidity compiler and export settings

* feat(network,recs,ri): correctly handle component removal events (latticexyz#20)

* Persona / Launcher Integration (latticexyz#18)

* refactor(ri/client): fix up the interface for action creators

* feat(ri): hook ri up to launcher and persona

* fix(ri): use 31337 as local chain id everywhere

* feat: integrate persona and player entity when spawning

* feat: join game with persona integrated

* fix(solecs,ri): fix remappings

* fix(ri/client): add lodash to ri client

* feat(contract): check entity owner when moving

* fix(ri/contracts): fix Diamond upgrade hardhat task and make it faster

* fix(ri/contract): remove garbage function

Co-authored-by: ludens <ludens@lattice.xyz>

* fix: make ecs-browser compatible with recs v2

* feat(ri): update ri to support recs v2

* feat(ri): create stamina system with a global turn timer (latticexyz#25)

* chore: update constants for lattice chain (latticexyz#26)

* Ability to select and move multiple units (latticexyz#27)

* feat(ri): remove area selection

* feat: spawn multiple units when joining game
- can select a specific unit and move it

* feat(ri-contracts): add spawn point and mineable components (latticexyz#28)

* feat: add persona-js package, add simple ri launcher (latticexyz#29)

* feat(persona-js): add boilerplate for ts library

* feat(ri-launcher): add boilerplate for ri launcher

* fix(ri-client): use new world disposer in boot.tsx

* feat(ri-launcher): add auto mint of persona

* feat(persona-js): add persona types and utils

* feat(ri-launcher): add simple boot screen

* build: yarn install

* chore(ri-launcher): rename game address config

* feat(ri-launcher): make config configurable

* fix(ri-launcher): remove logs

* feat(ri-client): change tile size from 24 to 16 and update art to latest ember-art tileset and atlas (latticexyz#30)

* beginnings of a UI (latticexyz#31)

* feat(ri): make a UI system for registering components in an area of the screen
- beginnings of a real UI

* feat: paint persona colors on entities owned by that persona

* feat: LOD (latticexyz#33)

* feat(ri): silly cluster lod + remove component browser

* feat(ri): add tactical view

* fix: properly hue hero sprite (latticexyz#32)

* fix: can highlight coord 0 (latticexyz#34)

* fix: some fixes (latticexyz#35)

* fix: manually edit auto generated snapshot ts file (latticexyz#36)

* feat(client): performance improvements (latticexyz#37)

* feat(network): optimize local cache

* fix(ri-launcher): fix passing checkpoint service

* feat(client): cache checkpoint, fix maps

* fix(network): await cache promise

* feat(ri/client): modify outline shader to accept color input (latticexyz#39)

* feat(ri/client): modify outline shader to accept color input

* fix(ri/client): pipeline hack is no longer needed

* chore(phaserx): remove log

* feat(phaserx): support any number of map chunks at once

* chore(recs): remove v1

* chore(client): remove check for entities with pos in joinGame

* chore(client): remove outdated log

* chore(client): clean up moveEntity api function

* chore(client): remove unnecessary gas limits

* chore(phaserx): set game object origin to 0,0

* chore(client): remove teleportation

* chore(contracts): remove duplicate contract

* chore(client): rename Window to Cell

* docs(std-contracts): add info about exports.txt to Readme.md

* feat(contracts): add param for amount of stamina to reduce to reduceStamina

* chore(network): fix typo

* chore(network): update persona.js

* chore(persona-js): add overrides as optional param

* fix: a couple review fixes

* fix: more review changes

* Opaque Entity Types (latticexyz#40)

* feat: add opaque types for EntityID and EntityIndex (formerly just string and number types)

* fix(recs): translate entity indices to IDs when using Proxy fragments

* Update packages/ecs-browser/src/EntityEditor.tsx

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* Update packages/ri/client/src/layers/Headless/systems/ActionSystem/createActionSystem.spec.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* fix(recs): remove mistaken EntityID in component type

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* fix: more review fixes

* fix(network): fix cache worker memory leak

* fix(client): remove unperformant pixel map

* fix(network): fix cache (latticexyz#41)

* docs(client): update comment about throttling application of ecs events

* fix(client): remove previous path in createDrawPotentialPathSystem

* chore: add optional update to sync system and simplify sync of CurrentStamina/LocalCurrentStamina

* fix(client): align tile highlight with tile grid

* fix(contract): remove onlyOwner, fix build

* fix(ri/client): remove manual gasLimit on moveEntity

* fix(ri/client): fix PotentialPath render position

* refactor(ri/client): refactor(ri/client): no longer support area select

i removed area selection because it doesn't make sense for the current prototype. the previous
implementation would go through every Selectable entity, assuming anything could potentially be in
the area. that was no longer necessary.

* fix(ri/client): fix selection test to not expect area selection

* fix(ri/client): properly update local stamina inside move action

* feat(ri): add a concept of DEV_MODE (latticexyz#42)

* feat(ri): add DEV_MODE

* fix(ri/client): feed DEV_MODE param through to contract setup

* Update packages/ri/client/src/layers/Network/createNetworkLayer.ts

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* refactor(ri): stamina as one component

* fix(client): more efficient memory handling in cache and sync worker (latticexyz#43)

* fix: fix cache once more (actually no more memory leako)

* chore: remove unused logs

* fix: await storing values before storing block number

* chore(contracts): pull out logic from EmberFacet to separate facets and libs (latticexyz#44)

* feat(ri/contracts): make LibStamina

* feat(ri/contracts): make Move and PlayerJoin facets

* chore: update require message

* chore: update require message

Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>

* fix: fix turn timer and hardhat block time (latticexyz#45)

* fix: make sure hardhat block time is in sync with local time

* fix(ri): make the UI render every second without component updates

* fix(ri/client): fix DevHighlight rendering

* fix: hot module replacement (latticexyz#46)

* fix: add empty dependency array to useEffect in ComponentRenderer

* fix: hot module replacement

* fix: self-revie

* newTurn$ stream (latticexyz#48)

* feat(ri): create newTurn$ stream

* refactor: i understand rxjs now?

* refactor(ri): refactor CurrentStaminaSystem to use a combined Stamina update and newTurn stream

* chore: remove unused import

* refactor(ri/client): refactor turn$ to be more rxjs-y

* fix: woops

* fix: fix rendering of maps and add chunk config per map (latticexyz#49)

* fix(phaserx): set tile size to map tileSize instead of tileset tileSize

* feat(phaserx): add padding around viewport to avoid black areas while panning

* feat(launcher): make rpc configurable via get params

* feat(phaserx): allow configuration of chunks per map

* fix: self review

* fix: self review

* feat: improve react UI engine, refactor component browser (latticexyz#50)

* fix(ecs-browser): fix ComponentBrowser by hooking into Component update streams

* fix(ecs-browser): load current values for component values when expanding entities

- before, the ComponentEditor components were waiting for an update to display anything

* feat(ecs-browser): sort components by id in the query filter shortcuts

* refactor(ecs-browser): create useComponentValueStream hook and use it in ecs-browser

* chore: align std-client version number to mud

* fix: review fixes

* chore: review

* fix(contracts): undo stamina component id change

* feat(ecs-browser): allow queries to be written without q and c prefix

Co-authored-by: alvrs <alvarius@lattice.xyz>

Co-authored-by: Big Nuge <davidkolop@gmail.com>
Co-authored-by: ludens <ludens@lattice.xyz>
Co-authored-by: andrii dobroshynski <24281657+andriidski@users.noreply.github.com>
Co-authored-by: alvarius <89248902+alvrs@users.noreply.github.com>
Co-authored-by: alvrs <alvarius@lattice.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants