Skip to content

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

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

Merged
merged 11 commits into from
Apr 11, 2025
Merged

Conversation

vdrg
Copy link
Contributor

@vdrg vdrg commented Apr 1, 2025

TODO: add tests

@vdrg vdrg requested a review from alvrs as a code owner April 1, 2025 15:13
Copy link

changeset-bot bot commented Apr 1, 2025

🦋 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

@frolic frolic changed the title feat: support systems without System suffix feat(world): find systems based on inheritance Apr 8, 2025
@@ -16,7 +16,8 @@ type BuildOptions = {
};

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
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
Copy link
Contributor

dk1a commented Apr 10, 2025

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
Copy link
Member

@alvrs alvrs left a comment

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
Copy link
Member

frolic commented Apr 11, 2025

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
Copy link
Member

frolic commented Apr 11, 2025

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

@frolic frolic merged commit 03af917 into main Apr 11, 2025
16 checks passed
@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