Skip to content

fix(world): support expectRevert and unusual nameless arguments in system libraries #3680

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dk1a
Copy link
Contributor

@dk1a dk1a commented Apr 18, 2025

4 issues:

  1. Using vm.expectRevert before a system library call always fails with a confusing EvmError: Revert, because the call is unexpectedly successful, but with an empty result, which breaks abi.decode(result, (...))
  2. When an address payable parameter doesn't have a name, address is parsed as its type, and payable as its name
  3. When a dynamic type (e.g. bytes calldata) parameter doesn't have a name, / calldata / in formatParams doesn't capture it because there is no whitespace at the end
  4. When a return parameter has calldata location, it doesn't get replaced with memory, unlike arguments

2-4 are obviously related and fixed by the changes to formatParams, and formatting returnParameters too

1 is much less related, but the fix for it is - after I conditionally skip return if result.length == 0, this causes the solidity warning Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable. solidity(6321).
And using the same formatParameters for returnParameters, including aux names, avoids the warning by naming the variables

I thought it'd be more convenient to review this way, but I can separate the expectRevert stuff if you don't like it

@dk1a dk1a requested a review from alvrs as a code owner April 18, 2025 09:24
Copy link

changeset-bot bot commented Apr 18, 2025

🦋 Changeset detected

Latest commit: 94354ea

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

This PR includes changesets to release 30 packages
Name Type
@latticexyz/store Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/entrykit Patch
@latticexyz/explorer Patch
@latticexyz/react Patch
@latticexyz/stash Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/world-consumer Patch
@latticexyz/world-module-callwithsignature Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world-modules 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/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud 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

@alvrs alvrs requested a review from vdrg April 18, 2025 09:26
Copy link
Contributor

@vdrg vdrg left a comment

Choose a reason for hiding this comment

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

love these 🔥 thank you boss

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