Skip to content

feat(world): find systems based on inheritance - #3649

Merged
frolic merged 11 commits into
mainfrom
vdrg/systems-without-suffix
Apr 11, 2025
Merged

feat(world): find systems based on inheritance#3649
frolic merged 11 commits into
mainfrom
vdrg/systems-without-suffix

Conversation

@vdrg

@vdrg vdrg commented Apr 1, 2025

Copy link
Copy Markdown
Contributor

TODO: add tests

@vdrg
vdrg requested a review from alvrs as a code owner April 1, 2025 15:13
@changeset-bot

changeset-bot Bot commented Apr 1, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1d087e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@latticexyz/world Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/entrykit Patch
@latticexyz/explorer Patch
@latticexyz/store-sync Patch
@latticexyz/world-consumer Patch
@latticexyz/world-module-callwithsignature Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/store-indexer Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/paymaster Patch
@latticexyz/protocol-parser Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/stash Patch
@latticexyz/store Patch
@latticexyz/utils Patch
vite-plugin-mud Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/world/ts/node/getSystemContracts.ts Outdated
Comment thread packages/world/ts/node/getSystemContracts.ts Outdated
Comment thread packages/world/ts/node/getSystemContracts.ts Outdated
@frolic frolic changed the title feat: support systems without System suffix feat(world): find systems based on inheritance Apr 8, 2025
Comment thread packages/cli/src/build.ts
export async function build({ rootDir, config, foundryProfile }: BuildOptions): Promise<void> {
await Promise.all([tablegen({ rootDir, config }), worldgen({ rootDir, config })]);
await tablegen({ rootDir, config });
await worldgen({ rootDir, config });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this has to be done serially now that we're parsing all *.sol source files in worldgen to determine if a source file is a system, otherwise we get a bunch of "file does not exist" errors from tablegen deleting/creating files

@frolic
frolic force-pushed the vdrg/systems-without-suffix branch 2 times, most recently from 3e14de5 to efae95c Compare April 8, 2025 10:42
@frolic
frolic force-pushed the vdrg/systems-without-suffix branch from efae95c to 2b0053b Compare April 8, 2025 10:43
@dk1a

dk1a commented Apr 10, 2025

Copy link
Copy Markdown
Contributor

I mention slang a bit in #3660 (doesn't conflict with this PR)
It has nice semantic analysis that can help handle more complex system inheritance, though it would be more complicated and expensive than single-file parsing ofc

alvrs
alvrs previously approved these changes Apr 11, 2025

@alvrs alvrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Should we add a config option to enable/disable this new behavior? Thinking about codebases that organized in some way that didn't expect all contracts that extend System to be automatically deployed and registered, or codebases that may have too many (irrelevant) files for which it would be a slowdown to have to parse all of them every time? (I think it's fine to enable this new behavior by default but would be nice to be able to opt out. If the opt out flag would be set, we could just early return after if (contractName.endsWith("System") && contractName !== baseSystemName) return true;)

@frolic

frolic commented Apr 11, 2025

Copy link
Copy Markdown
Member

Happy to put this behind a default-on config option.

If the opt out flag would be set, we could just early return after if (contractName.endsWith("System") && contractName !== baseSystemName) return true;)

Note that this would still read+parse each file (the expensive bit). This is mostly to avoid deploying abstract contracts. I don't think the perf cost is huge here, so can leave this as is and the improve this if we find opted-out folks with perf issues.

@frolic

frolic commented Apr 11, 2025

Copy link
Copy Markdown
Member

added an issue to follow up on this later: #3665

@frolic
frolic merged commit 03af917 into main Apr 11, 2025
@frolic
frolic deleted the vdrg/systems-without-suffix branch April 11, 2025 09:52
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.

4 participants