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: new systems pattern #63

Merged
merged 18 commits into from Jul 8, 2022
Merged

feat: new systems pattern #63

merged 18 commits into from Jul 8, 2022

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Jul 7, 2022

  • Implements the new system pattern described in https://www.notion.so/latticexyz/System-interface-004a7541ca3a48fe9e19f046bf90e0cd
  • Removes the Diamond pattern (not needed anymore with the new systems pattern)
  • Adds simple access control to components (described in https://www.notion.so/latticexyz/Component-access-roles-2044634cd458488c8ce829b226f254f7)
  • Adds componentComponent (a component on the world that stores all registered components) and systemComponent (a component on the world that stores all registered systems) to automatically and dynamically sync existing components and systems to the client -> next step is to dynamically display systems that entities can call when selecting an entity
  • Adds code generation for system types and abis and an automated way to "instantiate" system on the client: after running yarn build in the contracts folder, the systems object on the client (network layer) automatically contains all existing systems and their typed methods (integrated with the txQueue), so developers can simply call existing systems from there.
  • Updates deploy script and deploy code generation to work with the new systems pattern

Followups:

  • Fix the forge testing infra to support the new architecture
  • Add "schemas" and "validArgumentsQuery" to the systems to give the client a way to generate possible inputs for systems at runtime

@@ -120,6 +122,7 @@ async function bootLayers() {
disposeLayer("local");
disposeLayer("phaser");
await bootLayers();
await bootReact(layers as Layers);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reboot react when the network layer reboots, because block streams etc will be different

moveEntity: (entity: EntityIndex, direction: Direction) => {
"no-op for types";
},
moveEntity: curry(moveEntity)({ world, actions, network, LocalStamina }),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a circular dependency if the api functions take the layer as input, leading to type issues, we need to find a better solution for this

@alvrs alvrs marked this pull request as ready for review July 8, 2022 19:14
@alvrs alvrs requested review from Kooshaba, davidkol and ludns July 8, 2022 19:29
Kooshaba
Kooshaba previously approved these changes Jul 8, 2022
Copy link
Contributor

@Kooshaba Kooshaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@@ -0,0 +1,90 @@
"use strict";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to commit these generated files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Removed them

packages/solecs/src/Component.sol Outdated Show resolved Hide resolved
Co-authored-by: Andy Cernera <kooshaba@gmail.com>
@Kooshaba Kooshaba self-requested a review July 8, 2022 20:01
Kooshaba
Kooshaba previously approved these changes Jul 8, 2022

- Systems must implement the `ISystem` interface.
- Systems must declare an ID following this pattern: `uint256 constant ID = uint256(keccak256("<UNIQUE SYSTEM IDENTIFIER>"));`
- System contracs must be named exactly the same as the file containing them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contracs is a typo 🔭

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rekt

}

function requirement(bytes memory) public view returns (bytes memory) {
// NOTE: Make sure to not include this system in a production deployment, as anyone can cahnge all component values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another typo! cahnge 🔍

davidkol
davidkol previously approved these changes Jul 8, 2022
Copy link
Contributor

@davidkol davidkol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing work!

@alvrs alvrs dismissed stale reviews from davidkol and Kooshaba via 4737c88 July 8, 2022 20:09
@alvrs alvrs requested a review from davidkol July 8, 2022 20:13
@alvrs alvrs merged commit fb6197b into main Jul 8, 2022
@alvrs alvrs deleted the alvrs/rfc-7-systems branch July 19, 2022 19:50
LPSCRYPT pushed a commit to LPSCRYPT/esp that referenced this pull request Jan 23, 2023
* feat: add systems interface, systemsComponent, registerSystem

* chore: clean up

* feat: add client mappings for componentComponent, systemComponent

* fix: fix hot reloading react

* feat: wip MoveSystem

* feat: remove diamond

* feat: add createSystemExecutor

* feat: autogenerate system abis and types

* refactor: move from facets to systems, remove persona

* refactor: integrate LibStamina, GameConfigSystem

* chore: clean up

* refactor: port LibECS

* refactor: split up DebugFacets into ComponentDevSystem and BulkUploadSystem

* chore: remove unused params from deploy script

* fix: self review

* fix: remove unused console log in Component.sol

Co-authored-by: Andy Cernera <kooshaba@gmail.com>

* build(cli): gitignore build files, build on prepare

* fix: typos

Co-authored-by: Andy Cernera <kooshaba@gmail.com>
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.

None yet

3 participants